Changeset 10539 for code/branches/core7/src/libraries/core/class
- Timestamp:
- Jun 7, 2015, 12:10:24 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core7/src/libraries/core/class/Identifier.h
r10537 r10539 152 152 inline bool isInitialized() const { return this->bInitialized_; } 153 153 154 virtual void destroyObjects() = 0; 155 156 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const = 0; 157 158 static bool initConfigValues_s; // TODO: this is a hack - remove it as soon as possible 159 154 160 155 161 ///////////////////////////// … … 215 221 XMLPortObjectContainer* getXMLPortObjectContainer(const std::string& sectionname); 216 222 217 virtual bool canDynamicCastObjectToIdentifierClass(Identifiable* object) const = 0;218 219 static bool initConfigValues_s; // TODO: this is a hack - remove it as soon as possible220 221 223 protected: 222 224 virtual void createSuperFunctionCaller() const = 0; … … 297 299 { return dynamic_cast<T*>(object) != 0; } 298 300 301 virtual void destroyObjects(); 302 299 303 static ClassIdentifier<T>* getIdentifier(); 300 304 … … 307 311 void addObjectToList(T* object, Listable*); 308 312 void addObjectToList(T* object, Identifiable*); 313 314 void destroyObjects(Listable*); 315 void destroyObjects(void*); 316 317 void destroyObject(Destroyable* object); 318 void destroyObject(void* object); 309 319 310 320 void updateConfigValues(bool updateChildren, Listable*) const; … … 389 399 { 390 400 // no action 401 } 402 403 /** 404 * @brief Destroy all objects of this class (must be Listable). 405 * Destroyables are destroyed with destroy(), all other classes with delete. 406 */ 407 template <class T> 408 void ClassIdentifier<T>::destroyObjects() 409 { 410 this->destroyObjects((T*)0); 411 } 412 413 /** 414 * @brief Only searches and destroys objects if is a @ref Listable 415 */ 416 template <class T> 417 void ClassIdentifier<T>::destroyObjects(Listable*) 418 { 419 ObjectListBase* objectList = Context::getRootContext()->getObjectList(this); 420 ObjectListElement<T>* begin = static_cast<ObjectListElement<T>*>(objectList->begin()); 421 ObjectListElement<T>* end = static_cast<ObjectListElement<T>*>(objectList->end()); 422 for (typename ObjectList<T>::iterator it = begin; it != end; ) 423 this->destroyObject(*(it++)); 424 } 425 426 template <class T> 427 void ClassIdentifier<T>::destroyObjects(void*) 428 { 429 // no action 430 } 431 432 /** 433 * @brief Call 'object->destroy()' for Destroyables and 'delete object' for all other types. 434 */ 435 template <class T> 436 void ClassIdentifier<T>::destroyObject(Destroyable* object) 437 { 438 object->destroy(); 439 } 440 441 template <class T> 442 void ClassIdentifier<T>::destroyObject(void* object) 443 { 444 delete static_cast<Identifiable*>(object); 391 445 } 392 446
Note: See TracChangeset
for help on using the changeset viewer.