- Timestamp:
- Dec 9, 2007, 11:21:14 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/objecthierarchy/src/orxonox/core/Identifier.h
r434 r447 7 7 - a list with all objects 8 8 - parents and childs 9 - the factory , if available9 - the factory (if available) 10 10 - the networkID that can be synchronised with the server 11 - all configurable variables (if available) 11 12 12 13 Every object has a pointer to the Identifier of its class. This allows the use isA(...), … … 18 19 19 20 SubclassIdentifier is a separated class, acting like an Identifier, but has a given class. 20 You can only assign Identifiers of the given class ora derivative to a SubclassIdentifier.21 You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier. 21 22 */ 22 23 … … 48 49 - a list with all objects 49 50 - parents and childs 50 - the factory , if available51 - the factory (if available) 51 52 - the networkID that can be synchronised with the server 53 - all configurable variables (if available) 52 54 53 55 Every object has a pointer to the Identifier of its class. This allows the use isA(...), … … 87 89 inline IdentifierList& getChildren() const { return *this->children_; } 88 90 89 /** @returns true, if a branch of the class-hierarchy is getting created, causing all new objects to store their parents. */91 /** @returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. */ 90 92 inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); } 91 93 92 /** @returns the NetworkID to identify a class through the network. */94 /** @returns the network ID to identify a class through the network. */ 93 95 inline const unsigned int getNetworkID() const { return this->classID_; } 94 96 97 /** @brief Sets the network ID to a new value. @param id The new value */ 95 98 void setNetworkID(unsigned int id); 96 99 100 /** @returns the ConfigValueContainer of a variable, given by the string of its name. @param varname The name of the variable */ 97 101 inline ConfigValueContainer* getConfigValueContainer(const std::string& varname) 98 102 { return this->configValues_[varname]; } 99 103 104 /** @brief Sets the ConfigValueContainer of a variable, given by the string of its name. @param varname The name of the variablee @param container The container */ 100 105 inline void setConfigValueContainer(const std::string& varname, ConfigValueContainer* container) 101 106 { this->configValues_[varname] = container; } … … 134 139 std::string name_; //!< The name of the class the Identifier belongs to 135 140 136 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class 141 BaseFactory* factory_; //!< The Factory, able to create new objects of the given class (if available) 137 142 bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents) 138 143 static 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) 139 static unsigned int classIDcounter_s; //!< The number of uniqueIdentifiers140 unsigned int classID_; //!< The network ID to identify a class through the network141 std::map<std::string, ConfigValueContainer*> configValues_; 144 static unsigned int classIDcounter_s; //!< The number of existing Identifiers 145 unsigned int classID_; //!< The network ID to identify a class through the network 146 std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer 142 147 }; 143 148 … … 173 178 174 179 /** 175 @brief Constructor: Create the ObjectList.180 @brief Constructor: Creates the ObjectList. 176 181 */ 177 182 template <class T> … … 182 187 183 188 /** 184 @brief Destructor: Delete the ObjectList, setthe singleton-pointer to zero.189 @brief Destructor: Deletes the ObjectList, sets the singleton-pointer to zero. 185 190 */ 186 191 template <class T> … … 195 200 @param parents An IdentifierList, containing the Identifiers of all parents of the class 196 201 @param name A string, containing exactly the name of the class 197 @param bRootClass True if the class is either an Interface or BaseObject itself202 @param bRootClass True if the class is either an Interface or the BaseObject itself 198 203 @return The ClassIdentifier itself 199 204 */ … … 235 240 236 241 /** 237 @returns the Identifier itself 242 @returns the Identifier itself. 238 243 */ 239 244 template <class T> … … 270 275 //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites. 271 276 /** 272 You can only assign Identifiers that belong to a class of at least B(or derived) to a SubclassIdentifier<T>.277 You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>. 273 278 If you assign something else, the program aborts. 274 279 Because we know the minimal type, a dynamic_cast is done, which makes it easier to create a new object. … … 323 328 324 329 /** 325 @brief Creates a new object of the type of the assigned identifier and dynamic_casts it to the minimal type given by the SubclassIdentifier.330 @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T. 326 331 @return The new object 327 332 */ … … 330 335 BaseObject* newObject = this->identifier_->fabricate(); 331 336 332 // Check if the creation w orked337 // Check if the creation was successful 333 338 if (newObject) 334 339 {
Note: See TracChangeset
for help on using the changeset viewer.