[Orxonox-commit 1062] r5783 - code/branches/core5/src/libraries/core
landauf at orxonox.net
landauf at orxonox.net
Thu Sep 24 20:58:28 CEST 2009
Author: landauf
Date: 2009-09-24 20:58:27 +0200 (Thu, 24 Sep 2009)
New Revision: 5783
Modified:
code/branches/core5/src/libraries/core/ClassFactory.h
code/branches/core5/src/libraries/core/Identifier.cc
code/branches/core5/src/libraries/core/Identifier.h
Log:
some cleanup
Modified: code/branches/core5/src/libraries/core/ClassFactory.h
===================================================================
--- code/branches/core5/src/libraries/core/ClassFactory.h 2009-09-24 09:32:39 UTC (rev 5782)
+++ code/branches/core5/src/libraries/core/ClassFactory.h 2009-09-24 18:58:27 UTC (rev 5783)
@@ -64,32 +64,27 @@
class ClassFactory : public Factory
{
public:
- ClassFactory(const std::string& name, bool bLoadable = true);
- BaseObject* fabricate(BaseObject* creator);
- };
+ /**
+ @brief Constructor: Adds the ClassFactory to the Identifier of the same type.
+ @param name The name of the class
+ @param bLoadable True if the class can be loaded through XML
+ */
+ ClassFactory(const std::string& name, bool bLoadable = true)
+ {
+ COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
+ ClassIdentifier<T>::getIdentifier(name)->addFactory(this);
+ ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
+ }
- /**
- @brief Adds the ClassFactory to the Identifier of the same type.
- @param name The name of the class
- @param bLoadable True if the class can be loaded through XML
- */
- template <class T>
- ClassFactory<T>::ClassFactory(const std::string& name, bool bLoadable)
- {
- COUT(4) << "*** ClassFactory: Create entry for " << name << " in Factory." << std::endl;
- ClassIdentifier<T>::getIdentifier(name)->addFactory(this);
- ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
- }
-
- /**
- @brief Creates and returns a new object of class T.
- @return The new object
- */
- template <class T>
- inline BaseObject* ClassFactory<T>::fabricate(BaseObject* creator)
- {
- return static_cast<BaseObject*>(new T(creator));
- }
+ /**
+ @brief Creates and returns a new object of class T.
+ @return The new object
+ */
+ inline BaseObject* fabricate(BaseObject* creator)
+ {
+ return static_cast<BaseObject*>(new T(creator));
+ }
+ };
}
#endif /* _ClassFactory_H__ */
Modified: code/branches/core5/src/libraries/core/Identifier.cc
===================================================================
--- code/branches/core5/src/libraries/core/Identifier.cc 2009-09-24 09:32:39 UTC (rev 5782)
+++ code/branches/core5/src/libraries/core/Identifier.cc 2009-09-24 18:58:27 UTC (rev 5783)
@@ -65,9 +65,6 @@
this->bHasConfigValues_ = false;
this->bHasConsoleCommands_ = false;
- this->children_ = new std::set<const Identifier*>();
- this->directChildren_ = new std::set<const Identifier*>();
-
// Default network ID is the class ID
this->networkID_ = this->classID_;
}
@@ -77,8 +74,6 @@
*/
Identifier::~Identifier()
{
- delete this->children_;
- delete this->directChildren_;
delete this->objects_;
if (this->factory_)
@@ -164,7 +159,7 @@
for (std::set<const Identifier*>::iterator it = parents->begin(); it != parents->end(); ++it)
{
// Tell the parent we're one of it's children
- (*it)->getChildrenIntern().insert((*it)->getChildrenIntern().end(), this);
+ (*it)->children_.insert((*it)->children_.end(), this);
// Erase all parents of our parent from our direct-parent-list
for (std::set<const Identifier*>::const_iterator it1 = (*it)->getParents().begin(); it1 != (*it)->getParents().end(); ++it1)
@@ -186,7 +181,7 @@
for (std::set<const Identifier*>::iterator it = this->directParents_.begin(); it != this->directParents_.end(); ++it)
{
// Tell the parent we're one of it's direct children
- (*it)->getDirectChildrenIntern().insert((*it)->getDirectChildrenIntern().end(), this);
+ (*it)->directChildren_.insert((*it)->directChildren_.end(), this);
// Create the super-function dependencies
(*it)->createSuperFunctionCaller();
@@ -200,10 +195,8 @@
void Identifier::createClassHierarchy()
{
COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl;
- std::map<std::string, Identifier*>::const_iterator it;
- it = Identifier::getStringIdentifierMap().begin();
- Identifier::getStringIdentifierMap().begin()->second->startCreatingHierarchy();
- for (it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
+ Identifier::startCreatingHierarchy();
+ for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
{
// To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
if (it->second->hasFactory())
@@ -212,7 +205,7 @@
delete temp;
}
}
- Identifier::getStringIdentifierMap().begin()->second->stopCreatingHierarchy();
+ Identifier::stopCreatingHierarchy();
COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl;
}
@@ -314,7 +307,7 @@
*/
bool Identifier::isParentOf(const Identifier* identifier) const
{
- return (this->children_->find(identifier) != this->children_->end());
+ return (this->children_.find(identifier) != this->children_.end());
}
/**
@@ -323,7 +316,7 @@
*/
bool Identifier::isDirectParentOf(const Identifier* identifier) const
{
- return (this->directChildren_->find(identifier) != this->directChildren_->end());
+ return (this->directChildren_.find(identifier) != this->directChildren_.end());
}
/**
Modified: code/branches/core5/src/libraries/core/Identifier.h
===================================================================
--- code/branches/core5/src/libraries/core/Identifier.h 2009-09-24 09:32:39 UTC (rev 5782)
+++ code/branches/core5/src/libraries/core/Identifier.h 2009-09-24 18:58:27 UTC (rev 5783)
@@ -137,11 +137,11 @@
inline std::set<const Identifier*>::const_iterator getParentsEnd() const { return this->parents_.end(); }
/** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
- inline const std::set<const Identifier*>& getChildren() const { return (*this->children_); }
+ inline const std::set<const Identifier*>& getChildren() const { return this->children_; }
/** @brief Returns the begin-iterator of the children-list. @return The begin-iterator */
- inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_->begin(); }
+ inline std::set<const Identifier*>::const_iterator getChildrenBegin() const { return this->children_.begin(); }
/** @brief Returns the end-iterator of the children-list. @return The end-iterator */
- inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_->end(); }
+ inline std::set<const Identifier*>::const_iterator getChildrenEnd() const { return this->children_.end(); }
/** @brief Returns the direct parents of the class the Identifier belongs to. @return The list of all direct parents */
inline const std::set<const Identifier*>& getDirectParents() const { return this->directParents_; }
@@ -151,11 +151,11 @@
inline std::set<const Identifier*>::const_iterator getDirectParentsEnd() const { return this->directParents_.end(); }
/** @brief Returns the direct children the class the Identifier belongs to. @return The list of all direct children */
- inline const std::set<const Identifier*>& getDirectChildren() const { return (*this->directChildren_); }
+ inline const std::set<const Identifier*>& getDirectChildren() const { return this->directChildren_; }
/** @brief Returns the begin-iterator of the direct-children-list. @return The begin-iterator */
- inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_->begin(); }
+ inline std::set<const Identifier*>::const_iterator getDirectChildrenBegin() const { return this->directChildren_.begin(); }
/** @brief Returns the end-iterator of the direct-children-list. @return The end-iterator */
- inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_->end(); }
+ inline std::set<const Identifier*>::const_iterator getDirectChildrenEnd() const { return this->directChildren_.end(); }
//////////////////////////
@@ -295,40 +295,27 @@
static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern();
/** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
- inline std::set<const Identifier*>& getChildrenIntern() const { return (*this->children_); }
+ inline std::set<const Identifier*>& getChildrenIntern() const { return this->children_; }
/** @brief Returns the direct children of the class the Identifier belongs to. @return The list of all direct children */
- inline std::set<const Identifier*>& getDirectChildrenIntern() const { return (*this->directChildren_); }
+ inline std::set<const Identifier*>& getDirectChildrenIntern() const { return this->directChildren_; }
ObjectListBase* objects_; //!< The list of all objects of this class
private:
- /**
- @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
- */
- inline static void startCreatingHierarchy()
- {
- hierarchyCreatingCounter_s++;
- COUT(4) << "*** Identifier: Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
- }
+ /** @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents. */
+ inline static void startCreatingHierarchy() { hierarchyCreatingCounter_s++; }
+ /** @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents. */
+ inline static void stopCreatingHierarchy() { hierarchyCreatingCounter_s--; }
- /**
- @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
- */
- inline static void stopCreatingHierarchy()
- {
- hierarchyCreatingCounter_s--;
- COUT(4) << "*** Identifier: Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
- }
-
static std::map<std::string, Identifier*>& getTypeIDIdentifierMap();
void initialize(std::set<const Identifier*>* parents);
std::set<const Identifier*> parents_; //!< The parents of the class the Identifier belongs to
- std::set<const Identifier*>* children_; //!< The children of the class the Identifier belongs to
+ mutable std::set<const Identifier*> children_; //!< The children of the class the Identifier belongs to
std::set<const Identifier*> directParents_; //!< The direct parents of the class the Identifier belongs to
- std::set<const Identifier*>* directChildren_; //!< The direct children of the class the Identifier belongs to
+ mutable std::set<const Identifier*> directChildren_; //!< The direct children of the class the Identifier belongs to
bool bCreatedOneObject_; //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
bool bSetName_; //!< True if the name is set
More information about the Orxonox-commit
mailing list