[Orxonox-commit 4928] r9597 - in code/branches/core6/src/libraries/core: . class object
landauf at orxonox.net
landauf at orxonox.net
Fri Mar 29 11:44:22 CET 2013
Author: landauf
Date: 2013-03-29 11:44:22 +0100 (Fri, 29 Mar 2013)
New Revision: 9597
Removed:
code/branches/core6/src/libraries/core/object/MetaObjectList.cc
code/branches/core6/src/libraries/core/object/MetaObjectList.h
Modified:
code/branches/core6/src/libraries/core/CorePrereqs.h
code/branches/core6/src/libraries/core/class/Identifier.h
code/branches/core6/src/libraries/core/object/CMakeLists.txt
code/branches/core6/src/libraries/core/object/Listable.cc
code/branches/core6/src/libraries/core/object/Listable.h
code/branches/core6/src/libraries/core/object/ObjectListBase.cc
code/branches/core6/src/libraries/core/object/ObjectListBase.h
Log:
removed MetaObjectList. replaced it by std::vector because object list elements can now remove themselves from their lists.
Modified: code/branches/core6/src/libraries/core/CorePrereqs.h
===================================================================
--- code/branches/core6/src/libraries/core/CorePrereqs.h 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/CorePrereqs.h 2013-03-29 10:44:22 UTC (rev 9597)
@@ -166,8 +166,6 @@
class LuaState;
class MemoryArchive;
class MemoryArchiveFactory;
- class MetaObjectList;
- class MetaObjectListElement;
class Namespace;
class NamespaceNode;
template <class T>
Modified: code/branches/core6/src/libraries/core/class/Identifier.h
===================================================================
--- code/branches/core6/src/libraries/core/class/Identifier.h 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/class/Identifier.h 2013-03-29 10:44:22 UTC (rev 9597)
@@ -89,7 +89,6 @@
#include <loki/TypeTraits.h>
#include "util/Output.h"
-#include "core/object/MetaObjectList.h"
#include "core/object/ObjectList.h"
#include "core/object/ObjectListBase.h"
#include "IdentifierManager.h"
@@ -427,7 +426,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(object));
+ object->elements_.push_back(this->objects_->add(object));
}
template <class T>
Modified: code/branches/core6/src/libraries/core/object/CMakeLists.txt
===================================================================
--- code/branches/core6/src/libraries/core/object/CMakeLists.txt 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/object/CMakeLists.txt 2013-03-29 10:44:22 UTC (rev 9597)
@@ -2,6 +2,5 @@
Context.cc
Destroyable.cc
Listable.cc
- MetaObjectList.cc
ObjectListBase.cc
)
Modified: code/branches/core6/src/libraries/core/object/Listable.cc
===================================================================
--- code/branches/core6/src/libraries/core/object/Listable.cc 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/object/Listable.cc 2013-03-29 10:44:22 UTC (rev 9597)
@@ -32,17 +32,16 @@
*/
#include "Listable.h"
+#include "ObjectListBase.h"
-#include "core/object/MetaObjectList.h"
-
namespace orxonox
{
/**
- @brief Constructor: creates the meta-object-list.
+ @brief Constructor: Allocates space in the element list.
*/
Listable::Listable()
{
- this->metaList_ = new MetaObjectList();
+ this->elements_.reserve(6);
}
/**
@@ -58,8 +57,8 @@
*/
void Listable::unregisterObject()
{
- if (this->metaList_)
- delete this->metaList_;
- this->metaList_ = 0;
+ for (size_t i = 0; i < this->elements_.size(); ++i)
+ delete this->elements_[i];
+ this->elements_.clear();
}
}
Modified: code/branches/core6/src/libraries/core/object/Listable.h
===================================================================
--- code/branches/core6/src/libraries/core/object/Listable.h 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/object/Listable.h 2013-03-29 10:44:22 UTC (rev 9597)
@@ -36,12 +36,15 @@
#define _Listable_H__
#include "core/CorePrereqs.h"
+
+#include <vector>
+
#include "core/class/Identifiable.h"
namespace orxonox
{
/**
- @brief Listable stores the MetaObjectList which is used when storing instances in object lists.
+ @brief Listable stores the entries of all object lists pointing to this instance.
*/
class _CoreExport Listable : virtual public Identifiable
{
@@ -55,7 +58,7 @@
void unregisterObject();
private:
- MetaObjectList* metaList_; //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
+ std::vector<ObjectListBaseElement*> elements_; //!< The corresponding ObjectListElements in all object lists the object is registered in
};
}
Deleted: code/branches/core6/src/libraries/core/object/MetaObjectList.cc
===================================================================
--- code/branches/core6/src/libraries/core/object/MetaObjectList.cc 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/object/MetaObjectList.cc 2013-03-29 10:44:22 UTC (rev 9597)
@@ -1,90 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of the MetaObjectList class.
-*/
-
-#include "MetaObjectList.h"
-
-#include "util/Output.h"
-#include "core/class/Identifier.h"
-#include "ObjectListBase.h"
-
-namespace orxonox
-{
- // ###############################
- // ### MetaObjectListElement ###
- // ###############################
- /**
- @brief Destructor: Removes the ObjectListBaseElement from the ObjectListBase by linking next_ and prev_ of the ObjectListBaseElement.
- */
- MetaObjectListElement::~MetaObjectListElement()
- {
- delete this->element_;
- }
-
-
- // ###############################
- // ### MetaObjectList ###
- // ###############################
- /**
- @brief Constructor: Sets first_ to zero.
- */
- MetaObjectList::MetaObjectList()
- {
- this->first_ = 0;
- }
-
- /**
- @brief Destructor: Removes all elements from the list, causing them to remove the stored ObjectListElement from the ObjectList.
- */
- MetaObjectList::~MetaObjectList()
- {
- MetaObjectListElement* temp;
- while (this->first_)
- {
- temp = this->first_->next_;
- delete this->first_;
- this->first_ = temp;
- }
- }
-
- /**
- @brief Adds an ObjectList and an element of that list to the MetaObjectList.
- @param list The ObjectList wherein the element is
- @param element The element wherein the object is
- */
- void MetaObjectList::add(ObjectListBase* list, ObjectListBaseElement* element)
- {
- MetaObjectListElement* temp = this->first_;
- this->first_ = new MetaObjectListElement(list, element);
- this->first_->next_ = temp;
- }
-}
Deleted: code/branches/core6/src/libraries/core/object/MetaObjectList.h
===================================================================
--- code/branches/core6/src/libraries/core/object/MetaObjectList.h 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/object/MetaObjectList.h 2013-03-29 10:44:22 UTC (rev 9597)
@@ -1,86 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Fabian 'x3n' Landau
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @ingroup Object ObjectList
- @brief Declaration of the MetaObjectList class.
-
- The MetaObjectList is a single-linked list, containing all list-elements and their
- lists wherein the object, owning the MetaObjectList, is registered.
- This allows much faster deletion of objects because no iteration is needed.
-*/
-
-#ifndef _MetaObjectList_H__
-#define _MetaObjectList_H__
-
-#include "core/CorePrereqs.h"
-
-namespace orxonox
-{
- // ###############################
- // ### MetaObjectListElement ###
- // ###############################
- /// The list-element of the MetaObjectList
- class _CoreExport MetaObjectListElement
- {
- public:
- /**
- @brief Constructor: Creates the list-element with given list and element.
- */
- MetaObjectListElement(ObjectListBase* list, ObjectListBaseElement* element) : next_(0), element_(element), list_(list) {}
- ~MetaObjectListElement();
-
- MetaObjectListElement* next_; //!< The next Element in the list
- ObjectListBaseElement* element_; //!< The list element, containing the object
- ObjectListBase* list_; //!< The list, containing the element
- };
-
-
- // ###############################
- // ### MetaObjectList ###
- // ###############################
- /**
- @brief The MetaObjectList contains ObjectListBaseElements and their ObjectListBases.
-
- The MetaObjectList is a single-linked list, containing all list-elements and their
- lists wherein the object that owns the MetaObjectList is registered.
- This allows much faster deletion of objects because no iteration is needed.
- */
- class _CoreExport MetaObjectList
- {
- public:
- MetaObjectList();
- ~MetaObjectList();
- void add(ObjectListBase* list, ObjectListBaseElement* element);
-
- MetaObjectListElement* first_; //!< The first element in the list
- };
-}
-
-#endif /* _MetaObjectList_H__ */
Modified: code/branches/core6/src/libraries/core/object/ObjectListBase.cc
===================================================================
--- code/branches/core6/src/libraries/core/object/ObjectListBase.cc 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/object/ObjectListBase.cc 2013-03-29 10:44:22 UTC (rev 9597)
@@ -83,9 +83,8 @@
/**
@brief Adds a new object to the end of the list.
@param element The element to add
- @return The pointer to the new ObjectListBaseElement, needed by the MetaObjectList of the added object
*/
- ObjectListBaseElement* ObjectListBase::addElement(ObjectListBaseElement* element)
+ void ObjectListBase::addElement(ObjectListBaseElement* element)
{
if (!this->last_)
{
@@ -101,10 +100,11 @@
this->last_->prev_ = temp;
temp->next_ = this->last_;
}
-
- return this->last_;
}
+ /**
+ * @brief Removes the element from the list
+ */
void ObjectListBase::removeElement(ObjectListBaseElement* element)
{
orxout(verbose, context::object_list) << "Removing Object from " << element->objectBase_->getIdentifier()->getName() << "-list." << endl;
Modified: code/branches/core6/src/libraries/core/object/ObjectListBase.h
===================================================================
--- code/branches/core6/src/libraries/core/object/ObjectListBase.h 2013-03-28 23:42:24 UTC (rev 9596)
+++ code/branches/core6/src/libraries/core/object/ObjectListBase.h 2013-03-29 10:44:22 UTC (rev 9597)
@@ -100,9 +100,13 @@
template <class T>
inline ObjectListBaseElement* add(T* object)
- { return this->addElement(new ObjectListElement<T>(object, this)); }
+ {
+ ObjectListBaseElement* element = new ObjectListElement<T>(object, this);
+ this->addElement(element);
+ return element;
+ }
- ObjectListBaseElement* addElement(ObjectListBaseElement* element);
+ void addElement(ObjectListBaseElement* element);
void removeElement(ObjectListBaseElement* element);
/// Returns a pointer to the first element in the list. Works only with Iterator.
More information about the Orxonox-commit
mailing list