Changeset 9696 in orxonox.OLD for branches/new_class_id
- Timestamp:
- Aug 24, 2006, 10:50:47 PM (18 years ago)
- Location:
- branches/new_class_id/src/lib/lang
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/new_class_id/src/lib/lang/new_object_list.cc
r9685 r9696 113 113 114 114 /** 115 * @brief Searches for a ObjectList with the ID classID 116 * @param classID the ID to search for. 117 * @return The NewObjectList if found, NULL otherwise. 118 */ 119 const NewObjectListBase* const NewObjectListBase::getObjectList(int classID) 120 { 121 assert (NewObjectListBase::_classesByID != NULL); 122 NewObjectListBase::classIDMap::iterator it = NewObjectListBase::_classesByID->find(classID); 123 if (it != NewObjectListBase::_classesByID->end()) 124 return (*it).second; 125 else 126 return NULL; 127 } 128 129 /** 130 * @brief Searches for a ObjectList with the Name className 131 * @param className the Name to search for. 132 * @return The NewObjectList if found, NULL otherwise. 133 */ 134 const NewObjectListBase* const NewObjectListBase::getObjectList(const std::string& className) 135 { 136 assert (NewObjectListBase::_classesByName != NULL); 137 NewObjectListBase::classNameMap::iterator it = NewObjectListBase::_classesByName->find(className); 138 if (it != NewObjectListBase::_classesByName->end()) 139 return (*it).second; 140 else 141 return NULL; 142 } 143 144 /** 145 * @brief Searches for a ObjectList with the NewClassID classID 146 * @param classID the ID to search for. 147 * @return The NewObjectList if found, NULL otherwise. 148 */ 149 const NewObjectListBase* const NewObjectListBase::getObjectList(const NewClassID& classID) 150 { 151 return NewObjectListBase::getObjectList(classID.id()); 152 } 153 154 /** 155 * @brief Retrieves the first BaseObject matching the name objectName from the List matching classID. 156 * @param classID the ID of the List. 157 * @param objectName the Name of the Object to search for 158 */ 159 BaseObject* NewObjectListBase::getObject(int classID, const std::string& objectName) 160 { 161 const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID); 162 163 if (base != NULL) 164 return base->getBaseObject(objectName); 165 else 166 return NULL; 167 } 168 169 /** 170 * @brief Retrieves the first BaseObject matching the name objectName from the List matching className. 171 * @param className the Name of the List. 172 * @param objectName the Name of the Object to search for 173 */ 174 BaseObject* NewObjectListBase::getObject(const std::string& className, const std::string& objectName) 175 { 176 const NewObjectListBase* const base = NewObjectListBase::getObjectList(className); 177 178 if (base != NULL) 179 return base->getBaseObject(objectName); 180 else 181 return NULL; 182 } 183 184 /** 185 * @brief Retrieves the first BaseObject matching the name objectName from the List matching classID. 186 * @param classID The NewClassID of the List. 187 * @param objectName the Name of the Object to search for 188 */ 189 BaseObject* NewObjectListBase::getObject(const NewClassID& classID, const std::string& objectName) 190 { 191 const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID); 192 193 if (base != NULL) 194 return base->getBaseObject(objectName); 195 else 196 return NULL; 197 } 198 199 200 /** 115 201 * @brief Converts an ID into a ClassName String. 116 202 * @param classID The ID to convert. … … 119 205 const std::string& NewObjectListBase::IDToString(int classID) 120 206 { 121 assert (NewObjectListBase::_classesByID != NULL);122 NewObjectListBase::classIDMap::iterator it = NewObjectListBase::_classesByID->find(classID); 123 if ( it != NewObjectListBase::_classesByID->end())124 return (*it).second->name();207 const NewObjectListBase* const base = NewObjectListBase::getObjectList(classID); 208 209 if (base != NULL) 210 return base->name(); 125 211 else 126 212 { … … 138 224 int NewObjectListBase::StringToID(const std::string& className) 139 225 { 140 assert (NewObjectListBase::_classesByName != NULL);141 NewObjectListBase::classNameMap::iterator it = NewObjectListBase::_classesByName->find(className); 142 if ( it != NewObjectListBase::_classesByName->end())143 return (*it).second->id();226 const NewObjectListBase* const base = NewObjectListBase::getObjectList(className); 227 228 if (base != NULL) 229 return base->id(); 144 230 else 145 231 return -1; -
branches/new_class_id/src/lib/lang/new_object_list.h
r9695 r9696 116 116 virtual base_iterator base_end() const = 0; 117 117 118 static const NewObjectListBase* const getObjectList(int classID); 119 static const NewObjectListBase* const getObjectList(const std::string& className); 120 static const NewObjectListBase* const getObjectList(const NewClassID& classID); 121 122 static BaseObject* getObject(int classID, const std::string& objectName); 123 static BaseObject* getObject(const std::string& className, const std::string& objectName); 124 static BaseObject* getObject(const NewClassID& classID, const std::string& objectName); 125 126 virtual BaseObject* getBaseObject(const std::string& name) const = 0; 118 127 119 128 protected: … … 166 175 ~NewObjectList(); 167 176 177 virtual BaseObject* getBaseObject(const std::string& name) const; 168 178 T* getObject(const std::string& name) const; 169 179 inline const list& objects() const { return _objects; }; … … 239 249 } 240 250 251 /** 252 * @brief Retrieves a BaseObject matching the Name name in this List. 253 * @param name the Name of the Object. 254 * @returns a BaseObject pointing to the object if found, NULL otherwise. 255 */ 256 template <class T> 257 BaseObject* NewObjectList<T>::getBaseObject(const std::string& name) const 258 { 259 return this->getObject(name); 260 } 261 262 263 264 /** 265 * @brief Retrieves an Object of type T matching the Name name in this List. 266 * @param name the Name of the Object. 267 * @returns an Object of type T pointing to the object if found, NULL otherwise. 268 */ 241 269 template <class T> 242 270 T* NewObjectList<T>::getObject(const std::string& name) const … … 249 277 } 250 278 279 /** 280 * @brief registers an Object to the NewObjectList. 281 * @param T object the Object to register. 282 * @returns a pointer to the iterator inside of the list. 283 */ 251 284 template <class T> 252 285 NewObjectListBase::IteratorBase* NewObjectList<T>::registerObject(T* object) … … 256 289 } 257 290 291 /** 292 * @brief removes an Object from the ClassList. 293 * @param iterator the Position at which to remove the Object. 294 */ 258 295 template <class T> 259 296 void NewObjectList<T>::unregisterObject(IteratorBase* iterator) … … 263 300 } 264 301 265 302 /** 303 * @brief print out some debug information 304 * @note this function will most probably vanish from here and be completely moved to the base class. 305 */ 266 306 template <class T> 267 307 void NewObjectList<T>::debug() const
Note: See TracChangeset
for help on using the changeset viewer.