Changeset 5783 for code/branches/core5/src
- Timestamp:
- Sep 24, 2009, 8:58:27 PM (15 years ago)
- Location:
- code/branches/core5/src/libraries/core
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core5/src/libraries/core/ClassFactory.h
r5779 r5783 65 65 { 66 66 public: 67 ClassFactory(const std::string& name, bool bLoadable = true); 68 BaseObject* fabricate(BaseObject* creator); 67 /** 68 @brief Constructor: Adds the ClassFactory to the Identifier of the same type. 69 @param name The name of the class 70 @param bLoadable True if the class can be loaded through XML 71 */ 72 ClassFactory(const std::string& name, bool bLoadable = true) 73 { 74 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl; 75 ClassIdentifier<T>::getIdentifier(name)->addFactory(this); 76 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable); 77 } 78 79 /** 80 @brief Creates and returns a new object of class T. 81 @return The new object 82 */ 83 inline BaseObject* fabricate(BaseObject* creator) 84 { 85 return static_cast<BaseObject*>(new T(creator)); 86 } 69 87 }; 70 71 /**72 @brief Adds the ClassFactory to the Identifier of the same type.73 @param name The name of the class74 @param bLoadable True if the class can be loaded through XML75 */76 template <class T>77 ClassFactory<T>::ClassFactory(const std::string& name, bool bLoadable)78 {79 COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;80 ClassIdentifier<T>::getIdentifier(name)->addFactory(this);81 ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);82 }83 84 /**85 @brief Creates and returns a new object of class T.86 @return The new object87 */88 template <class T>89 inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)90 {91 return static_cast<BaseObject*>(new T(creator));92 }93 88 } 94 89 -
code/branches/core5/src/libraries/core/Identifier.cc
r5780 r5783 66 66 this->bHasConsoleCommands_ = false; 67 67 68 this->children_ = new std::set<const Identifier*>();69 this->directChildren_ = new std::set<const Identifier*>();70 71 68 // Default network ID is the class ID 72 69 this->networkID_ = this->classID_; … … 78 75 Identifier::~Identifier() 79 76 { 80 delete this->children_;81 delete this->directChildren_;82 77 delete this->objects_; 83 78 … … 165 160 { 166 161 // Tell the parent we're one of it's children 167 (*it)-> getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);162 (*it)->children_.insert((*it)->children_.end(), this); 168 163 169 164 // Erase all parents of our parent from our direct-parent-list … … 187 182 { 188 183 // Tell the parent we're one of it's direct children 189 (*it)-> getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);184 (*it)->directChildren_.insert((*it)->directChildren_.end(), this); 190 185 191 186 // Create the super-function dependencies … … 201 196 { 202 197 COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl; 203 std::map<std::string, Identifier*>::const_iterator it; 204 it = Identifier::getStringIdentifierMap().begin(); 205 Identifier::getStringIdentifierMap().begin()->second->startCreatingHierarchy(); 206 for (it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it) 198 Identifier::startCreatingHierarchy(); 199 for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it) 207 200 { 208 201 // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards. … … 213 206 } 214 207 } 215 Identifier:: getStringIdentifierMap().begin()->second->stopCreatingHierarchy();208 Identifier::stopCreatingHierarchy(); 216 209 COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl; 217 210 } … … 315 308 bool Identifier::isParentOf(const Identifier* identifier) const 316 309 { 317 return (this->children_ ->find(identifier) != this->children_->end());310 return (this->children_.find(identifier) != this->children_.end()); 318 311 } 319 312 … … 324 317 bool Identifier::isDirectParentOf(const Identifier* identifier) const 325 318 { 326 return (this->directChildren_ ->find(identifier) != this->directChildren_->end());319 return (this->directChildren_.find(identifier) != this->directChildren_.end()); 327 320 } 328 321 -
code/branches/core5/src/libraries/core/Identifier.h
r5779 r5783 138 138 139 139 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 140 inline const std::set<const Identifier*>& getChildren() const { return (*this->children_); }140 inline const std::set<const Identifier*>& getChildren() const { return this->children_; } 141 141 /** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */ 142 inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_ ->begin(); }142 inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); } 143 143 /** @brief Returns the end-iterator of the children-list. @return The end-iterator */ 144 inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_ ->end(); }144 inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); } 145 145 146 146 /** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */ … … 152 152 153 153 /** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */ 154 inline const std::set<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); }154 inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; } 155 155 /** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */ 156 inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_ ->begin(); }156 inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); } 157 157 /** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */ 158 inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_ ->end(); }158 inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); } 159 159 160 160 … … 296 296 297 297 /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */ 298 inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); }298 inline std::set<const Identifier*>& getChildrenIntern() const { return this->children_; } 299 299 /** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */ 300 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }300 inline std::set<const Identifier*>& getDirectChildrenIntern() const { return this->directChildren_; } 301 301 302 302 ObjectListBase* objects_; //!< The list of all objects of this class 303 303 304 304 private: 305 /** 306 @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. 307 */ 308 inline static void startCreatingHierarchy() 309 { 310 hierarchyCreatingCounter_s++; 311 COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl; 312 } 313 314 /** 315 @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. 316 */ 317 inline static void stopCreatingHierarchy() 318 { 319 hierarchyCreatingCounter_s--; 320 COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl; 321 } 305 /** @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. */ 306 inline static void startCreatingHierarchy() { hierarchyCreatingCounter_s++; } 307 /** @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. */ 308 inline static void stopCreatingHierarchy() { hierarchyCreatingCounter_s--; } 322 309 323 310 static std::map<std::string, Identifier*>& getTypeIDIdentifierMap(); … … 326 313 327 314 std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to 328 std::set<const Identifier*>* children_;//!< The children of the class the Identifier belongs to315 mutable std::set<const Identifier*> children_; //!< The children of the class the Identifier belongs to 329 316 330 317 std::set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to 331 std::set<const Identifier*>* directChildren_;//!< The direct children of the class the Identifier belongs to318 mutable std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to 332 319 333 320 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
Note: See TracChangeset
for help on using the changeset viewer.