Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 10830


Ignore:
Timestamp:
Nov 22, 2015, 5:31:51 PM (9 years ago)
Author:
landauf
Message:

removed SharedPtr (use std::shared_ptr instead)

Location:
code/branches/cpp11_v2
Files:
2 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/cpp11_v2/src/libraries/util/CMakeLists.txt

    r10624 r10830  
    2626  CRC32.cc
    2727  ExprParser.cc
    28   SharedPtr.cc
    2928  Sleep.cc
    3029  SmallObjectAllocator.cc
  • code/branches/cpp11_v2/src/libraries/util/UtilPrereqs.h

    r10624 r10830  
    8080    class OutputStream;
    8181    class ScopeListener;
    82     template <class T>
    83     class SharedPtr;
    8482    class SignalHandler;
    8583    template <class T>
  • code/branches/cpp11_v2/test/util/SharedPtrTest.cc

    r10770 r10830  
     1#include <memory>
    12#include <utility>
    23#include <gtest/gtest.h>
    34#include <gmock/gmock.h>
    4 #include "util/SharedPtr.h"
    55
    66namespace orxonox
     
    4040    TEST(SharedPtr, ConstructorDefault)
    4141    {
    42         SharedPtr<TestClass> test;
     42        std::shared_ptr<TestClass> test;
    4343        EXPECT_EQ(nullptr, test.get());
    4444    }
     
    4848        TestClass* pointer = new TestClass();
    4949
    50         SharedPtr<TestClass> test = pointer;
     50        std::shared_ptr<TestClass> test(pointer);
    5151        EXPECT_EQ(pointer, test.get());
    5252        EXPECT_EQ(pointer, &(*test));
     
    5757        TestChildClass* pointer = new TestChildClass();
    5858
    59         SharedPtr<TestClass> test = pointer;
     59        std::shared_ptr<TestClass> test(pointer);
    6060        EXPECT_EQ(pointer, test.get());
    6161    }
     
    6565        TestClass* pointer = new TestClass();
    6666
    67         SharedPtr<TestClass> other = pointer;
    68         EXPECT_EQ(pointer, other.get());
    69 
    70         SharedPtr<TestClass> test = other;
     67        std::shared_ptr<TestClass> other(pointer);
     68        EXPECT_EQ(pointer, other.get());
     69
     70        std::shared_ptr<TestClass> test = other;
    7171        EXPECT_EQ(pointer, test.get());
    7272    }
     
    7676        TestChildClass* pointer = new TestChildClass();
    7777
    78         SharedPtr<TestChildClass> other = pointer;
    79         EXPECT_EQ(pointer, other.get());
    80 
    81         SharedPtr<TestClass> test = other;
     78        std::shared_ptr<TestChildClass> other(pointer);
     79        EXPECT_EQ(pointer, other.get());
     80
     81        std::shared_ptr<TestClass> test = other;
    8282        EXPECT_EQ(pointer, test.get());
    8383    }
     
    8787        TestClass* pointer = new TestClass();
    8888
    89         SharedPtr<TestClass> other = pointer;
    90         EXPECT_EQ(pointer, other.get());
    91 
    92         SharedPtr<TestClass> test;
     89        std::shared_ptr<TestClass> other(pointer);
     90        EXPECT_EQ(pointer, other.get());
     91
     92        std::shared_ptr<TestClass> test;
    9393        EXPECT_EQ(nullptr, test.get());
    9494
     
    101101        TestChildClass* pointer = new TestChildClass();
    102102
    103         SharedPtr<TestChildClass> other = pointer;
    104         EXPECT_EQ(pointer, other.get());
    105 
    106         SharedPtr<TestClass> test;
     103        std::shared_ptr<TestChildClass> other(pointer);
     104        EXPECT_EQ(pointer, other.get());
     105
     106        std::shared_ptr<TestClass> test;
    107107        EXPECT_EQ(nullptr, test.get());
    108108
     
    115115        TestChildClass* pointer = new TestChildClass();
    116116
    117         SharedPtr<TestChildClass> other = pointer;
    118         EXPECT_EQ(pointer, other.get());
    119 
    120         SharedPtr<TestClass> test = other.cast<TestClass>();
     117        std::shared_ptr<TestChildClass> other(pointer);
     118        EXPECT_EQ(pointer, other.get());
     119
     120        std::shared_ptr<TestClass> test = std::static_pointer_cast<TestClass>(other);
    121121        EXPECT_EQ(pointer, test.get());
    122122    }
     
    126126        TestClass* pointer = new TestClass();
    127127
    128         SharedPtr<TestClass> test = pointer;
     128        std::shared_ptr<TestClass> test(pointer);
    129129        EXPECT_EQ(pointer, test.get());
    130130
     
    137137    TEST(SharedPtr, Boolean)
    138138    {
    139         SharedPtr<TestClass> test;
     139        std::shared_ptr<TestClass> test;
    140140        EXPECT_EQ(nullptr, test.get());
    141141        EXPECT_FALSE(test);
     
    143143        TestClass* pointer = new TestClass();
    144144
    145         test = pointer;
     145        test.reset(pointer);
    146146        EXPECT_EQ(pointer, test.get());
    147147        EXPECT_TRUE(static_cast<bool>(test));
     
    153153        TestClass* pointer2 = new TestClass();
    154154
    155         SharedPtr<TestClass> test1 = pointer1;
    156         SharedPtr<TestClass> test2 = pointer2;
     155        std::shared_ptr<TestClass> test1(pointer1);
     156        std::shared_ptr<TestClass> test2(pointer2);
    157157
    158158        EXPECT_EQ(pointer1, test1.get());
     
    168168    {
    169169        TestChildClassMock* pointer = new TestChildClassMock();
    170         SharedPtr<TestClass> test = pointer;
     170        std::shared_ptr<TestClass> test(pointer);
    171171
    172172        EXPECT_CALL(*pointer, objectDestroyed()).Times(1);
     
    177177        TestChildClassMock* pointer = new TestChildClassMock();
    178178
    179         SharedPtr<TestClass> test = pointer;
    180         std::vector<SharedPtr<TestClass>> tests;
     179        std::shared_ptr<TestClass> test(pointer);
     180        std::vector<std::shared_ptr<TestClass>> tests;
    181181        for (size_t i = 0; i < 100; ++i)
    182             tests.push_back(SharedPtr<TestClass>(test));
     182            tests.push_back(std::shared_ptr<TestClass>(test));
    183183
    184184        EXPECT_CALL(*pointer, objectDestroyed()).Times(1);
     
    191191
    192192        // default
    193         SharedPtr<TestChildClass> sharedPtr1;
     193        std::shared_ptr<TestChildClass> sharedPtr1;
    194194        EXPECT_EQ(nullptr, sharedPtr1.get());
    195195
    196196        // pointer
    197         SharedPtr<TestChildClass> sharedPtr2(pointer);
     197        std::shared_ptr<TestChildClass> sharedPtr2(pointer);
    198198        EXPECT_EQ(pointer, sharedPtr2.get());
    199199
    200200        // copy
    201         SharedPtr<TestChildClass> sharedPtr3(sharedPtr2);
     201        std::shared_ptr<TestChildClass> sharedPtr3(sharedPtr2);
    202202        EXPECT_EQ(pointer, sharedPtr3.get());
    203203
    204204        // move
    205         SharedPtr<TestChildClass> sharedPtr4(std::move(sharedPtr3));
     205        std::shared_ptr<TestChildClass> sharedPtr4(std::move(sharedPtr3));
    206206        EXPECT_EQ(pointer, sharedPtr4.get());
    207207
    208208        // other
    209         SharedPtr<TestClass> sharedPtr5(sharedPtr4);
     209        std::shared_ptr<TestClass> sharedPtr5(sharedPtr4);
    210210        EXPECT_EQ(pointer, sharedPtr5.get());
    211211
     
    220220
    221221        // default
    222         SharedPtr<TestChildClass> sharedPtr1;
     222        std::shared_ptr<TestChildClass> sharedPtr1;
    223223        EXPECT_EQ(nullptr, sharedPtr1.get());
    224224
    225225        // pointer
    226         SharedPtr<TestChildClass> sharedPtr2 = pointer;
     226        std::shared_ptr<TestChildClass> sharedPtr2(pointer);
    227227        EXPECT_EQ(pointer, sharedPtr2.get());
    228228
    229229        // copy
    230         SharedPtr<TestChildClass> sharedPtr3 = sharedPtr2;
     230        std::shared_ptr<TestChildClass> sharedPtr3 = sharedPtr2;
    231231        EXPECT_EQ(pointer, sharedPtr3.get());
    232232
    233233        // move
    234         SharedPtr<TestChildClass> sharedPtr4 = std::move(sharedPtr3);
     234        std::shared_ptr<TestChildClass> sharedPtr4 = std::move(sharedPtr3);
    235235        EXPECT_EQ(pointer, sharedPtr4.get());
    236236
    237237        // other
    238         SharedPtr<TestClass> sharedPtr5 = sharedPtr4;
     238        std::shared_ptr<TestClass> sharedPtr5 = sharedPtr4;
    239239        EXPECT_EQ(pointer, sharedPtr5.get());
    240240
     
    247247        TestChildClassMock* pointer = new TestChildClassMock();
    248248
    249         SharedPtr<TestChildClass> sharedPtr1(pointer);
     249        std::shared_ptr<TestChildClass> sharedPtr1(pointer);
    250250        EXPECT_EQ(pointer, sharedPtr1.get());
    251251
    252252        // copy
    253         SharedPtr<TestChildClass> sharedPtr2;
     253        std::shared_ptr<TestChildClass> sharedPtr2;
    254254        sharedPtr2 = sharedPtr1;
    255255        EXPECT_EQ(pointer, sharedPtr2.get());
    256256
    257257        // move
    258         SharedPtr<TestChildClass> sharedPtr3;
     258        std::shared_ptr<TestChildClass> sharedPtr3;
    259259        sharedPtr3 = std::move(sharedPtr2);
    260260        EXPECT_EQ(pointer, sharedPtr3.get());
    261261
    262262        // other
    263         SharedPtr<TestClass> sharedPtr4;
     263        std::shared_ptr<TestClass> sharedPtr4;
    264264        sharedPtr4 = sharedPtr3;
    265265        EXPECT_EQ(pointer, sharedPtr4.get());
Note: See TracChangeset for help on using the changeset viewer.