Changeset 10920
- Timestamp:
- Dec 6, 2015, 2:51:14 PM (9 years ago)
- Location:
- code/branches/cpp11_v2
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/libraries/core/ClassTreeMask.cc
r10919 r10920 851 851 this->objectIterator_ = Context::getRootContext()->getObjectList(this->subclassIterator_->first)->begin(); 852 852 else 853 this->objectIterator_ = ObjectList<BaseObject> ::end();853 this->objectIterator_ = ObjectList<BaseObject>().end(); 854 854 855 855 // Check if the iterator points on a valid object. If not, go to the next object by calling ++ -
code/branches/cpp11_v2/src/libraries/core/Loader.cc
r10917 r10920 207 207 if (!file) 208 208 return; 209 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject> ::begin(); it; )209 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>().begin(); it; ) 210 210 { 211 211 if ((it->getFile() == file) && mask.isIncluded(it->getIdentifier())) -
code/branches/cpp11_v2/src/libraries/core/class/Identifier.h
r10919 r10920 415 415 void ClassIdentifier<T>::destroyObjects(Listable*) 416 416 { 417 ObjectListBase* objectList = Context::getRootContext()->getObjectList(this); 418 ObjectListElement<T>* begin = static_cast<ObjectListElement<T>*>(objectList->begin()); 419 ObjectListElement<T>* end = static_cast<ObjectListElement<T>*>(objectList->end()); 420 for (typename ObjectList<T>::iterator it = begin; it != end; ) 417 ObjectList<T> list(Context::getRootContext()->getObjectList(this)); 418 for (typename ObjectList<T>::iterator it = list.begin(); it != list.end(); ) 421 419 this->destroyObject(*(it++)); 422 420 } -
code/branches/cpp11_v2/src/libraries/core/object/ObjectList.h
r10774 r10920 71 71 typedef ObjectListIterator<T> iterator; 72 72 73 /// Returns the size of the list (for the root context) 74 inline static size_t size() 75 { return size(Context::getRootContext()); } 73 ObjectList() : ObjectList(Context::getRootContext()) {} 74 ObjectList(Context* context) : ObjectList(context->getObjectList<T>()) {} 75 ObjectList(ObjectListBase* list) : list_(list) {} 76 76 77 /// Returns the size of the list 77 inline static size_t size(Context* context) 78 { 79 return context->getObjectList<T>()->size(); 80 } 78 inline size_t size() 79 { return this->list_->size(); } 81 80 82 /// Returns an Iterator to the first element in the list (for the root context).83 inline static ObjectListIterator<T> begin()84 { return begin(Context::getRootContext()); }85 81 /// Returns an Iterator to the first element in the list. 86 inline static ObjectListIterator<T> begin(Context* context)87 { 88 ObjectListBase* list = context->getObjectList<T>();89 return static_cast<ObjectListElement<T>*>(list->begin());90 }82 inline ObjectListIterator<T> begin() 83 { return static_cast<ObjectListElement<T>*>(this->list_->begin()); } 84 /// Returns an Iterator to the element after the last element in the list. 85 inline ObjectListIterator<T> end() 86 { return static_cast<ObjectListElement<T>*>(this->list_->end()); } 91 87 92 /// Returns an Iterator to the element after the last element in the list (for the root context). 93 inline static ObjectListIterator<T> end() 94 { return end(Context::getRootContext()); } 95 /// Returns an Iterator to the element after the last element in the list. 96 inline static ObjectListIterator<T> end(Context* context) 97 { 98 ObjectListBase* list = context->getObjectList<T>(); 99 return static_cast<ObjectListElement<T>*>(list->end()); 100 } 88 /// Returns an Iterator to the last element in the list. 89 inline ObjectListIterator<T> rbegin() 90 { return static_cast<ObjectListElement<T>*>(this->list_->rbegin()); } 91 /// Returns an Iterator to the element before the first element in the list. 92 inline ObjectListIterator<T> rend() 93 { return static_cast<ObjectListElement<T>*>(this->list_->rend()); } 101 94 102 /// Returns an Iterator to the last element in the list (for the root context). 103 inline static ObjectListIterator<T> rbegin() 104 { return rbegin(Context::getRootContext()); } 105 /// Returns an Iterator to the last element in the list. 106 inline static ObjectListIterator<T> rbegin(Context* context) 107 { 108 ObjectListBase* list = context->getObjectList<T>(); 109 return static_cast<ObjectListElement<T>*>(list->rbegin()); 110 } 111 112 /// Returns an Iterator to the element before the first element in the list (for the root context). 113 inline static ObjectListIterator<T> rend() 114 { return rend(Context::getRootContext()); } 115 /// Returns an Iterator to the element before the first element in the list. 116 inline static ObjectListIterator<T> rend(Context* context) 117 { 118 ObjectListBase* list = context->getObjectList<T>(); 119 return static_cast<ObjectListElement<T>*>(list->rend()); 120 } 95 private: 96 ObjectListBase* list_; 121 97 }; 122 98 } -
code/branches/cpp11_v2/src/libraries/core/object/ObjectListIterator.h
r10769 r10920 41 41 Usage: 42 42 @code 43 for (ObjectListIterator<myClass> it = ObjectList<myClass>::begin(); it != ObjectList<myClass>::end(); ++it) 43 ObjectList<myClass> list; 44 for (ObjectListIterator<myClass> it = list.begin(); it != list.end(); ++it) 44 45 { 45 46 it->someFunction(...); -
code/branches/cpp11_v2/src/libraries/network/packet/Gamestate.cc
r10919 r10920 126 126 mem += GamestateHeader::getSize(); 127 127 ObjectList<Synchronisable>::iterator it; 128 for(it = ObjectList<Synchronisable> ::begin(); it; ++it)128 for(it = ObjectList<Synchronisable>().begin(); it; ++it) 129 129 { 130 130 -
code/branches/cpp11_v2/src/modules/gametypes/SpaceRaceController.cc
r10919 r10920 59 59 60 60 virtualCheckPointIndex = -2; 61 if (ObjectList<SpaceRaceManager> ::size() != 1)62 orxout(internal_warning) << "Expected 1 instance of SpaceRaceManager but found " << ObjectList<SpaceRaceManager> ::size() << endl;61 if (ObjectList<SpaceRaceManager>().size() != 1) 62 orxout(internal_warning) << "Expected 1 instance of SpaceRaceManager but found " << ObjectList<SpaceRaceManager>().size() << endl; 63 63 for (SpaceRaceManager* manager : ObjectList<SpaceRaceManager>()) 64 64 { … … 299 299 orxout()<<"add VCP at"<<virtualCheckPointPosition.x<<", "<<virtualCheckPointPosition.y<<", "<<virtualCheckPointPosition.z<<endl; 300 300 RaceCheckPoint* newTempRaceCheckPoint; 301 for (ObjectList<SpaceRaceManager>::iterator it = ObjectList<SpaceRaceManager>::begin(); it!= ObjectList<SpaceRaceManager>::end(); ++it) 301 ObjectList<SpaceRaceManager> list; 302 for (ObjectList<SpaceRaceManager>::iterator it = list.begin(); it!= list.end(); ++it) 302 303 { 303 304 newTempRaceCheckPoint = new RaceCheckPoint((*it)); … … 488 489 std::vector<StaticEntity*> problematicObjects; 489 490 490 for (ObjectList<StaticEntity>::iterator it = ObjectList<StaticEntity>::begin(); it!= ObjectList<StaticEntity>::end(); ++it) 491 ObjectList<StaticEntity> list; 492 for (ObjectList<StaticEntity>::iterator it = list.begin(); it!= list.end(); ++it) 491 493 { 492 494 -
code/branches/cpp11_v2/src/modules/jump/Jump.cc
r10916 r10920 141 141 } 142 142 143 ObjectList<JumpPlatform>::iterator beginPlatform = ObjectList<JumpPlatform>::begin(); 144 ObjectList<JumpPlatform>::iterator endPlatform = ObjectList<JumpPlatform>::end(); 145 ObjectList<JumpPlatform>::iterator itPlatform = beginPlatform; 143 ObjectList<JumpPlatform> listPlatform; 144 ObjectList<JumpPlatform>::iterator itPlatform = listPlatform.begin(); 146 145 Vector3 platformPosition; 147 146 148 while (itPlatform != endPlatform)147 while (itPlatform != listPlatform.end()) 149 148 { 150 149 platformPosition = itPlatform->getPosition(); … … 163 162 164 163 // Deleted deactivated platforms 165 ObjectList<JumpPlatformDisappear>::iterator beginDisappear = ObjectList<JumpPlatformDisappear>::begin(); 166 ObjectList<JumpPlatformDisappear>::iterator endDisappear = ObjectList<JumpPlatformDisappear>::end(); 167 ObjectList<JumpPlatformDisappear>::iterator itDisappear = beginDisappear; 168 169 while (itDisappear != endDisappear) 164 ObjectList<JumpPlatformDisappear> listDisappear; 165 ObjectList<JumpPlatformDisappear>::iterator itDisappear = listDisappear.begin(); 166 167 while (itDisappear != listDisappear.end()) 170 168 { 171 169 if (!itDisappear->isActive()) … … 182 180 } 183 181 184 ObjectList<JumpPlatformTimer>::iterator beginTimer = ObjectList<JumpPlatformTimer>::begin(); 185 ObjectList<JumpPlatformTimer>::iterator endTimer = ObjectList<JumpPlatformTimer>::end(); 186 ObjectList<JumpPlatformTimer>::iterator itTimer = beginTimer; 187 188 while (itTimer != endTimer) 182 ObjectList<JumpPlatformTimer> listTimer; 183 ObjectList<JumpPlatformTimer>::iterator itTimer = listTimer.begin(); 184 185 while (itTimer != listTimer.end()) 189 186 { 190 187 if (!itTimer->isActive()) … … 201 198 } 202 199 203 ObjectList<JumpProjectile>::iterator beginProjectile = ObjectList<JumpProjectile>::begin(); 204 ObjectList<JumpProjectile>::iterator endProjectile = ObjectList<JumpProjectile>::end(); 205 ObjectList<JumpProjectile>::iterator itProjectile = beginProjectile; 200 ObjectList<JumpProjectile> listProjectile; 201 ObjectList<JumpProjectile>::iterator itProjectile = listProjectile.begin(); 206 202 Vector3 projectilePosition; 207 203 208 while (itProjectile != endProjectile)204 while (itProjectile != listProjectile.end()) 209 205 { 210 206 projectilePosition = itProjectile->getPosition(); … … 222 218 } 223 219 224 ObjectList<JumpEnemy>::iterator beginEnemy = ObjectList<JumpEnemy>::begin(); 225 ObjectList<JumpEnemy>::iterator endEnemy = ObjectList<JumpEnemy>::end(); 226 ObjectList<JumpEnemy>::iterator itEnemy = beginEnemy; 220 ObjectList<JumpEnemy> listEnemy; 221 ObjectList<JumpEnemy>::iterator itEnemy = listEnemy.begin(); 227 222 Vector3 enemyPosition; 228 223 229 while (itEnemy != endEnemy)224 while (itEnemy != listEnemy.end()) 230 225 { 231 226 enemyPosition = itEnemy->getPosition(); … … 243 238 } 244 239 245 ObjectList<JumpItem>::iterator beginItem = ObjectList<JumpItem>::begin(); 246 ObjectList<JumpItem>::iterator endItem = ObjectList<JumpItem>::end(); 247 ObjectList<JumpItem>::iterator itItem = beginItem; 240 ObjectList<JumpItem> listItem; 241 ObjectList<JumpItem>::iterator itItem = listItem.begin(); 248 242 Vector3 itemPosition; 249 243 250 while (itItem != endItem)244 while (itItem != listItem.end()) 251 245 { 252 246 itemPosition = itItem->getPosition(); -
code/branches/cpp11_v2/src/modules/mini4dgame/Mini4Dgame.cc
r10917 r10920 183 183 void Mini4Dgame::undoStone()//Vector4 move, const int playerColor) 184 184 { 185 ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard> ::begin();185 ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard>().begin(); 186 186 it->undoMove(); 187 187 } … … 191 191 { 192 192 Mini4DgamePosition move = Mini4DgamePosition(x,y,z,w); 193 ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard> ::begin();193 ObjectList<Mini4DgameBoard>::iterator it = ObjectList<Mini4DgameBoard>().begin(); 194 194 it->makeMove(move); 195 195 } -
code/branches/cpp11_v2/src/modules/overlays/debugging/DebugPositionText.cc
r9943 r10920 52 52 SUPER(DebugPositionText, tick, dt); 53 53 54 ObjectList<NewHumanController>::iterator it = ObjectList<NewHumanController> ::begin();54 ObjectList<NewHumanController>::iterator it = ObjectList<NewHumanController>().begin(); 55 55 if (it && it->getControllableEntity() ) 56 56 { -
code/branches/cpp11_v2/src/orxonox/Radar.cc
r10919 r10920 138 138 void Radar::cycleFocus() 139 139 { 140 if (ObjectList<RadarViewable>::begin() == ObjectList<RadarViewable>::end()) 140 ObjectList<RadarViewable> listRadarViewable; 141 if (listRadarViewable.size() == 0) 141 142 { 142 143 // list is empty … … 158 159 ObjectList<RadarViewable>::iterator itFallback = nullptr; 159 160 160 for (ObjectList<RadarViewable>::iterator it = ObjectList<RadarViewable>::begin(); it; ++it)161 for (ObjectList<RadarViewable>::iterator it = listRadarViewable.begin(); it; ++it) 161 162 { 162 163 if (*it == static_cast<RadarViewable*>(HumanController::getLocalControllerEntityAsPawn())) -
code/branches/cpp11_v2/src/orxonox/gamestates/GSLevel.cc
r10919 r10920 215 215 void GSLevel::unloadLevelAsClient() 216 216 { 217 for (ObjectList<Level>::iterator it = ObjectList<Level>::begin(); it != ObjectList<Level>::end(); ) 217 ObjectList<Level> listLevel; 218 for (ObjectList<Level>::iterator it = listLevel.begin(); it != listLevel.end(); ) 218 219 { 219 220 StrongPtr<Level> level = *(it++); // StrongPtr prevents that the Level gets destroyed while we loop over it 220 for (ObjectList<BaseObject>::iterator it = ObjectList<BaseObject>::begin(level); it != ObjectList<BaseObject>::end(level); ) 221 ObjectList<BaseObject> listBaseObject(level); 222 for (ObjectList<BaseObject>::iterator it = listBaseObject.begin(); it != listBaseObject.end(); ) 221 223 (it++)->destroy(); 222 224 } 223 225 224 for (ObjectList<Synchronisable>::iterator it = ObjectList<Synchronisable>::begin(); it != ObjectList<Synchronisable>::end(); ) 226 ObjectList<Synchronisable> listSynchronisable; 227 for (ObjectList<Synchronisable>::iterator it = listSynchronisable.begin(); it != listSynchronisable.end(); ) 225 228 { 226 229 if (it->getSyncMode() != 0x0) -
code/branches/cpp11_v2/src/orxonox/gamestates/GSRoot.cc
r10919 r10920 113 113 } 114 114 115 for (ObjectList<Timer>::iterator it = ObjectList<Timer>::begin(); it; ) 115 ObjectList<Timer> listTimer; 116 for (ObjectList<Timer>::iterator it = listTimer.begin(); it; ) 116 117 { 117 118 Timer* object = *it; … … 129 130 } 130 131 float realdt = leveldt * TimeFactorListener::getTimeFactor(); 131 for (ObjectList<Tickable>::iterator it = ObjectList<Tickable>::begin(); it; ) 132 ObjectList<Tickable> listTickable; 133 for (ObjectList<Tickable>::iterator it = listTickable.begin(); it; ) 132 134 { 133 135 Tickable* object = *it; -
code/branches/cpp11_v2/src/orxonox/gametypes/Gametype.cc
r10919 r10920 492 492 { 493 493 unsigned int i = 0; 494 for (ObjectList<Bot>::iterator it = ObjectList<Bot>::begin(); (it != ObjectList<Bot>::end()) && ((amount == 0) || (i < amount)); ) 494 ObjectList<Bot> list; 495 for (ObjectList<Bot>::iterator it = list.begin(); (it != list.end()) && ((amount == 0) || (i < amount)); ) 495 496 { 496 497 if (it->getGametype() == this) -
code/branches/cpp11_v2/test/core/object/IteratorTest.cc
r10846 r10920 55 55 TEST_F(IteratorTest, CanAssignIterator) 56 56 { 57 Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); 57 ObjectList<TestInterface> list; 58 Iterator<TestInterface> it = list.begin(); 58 59 } 59 60 … … 61 62 { 62 63 size_t i = 0; 63 for (Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 64 ObjectList<TestInterface> list; 65 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 64 66 ++i; 65 67 EXPECT_EQ(0u, i); … … 77 79 78 80 // iterate over interfaces but use a TestClass iterator - now we can call TestClass::test() 79 for (Iterator<TestClass> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 81 ObjectList<TestInterface> list; 82 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 80 83 it->test(); 81 84 } … … 87 90 88 91 size_t i = 0; 89 for (Iterator<TestInterface> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 92 ObjectList<TestInterface> list; 93 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 90 94 { 91 95 ++i; … … 102 106 103 107 size_t i = 0; 104 for (Iterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 108 ObjectList<TestClass> list; 109 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 105 110 { 106 111 ++i; … … 116 121 117 122 size_t i = 0; 118 for (Iterator<TestClass> it = ObjectList<TestInterface>::begin(); it != ObjectList<TestInterface>::end(); ++it) 123 ObjectList<TestInterface> list; 124 for (Iterator<TestClass> it = list.begin(); it != list.end(); ++it) 119 125 { 120 126 ++i; … … 131 137 132 138 size_t i = 0; 133 for (Iterator<TestInterface> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 139 ObjectList<TestClass> list; 140 for (Iterator<TestInterface> it = list.begin(); it != list.end(); ++it) 134 141 { 135 142 ++i; -
code/branches/cpp11_v2/test/core/object/ListableTest.cc
r10846 r10920 63 63 { 64 64 ListableClassTest test; 65 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());65 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 66 66 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 67 67 } … … 70 70 { 71 71 ListableSubclassTest test; 72 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());72 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 73 73 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 74 EXPECT_EQ(1u, ObjectList<ListableSubclassTest> ::size());74 EXPECT_EQ(1u, ObjectList<ListableSubclassTest>().size()); 75 75 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test)); 76 76 } … … 78 78 TEST_F(ListableTest, RemovesFromObjectList) 79 79 { 80 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());80 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 81 81 { 82 82 ListableClassTest test; 83 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());83 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 84 84 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 85 85 } 86 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());86 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 87 87 } 88 88 89 89 TEST_F(ListableTest, RemovesFromAllObjectLists) 90 90 { 91 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());92 EXPECT_EQ(0u, ObjectList<ListableSubclassTest> ::size());91 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 92 EXPECT_EQ(0u, ObjectList<ListableSubclassTest>().size()); 93 93 { 94 94 ListableSubclassTest test; 95 EXPECT_EQ(1u, ObjectList<ListableClassTest> ::size());95 EXPECT_EQ(1u, ObjectList<ListableClassTest>().size()); 96 96 EXPECT_TRUE(objectListContains<ListableClassTest>(&test)); 97 EXPECT_EQ(1u, ObjectList<ListableSubclassTest> ::size());97 EXPECT_EQ(1u, ObjectList<ListableSubclassTest>().size()); 98 98 EXPECT_TRUE(objectListContains<ListableSubclassTest>(&test)); 99 99 } 100 EXPECT_EQ(0u, ObjectList<ListableClassTest> ::size());101 EXPECT_EQ(0u, ObjectList<ListableSubclassTest> ::size());100 EXPECT_EQ(0u, ObjectList<ListableClassTest>().size()); 101 EXPECT_EQ(0u, ObjectList<ListableSubclassTest>().size()); 102 102 } 103 103 -
code/branches/cpp11_v2/test/core/object/ObjectListIteratorTest.cc
r10846 r10920 55 55 TEST_F(ObjectListIteratorTest, CanAssignIterator) 56 56 { 57 ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); 57 ObjectList<TestClass> list; 58 ObjectListIterator<TestClass> it = list.begin(); 58 59 } 59 60 … … 61 62 { 62 63 size_t i = 0; 63 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 64 ObjectList<TestClass> list; 65 for (ObjectListIterator<TestClass> it = list.begin(); it != list.end(); ++it) 64 66 ++i; 65 67 EXPECT_EQ(0u, i); … … 74 76 75 77 size_t i = 0; 76 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 78 ObjectList<TestClass> list; 79 for (ObjectListIterator<TestClass> it = list.begin(); it != list.end(); ++it) 77 80 { 78 81 ++i; … … 92 95 93 96 size_t i = 0; 94 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::rbegin(); it != ObjectList<TestClass>::rend(); --it) 97 ObjectList<TestClass> list; 98 for (ObjectListIterator<TestClass> it = list.rbegin(); it != list.rend(); --it) 95 99 { 96 100 ++i; … … 113 117 EXPECT_CALL(test3, test()); 114 118 115 for (ObjectListIterator<TestClass> it = ObjectList<TestClass>::begin(); it != ObjectList<TestClass>::end(); ++it) 119 ObjectList<TestClass> list; 120 for (ObjectListIterator<TestClass> it = list.begin(); it != list.end(); ++it) 116 121 it->test(); 117 122 } -
code/branches/cpp11_v2/test/core/object/ObjectListTest.cc
r10846 r10920 15 15 public: 16 16 ListableTest() { RegisterObject(ListableTest); } 17 ListableTest(Context* context) : Listable(context) { RegisterObject(ListableTest); } 17 18 MOCK_METHOD0(test, void()); 18 19 }; … … 103 104 object->test(); 104 105 } 106 107 TEST_F(ObjectListTest, UsesCorrectContext) 108 { 109 Context context1(Context::getRootContext()); 110 Context context2(Context::getRootContext()); 111 112 ListableTest test1(&context1); 113 ListableTest test2(&context1); 114 ListableTest test3(&context2); 115 116 EXPECT_EQ(3, ObjectList<ListableTest>().size()); 117 EXPECT_EQ(2, ObjectList<ListableTest>(&context1).size()); 118 EXPECT_EQ(1, ObjectList<ListableTest>(&context2).size()); 119 } 120 121 TEST_F(ObjectListTest, CanIterateOverCorrectContext) 122 { 123 Context context1(Context::getRootContext()); 124 Context context2(Context::getRootContext()); 125 126 ListableTest test1(&context1); 127 ListableTest test2(&context1); 128 ListableTest test3(&context2); 129 130 { 131 size_t i = 0; 132 for (ListableTest* object : ObjectList<ListableTest>(&context1)) 133 { 134 ++i; 135 if (i == 1u) EXPECT_EQ(&test1, object); 136 if (i == 2u) EXPECT_EQ(&test2, object); 137 } 138 EXPECT_EQ(2u, i); 139 } 140 { 141 size_t i = 0; 142 for (ListableTest* object : ObjectList<ListableTest>(&context2)) 143 { 144 ++i; 145 if (i == 1u) EXPECT_EQ(&test3, object); 146 } 147 EXPECT_EQ(1u, i); 148 } 149 } 105 150 }
Note: See TracChangeset
for help on using the changeset viewer.