Changeset 9646 for code/branches/core6
- Timestamp:
- Aug 13, 2013, 11:35:26 PM (11 years ago)
- Location:
- code/branches/core6
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core6/src/libraries/core/CoreIncludes.h
r9644 r9646 90 90 91 91 /** 92 @brief Registers the class in the framework. 93 @param ClassName The name of the class 94 */ 95 #define RegisterClass(ClassName) \ 96 RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), true) 97 98 /** 99 @brief Registers the class in the framework (for classes without arguments in their constructor). 100 @param ClassName The name of the class 101 */ 102 #define RegisterClassNoArgs(ClassName) \ 103 RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryNoArgs<ClassName>(), true) 104 105 /** 106 @brief Registers the class in the framework (for classes which should not be loaded through XML). 107 @param ClassName The name of the class 108 */ 109 #define RegisterUnloadableClass(ClassName) \ 110 RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), false) 111 112 /** 113 @brief Registers an abstract class in the framework. 114 @param ClassName The name of the class 115 */ 116 #define RegisterAbstractClass(ClassName) \ 117 RegisterClassWithFactory(ClassName, static_cast<ClassFactory<ClassName>*>(NULL), false) 118 119 /** 120 @brief Registers the class in the framework with a given Factory. 121 @param ClassName The name of the class 122 */ 123 #define RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) \ 124 Identifier& _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable) 125 126 /** 92 127 @brief Intern macro, containing the common parts of @c RegisterObject and @c RegisterRootObject. 93 128 @param ClassName The name of the class 94 129 @param bRootClass True if the class is directly derived from orxonox::OrxonoxClass 95 130 */ 96 #define InternRegisterObject(ClassName , bRootClass) \97 if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeObject(this , #ClassName, bRootClass)) \131 #define InternRegisterObject(ClassName) \ 132 if (ClassIdentifier<ClassName>::getIdentifier(#ClassName)->initializeObject(this)) \ 98 133 return; \ 99 134 else \ … … 105 140 */ 106 141 #define RegisterObject(ClassName) \ 107 InternRegisterObject(ClassName , false)142 InternRegisterObject(ClassName) 108 143 109 144 /** … … 115 150 */ 116 151 #define RegisterRootObject(ClassName) \ 117 InternRegisterObject(ClassName, true) 118 119 /** 120 @brief Registers the class in the framework. 121 @param ClassName The name of the class 122 */ 123 #define RegisterClass(ClassName) \ 124 RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), true) 125 126 /** 127 @brief Registers the class in the framework (for classes which should not be loaded through XML). 128 @param ClassName The name of the class 129 */ 130 #define RegisterUnloadableClass(ClassName) \ 131 RegisterClassWithFactory(ClassName, new orxonox::ClassFactoryWithContext<ClassName>(), false) 132 133 /** 134 @brief Registers the class in the framework with a given Factory. 135 @param ClassName The name of the class 136 */ 137 #define RegisterClassWithFactory(ClassName, FactoryInstance, bLoadable) \ 138 Identifier* _##ClassName##Identifier = orxonox::registerClass<ClassName>(#ClassName, FactoryInstance, bLoadable) 152 InternRegisterObject(ClassName) 139 153 140 154 /** … … 152 166 */ 153 167 template <class T> 154 inline Identifier *registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true)168 inline Identifier& registerClass(const std::string& name, ClassFactory<T>* factory, bool bLoadable = true) 155 169 { 156 170 return registerClass<T>(name, static_cast<Factory*>(factory), bLoadable); … … 164 178 */ 165 179 template <class T> 166 inline Identifier *registerClass(const std::string& name, Factory* factory, bool bLoadable = true)180 inline Identifier& registerClass(const std::string& name, Factory* factory, bool bLoadable = true) 167 181 { 168 182 orxout(verbose, context::misc::factory) << "Create entry for " << name << " in Factory." << endl; … … 170 184 identifier->setFactory(factory); 171 185 identifier->setLoadable(bLoadable); 172 return identifier;186 return *identifier; 173 187 } 174 188 -
code/branches/core6/src/libraries/core/class/CMakeLists.txt
r9577 r9646 3 3 Identifier.cc 4 4 IdentifierManager.cc 5 OrxonoxClass.cc 6 OrxonoxInterface.cc 5 7 ) -
code/branches/core6/src/libraries/core/class/Identifiable.cc
r9574 r9646 35 35 36 36 #include <cassert> 37 #include "core/CoreIncludes.h" 37 38 #include "core/object/Context.h" 38 39 #include "Identifier.h" … … 40 41 namespace orxonox 41 42 { 43 RegisterClassNoArgs(Identifiable); 44 42 45 /** 43 46 @brief Constructor: Sets the default values. … … 46 49 { 47 50 this->identifier_ = 0; 48 this->parents_ = 0; 49 // Optimisation 50 this->objectPointers_.reserve(6); 51 } 51 this->objectPointers_.reserve(6); // Optimisation 52 52 53 /** 54 @brief Destructor: Removes the object from the object-lists 55 */ 56 Identifiable::~Identifiable() 57 { 58 // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class 59 if (this->parents_) 60 delete this->parents_; 53 RegisterObject(Identifiable); 61 54 } 62 55 -
code/branches/core6/src/libraries/core/class/Identifiable.h
r9574 r9646 55 55 public: 56 56 Identifiable(); 57 virtual ~Identifiable() ;57 virtual ~Identifiable() {} 58 58 59 59 /// Returns the Identifier of the object. … … 119 119 private: 120 120 Identifier* identifier_; //!< The Identifier of the object 121 std::set<const Identifier*>* parents_; //!< List of all parents of the object122 121 123 122 /// 'Fast map' that holds this-pointers of all derived types -
code/branches/core6/src/libraries/core/class/Identifier.cc
r9641 r9646 37 37 38 38 #include "util/StringUtils.h" 39 #include "core/CoreIncludes.h" 39 40 #include "core/config/ConfigValueContainer.h" 40 41 #include "core/XMLPort.h" … … 52 53 : classID_(IdentifierManager::getInstance().getUniqueClassId()) 53 54 { 54 this->bCreatedOneObject_ = false;55 this->bSetName_ = false;56 55 this->factory_ = 0; 56 this->bInitialized_ = false; 57 57 this->bLoadable_ = false; 58 58 … … 80 80 81 81 /** 82 @brief Registers a class, which means that the name and the parents get stored.83 @param parents A list, containing the Identifiers of all parents of the class84 @param bRootClass True if the class is either an Interface or the BaseObject itself85 */86 void Identifier::initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass)87 {88 // Check if at least one object of the given type was created89 if (!this->bCreatedOneObject_ && IdentifierManager::getInstance().isCreatingHierarchy())90 {91 // If no: We have to store the information and initialize the Identifier92 orxout(verbose, context::identifier) << "Register Class in ClassIdentifier<" << this->getName() << ">-Singleton -> Initialize Singleton." << endl;93 if (bRootClass)94 this->initialize(0); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.95 else96 this->initialize(parents);97 }98 }99 100 /**101 @brief Initializes the Identifier with a list containing all parents of the class the Identifier belongs to.102 @param parents A list containing all parents103 */104 void Identifier::initialize(std::set<const Identifier*>* parents)105 {106 orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << this->name_ << ">-Singleton." << endl;107 this->bCreatedOneObject_ = true;108 109 if (parents)110 {111 this->parents_ = (*parents);112 this->directParents_ = (*parents);113 114 // Iterate through all parents115 for (std::set<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it)116 {117 // Tell the parent we're one of it's children118 (*it)->children_.insert((*it)->children_.end(), this);119 120 // Erase all parents of our parent from our direct-parent-list121 for (std::set<const Identifier*>::const_iterator it1 = (*it)->getParents().begin(); it1 != (*it)->getParents().end(); ++it1)122 {123 // Search for the parent's parent in our direct-parent-list124 for (std::set<const Identifier*>::iterator it2 = this->directParents_.begin(); it2 != this->directParents_.end(); ++it2)125 {126 if ((*it1) == (*it2))127 {128 // We've found a non-direct parent in our list: Erase it129 this->directParents_.erase(it2);130 break;131 }132 }133 }134 }135 136 // Now iterate through all direct parents137 for (std::set<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)138 {139 // Tell the parent we're one of it's direct children140 (*it)->directChildren_.insert((*it)->directChildren_.end(), this);141 142 // Create the super-function dependencies143 (*it)->createSuperFunctionCaller();144 }145 }146 }147 148 /**149 82 @brief Sets the name of the class. 150 83 */ 151 84 void Identifier::setName(const std::string& name) 152 85 { 153 if ( !this->bSetName_)86 if (name != this->name_) 154 87 { 155 88 this->name_ = name; 156 this->bSetName_ = true; 157 IdentifierManager::getInstance().registerIdentifier(this); 89 IdentifierManager::getInstance().addIdentifierToLookupMaps(this); 158 90 } 159 91 } … … 194 126 { 195 127 this->networkID_ = id; 196 IdentifierManager::getInstance().registerIdentifier(this); 128 IdentifierManager::getInstance().addIdentifierToLookupMaps(this); 129 } 130 131 /** 132 * @brief Used to define the direct parents of an Identifier of an abstract class. 133 */ 134 Identifier& Identifier::inheritsFrom(Identifier* directParent) 135 { 136 if (this->parents_.empty()) 137 this->directParents_.insert(directParent); 138 else 139 orxout(internal_error) << "Trying to add " << directParent->getName() << " as a direct parent of " << this->getName() << " after the latter was already initialized" << endl; 140 141 return *this; 142 } 143 144 /** 145 * @brief Initializes the parents of this Identifier while creating the class hierarchy. 146 * @param identifiers All identifiers that were used to create an instance of this class (including this identifier itself) 147 */ 148 void Identifier::initializeParents(const std::set<const Identifier*>& identifiers) 149 { 150 if (!IdentifierManager::getInstance().isCreatingHierarchy()) 151 { 152 orxout(internal_warning) << "Identifier::initializeParents() created outside of class hierarchy creation" << endl; 153 return; 154 } 155 156 for (std::set<const Identifier*>::const_iterator it = identifiers.begin(); it != identifiers.end(); ++it) 157 if (*it != this) 158 this->parents_.insert(*it); 159 } 160 161 /** 162 * @brief Initializes the direct parents of this Identifier while creating the class hierarchy. This is only intended for abstract classes. 163 */ 164 void Identifier::initializeDirectParentsOfAbstractClass() 165 { 166 if (!IdentifierManager::getInstance().isCreatingHierarchy()) 167 { 168 orxout(internal_warning) << "Identifier::initializeDirectParentsOfAbstractClass() created outside of class hierarchy creation" << endl; 169 return; 170 } 171 172 // only Identifiable is allowed to have no parents (even tough it's currently not abstract) 173 if (this->directParents_.empty() && !this->isExactlyA(Class(Identifiable))) 174 { 175 orxout(internal_error) << "Identifier " << this->getName() << " / " << this->getTypeidName() << " is marked as abstract but has no direct parents defined" << endl; 176 orxout(internal_error) << " If this class is not abstract, use RegisterClass(ThisClass);" << endl; 177 orxout(internal_error) << " If this class is abstract, use RegisterAbstractClass(ThisClass).inheritsFrom(Class(BaseClass));" << endl; 178 } 179 } 180 181 /** 182 * @brief Finishes the initialization of this Identifier after creating the class hierarchy by wiring the (direct) parent/child references correctly. 183 */ 184 void Identifier::finishInitialization() 185 { 186 if (!IdentifierManager::getInstance().isCreatingHierarchy()) 187 { 188 orxout(internal_warning) << "Identifier::finishInitialization() created outside of class hierarchy creation" << endl; 189 return; 190 } 191 192 if (this->isInitialized()) 193 return; 194 195 // if no direct parents were defined, initialize them with the set of all parents 196 if (this->directParents_.empty()) 197 this->directParents_ = this->parents_; 198 199 // initialize all parents before continuing to initialize this identifier 200 for (std::set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 201 { 202 Identifier* directParent = const_cast<Identifier*>(*it); 203 directParent->finishInitialization(); // initialize parent 204 this->parents_.insert(directParent); // direct parent is also a parent 205 this->parents_.insert(directParent->parents_.begin(), directParent->parents_.end()); // parents of direct parent are also parents 206 } 207 208 // parents of parents are no direct parents of this identifier 209 for (std::set<const Identifier*>::const_iterator it_parent = this->parents_.begin(); it_parent != this->parents_.end(); ++it_parent) 210 for (std::set<const Identifier*>::const_iterator it_parent_parent = const_cast<Identifier*>(*it_parent)->parents_.begin(); it_parent_parent != const_cast<Identifier*>(*it_parent)->parents_.end(); ++it_parent_parent) 211 this->directParents_.erase(*it_parent_parent); 212 213 // tell all parents that this identifier is a child 214 for (std::set<const Identifier*>::const_iterator it = this->parents_.begin(); it != this->parents_.end(); ++it) 215 const_cast<Identifier*>(*it)->children_.insert(this); 216 217 // tell all direct parents that this identifier is a direct child 218 for (std::set<const Identifier*>::const_iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it) 219 { 220 const_cast<Identifier*>(*it)->directChildren_.insert(this); 221 222 // Create the super-function dependencies 223 (*it)->createSuperFunctionCaller(); 224 } 225 226 this->bInitialized_ = true; 197 227 } 198 228 -
code/branches/core6/src/libraries/core/class/Identifier.h
r9645 r9646 139 139 inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; } 140 140 141 /// Returns true if the Identifier was completely initialized. 142 inline bool isInitialized() const { return this->bInitialized_; } 143 144 145 ///////////////////////////// 146 ////// Class Hierarchy ////// 147 ///////////////////////////// 148 Identifier& inheritsFrom(Identifier* directParent); 149 150 void initializeParents(const std::set<const Identifier*>& identifiers); 151 void initializeDirectParentsOfAbstractClass(); 152 void finishInitialization(); 153 141 154 bool isA(const Identifier* identifier) const; 142 155 bool isExactlyA(const Identifier* identifier) const; … … 146 159 bool isDirectParentOf(const Identifier* identifier) const; 147 160 148 149 /////////////////////////////150 ////// Class Hierarchy //////151 /////////////////////////////152 161 /// Returns the parents of the class the Identifier belongs to. 153 162 inline const std::set<const Identifier*>& getParents() const { return this->parents_; } … … 218 227 virtual void createSuperFunctionCaller() const = 0; 219 228 220 void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);221 222 /// Returns the children of the class the Identifier belongs to.223 inline std::set<const Identifier*>& getChildrenIntern() const { return this->children_; }224 /// Returns the direct children of the class the Identifier belongs to.225 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return this->directChildren_; }226 227 229 private: 228 void initialize(std::set<const Identifier*>* parents);229 230 230 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 231 mutable std::set<const Identifier*> children_;//!< The children of the class the Identifier belongs to231 std::set<const Identifier*> children_; //!< The children of the class the Identifier belongs to 232 232 233 233 std::set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to 234 mutable std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to 235 236 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 237 bool bSetName_; //!< True if the name is set 234 std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to 235 236 bool bInitialized_; //!< Is true if the Identifier was completely initialized 238 237 bool bLoadable_; //!< False = it's not permitted to load the object through XML 239 238 std::string name_; //!< The name of the class the Identifier belongs to … … 277 276 static ClassIdentifier<T>* getIdentifier(const std::string& name); 278 277 279 bool initializeObject(T* object , const std::string& className, bool bRootClass);278 bool initializeObject(T* object); 280 279 281 280 void setConfigValues(T* object, Configurable*) const; … … 351 350 352 351 // Get the entry from the map 353 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().get IdentifierSingleton(proposal);352 ClassIdentifier<T>::classIdentifier_s = (ClassIdentifier<T>*)IdentifierManager::getInstance().getGloballyUniqueIdentifier(proposal); 354 353 355 354 if (ClassIdentifier<T>::classIdentifier_s == proposal) … … 365 364 @brief Adds an object of the given type to the ObjectList. 366 365 @param object The object to add 367 @param className The name of the class T 368 @param bRootClass True if this is a root class (i.e. it inherits directly from OrxonoxClass) 369 */ 370 template <class T> 371 bool ClassIdentifier<T>::initializeObject(T* object, const std::string& className, bool bRootClass) 372 { 373 if (bRootClass) 374 orxout(verbose, context::object_list) << "Register Root-Object: " << className << endl; 375 else 376 orxout(verbose, context::object_list) << "Register Object: " << className << endl; 366 */ 367 template <class T> 368 bool ClassIdentifier<T>::initializeObject(T* object) 369 { 370 orxout(verbose, context::object_list) << "Register Object: " << this->getName() << endl; 377 371 378 372 object->identifier_ = this; 379 373 if (IdentifierManager::getInstance().isCreatingHierarchy()) 380 374 { 381 if (bRootClass && !object->parents_) 382 object->parents_ = new std::set<const Identifier*>(); 383 384 if (object->parents_) 385 { 386 this->initializeClassHierarchy(object->parents_, bRootClass); 387 object->parents_->insert(object->parents_->end(), this); 388 } 375 IdentifierManager::getInstance().createdObject(object); 389 376 390 377 this->setConfigValues(object, object); -
code/branches/core6/src/libraries/core/class/IdentifierManager.cc
r9644 r9646 37 37 38 38 #include "util/StringUtils.h" 39 #include "core/CoreIncludes.h" 39 40 #include "core/config/ConfigValueContainer.h" 40 41 #include "core/XMLPort.h" … … 60 61 @return The identifier (unique instance) 61 62 */ 62 Identifier* IdentifierManager::get IdentifierSingleton(Identifier* proposal)63 Identifier* IdentifierManager::getGloballyUniqueIdentifier(Identifier* proposal) 63 64 { 64 65 const std::string& typeidName = proposal->getTypeidName(); … … 81 82 * Registers the identifier in all maps of the IdentifierManager. 82 83 */ 83 void IdentifierManager::registerIdentifier(Identifier* identifier) 84 { 85 IdentifierManager::getInstance().identifierByString_[identifier->getName()] = identifier; 86 IdentifierManager::getInstance().identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier; 87 IdentifierManager::getInstance().identifierByNetworkId_[identifier->getNetworkID()] = identifier; 84 void IdentifierManager::addIdentifierToLookupMaps(Identifier* identifier) 85 { 86 const std::string& typeidName = identifier->getTypeidName(); 87 if (this->identifierByTypeidName_.find(typeidName) != this->identifierByTypeidName_.end()) 88 { 89 this->identifierByString_[identifier->getName()] = identifier; 90 this->identifierByLowercaseString_[getLowercase(identifier->getName())] = identifier; 91 this->identifierByNetworkId_[identifier->getNetworkID()] = identifier; 92 } 93 else 94 orxout(internal_warning) << "Trying to add an identifier to lookup maps which is not known to IdentifierManager" << endl; 88 95 } 89 96 … … 95 102 orxout(internal_status) << "Create class-hierarchy" << endl; 96 103 this->startCreatingHierarchy(); 104 105 std::set<Identifier*> initializedIdentifiers; 106 107 // iterate over all identifiers, create one instance of each class and initialize the identifiers 108 { 109 Context temporaryContext(NULL); 110 for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it) 111 { 112 orxout(verbose, context::identifier) << "Initialize ClassIdentifier<" << it->second->getName() << ">-Singleton." << endl; 113 // To initialize the identifier, we create a new object and delete it afterwards. 114 if (it->second->hasFactory()) 115 { 116 this->identifiersOfNewObject_.clear(); 117 Identifiable* temp = it->second->fabricate(&temporaryContext); 118 if (temp->getIdentifier() != it->second) 119 orxout(internal_error) << "Newly created object has unexpected identifier" << endl; 120 delete temp; 121 122 it->second->initializeParents(this->identifiersOfNewObject_); 123 } 124 else 125 it->second->initializeDirectParentsOfAbstractClass(); 126 127 initializedIdentifiers.insert(it->second); 128 } 129 } 130 131 // finish the initialization of all identifiers 97 132 for (std::map<std::string, Identifier*>::const_iterator it = this->identifierByTypeidName_.begin(); it != this->identifierByTypeidName_.end(); ++it) 98 133 { 99 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. 100 if (it->second->hasFactory()) 101 { 102 Identifiable* temp = it->second->fabricate(0); 103 delete temp; 104 } 105 } 134 if (initializedIdentifiers.find(it->second) != initializedIdentifiers.end()) 135 it->second->finishInitialization(); 136 else 137 orxout(internal_error) << "Identifier was registered late and is not initialized: " << it->second->getName() << " / " << it->second->getTypeidName() << endl; 138 } 139 106 140 this->stopCreatingHierarchy(); 107 141 orxout(internal_status) << "Finished class-hierarchy creation" << endl; … … 123 157 124 158 /** 159 * @brief Notifies the IdentifierManager about a newly created object while creating the class hierarchy. 160 */ 161 void IdentifierManager::createdObject(Identifiable* identifiable) 162 { 163 if (this->isCreatingHierarchy()) 164 this->identifiersOfNewObject_.insert(identifiable->getIdentifier()); 165 else 166 orxout(internal_warning) << "createdObject() called outside of class hierarchy creation" << endl; 167 } 168 169 /** 125 170 @brief Returns the Identifier with a given name. 126 171 @param name The name of the wanted Identifier -
code/branches/core6/src/libraries/core/class/IdentifierManager.h
r9644 r9646 38 38 39 39 #include <map> 40 #include <set> 40 41 #include <string> 41 42 … … 47 48 static IdentifierManager& getInstance(); 48 49 49 Identifier* get IdentifierSingleton(Identifier* proposal);50 void registerIdentifier(Identifier* identifier);50 Identifier* getGloballyUniqueIdentifier(Identifier* proposal); 51 void addIdentifierToLookupMaps(Identifier* identifier); 51 52 52 53 unsigned int getUniqueClassId() … … 59 60 void createClassHierarchy(); 60 61 void destroyAllIdentifiers(); 62 63 void createdObject(Identifiable* identifiable); 61 64 62 65 /// Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. … … 103 106 104 107 int hierarchyCreatingCounter_s; //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading) 108 std::set<const Identifier*> identifiersOfNewObject_; //!< Used while creating the object hierarchy to keep track of the identifiers of a newly created object 105 109 unsigned int classIDCounter_s; //!< counter for the unique classIDs 106 110 }; -
code/branches/core6/src/libraries/core/class/OrxonoxClass.h
r9607 r9646 53 53 class _CoreExport OrxonoxClass : virtual public Configurable, virtual public Destroyable 54 54 { 55 public: 56 OrxonoxClass(); 55 57 }; 56 58 } -
code/branches/core6/src/libraries/core/class/OrxonoxInterface.h
r9585 r9646 50 50 class _CoreExport OrxonoxInterface : virtual public Configurable, virtual public Destroyable 51 51 { 52 public: 53 OrxonoxInterface(); 52 54 }; 53 55 } -
code/branches/core6/src/libraries/core/class/Super.h
r9568 r9646 103 103 { \ 104 104 ClassIdentifier<T>* identifier = ClassIdentifier<T>::getIdentifier(); \ 105 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildren Intern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it) \105 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildren().begin(); it != identifier->getDirectChildren().end(); ++it) \ 106 106 { \ 107 107 if (((ClassIdentifier<T>*)(*it))->bSuperFunctionCaller_##functionname##_isFallback_ && ((ClassIdentifier<T>*)(*it))->superFunctionCaller_##functionname##_) \ … … 171 171 172 172 // Iterate through all children 173 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildren Intern().begin(); it != identifier->getDirectChildrenIntern().end(); ++it)173 for (std::set<const Identifier*>::iterator it = identifier->getDirectChildren().begin(); it != identifier->getDirectChildren().end(); ++it) 174 174 { 175 175 // Check if the caller is a fallback-caller -
code/branches/core6/test/core/class/IdentifierClassHierarchyTest.cc
r9640 r9646 20 20 { 21 21 class BaseInterface1 : public OrxonoxInterface 22 { public: BaseInterface1() { RegisterRootObject(BaseInterface1); } }; 22 { 23 public: 24 BaseInterface1() 25 { 26 RegisterRootObject(BaseInterface1); 27 } 28 29 virtual void test1() = 0; 30 }; 23 31 24 32 class BaseInterface2 : public OrxonoxInterface 25 { public: BaseInterface2() { RegisterRootObject(BaseInterface2); } }; 33 { 34 public: 35 BaseInterface2() 36 { 37 RegisterRootObject(BaseInterface2); 38 } 39 40 virtual void test2() = 0; 41 }; 26 42 27 43 class Interface1 : public BaseInterface1 28 { public: Interface1() { RegisterObject(Interface1); } }; 44 { 45 public: 46 Interface1() 47 { 48 RegisterObject(Interface1); 49 } 50 }; 29 51 30 52 class Interface2 : public BaseInterface2 31 { public: Interface2() { RegisterObject(Interface2); } }; 53 { 54 public: 55 Interface2() 56 { 57 RegisterObject(Interface2); 58 } 59 }; 32 60 33 61 class BaseClass : public OrxonoxClass 34 { public: BaseClass() { RegisterRootObject(BaseClass); } }; 62 { 63 public: 64 BaseClass() 65 { 66 RegisterRootObject(BaseClass); 67 } 68 }; 35 69 36 70 class Class0 : public BaseClass 37 { public: Class0() { RegisterObject(Class0); } }; 71 { 72 public: 73 Class0() 74 { 75 RegisterObject(Class0); 76 } 77 }; 38 78 39 79 class Class1 : public BaseClass, public Interface1 40 { public: Class1() { RegisterObject(Class1); } }; 80 { 81 public: 82 Class1() 83 { 84 RegisterObject(Class1); 85 } 86 87 virtual void test1() {} 88 }; 41 89 42 90 class Class2a : public BaseClass, public Interface1, Interface2 43 { public: Class2a() { RegisterObject(Class2a); } }; 91 { 92 public: 93 Class2a() 94 { 95 RegisterObject(Class2a); 96 } 97 98 virtual void test1() {} 99 virtual void test2() {} 100 }; 44 101 45 102 class Class2b : public BaseClass, public Interface2, Interface1 46 { public: Class2b() { RegisterObject(Class2b); } }; 103 { 104 public: 105 Class2b() 106 { 107 RegisterObject(Class2b); 108 } 109 110 virtual void test1() {} 111 virtual void test2() {} 112 }; 47 113 48 114 class Class3 : public BaseClass, public BaseInterface1, BaseInterface2 49 { public: Class3() { RegisterObject(Class3); } }; 115 { 116 public: 117 Class3() 118 { 119 RegisterObject(Class3); 120 } 121 122 virtual void test1() {} 123 virtual void test2() {} 124 }; 50 125 51 126 // Fixture … … 55 130 virtual void SetUp() 56 131 { 57 registerClass("BaseInterface1", new ClassFactoryNoArgs<BaseInterface1>()); 58 registerClass("BaseInterface2", new ClassFactoryNoArgs<BaseInterface2>()); 59 registerClass("Interface1", new ClassFactoryNoArgs<Interface1>()); 60 registerClass("Interface2", new ClassFactoryNoArgs<Interface2>()); 132 registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>()); 133 registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>()); 134 registerClass("BaseInterface1", static_cast<ClassFactory<BaseInterface1>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface)); 135 registerClass("BaseInterface2", static_cast<ClassFactory<BaseInterface2>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface)); 136 registerClass("Interface1", static_cast<ClassFactory<Interface1>*>(NULL), false).inheritsFrom(Class(BaseInterface1)); 137 registerClass("Interface2", static_cast<ClassFactory<Interface2>*>(NULL), false).inheritsFrom(Class(BaseInterface2)); 61 138 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 62 139 registerClass("Class0", new ClassFactoryNoArgs<Class0>()); … … 74 151 } 75 152 }; 153 154 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 155 { 156 return identifiers.find(identifier) != identifiers.end(); 157 } 76 158 } 77 159 … … 135 217 136 218 EXPECT_EQ(2u, identifier->getDirectChildren().size()); 219 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Interface1))); 220 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class3))); 221 137 222 EXPECT_EQ(5u, identifier->getChildren().size()); 138 EXPECT_EQ(0u, identifier->getDirectParents().size()); 139 EXPECT_EQ(0u, identifier->getParents().size()); 223 EXPECT_TRUE(contains(identifier->getChildren(), Class(Interface1))); 224 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class3))); 225 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class1))); 226 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2a))); 227 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2b))); 228 229 EXPECT_EQ(1u, identifier->getDirectParents().size()); 230 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxInterface))); 231 232 EXPECT_EQ(2u, identifier->getParents().size()); 233 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 234 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 140 235 } 141 236 … … 145 240 146 241 EXPECT_EQ(2u, identifier->getDirectChildren().size()); 242 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Interface2))); 243 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class3))); 244 147 245 EXPECT_EQ(4u, identifier->getChildren().size()); 148 EXPECT_EQ(0u, identifier->getDirectParents().size()); 149 EXPECT_EQ(0u, identifier->getParents().size()); 246 EXPECT_TRUE(contains(identifier->getChildren(), Class(Interface2))); 247 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class3))); 248 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2a))); 249 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2b))); 250 251 EXPECT_EQ(1u, identifier->getDirectParents().size()); 252 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxInterface))); 253 254 EXPECT_EQ(2u, identifier->getParents().size()); 255 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 256 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 150 257 } 151 258 … … 155 262 156 263 EXPECT_EQ(3u, identifier->getDirectChildren().size()); 264 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class1))); 265 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class2a))); 266 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class2b))); 267 157 268 EXPECT_EQ(3u, identifier->getChildren().size()); 158 EXPECT_EQ(1u, identifier->getDirectParents().size()); 159 EXPECT_EQ(1u, identifier->getParents().size()); 269 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class1))); 270 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2a))); 271 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2b))); 272 273 EXPECT_EQ(1u, identifier->getDirectParents().size()); 274 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseInterface1))); 275 276 EXPECT_EQ(3u, identifier->getParents().size()); 277 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 278 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 279 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface1))); 160 280 } 161 281 … … 165 285 166 286 EXPECT_EQ(2u, identifier->getDirectChildren().size()); 287 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class2a))); 288 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class2b))); 289 167 290 EXPECT_EQ(2u, identifier->getChildren().size()); 168 EXPECT_EQ(1u, identifier->getDirectParents().size()); 169 EXPECT_EQ(1u, identifier->getParents().size()); 291 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2a))); 292 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2b))); 293 294 EXPECT_EQ(1u, identifier->getDirectParents().size()); 295 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseInterface2))); 296 297 EXPECT_EQ(3u, identifier->getParents().size()); 298 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 299 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 300 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface2))); 170 301 } 171 302 … … 175 306 176 307 EXPECT_EQ(5u, identifier->getDirectChildren().size()); 308 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class0))); 309 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class1))); 310 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class2a))); 311 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class2b))); 312 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(Class3))); 313 177 314 EXPECT_EQ(5u, identifier->getChildren().size()); 178 EXPECT_EQ(0u, identifier->getDirectParents().size()); 179 EXPECT_EQ(0u, identifier->getParents().size()); 315 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class0))); 316 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class1))); 317 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2a))); 318 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class2b))); 319 EXPECT_TRUE(contains(identifier->getChildren(), Class(Class3))); 320 321 EXPECT_EQ(1u, identifier->getDirectParents().size()); 322 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxClass))); 323 324 EXPECT_EQ(2u, identifier->getParents().size()); 325 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 326 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 180 327 } 181 328 … … 185 332 186 333 EXPECT_EQ(0u, identifier->getDirectChildren().size()); 334 187 335 EXPECT_EQ(0u, identifier->getChildren().size()); 188 EXPECT_EQ(1u, identifier->getDirectParents().size()); 189 EXPECT_EQ(1u, identifier->getParents().size()); 336 337 EXPECT_EQ(1u, identifier->getDirectParents().size()); 338 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass))); 339 340 EXPECT_EQ(3u, identifier->getParents().size()); 341 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 342 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 343 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass))); 190 344 } 191 345 … … 195 349 196 350 EXPECT_EQ(0u, identifier->getDirectChildren().size()); 351 197 352 EXPECT_EQ(0u, identifier->getChildren().size()); 353 198 354 EXPECT_EQ(2u, identifier->getDirectParents().size()); 199 EXPECT_EQ(3u, identifier->getParents().size()); 355 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass))); 356 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Interface1))); 357 358 EXPECT_EQ(6u, identifier->getParents().size()); 359 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 360 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 361 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass))); 362 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 363 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface1))); 364 EXPECT_TRUE(contains(identifier->getParents(), Class(Interface1))); 200 365 } 201 366 … … 205 370 206 371 EXPECT_EQ(0u, identifier->getDirectChildren().size()); 372 207 373 EXPECT_EQ(0u, identifier->getChildren().size()); 374 208 375 EXPECT_EQ(3u, identifier->getDirectParents().size()); 209 EXPECT_EQ(5u, identifier->getParents().size()); 376 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass))); 377 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Interface1))); 378 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Interface2))); 379 380 EXPECT_EQ(8u, identifier->getParents().size()); 381 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 382 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 383 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass))); 384 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 385 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface1))); 386 EXPECT_TRUE(contains(identifier->getParents(), Class(Interface1))); 387 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface2))); 388 EXPECT_TRUE(contains(identifier->getParents(), Class(Interface2))); 210 389 } 211 390 … … 215 394 216 395 EXPECT_EQ(0u, identifier->getDirectChildren().size()); 396 217 397 EXPECT_EQ(0u, identifier->getChildren().size()); 398 218 399 EXPECT_EQ(3u, identifier->getDirectParents().size()); 219 EXPECT_EQ(5u, identifier->getParents().size()); 400 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass))); 401 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Interface1))); 402 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Interface2))); 403 404 EXPECT_EQ(8u, identifier->getParents().size()); 405 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 406 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 407 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass))); 408 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 409 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface1))); 410 EXPECT_TRUE(contains(identifier->getParents(), Class(Interface1))); 411 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface2))); 412 EXPECT_TRUE(contains(identifier->getParents(), Class(Interface2))); 220 413 } 221 414 … … 225 418 226 419 EXPECT_EQ(0u, identifier->getDirectChildren().size()); 420 227 421 EXPECT_EQ(0u, identifier->getChildren().size()); 422 228 423 EXPECT_EQ(3u, identifier->getDirectParents().size()); 229 EXPECT_EQ(3u, identifier->getParents().size()); 424 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass))); 425 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseInterface1))); 426 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseInterface2))); 427 428 EXPECT_EQ(6u, identifier->getParents().size()); 429 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 430 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 431 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass))); 432 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 433 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface1))); 434 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseInterface2))); 230 435 } 231 436 } -
code/branches/core6/test/core/class/IdentifierExternalClassHierarchyTest.cc
r9640 r9646 8 8 { 9 9 class Interface : virtual public Identifiable 10 { public: Interface() { RegisterRootObject(Interface); } }; 10 { 11 public: 12 Interface() 13 { 14 RegisterRootObject(Interface); 15 } 16 17 virtual void test() = 0; 18 }; 11 19 12 20 class BaseClass : virtual public Identifiable 13 { public: BaseClass() { RegisterRootObject(BaseClass); } }; 21 { 22 public: 23 BaseClass() 24 { 25 RegisterRootObject(BaseClass); 26 } 27 }; 14 28 15 29 class RealClass : public BaseClass, public Interface 16 { public: RealClass() { RegisterObject(RealClass); } }; 30 { 31 public: 32 RealClass() 33 { 34 RegisterObject(RealClass); 35 } 36 37 virtual void test() {} 38 }; 17 39 18 40 // Fixture … … 22 44 virtual void SetUp() 23 45 { 24 registerClass("Interface", new ClassFactoryNoArgs<Interface>());46 registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(Identifiable)); 25 47 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 26 48 registerClass("RealClass", new ClassFactoryNoArgs<RealClass>()); … … 34 56 } 35 57 }; 58 59 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 60 { 61 return identifiers.find(identifier) != identifiers.end(); 62 } 36 63 } 37 64 … … 59 86 Identifier* identifier = Class(Interface); 60 87 88 EXPECT_EQ(1u, identifier->getDirectChildren().size()); 89 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(RealClass))); 90 61 91 EXPECT_EQ(1u, identifier->getChildren().size()); 62 EXPECT_EQ(0u, identifier->getParents().size()); 92 EXPECT_TRUE(contains(identifier->getChildren(), Class(RealClass))); 93 94 EXPECT_EQ(1u, identifier->getDirectParents().size()); 95 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Identifiable))); 96 97 EXPECT_EQ(1u, identifier->getParents().size()); 98 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 63 99 } 64 100 … … 67 103 Identifier* identifier = Class(BaseClass); 68 104 105 EXPECT_EQ(1u, identifier->getDirectChildren().size()); 106 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(RealClass))); 107 69 108 EXPECT_EQ(1u, identifier->getChildren().size()); 70 EXPECT_EQ(0u, identifier->getParents().size()); 109 EXPECT_TRUE(contains(identifier->getChildren(), Class(RealClass))); 110 111 EXPECT_EQ(1u, identifier->getDirectParents().size()); 112 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Identifiable))); 113 114 EXPECT_EQ(1u, identifier->getParents().size()); 115 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 71 116 } 72 117 … … 75 120 Identifier* identifier = Class(RealClass); 76 121 122 EXPECT_EQ(0u, identifier->getDirectChildren().size()); 123 77 124 EXPECT_EQ(0u, identifier->getChildren().size()); 78 EXPECT_EQ(2u, identifier->getParents().size()); 125 126 EXPECT_EQ(2u, identifier->getDirectParents().size()); 127 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Interface))); 128 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass))); 129 130 EXPECT_EQ(3u, identifier->getParents().size()); 131 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 132 EXPECT_TRUE(contains(identifier->getParents(), Class(Interface))); 133 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass))); 79 134 } 80 135 } -
code/branches/core6/test/core/class/IdentifierSimpleClassHierarchyTest.cc
r9640 r9646 10 10 { 11 11 class Interface : public OrxonoxInterface 12 { public: Interface() { RegisterRootObject(Interface); } }; 12 { 13 public: 14 Interface() 15 { 16 RegisterRootObject(Interface); 17 } 18 19 virtual void test() = 0; 20 }; 13 21 14 22 class BaseClass : public OrxonoxClass 15 { public: BaseClass() { RegisterRootObject(BaseClass); } }; 23 { 24 public: 25 BaseClass() 26 { 27 RegisterRootObject(BaseClass); 28 } 29 }; 16 30 17 31 class RealClass : public BaseClass, public Interface 18 { public: RealClass() { RegisterObject(RealClass); } }; 32 { 33 public: 34 RealClass() 35 { 36 RegisterObject(RealClass); 37 } 38 39 virtual void test() {} 40 }; 19 41 20 42 // Fixture … … 24 46 virtual void SetUp() 25 47 { 26 registerClass("Interface", new ClassFactoryNoArgs<Interface>()); 48 registerClass("OrxonoxInterface", new ClassFactoryNoArgs<OrxonoxInterface>()); 49 registerClass("OrxonoxClass", new ClassFactoryNoArgs<OrxonoxClass>()); 50 registerClass("Interface", static_cast<ClassFactory<Interface>*>(NULL), false).inheritsFrom(Class(OrxonoxInterface)); 27 51 registerClass("BaseClass", new ClassFactoryNoArgs<BaseClass>()); 28 52 registerClass("RealClass", new ClassFactoryNoArgs<RealClass>()); … … 36 60 } 37 61 }; 62 63 bool contains(const std::set<const Identifier*> identifiers, Identifier* identifier) 64 { 65 return identifiers.find(identifier) != identifiers.end(); 66 } 38 67 } 39 68 … … 61 90 Identifier* identifier = Class(Interface); 62 91 92 EXPECT_EQ(1u, identifier->getDirectChildren().size()); 93 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(RealClass))); 94 63 95 EXPECT_EQ(1u, identifier->getChildren().size()); 64 EXPECT_EQ(0u, identifier->getParents().size()); 96 EXPECT_TRUE(contains(identifier->getChildren(), Class(RealClass))); 97 98 EXPECT_EQ(1u, identifier->getDirectParents().size()); 99 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxInterface))); 100 101 EXPECT_EQ(2u, identifier->getParents().size()); 102 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 103 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 65 104 } 66 105 … … 69 108 Identifier* identifier = Class(BaseClass); 70 109 110 EXPECT_EQ(1u, identifier->getDirectChildren().size()); 111 EXPECT_TRUE(contains(identifier->getDirectChildren(), Class(RealClass))); 112 71 113 EXPECT_EQ(1u, identifier->getChildren().size()); 72 EXPECT_EQ(0u, identifier->getParents().size()); 114 EXPECT_TRUE(contains(identifier->getChildren(), Class(RealClass))); 115 116 EXPECT_EQ(1u, identifier->getDirectParents().size()); 117 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(OrxonoxClass))); 118 119 EXPECT_EQ(2u, identifier->getParents().size()); 120 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 121 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 73 122 } 74 123 … … 77 126 Identifier* identifier = Class(RealClass); 78 127 128 EXPECT_EQ(0u, identifier->getDirectChildren().size()); 129 79 130 EXPECT_EQ(0u, identifier->getChildren().size()); 80 EXPECT_EQ(2u, identifier->getParents().size()); 131 132 EXPECT_EQ(2u, identifier->getDirectParents().size()); 133 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(Interface))); 134 EXPECT_TRUE(contains(identifier->getDirectParents(), Class(BaseClass))); 135 136 EXPECT_EQ(5u, identifier->getParents().size()); 137 EXPECT_TRUE(contains(identifier->getParents(), Class(Identifiable))); 138 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxInterface))); 139 EXPECT_TRUE(contains(identifier->getParents(), Class(OrxonoxClass))); 140 EXPECT_TRUE(contains(identifier->getParents(), Class(Interface))); 141 EXPECT_TRUE(contains(identifier->getParents(), Class(BaseClass))); 81 142 } 82 143 }
Note: See TracChangeset
for help on using the changeset viewer.