[Orxonox-commit 4924] r9593 - in code/branches/core6/src/libraries/core: class object
landauf at orxonox.net
landauf at orxonox.net
Wed Mar 27 23:17:45 CET 2013
Author: landauf
Date: 2013-03-27 23:17:45 +0100 (Wed, 27 Mar 2013)
New Revision: 9593
Modified:
code/branches/core6/src/libraries/core/class/Identifier.cc
code/branches/core6/src/libraries/core/class/Identifier.h
code/branches/core6/src/libraries/core/object/MetaObjectList.cc
code/branches/core6/src/libraries/core/object/ObjectListBase.cc
code/branches/core6/src/libraries/core/object/ObjectListBase.h
Log:
moved logic to remove an element from an ObjectListBase from MetaObjectList to ObjectListBase
Modified: code/branches/core6/src/libraries/core/class/Identifier.cc
===================================================================
--- code/branches/core6/src/libraries/core/class/Identifier.cc 2013-03-27 20:35:06 UTC (rev 9592)
+++ code/branches/core6/src/libraries/core/class/Identifier.cc 2013-03-27 22:17:45 UTC (rev 9593)
@@ -51,7 +51,7 @@
Identifier::Identifier()
: classID_(IdentifierManager::classIDCounter_s++)
{
- this->objects_ = new ObjectListBase(this);
+ this->objects_ = new ObjectListBase();
this->bCreatedOneObject_ = false;
this->bSetName_ = false;
Modified: code/branches/core6/src/libraries/core/class/Identifier.h
===================================================================
--- code/branches/core6/src/libraries/core/class/Identifier.h 2013-03-27 20:35:06 UTC (rev 9592)
+++ code/branches/core6/src/libraries/core/class/Identifier.h 2013-03-27 22:17:45 UTC (rev 9593)
@@ -427,7 +427,7 @@
void ClassIdentifier<T>::addObjectToList(T* object, Listable*)
{
orxout(verbose, context::object_list) << "Added object to " << this->getName() << "-list." << endl;
- object->metaList_->add(this->objects_, this->objects_->add(new ObjectListElement<T>(object)));
+ object->metaList_->add(this->objects_, this->objects_->add(object));
}
template <class T>
Modified: code/branches/core6/src/libraries/core/object/MetaObjectList.cc
===================================================================
--- code/branches/core6/src/libraries/core/object/MetaObjectList.cc 2013-03-27 20:35:06 UTC (rev 9592)
+++ code/branches/core6/src/libraries/core/object/MetaObjectList.cc 2013-03-27 22:17:45 UTC (rev 9593)
@@ -47,19 +47,7 @@
*/
MetaObjectListElement::~MetaObjectListElement()
{
- orxout(verbose, context::object_list) << "Removing Object from " << this->list_->getIdentifier()->getName() << "-list." << endl;
- this->list_->notifyIterators(this->element_->objectBase_);
-
- if (this->element_->next_)
- this->element_->next_->prev_ = this->element_->prev_;
- else
- this->list_->last_ = this->element_->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
-
- if (this->element_->prev_)
- this->element_->prev_->next_ = this->element_->next_;
- else
- this->list_->first_ = this->element_->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
-
+ this->list_->removeElement(this->element_);
delete this->element_;
}
Modified: code/branches/core6/src/libraries/core/object/ObjectListBase.cc
===================================================================
--- code/branches/core6/src/libraries/core/object/ObjectListBase.cc 2013-03-27 20:35:06 UTC (rev 9592)
+++ code/branches/core6/src/libraries/core/object/ObjectListBase.cc 2013-03-27 22:17:45 UTC (rev 9593)
@@ -35,6 +35,7 @@
#include <set>
#include "Iterator.h"
+#include "Listable.h"
#include "ObjectListIterator.h"
namespace orxonox
@@ -42,9 +43,8 @@
/**
@brief Constructor: Sets default values.
*/
- ObjectListBase::ObjectListBase(Identifier* identifier)
+ ObjectListBase::ObjectListBase()
{
- this->identifier_ = identifier;
this->first_ = 0;
this->last_ = 0;
}
@@ -80,7 +80,7 @@
@param element The element to add
@return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object
*/
- ObjectListBaseElement* ObjectListBase::add(ObjectListBaseElement* element)
+ ObjectListBaseElement* ObjectListBase::addElement(ObjectListBaseElement* element)
{
if (!this->last_)
{
@@ -99,4 +99,20 @@
return this->last_;
}
+
+ void ObjectListBase::removeElement(ObjectListBaseElement* element)
+ {
+ orxout(verbose, context::object_list) << "Removing Object from " << element->objectBase_->getIdentifier()->getName() << "-list." << endl;
+ this->notifyIterators(element->objectBase_);
+
+ if (element->next_)
+ element->next_->prev_ = element->prev_;
+ else
+ this->last_ = element->prev_; // If there is no next_, we deleted the last object and have to update the last_ pointer of the list
+
+ if (element->prev_)
+ element->prev_->next_ = element->next_;
+ else
+ this->first_ = element->next_; // If there is no prev_, we deleted the first object and have to update the first_ pointer of the list
+ }
}
Modified: code/branches/core6/src/libraries/core/object/ObjectListBase.h
===================================================================
--- code/branches/core6/src/libraries/core/object/ObjectListBase.h 2013-03-27 20:35:06 UTC (rev 9592)
+++ code/branches/core6/src/libraries/core/object/ObjectListBase.h 2013-03-27 22:17:45 UTC (rev 9593)
@@ -92,14 +92,17 @@
*/
class _CoreExport ObjectListBase
{
- friend class MetaObjectListElement;
-
public:
- ObjectListBase(Identifier* identifier);
+ ObjectListBase();
~ObjectListBase();
- ObjectListBaseElement* add(ObjectListBaseElement* element);
+ template <class T>
+ inline ObjectListBaseElement* add(T* object)
+ { return this->addElement(new ObjectListElement<T>(object)); }
+ ObjectListBaseElement* addElement(ObjectListBaseElement* element);
+ void removeElement(ObjectListBaseElement* element);
+
/// Helper struct, used to export an element and the list to an instance of Iterator.
struct Export
{
@@ -143,10 +146,7 @@
}
void notifyIterators(Listable* object) const;
- inline Identifier* getIdentifier() const { return this->identifier_; }
-
private:
- Identifier* identifier_; //!< The Iterator owning this list
ObjectListBaseElement* first_; //!< The first element in the list
ObjectListBaseElement* last_; //!< The last element in the list
std::vector<void*> iterators_; //!< A list of Iterators pointing on an element in this list
More information about the Orxonox-commit
mailing list