Changeset 10403
- Timestamp:
- Apr 26, 2015, 4:16:49 PM (10 years ago)
- Location:
- code/branches/core7
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/class/Identifier.cc
r10400 r10403 221 221 222 222 /** 223 * Resets all information about the class hierarchy. The identifier is considered uninitialized afterwards. 224 */ 225 void Identifier::reset() 226 { 227 if (this->factory_ != NULL) // TODO: should reset ALL identifiers, but currently the calls to inheritsFrom<>() are not reproducible 228 this->directParents_.clear(); 229 this->parents_.clear(); 230 this->directChildren_.clear(); 231 this->children_.clear(); 232 this->bInitialized_ = false; 233 } 234 235 /** 223 236 * Verifies if the recorded trace of parent identifiers matches the expected trace according to the class hierarchy. If it doesn't match, the class 224 237 * hierarchy is likely wrong, e.g. due to wrong inheritsFrom<>() definitions in abstract classes. -
code/branches/core7/src/libraries/core/class/Identifier.h
r10400 r10403 151 151 void initializeParents(const std::list<const Identifier*>& initializationTrace); 152 152 void finishInitialization(); 153 void reset(); 153 154 154 155 bool isA(const Identifier* identifier) const; -
code/branches/core7/src/libraries/core/class/IdentifierManager.cc
r10399 r10403 172 172 173 173 /** 174 @brief Destroys all Identifiers. Called when exiting the program. 175 */ 176 void IdentifierManager::destroyAllIdentifiers() 177 { 178 for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it) 179 delete (*it); 180 181 this->identifiers_.clear(); 182 this->identifierByString_.clear(); 183 this->identifierByLowercaseString_.clear(); 184 this->identifierByNetworkId_.clear(); 174 * @brief Resets all Identifiers. 175 */ 176 void IdentifierManager::destroyClassHierarchy() 177 { 178 orxout(internal_status) << "Destroy class-hierarchy" << endl; 179 for (std::set<Identifier*>::const_iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it) 180 (*it)->reset(); 185 181 } 186 182 … … 270 266 this->identifierByNetworkId_.clear(); 271 267 } 268 269 /** 270 @brief Destroys all Identifiers. Called when exiting the program. 271 */ 272 void IdentifierManager::destroyAllIdentifiers() 273 { 274 for (std::set<Identifier*>::iterator it = this->identifiers_.begin(); it != this->identifiers_.end(); ++it) 275 delete (*it); 276 277 this->identifiers_.clear(); 278 this->identifierByString_.clear(); 279 this->identifierByLowercaseString_.clear(); 280 this->identifierByNetworkId_.clear(); 281 } 272 282 } -
code/branches/core7/src/libraries/core/class/IdentifierManager.h
r10399 r10403 60 60 void createClassHierarchy(); 61 61 void verifyClassHierarchy(); 62 void destroy AllIdentifiers();62 void destroyClassHierarchy(); 63 63 64 64 void createdObject(Identifiable* identifiable); … … 88 88 inline const std::map<uint32_t, Identifier*>& getIdentifierByNetworkIdMap() 89 89 { return this->identifierByNetworkId_; } 90 91 void destroyAllIdentifiers(); 90 92 91 93 private: -
code/branches/core7/test/core/class/IdentifierClassHierarchyTest.cc
r10400 r10403 4 4 #include "core/class/OrxonoxClass.h" 5 5 #include "core/class/OrxonoxInterface.h" 6 #include "core/module/ModuleInstance.h" 6 7 7 8 namespace orxonox … … 141 142 virtual void SetUp() 142 143 { 144 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 145 ModuleInstance::setCurrentModuleInstance(new ModuleInstance()); // overwrite ModuleInstance because the old one is now loaded and shouln't be used anymore. TODO: better solution? 146 Identifier::initConfigValues_s = false; // TODO: hack! 147 IdentifierManager::getInstance().createClassHierarchy(); 143 148 } 144 149 145 150 virtual void TearDown() 146 151 { 152 IdentifierManager::getInstance().destroyClassHierarchy(); 147 153 } 148 154 }; … … 159 165 } 160 166 161 //TEST(IdentifierClassHierarchyTest_NoFixture, NoInitialization)162 //{163 //{164 //Identifier* identifier = Class(BaseInterface1);165 //EXPECT_EQ(0u, identifier->getChildren().size());166 //EXPECT_EQ(0u, identifier->getParents().size());167 //}168 //{169 //Identifier* identifier = Class(BaseInterface2);170 //EXPECT_EQ(0u, identifier->getChildren().size());171 //EXPECT_EQ(0u, identifier->getParents().size());172 //}173 //{174 //Identifier* identifier = Class(Interface1);175 //EXPECT_EQ(0u, identifier->getChildren().size());176 //EXPECT_EQ(0u, identifier->getParents().size());177 //}178 //{179 //Identifier* identifier = Class(Interface2);180 //EXPECT_EQ(0u, identifier->getChildren().size());181 //EXPECT_EQ(0u, identifier->getParents().size());182 //}183 //{184 //Identifier* identifier = Class(BaseClass);185 //EXPECT_EQ(0u, identifier->getChildren().size());186 //EXPECT_EQ(0u, identifier->getParents().size());187 //}188 //{189 //Identifier* identifier = Class(Class0);190 //EXPECT_EQ(0u, identifier->getChildren().size());191 //EXPECT_EQ(0u, identifier->getParents().size());192 //}193 //{194 //Identifier* identifier = Class(Class1);195 //EXPECT_EQ(0u, identifier->getChildren().size());196 //EXPECT_EQ(0u, identifier->getParents().size());197 //}198 //{199 //Identifier* identifier = Class(Class2a);200 //EXPECT_EQ(0u, identifier->getChildren().size());201 //EXPECT_EQ(0u, identifier->getParents().size());202 //}203 //{204 //Identifier* identifier = Class(Class2b);205 //EXPECT_EQ(0u, identifier->getChildren().size());206 //EXPECT_EQ(0u, identifier->getParents().size());207 //}208 //{209 //Identifier* identifier = Class(Class3);210 //EXPECT_EQ(0u, identifier->getChildren().size());211 //EXPECT_EQ(0u, identifier->getParents().size());212 //}213 //}167 TEST(IdentifierClassHierarchyTest_NoFixture, NoInitialization) 168 { 169 { 170 Identifier* identifier = Class(BaseInterface1); 171 EXPECT_EQ(0u, identifier->getChildren().size()); 172 EXPECT_EQ(0u, identifier->getParents().size()); 173 } 174 { 175 Identifier* identifier = Class(BaseInterface2); 176 EXPECT_EQ(0u, identifier->getChildren().size()); 177 EXPECT_EQ(0u, identifier->getParents().size()); 178 } 179 { 180 Identifier* identifier = Class(Interface1); 181 EXPECT_EQ(0u, identifier->getChildren().size()); 182 EXPECT_EQ(0u, identifier->getParents().size()); 183 } 184 { 185 Identifier* identifier = Class(Interface2); 186 EXPECT_EQ(0u, identifier->getChildren().size()); 187 EXPECT_EQ(0u, identifier->getParents().size()); 188 } 189 { 190 Identifier* identifier = Class(BaseClass); 191 EXPECT_EQ(0u, identifier->getChildren().size()); 192 EXPECT_EQ(0u, identifier->getParents().size()); 193 } 194 { 195 Identifier* identifier = Class(Class0); 196 EXPECT_EQ(0u, identifier->getChildren().size()); 197 EXPECT_EQ(0u, identifier->getParents().size()); 198 } 199 { 200 Identifier* identifier = Class(Class1); 201 EXPECT_EQ(0u, identifier->getChildren().size()); 202 EXPECT_EQ(0u, identifier->getParents().size()); 203 } 204 { 205 Identifier* identifier = Class(Class2a); 206 EXPECT_EQ(0u, identifier->getChildren().size()); 207 EXPECT_EQ(0u, identifier->getParents().size()); 208 } 209 { 210 Identifier* identifier = Class(Class2b); 211 EXPECT_EQ(0u, identifier->getChildren().size()); 212 EXPECT_EQ(0u, identifier->getParents().size()); 213 } 214 { 215 Identifier* identifier = Class(Class3); 216 EXPECT_EQ(0u, identifier->getChildren().size()); 217 EXPECT_EQ(0u, identifier->getParents().size()); 218 } 219 } 214 220 215 221 TEST_F(IdentifierClassHierarchyTest, TestBaseInterface1) -
code/branches/core7/test/core/class/IdentifierExternalClassHierarchyTest.cc
r10400 r10403 2 2 #include "core/CoreIncludes.h" 3 3 #include "core/class/Identifiable.h" 4 #include "core/module/ModuleInstance.h" 4 5 5 6 namespace orxonox … … 48 49 virtual void SetUp() 49 50 { 51 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 52 ModuleInstance::setCurrentModuleInstance(new ModuleInstance()); // overwrite ModuleInstance because the old one is now loaded and shouln't be used anymore. TODO: better solution? 53 Identifier::initConfigValues_s = false; // TODO: hack! 54 IdentifierManager::getInstance().createClassHierarchy(); 50 55 } 51 56 52 57 virtual void TearDown() 53 58 { 59 IdentifierManager::getInstance().destroyClassHierarchy(); 54 60 } 55 61 }; … … 66 72 } 67 73 68 //TEST(IdentifierExternalClassHierarchyTest_NoFixture, NoInitialization)69 //{70 //{71 //Identifier* identifier = Class(Interface);72 //EXPECT_EQ(0u, identifier->getChildren().size());73 //EXPECT_EQ(0u, identifier->getParents().size());74 //}75 //{76 //Identifier* identifier = Class(BaseClass);77 //EXPECT_EQ(0u, identifier->getChildren().size());78 //EXPECT_EQ(0u, identifier->getParents().size());79 //}80 //{81 //Identifier* identifier = Class(RealClass);82 //EXPECT_EQ(0u, identifier->getChildren().size());83 //EXPECT_EQ(0u, identifier->getParents().size());84 //}85 //}74 TEST(IdentifierExternalClassHierarchyTest_NoFixture, NoInitialization) 75 { 76 { 77 Identifier* identifier = Class(Interface); 78 EXPECT_EQ(0u, identifier->getChildren().size()); 79 EXPECT_EQ(0u, identifier->getParents().size()); 80 } 81 { 82 Identifier* identifier = Class(BaseClass); 83 EXPECT_EQ(0u, identifier->getChildren().size()); 84 EXPECT_EQ(0u, identifier->getParents().size()); 85 } 86 { 87 Identifier* identifier = Class(RealClass); 88 EXPECT_EQ(0u, identifier->getChildren().size()); 89 EXPECT_EQ(0u, identifier->getParents().size()); 90 } 91 } 86 92 87 93 TEST_F(IdentifierExternalClassHierarchyTest, TestInterface) -
code/branches/core7/test/core/class/IdentifierNestedClassHierarchyTest.cc
r10400 r10403 4 4 #include "core/class/OrxonoxClass.h" 5 5 #include "core/class/OrxonoxInterface.h" 6 #include "core/module/ModuleInstance.h" 6 7 7 8 namespace orxonox … … 108 109 virtual void SetUp() 109 110 { 111 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 112 ModuleInstance::setCurrentModuleInstance(new ModuleInstance()); // overwrite ModuleInstance because the old one is now loaded and shouln't be used anymore. TODO: better solution? 113 Identifier::initConfigValues_s = false; // TODO: hack! 114 IdentifierManager::getInstance().createClassHierarchy(); 110 115 } 111 116 112 117 virtual void TearDown() 113 118 { 119 IdentifierManager::getInstance().destroyClassHierarchy(); 114 120 } 115 121 }; -
code/branches/core7/test/core/class/IdentifierSimpleClassHierarchyTest.cc
r10400 r10403 4 4 #include "core/class/OrxonoxClass.h" 5 5 #include "core/class/OrxonoxInterface.h" 6 #include "core/module/ModuleInstance.h" 6 7 7 8 namespace orxonox … … 50 51 virtual void SetUp() 51 52 { 53 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 54 ModuleInstance::setCurrentModuleInstance(new ModuleInstance()); // overwrite ModuleInstance because the old one is now loaded and shouln't be used anymore. TODO: better solution? 55 Identifier::initConfigValues_s = false; // TODO: hack! 56 IdentifierManager::getInstance().createClassHierarchy(); 52 57 } 53 58 54 59 virtual void TearDown() 55 60 { 61 IdentifierManager::getInstance().destroyClassHierarchy(); 56 62 } 57 63 }; … … 68 74 } 69 75 70 //TEST(IdentifierSimpleClassHierarchyTest_NoFixture, NoInitialization)71 //{72 //{73 //Identifier* identifier = Class(Interface);74 //EXPECT_EQ(0u, identifier->getChildren().size());75 //EXPECT_EQ(0u, identifier->getParents().size());76 //}77 //{78 //Identifier* identifier = Class(BaseClass);79 //EXPECT_EQ(0u, identifier->getChildren().size());80 //EXPECT_EQ(0u, identifier->getParents().size());81 //}82 //{83 //Identifier* identifier = Class(RealClass);84 //EXPECT_EQ(0u, identifier->getChildren().size());85 //EXPECT_EQ(0u, identifier->getParents().size());86 //}87 //}76 TEST(IdentifierSimpleClassHierarchyTest_NoFixture, NoInitialization) 77 { 78 { 79 Identifier* identifier = Class(Interface); 80 EXPECT_EQ(0u, identifier->getChildren().size()); 81 EXPECT_EQ(0u, identifier->getParents().size()); 82 } 83 { 84 Identifier* identifier = Class(BaseClass); 85 EXPECT_EQ(0u, identifier->getChildren().size()); 86 EXPECT_EQ(0u, identifier->getParents().size()); 87 } 88 { 89 Identifier* identifier = Class(RealClass); 90 EXPECT_EQ(0u, identifier->getChildren().size()); 91 EXPECT_EQ(0u, identifier->getParents().size()); 92 } 93 } 88 94 89 95 TEST_F(IdentifierSimpleClassHierarchyTest, TestInterface) -
code/branches/core7/test/core/class/SubclassIdentifierTest.cc
r10400 r10403 4 4 #include "core/class/SubclassIdentifier.h" 5 5 #include "core/class/OrxonoxClass.h" 6 #include "core/module/ModuleInstance.h" 6 7 7 8 namespace orxonox … … 30 31 virtual void SetUp() 31 32 { 33 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 34 ModuleInstance::setCurrentModuleInstance(new ModuleInstance()); // overwrite ModuleInstance because the old one is now loaded and shouln't be used anymore. TODO: better solution? 35 Identifier::initConfigValues_s = false; // TODO: hack! 36 IdentifierManager::getInstance().createClassHierarchy(); 37 32 38 Context::setRootContext(new Context(NULL)); 33 39 } … … 36 42 { 37 43 Context::setRootContext(NULL); 44 45 IdentifierManager::getInstance().destroyClassHierarchy(); 38 46 } 39 47 }; -
code/branches/core7/test/core/class/SuperTest.cc
r10400 r10403 5 5 #include "core/BaseObject.h" 6 6 #include "core/class/Super.h" 7 #include "core/module/ModuleInstance.h" 7 8 8 9 namespace orxonox … … 65 66 RegisterClass(TestSubclass); 66 67 67 // Fixture68 // Fixture 68 69 class SuperTest : public ::testing::Test 69 70 { … … 71 72 virtual void SetUp() 72 73 { 74 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 75 ModuleInstance::setCurrentModuleInstance(new ModuleInstance()); // overwrite ModuleInstance because the old one is now loaded and shouln't be used anymore. TODO: better solution? 76 Identifier::initConfigValues_s = false; // TODO: hack! 77 IdentifierManager::getInstance().createClassHierarchy(); 78 73 79 Context::setRootContext(new Context(NULL)); 74 80 } … … 77 83 { 78 84 Context::setRootContext(NULL); 85 86 IdentifierManager::getInstance().destroyClassHierarchy(); 79 87 } 80 88 }; -
code/branches/core7/test/core/command/CommandTest.cc
r10400 r10403 133 133 ModifyConsoleCommand("test").popFunction(); 134 134 } 135 136 // Fixture 137 class CommandTest : public ::testing::Test 138 { 139 public: 140 virtual void SetUp() 141 { 142 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances(); 143 ModuleInstance::setCurrentModuleInstance(new ModuleInstance()); // overwrite ModuleInstance because the old one is now loaded and shouln't be used anymore. TODO: better solution? 144 Identifier::initConfigValues_s = false; // TODO: hack! 145 IdentifierManager::getInstance().createClassHierarchy(); 146 } 147 148 virtual void TearDown() 149 { 150 IdentifierManager::getInstance().destroyClassHierarchy(); 151 } 152 }; 135 153 } 136 154 … … 142 160 } 143 161 144 TEST (CommandTest, ModuleTest)162 TEST_F(CommandTest, ModuleTest) 145 163 { 146 ModuleInstance::getCurrentModuleInstance()->loadAllStaticallyInitializedInstances();147 Identifier::initConfigValues_s = false; // TODO: hack!148 IdentifierManager::getInstance().createClassHierarchy();149 150 164 test(0, 0, 0); 151 165 CommandExecutor::execute("test 0", false);
Note: See TracChangeset
for help on using the changeset viewer.