Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 7, 2008, 5:01:44 PM (16 years ago)
Author:
nicolasc
Message:

merged FICN back into trunk
awaiting release.

Location:
code/trunk
Files:
1 deleted
14 edited
20 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

    • Property svn:ignore set to
      dependencies
  • code/trunk/src/orxonox/core/ClassFactory.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file ClassFactory.h
     30    @brief Definition and implementation of the ClassFactory class
     31
     32    The ClassFactory is able to create new objects of a specific class.
     33*/
     34
    135#ifndef _ClassFactory_H__
    236#define _ClassFactory_H__
    337
     38#include <string>
     39
     40#include "CorePrereqs.h"
     41
     42#include "Factory.h"
    443#include "Identifier.h"
     44#include "Debug.h"
    545
    646namespace orxonox
     
    949    // ###      ClassFactory       ###
    1050    // ###############################
     51    //! The ClassFactory is able to create new objects of a specific class.
    1152    template <class T>
    1253    class ClassFactory : public BaseFactory
    1354    {
    1455        public:
    15             static bool create();
     56            static bool create(const std::string& name);
    1657            BaseObject* fabricate();
    1758
    1859        private:
    19             ClassFactory() {}
    20             ClassFactory(const ClassFactory& factory) {}
    21             ~ClassFactory() {}
     60            ClassFactory() {}                               // Don't create
     61            ClassFactory(const ClassFactory& factory) {}    // Don't copy
     62            virtual ~ClassFactory() {}                      // Don't delete
    2263
    2364            static T* createNewObject();
    2465    };
    2566
     67    /**
     68        @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
     69        @return Always true (this is needed because the compiler only allows assignments before main())
     70    */
    2671    template <class T>
    27     bool ClassFactory<T>::create()
     72    bool ClassFactory<T>::create(const std::string& name)
    2873    {
     74        COUT(4) << "*** Create entry for " << name << " in Factory." << std::endl;
    2975        ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>);
    30 
    31         ClassIdentifier<T>::getIdentifier()->startCreatingHierarchy();
    32 #if HIERARCHY_VERBOSE
    33         std::cout << "*** Create Factory -> Create Class\n";
    34 #endif
    35         BaseObject* temp = ClassIdentifier<T>::getIdentifier()->fabricate();
    36         delete temp;
    37         ClassIdentifier<T>::getIdentifier()->stopCreatingHierarchy();
     76        Factory::add(name, ClassIdentifier<T>::getIdentifier());
    3877
    3978        return true;
    4079    }
    4180
     81    /**
     82        @brief Creates and returns a new object of class T.
     83        @return The new object
     84    */
    4285    template <class T>
    4386    BaseObject* ClassFactory<T>::fabricate()
     
    4689    }
    4790
     91    /**
     92        @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
     93        @return The new object
     94    */
    4895    template <class T>
    4996    T* ClassFactory<T>::createNewObject()
     
    53100}
    54101
    55 #endif
     102#endif /* _ClassFactory_H__ */
  • code/trunk/src/orxonox/core/Factory.cc

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file Factory.cc
     30    @brief Implementation of the Factory class.
     31*/
     32
     33#include "Identifier.h"
     34#include "Debug.h"
     35#include "BaseObject.h"
    136#include "Factory.h"
    2 #include "Identifier.h"
    337
    438namespace orxonox
    539{
    6     Factory* Factory::pointer_s = NULL;
    7 
     40    /**
     41        @returns the Identifier with a given name.
     42        @param name The name of the wanted Identifier
     43    */
    844    Identifier* Factory::getIdentifier(const std::string& name)
    945    {
    10         if (!pointer_s)
    11             pointer_s = new Factory;
    12 
    13         return pointer_s->identifierMap_[name];
     46        return getFactoryPointer()->identifierStringMap_[name];
    1447    }
    1548
     49    /**
     50        @returns the Identifier with a given network ID.
     51        @param id The network ID of the wanted Identifier
     52    */
     53    Identifier* Factory::getIdentifier(const unsigned int id)
     54    {
     55        return getFactoryPointer()->identifierNetworkIDMap_[id];
     56    }
     57
     58    /**
     59        @brief Adds a new Identifier to both maps.
     60        @param name The name of the identifier
     61        @param identifier The identifier to add
     62    */
    1663    void Factory::add(const std::string& name, Identifier* identifier)
    1764    {
    18         if (!pointer_s)
    19             pointer_s = new Factory;
     65        getFactoryPointer()->identifierStringMap_[name] = identifier;
     66        getFactoryPointer()->identifierNetworkIDMap_[identifier->getNetworkID()] = identifier;
     67    }
    2068
    21         pointer_s->identifierMap_[name] = identifier;
     69    /**
     70        @brief Removes the entry with the old network ID and adds a new one.
     71        @param identifier The identifier to change
     72        @param oldID The old networkID
     73        @param newID The new networkID
     74    */
     75    void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID)
     76    {
     77        getFactoryPointer()->identifierNetworkIDMap_.erase(oldID);
     78        getFactoryPointer()->identifierNetworkIDMap_[newID] = identifier;
     79    }
     80
     81    /**
     82        @brief Creates the class-hierarchy by creating and destroying one object of each type.
     83    */
     84    void Factory::createClassHierarchy()
     85    {
     86        COUT(3) << "*** Factory -> Create class-hierarchy" << std::endl;
     87        std::map<std::string, Identifier*>::iterator it;
     88        it = getFactoryPointer()->identifierStringMap_.begin();
     89        (*getFactoryPointer()->identifierStringMap_.begin()).second->startCreatingHierarchy();
     90        for (it = getFactoryPointer()->identifierStringMap_.begin(); it != getFactoryPointer()->identifierStringMap_.end(); ++it)
     91        {
     92            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
     93            BaseObject* temp = (*it).second->fabricate();
     94            delete temp;
     95        }
     96        (*getFactoryPointer()->identifierStringMap_.begin()).second->stopCreatingHierarchy();
     97        COUT(3) << "*** Factory -> Finished class-hierarchy creation" << std::endl;
     98    }
     99
     100    /**
     101        @brief Ensures the Factory gets created in the right moment.
     102        @return The Factory.
     103    */
     104    Factory* Factory::getFactoryPointer()
     105    {
     106      static Factory theOneAndOnlyFactoryInstance = Factory();
     107      return &theOneAndOnlyFactoryInstance;
    22108    }
    23109}
  • code/trunk/src/orxonox/core/Factory.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file Factory.h
     30    @brief Definition of the Factory and the BaseFactory class.
     31
     32    The Factory is a singleton, containing two maps to map either the name or the network ID
     33    of a class with the corresponding Identifier.
     34
     35    Usage:
     36    ID(classname) or ID(networkID) returns the corresponding Identifier.
     37
     38
     39    BaseObject is the parent of ClassFactory which is defined in ClassFactory.h.
     40    It can't be defined in ClassFactory.h, because of circular dependencies.
     41*/
     42
    143#ifndef _Factory_H__
    244#define _Factory_H__
     
    547#include <string>
    648
     49#include "CorePrereqs.h"
     50
    751namespace orxonox
    852{
    9     class BaseObject;
    10     class Identifier;
     53    class BaseObject; // Forward declaration
    1154
    1255    // ###############################
    1356    // ###         Factory         ###
    1457    // ###############################
    15     class Factory
     58    //! The Factory is used to map the name or the network ID of a class with its Identifier.
     59    class _CoreExport Factory
    1660    {
    1761        public:
    1862            static Identifier* getIdentifier(const std::string& name);
     63            static Identifier* getIdentifier(const unsigned int id);
    1964            static void add(const std::string& name, Identifier* identifier);
     65            static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
     66            static void createClassHierarchy();
     67
     68            static Factory* getFactoryPointer();    // avoid overriding order problem in the static intialisation process
    2069
    2170        private:
    22             Factory() {}
    23             Factory(const Factory& factory) {}
    24             ~Factory() {}
     71            Factory() {}                            // don't create
     72            Factory(const Factory& factory) {}      // don't copy
     73            ~Factory() {}                           // don't delete
    2574
    26             static Factory* pointer_s;
    27             std::map<std::string, Identifier*> identifierMap_;
     75            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
     76            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
    2877    };
    2978
     
    3180    // ###       BaseFactory       ###
    3281    // ###############################
    33     class BaseFactory
     82    //! Base-class of ClassFactory. Has to be defined separate because of circular dependencies.
     83    class _CoreExport BaseFactory
    3484    {
    3585        public:
    3686            virtual BaseObject* fabricate() = 0;
     87            virtual ~BaseFactory() {};
    3788    };
    3889}
    3990
    40 #endif
     91#endif /* _Factory_H__ */
  • code/trunk/src/orxonox/core/Identifier.cc

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file Identifier.cc
     30    @brief Implementation of the Identifier class.
     31*/
     32
    133#include "Identifier.h"
     34#include "Factory.h"
    235
    336namespace orxonox
     
    639    // ###       Identifier        ###
    740    // ###############################
    8     int Identifier::hierarchyCreatingCounter_s = 0;
     41    int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero (this static member variable is ok: it's used in main(), not before)
    942
     43    /**
     44        @brief Constructor: No factory, no object created, new ObjectList and a unique networkID.
     45    */
    1046    Identifier::Identifier()
    1147    {
     
    1450
    1551        this->children_ = new IdentifierList;
     52
     53        // Use a static variable because the classID gets created before main() and that's why we should avoid static member variables
     54        static unsigned int classIDcounter_s = 0;
     55        this->classID_ = classIDcounter_s++;
    1656    }
    1757
     58    /**
     59        @brief Destructor: Deletes the IdentifierList containing the children.
     60    */
    1861    Identifier::~Identifier()
    1962    {
    20         delete &this->name_;
    21 
    2263        delete this->children_;
    2364    }
    2465
     66    /**
     67        @brief Initializes the Identifier with an IdentifierList containing all parents of the class the Identifier belongs to.
     68        @param parents The IdentifierList containing all parents
     69    */
    2570    void Identifier::initialize(const IdentifierList* parents)
    2671    {
    27 #if HIERARCHY_VERBOSE
    28         std::cout << "*** Initialize " << this->name_ << "-Singleton.\n";
    29 #endif
     72        COUT(4) << "*** Initialize " << this->name_ << "-Singleton." << std::endl;
    3073        this->bCreatedOneObject_ = true;
    3174
     
    3679            {
    3780                this->parents_.add(temp1->identifier_);
    38                 temp1->identifier_->getChildren().add(this);
     81                temp1->identifier_->getChildren().add(this); // We're a child of our parents
    3982
    4083                temp1 = temp1->next_;
     
    4386    }
    4487
     88    /**
     89        @brief Creates an object of the type the Identifier belongs to.
     90        @return The new object
     91    */
    4592    BaseObject* Identifier::fabricate()
    4693    {
    4794        if (this->factory_)
    4895        {
    49             return this->factory_->fabricate();
     96            return this->factory_->fabricate(); // We have to return a BaseObject, because we don't know the exact type.
    5097        }
    5198        else
    5299        {
    53             std::cout << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract.\n";
    54             std::cout << "Aborting...";
     100            // Abstract classes don't have a factory and therefore can't create new objects
     101            COUT(1) << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract." << std::endl;
     102            COUT(1) << "Aborting..." << std::endl;
    55103            abort();
     104            return NULL;
    56105        }
    57106    }
    58107
     108    /**
     109        @brief Sets the network ID to a new value and changes the entry in the Factory.
     110        @param id The new network ID
     111    */
     112    void Identifier::setNetworkID(unsigned int id)
     113    {
     114        Factory::changeNetworkID(this, this->classID_, id);
     115        this->classID_ = id;
     116    }
     117
     118    /**
     119        @returns a reference to the Identifier map, containing all Identifiers.
     120    */
     121    std::map<std::string, Identifier*>& Identifier::getIdentifierMap()
     122    {
     123        static std::map<std::string, Identifier*> identifierMapStaticReference = std::map<std::string, Identifier*>();
     124        return identifierMapStaticReference;
     125    }
     126
     127    /**
     128        @returns true, if the Identifier is at least of the given type.
     129        @param identifier The identifier to compare with
     130    */
    59131    bool Identifier::isA(const Identifier* identifier) const
    60132    {
     
    62134    }
    63135
     136    /**
     137        @returns true, if the Identifier is exactly of the given type.
     138        @param identifier The identifier to compare with
     139    */
    64140    bool Identifier::isDirectlyA(const Identifier* identifier) const
    65141    {
     
    67143    }
    68144
     145    /**
     146        @returns true, if the assigned identifier is a child of the given identifier.
     147        @param identifier The identifier to compare with
     148    */
    69149    bool Identifier::isChildOf(const Identifier* identifier) const
    70150    {
     
    72152    }
    73153
     154    /**
     155        @returns true, if the assigned identifier is a parent of the given identifier.
     156        @param identifier The identifier to compare with
     157    */
    74158    bool Identifier::isParentOf(const Identifier* identifier) const
    75159    {
  • code/trunk/src/orxonox/core/Identifier.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file Identifier.h
     30    @brief Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes, implementation of the ClassIdentifier and SubclassIdentifier classes.
     31
     32    The Identifier contains all needed informations about the class it belongs to:
     33     - the name
     34     - a list with all objects
     35     - parents and childs
     36     - the factory (if available)
     37     - the networkID that can be synchronised with the server
     38     - all configurable variables (if available)
     39
     40    Every object has a pointer to the Identifier of its class. This allows the use isA(...),
     41    isDirectlyA(...), isChildOf(...) and isParentOf(...).
     42
     43    To create the class-hierarchy, the Identifier has some intern functions and variables.
     44
     45    Every Identifier is in fact a ClassIdentifier, but they are derived from Identifier.
     46
     47    SubclassIdentifier is a separated class, acting like an Identifier, but has a given class.
     48    You can only assign Identifiers of exactly the given class or of a derivative to a SubclassIdentifier.
     49*/
     50
    151#ifndef _Identifier_H__
    252#define _Identifier_H__
    353
    4 #include <iostream>
    5 
     54#include <map>
     55#include <string>
     56#include <utility>
     57
     58#include "CorePrereqs.h"
     59
     60#include "ObjectList.h"
    661#include "IdentifierList.h"
    7 #include "ObjectList.h"
    8 #include "Factory.h"
    9 
    10 #define HIERARCHY_VERBOSE false
    11 
     62#include "Debug.h"
     63#include "Iterator.h"
    1264
    1365namespace orxonox
    1466{
    15     class BaseObject;
     67    class BaseFactory; // Forward declaration
     68    class BaseObject;  // Forward declaration
    1669
    1770    // ###############################
    1871    // ###       Identifier        ###
    1972    // ###############################
    20     class Identifier
     73    //! The Identifier is used to identify the class of an object and to store informations about the class.
     74    /**
     75        The Identifier contains all needed informations about the class it belongs to:
     76         - the name
     77         - a list with all objects
     78         - parents and childs
     79         - the factory (if available)
     80         - the networkID that can be synchronised with the server
     81         - all configurable variables (if available)
     82
     83        Every object has a pointer to the Identifier of its class. This allows the use isA(...),
     84        isDirectlyA(...), isChildOf(...) and isParentOf(...).
     85
     86        You can't directly create an Identifier, it's just the base-class for ClassIdentifier.
     87    */
     88    class _CoreExport Identifier
    2189    {
    2290        template <class T>
    23         friend class ClassIdentifier;
     91        friend class ClassIdentifier; // Forward declaration
    2492
    2593        template <class T>
    26         friend class SubclassIdentifier;
    27 
    28         template <class T>
    29         friend class ClassFactory;
     94        friend class SubclassIdentifier; // Forward declaration
     95
     96        friend class Factory; // Forward declaration
    3097
    3198        public:
     99            /** @brief Sets the Factory. @param factory The factory to assign */
    32100            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
     101
    33102            BaseObject* fabricate();
    34 
    35103            bool isA(const Identifier* identifier) const;
    36104            bool isDirectlyA(const Identifier* identifier) const;
     
    38106            bool isParentOf(const Identifier* identifier) const;
    39107
     108            static std::map<std::string, Identifier*>& getIdentifierMap();
     109
     110            /** @brief Removes all objects of the corresponding class. */
     111            virtual void removeObjects() const = 0;
     112
     113            /** @returns the name of the class the Identifier belongs to. */
    40114            inline const std::string& getName() const { return this->name_; }
     115
     116            /** @returns the parents of the class the Identifier belongs to. */
    41117            inline const IdentifierList& getParents() const { return this->parents_; }
     118
     119            /** @returns the children of the class the Identifier belongs to. */
    42120            inline IdentifierList& getChildren() const { return *this->children_; }
    43121
     122            /** @returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. */
    44123            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
     124
     125            /** @returns the network ID to identify a class through the network. */
     126            inline const unsigned int getNetworkID() const { return this->classID_; }
     127
     128            /** @brief Sets the network ID to a new value. @param id The new value */
     129            void setNetworkID(unsigned int id);
     130
     131            /** @returns the ConfigValueContainer of a variable, given by the string of its name. @param varname The name of the variable */
     132            inline ConfigValueContainer* getConfigValueContainer(const std::string& varname)
     133                { return this->configValues_[varname]; }
     134
     135            /** @brief Sets the ConfigValueContainer of a variable, given by the string of its name. @param varname The name of the variablee @param container The container */
     136            inline void setConfigValueContainer(const std::string& varname, ConfigValueContainer* container)
     137                { this->configValues_[varname] = container; }
    45138
    46139        private:
    47140            Identifier();
    48             Identifier(const Identifier& identifier) {}
     141            Identifier(const Identifier& identifier) {} // don't copy
    49142            virtual ~Identifier();
    50143            void initialize(const IdentifierList* parents);
    51144
     145            /**
     146                @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
     147            */
    52148            inline static void startCreatingHierarchy()
    53149            {
    54150                hierarchyCreatingCounter_s++;
    55 #if HIERARCHY_VERBOSE
    56                 std::cout << "*** Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << "\n";
    57 #endif
    58             }
    59 
     151                COUT(4) << "*** Increased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
     152            }
     153
     154            /**
     155                @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
     156            */
    60157            inline static void stopCreatingHierarchy()
    61158            {
    62159                hierarchyCreatingCounter_s--;
    63 #if HIERARCHY_VERBOSE
    64                 std::cout << "*** Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << "\n";
    65 #endif
    66             }
    67 
    68             IdentifierList parents_;
    69             IdentifierList* children_;
    70 
    71             std::string name_;
    72 
    73             BaseFactory* factory_;
    74             bool bCreatedOneObject_;
    75             static int hierarchyCreatingCounter_s;
     160                COUT(4) << "*** Decreased Hierarchy-Creating-Counter to " << hierarchyCreatingCounter_s << std::endl;
     161            }
     162
     163            IdentifierList parents_;                                    //!< The Parents of the class the Identifier belongs to
     164            IdentifierList* children_;                                  //!< The Children of the class the Identifier belongs to
     165
     166            std::string name_;                                          //!< The name of the class the Identifier belongs to
     167
     168            BaseFactory* factory_;                                      //!< The Factory, able to create new objects of the given class (if available)
     169            bool bCreatedOneObject_;                                    //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
     170            static int hierarchyCreatingCounter_s;                      //!< Bigger than zero if at least one Identifier stores its parents (its an int instead of a bool to avoid conflicts with multithreading)
     171            unsigned int classID_;                                      //!< The network ID to identify a class through the network
     172            std::map<std::string, ConfigValueContainer*> configValues_; //!< A map to link the string of configurable variables with their ConfigValueContainer
    76173    };
    77174
     
    80177    // ###     ClassIdentifier     ###
    81178    // ###############################
     179    //! The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables the Identifier cannot have.
     180    /**
     181        ClassIdentifier is a Singleton, which means that only one object of a given type T exists.
     182        This makes it possible to store informations about a class, sharing them with all
     183        objects of that class without defining static variables in every class.
     184    */
    82185    template <class T>
    83186    class ClassIdentifier : public Identifier
     
    85188        public:
    86189            static ClassIdentifier<T>* registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass);
     190            static void addObject(T* object);
    87191            static ClassIdentifier<T>* getIdentifier();
    88             static void addObject(T* object);
     192            void removeObjects() const;
     193            void setName(const std::string& name);
    89194
    90195        private:
    91196            ClassIdentifier();
    92             ClassIdentifier(const ClassIdentifier<T>& identifier) {}
    93             ~ClassIdentifier();
    94 
    95             static ClassIdentifier<T>* pointer_s;
    96             ObjectList<T>* objects_;
     197            ClassIdentifier(const ClassIdentifier<T>& identifier) {}    // don't copy
     198            ~ClassIdentifier() {}                                       // don't delete
     199
     200            ObjectList<T>* objects_;    //!< The ObjectList, containing all objects of type T
     201            bool bSetName_;             //!< True if the name is set
    97202    };
    98203
    99     template <class T>
    100     ClassIdentifier<T>* ClassIdentifier<T>::pointer_s = NULL;
    101 
     204    /**
     205        @brief Constructor: Creates the ObjectList.
     206    */
    102207    template <class T>
    103208    ClassIdentifier<T>::ClassIdentifier()
    104209    {
    105         this->objects_ = new ObjectList<T>;
    106     }
    107 
    108     template <class T>
    109     ClassIdentifier<T>::~ClassIdentifier()
    110     {
    111         delete this->objects_;
    112         this->pointer_s = NULL;
    113     }
    114 
     210        this->objects_ = ObjectList<T>::getList();
     211        this->bSetName_ = false;
     212    }
     213
     214    /**
     215        @brief Registers a class, which means that the name and the parents get stored.
     216        @param parents An IdentifierList, containing the Identifiers of all parents of the class
     217        @param name A string, containing exactly the name of the class
     218        @param bRootClass True if the class is either an Interface or the BaseObject itself
     219        @return The ClassIdentifier itself
     220    */
    115221    template <class T>
    116222    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass)
    117223    {
    118 #if HIERARCHY_VERBOSE
    119         std::cout << "*** Register Class in " << name << "-Singleton.\n";
    120 #endif
    121         if (!pointer_s)
     224        COUT(4) << "*** Register Class in " << name << "-Singleton." << std::endl;
     225
     226        // Check if at least one object of the given type was created
     227        if (!getIdentifier()->bCreatedOneObject_)
    122228        {
    123 #if HIERARCHY_VERBOSE
    124             std::cout << "*** Register Class in " << name << "-Singleton -> Create Singleton.\n";
    125 #endif
    126             pointer_s = new ClassIdentifier();
     229            // If no: We have to store the informations and initialize the Identifier
     230            getIdentifier()->setName(name);
     231
     232            COUT(4) << "*** Register Class in " << name << "-Singleton -> Initialize Singleton." << std::endl;
     233            if (bRootClass)
     234                getIdentifier()->initialize(NULL); // If a class is derived from two interfaces, the second interface might think it's derived from the first because of the order of constructor-calls. Thats why we set parents to zero in that case.
     235            else
     236                getIdentifier()->initialize(parents);
    127237        }
    128238
    129         if (!pointer_s->bCreatedOneObject_)
     239        return getIdentifier();
     240    }
     241
     242    /**
     243        @brief Creates the only instance of this class for the template class T.
     244        @return The Identifier itself
     245    */
     246    template <class T>
     247    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
     248    {
     249        static ClassIdentifier<T> theOneAndOnlyInstance = ClassIdentifier<T>();
     250        static bool bIdentifierCreated = false;
     251
     252        if (!bIdentifierCreated)
    130253        {
    131 #if HIERARCHY_VERBOSE
    132             std::cout << "*** Register Class in " << name << "-Singleton -> Initialize Singleton.\n";
    133 #endif
    134             pointer_s->name_ = name;
    135             Factory::add(name, pointer_s);
    136 
    137             if (bRootClass)
    138                 pointer_s->initialize(NULL);
    139             else
    140                 pointer_s->initialize(parents);
     254            COUT(4) << "*** Create Identifier Singleton." << std::endl;
     255            bIdentifierCreated = true;
    141256        }
    142257
    143         return pointer_s;
    144     }
    145 
    146     template <class T>
    147     ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
    148     {
    149         if (!pointer_s)
     258        return &theOneAndOnlyInstance;
     259    }
     260
     261    /**
     262        @brief Sets the name of the class.
     263        @param name The name
     264    */
     265    template <class T>
     266    void ClassIdentifier<T>::setName(const std::string& name)
     267    {
     268        // Make sure we didn't already set the name, to avoid duplicate entries in the Identifier map
     269        if (!this->bSetName_)
    150270        {
    151 #if HIERARCHY_VERBOSE
    152             std::cout << "*** Create Singleton.\n";
    153 #endif
    154             pointer_s = new ClassIdentifier();
     271            this->name_ = name;
     272            this->getIdentifierMap().insert(std::pair<std::string, Identifier*>(name, this));
     273            this->bSetName_ = true;
    155274        }
    156 
    157         return pointer_s;
    158     }
    159 
     275    }
     276
     277    /**
     278        @brief Adds an object of the given type to the ObjectList.
     279        @param object The object to add
     280    */
    160281    template <class T>
    161282    void ClassIdentifier<T>::addObject(T* object)
    162283    {
    163 #if HIERARCHY_VERBOSE
    164         std::cout << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    165 #endif
    166         object->getMetaList()->add(ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object));
    167     }
    168 
     284        COUT(4) << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;
     285        object->getMetaList().add(ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object));
     286    }
     287
     288    /**
     289        @brief Removes all objects of the corresponding class.
     290    */
     291    template <class T>
     292    void ClassIdentifier<T>::removeObjects() const
     293    {
     294        for (Iterator<T> it = ObjectList<T>::start(); it;)
     295            delete *(it++);
     296    }
    169297
    170298    // ###############################
    171299    // ###   SubclassIdentifier    ###
    172300    // ###############################
    173     template <class B>
     301    //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
     302    /**
     303        You can only assign an Identifier that belongs to a class T (or derived) to a SubclassIdentifier<T>.
     304        If you assign something else, the program aborts.
     305        Because we know the minimal type, a dynamic_cast is done, which makes it easier to create a new object.
     306    */
     307    template <class T>
    174308    class SubclassIdentifier
    175309    {
    176310        public:
    177             SubclassIdentifier();
    178 
    179             SubclassIdentifier<B>& operator=(Identifier* identifier)
    180             {
    181                 if (!identifier->isA(ClassIdentifier<B>::getIdentifier()))
     311            /**
     312                @brief Constructor: Automaticaly assigns the Identifier of the given class.
     313            */
     314            SubclassIdentifier()
     315            {
     316                this->identifier_ = ClassIdentifier<T>::getIdentifier();
     317            }
     318
     319            /**
     320                @brief Overloading of the = operator: assigns the identifier and checks its type.
     321                @param identifier The Identifier to assign
     322                @return The SubclassIdentifier itself
     323            */
     324            SubclassIdentifier<T>& operator=(Identifier* identifier)
     325            {
     326                if (!identifier->isA(ClassIdentifier<T>::getIdentifier()))
    182327                {
    183                     std::cout << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<B>::getIdentifier()->getName() << "!\n";
    184                     std::cout << "Error: SubclassIdentifier<" << ClassIdentifier<B>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden.\n";
    185                     std::cout << "Aborting...\n";
     328                    COUT(1) << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
     329                    COUT(1) << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden." << std::endl;
     330                    COUT(1) << "Aborting..." << std::endl;
    186331                    abort();
    187332                }
     
    190335            }
    191336
     337            /**
     338                @brief Overloading of the * operator: returns the assigned identifier.
     339                @return The assigned identifier
     340            */
    192341            Identifier* operator*()
    193342            {
     
    195344            }
    196345
     346            /**
     347                @brief Overloading of the -> operator: returns the assigned identifier.
     348                @return The assigned identifier
     349            */
    197350            Identifier* operator->() const
    198351            {
     
    200353            }
    201354
    202             B* fabricate()
     355            /**
     356                @brief Creates a new object of the type of the assigned Identifier and dynamic_casts it to the minimal type given by T.
     357                @return The new object
     358            */
     359            T* fabricate()
    203360            {
    204361                BaseObject* newObject = this->identifier_->fabricate();
     362
     363                // Check if the creation was successful
    205364                if (newObject)
    206365                {
    207                     return dynamic_cast<B*>(newObject);
     366                    // Do a dynamic_cast, because an object of type T is much better than of type BaseObject
     367                    return (T*)(newObject);
    208368                }
    209369                else
    210370                {
     371                    // Something went terribly wrong
    211372                    if (this->identifier_)
    212373                    {
    213                         std::cout << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<B>::getIdentifier()->getName() << "!\n";
    214                         std::cout << "Error: Couldn't fabricate a new Object.\n";
    215                         std::cout << "Aborting...\n";
     374                        COUT(1) << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!" << std::endl;
     375                        COUT(1) << "Error: Couldn't fabricate a new Object." << std::endl;
     376                        COUT(1) << "Aborting..." << std::endl;
    216377                    }
    217378                    else
    218379                    {
    219                         std::cout << "Error: Couldn't fabricate a new Object - Identifier is undefined.\n";
    220                         std::cout << "Aborting...\n";
     380                        COUT(1) << "Error: Couldn't fabricate a new Object - Identifier is undefined." << std::endl;
     381                        COUT(1) << "Aborting..." << std::endl;
    221382                    }
    222383
     
    225386            }
    226387
     388            /** @returns the assigned identifier. */
    227389            inline const Identifier* getIdentifier() const
    228390                { return this->identifier_; }
     391
     392            /** @returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */
    229393            inline bool isA(const Identifier* identifier) const
    230394                { return this->identifier_->isA(identifier); }
     395
     396            /** @returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
    231397            inline bool isDirectlyA(const Identifier* identifier) const
    232398                { return this->identifier_->isDirectlyA(identifier); }
     399
     400            /** @returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
    233401            inline bool isChildOf(const Identifier* identifier) const
    234402                { return this->identifier_->isChildOf(identifier); }
     403
     404            /** @returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
    235405            inline bool isParentOf(const Identifier* identifier) const
    236406                { return this->identifier_->isParentOf(identifier); }
    237407
    238408        private:
    239             Identifier* identifier_;
     409            Identifier* identifier_;        //!< The assigned identifier
    240410    };
    241 
    242     template <class B>
    243     SubclassIdentifier<B>::SubclassIdentifier()
    244     {
    245         this->identifier_ = ClassIdentifier<B>::getIdentifier();
    246     }
    247411}
    248412
    249 #endif
     413#endif /* _Identifier_H__ */
  • code/trunk/src/orxonox/core/IdentifierList.cc

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file IdentifierList.cc
     30    @brief Implementation of the IdentifierList class.
     31*/
     32
     33#include "Identifier.h"
    134#include "IdentifierList.h"
    2 #include "Identifier.h"
    335
    436namespace orxonox
     
    739    // ###     IdentifierList      ###
    840    // ###############################
     41    /**
     42        @brief Constructor: Sets first_ to zero.
     43    */
    944    IdentifierList::IdentifierList()
    1045    {
     
    1247    }
    1348
     49    /**
     50        @brief Destructor: Deletes all elements in the list, but NOT THE IDENTIFIERS.
     51    */
    1452    IdentifierList::~IdentifierList()
    1553    {
     
    2361    }
    2462
     63    /**
     64        @brief Adds an Identifier to the list.
     65        @param identifier The Identifier to add
     66    */
    2567    void IdentifierList::add(const Identifier* identifier)
    2668    {
     
    3072    }
    3173
     74    /**
     75        @brief Removes an Identifier from the list.
     76        @param identifier The Identifier to remove
     77    */
    3278    void IdentifierList::remove(const Identifier* identifier)
    3379    {
     
    3581            return;
    3682
     83        // Check if we have to delete the first element
    3784        if (this->first_->identifier_ == identifier)
    3885        {
     
    4491        }
    4592
     93        // Iterate through the list
    4694        IdentifierListElement* temp = this->first_;
    4795        while (temp->next_)
     
    60108    }
    61109
     110    /**
     111        @brief Checks if a given Identifier is in the list and returns true if yes.
     112        @param identifier The Identifier to check
     113        @return True if the Identifier is in the list
     114    */
    62115    bool IdentifierList::isInList(const Identifier* identifier) const
    63116    {
     
    74127    }
    75128
     129    /**
     130        @returns a string, containing a list of the names of all Identifiers in the list.
     131    */
    76132    std::string IdentifierList::toString() const
    77133    {
     
    94150    // ###  IdentifierListElement  ###
    95151    // ###############################
     152    /**
     153        @brief Constructor: Creates the list-element with a given identifier.
     154        @param identifier The Identifier to store
     155    */
    96156    IdentifierListElement::IdentifierListElement(const Identifier* identifier)
    97157    {
     
    99159        this->next_ = 0;
    100160    }
    101 
    102     IdentifierListElement::~IdentifierListElement()
    103     {
    104     }
    105161}
  • code/trunk/src/orxonox/core/IdentifierList.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file IdentifierList.h
     30    @brief Definition of the IdentifierList class
     31
     32    The IdentifierList is a single-linked list, containing Identifiers.
     33    The IdentifierList is used to store parents and childs of each Identifier.
     34*/
     35
    136#ifndef _IdentifierList_H__
    237#define _IdentifierList_H__
     
    439#include <string>
    540
     41#include "CorePrereqs.h"
     42
    643namespace orxonox
    744{
    8     class Identifier;
    9 
     45    //! The list-element of the IdentifierList
    1046    class IdentifierListElement
    1147    {
    1248        public:
    1349            IdentifierListElement(const Identifier* identifier);
    14             ~IdentifierListElement();
    1550
    16             const Identifier* identifier_;
    17             IdentifierListElement* next_;
     51            const Identifier* identifier_;      //!< The identifier
     52            IdentifierListElement* next_;       //!< The next element in the list
    1853    };
    1954
    20     class IdentifierList
     55    //! The IdentifierList contains Identifiers
     56    class _CoreExport IdentifierList
    2157    {
    2258        public:
     
    2864            std::string toString() const;
    2965
    30             IdentifierListElement* first_;
     66            IdentifierListElement* first_;      //!< The first element in the list
    3167    };
    3268}
    3369
    34 #endif
     70#endif /* _IdentifierList_H__ */
  • code/trunk/src/orxonox/core/Iterator.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file Iterator.h
     30    @brief Definition and implementation of the Iterator class.
     31
     32    The Iterator of a given class allows to iterate through an ObjectList, containing all objects of that type.
     33    This is the only way to access the objects stored in an ObjectList.
     34
     35    Usage:
     36    for (Iterator<class> it = ObjectList<class>::start(); it != 0; ++it)
     37    {
     38        it->someFunction(...);
     39        class* myObject = *it;
     40    }
     41
     42    Warning: Don't delete objects directly through the iterator.
     43*/
     44
    145#ifndef _Iterator_H__
    246#define _Iterator_H__
    347
     48#include "CorePrereqs.h"
     49
     50#include "ObjectList.h"
     51#include "Debug.h"
     52
    453namespace orxonox
    554{
     55    //! The iterator allows to iterate through an ObjectList of a given class.
    656    template <class T>
    757    class Iterator
    858    {
    959        public:
     60            /**
     61                @brief Constructor: Sets the element, whereon the iterator points, to zero.
     62            */
    1063            Iterator()
    1164            {
     
    1366            }
    1467
     68            /**
     69                @brief Constructor: Sets the element, whereon the iterator points, to a given element.
     70                @param element The element to start with
     71            */
    1572            Iterator(ObjectListElement<T>* element)
    1673            {
     
    1875            }
    1976
     77            /**
     78                @brief Overloading of the ++it operator: Iterator points to the next object in the list.
     79                @return The Iterator itself
     80            */
    2081            Iterator<T> operator++()
    2182            {
     
    2485            }
    2586
     87            /**
     88                @brief Overloading of the it++ operator: Iterator points to the next object in the list.
     89                @return The Iterator itself
     90            */
     91            Iterator<T> operator++(int i)
     92            {
     93                Iterator<T> copy = *this;
     94                this->element_ = this->element_->next_;
     95                return copy;
     96            }
     97
     98            /**
     99                @brief Overloading of the --it operator: Iterator points to the previous object in the list.
     100                @return The Iterator itself
     101            */
    26102            Iterator<T> operator--()
    27103            {
     
    30106            }
    31107
     108            /**
     109                @brief Overloading of the it-- operator: Iterator points to the previous object in the list.
     110                @return The Iterator itself
     111            */
     112            Iterator<T> operator--(int i)
     113            {
     114                Iterator<T> copy = *this;
     115                this->element_ = this->element_->prev_;
     116                return copy;
     117            }
     118
     119            /**
     120                @brief Overloading of the *it operator: returns the pointer to the object.
     121                @return The object the Iterator points at
     122            */
    32123            T* operator*()
    33124            {
     
    35126            }
    36127
     128            /**
     129                @brief Overloading of the it-> operator: returns the pointer to the object.
     130                @return The object the Iterator points at
     131            */
    37132            T* operator->() const
    38133            {
     
    41136            }
    42137
     138            /**
     139                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
     140                @return True if the iterator points to an existing object.
     141            */
    43142            operator bool()
    44143            {
     
    46145            }
    47146
     147            /**
     148                @brief Overloading of the (it != int) operator: Used for (it != 0) instead of typecast-operator to bool.
     149                @param compare The integer (must be zero, everything else makes no sense).
     150                @return True if the iterator points to an existing object.
     151            */
    48152            bool operator!=(int compare)
    49153            {
     154                // Comparing with anything except zero makes no sense
    50155                if (compare != 0)
    51                     std::cout << "Warning: Comparing the " << ClassIdentifier<T>::getIdentifier()->getName() << "-List-Iterator with " << compare << " has no effect. Only comparison with 0 works.\n";
     156                    COUT(2) << "Warning: Comparing the " << ClassIdentifier<T>::getIdentifier()->getName() << "-List-Iterator with " << compare << " has no effect. Only comparison with 0 works." << std::endl;
    52157
    53158                return (this->element_ != 0);
     
    55160
    56161        private:
    57             ObjectListElement<T>* element_;
     162            ObjectListElement<T>* element_;     //!< The element the Iterator points at
    58163    };
    59164}
    60165
    61 #endif
     166#endif /* _Iterator_H__ */
  • code/trunk/src/orxonox/core/MetaObjectList.cc

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file MetaObjectList.cc
     30    @brief Implementation of the MetaObjectList class.
     31*/
     32
    133#include "MetaObjectList.h"
    234
    335namespace orxonox
    436{
     37    /**
     38        @brief Constructor: Sets first_ to zero.
     39    */
    540    MetaObjectList::MetaObjectList()
    641    {
     
    843    }
    944
     45    /**
     46        @brief Destructor: Removes all elements from the list, causing them to remove the stored ObjectListElement from the ObjectList.
     47    */
    1048    MetaObjectList::~MetaObjectList()
    1149    {
  • code/trunk/src/orxonox/core/MetaObjectList.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file MetaObjectList.h
     30    @brief Definition of the MetaObjectList class.
     31
     32    The MetaObjectList is a single-linked list, containing all list-elements and their
     33    lists wherein the object, owning the MetaObjectList, is registered.
     34    This allows much faster deletion of objects because no iteration is needed.
     35*/
     36
    137#ifndef _MetaObjectList_H__
    238#define _MetaObjectList_H__
    339
     40#include "CorePrereqs.h"
     41
    442#include "ObjectList.h"
    543#include "Identifier.h"
     44#include "Debug.h"
    645
    746namespace orxonox
    847{
     48    //! Base-class of MetaObjectListElement, because those is a template
    949    class BaseMetaObjectListElement
    1050    {
    1151        public:
     52            /** @brief Default destructor */
    1253            virtual ~BaseMetaObjectListElement() {};
    1354
    14             BaseMetaObjectListElement* next_;
     55            BaseMetaObjectListElement* next_;       //!< The next Element in the list
    1556    };
    1657
     
    1859    // ###  MetaObjectListElement  ###
    1960    // ###############################
     61    //! The list-element of the MetaObjectList
    2062    template <class T>
    2163    class MetaObjectListElement : public BaseMetaObjectListElement
     
    2365        public:
    2466            MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element);
    25             ~MetaObjectListElement();
     67            virtual ~MetaObjectListElement();
    2668
    27             ObjectListElement<T>* element_;
    28             ObjectList<T>* list_;
     69            ObjectListElement<T>* element_;         //!< The list element, containing the object
     70            ObjectList<T>* list_;                   //!< The list, containing the element
    2971    };
    3072
     73    /**
     74        @brief Constructor: Creates the list-element with given list and element.
     75    */
    3176    template <class T>
    3277    MetaObjectListElement<T>::MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element)
     
    3782    }
    3883
     84    /**
     85        @brief Destructor: Removes the ObjectListElement from the ObjectList by linking next_ and prev_ of the ObjectListElement.
     86    */
    3987    template <class T>
    4088    MetaObjectListElement<T>::~MetaObjectListElement()
     
    4391            this->element_->next_->prev_ = this->element_->prev_;
    4492        else
    45             this->list_->last_ = this->element_->prev_;
     93            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
    4694
    4795        if (this->element_->prev_)
    4896            this->element_->prev_->next_ = this->element_->next_;
    4997        else
    50             this->list_->first_ = this->element_->next_;
     98            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
    5199
    52100
    53 #if HIERARCHY_VERBOSE
    54         std::cout << "*** Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    55 #endif
     101        COUT(4) << "*** Removing Object from " << ClassIdentifier<T>::getIdentifier()->getName() << "-list." << std::endl;
    56102        delete this->element_;
    57103    }
     
    61107    // ###       ObjectList        ###
    62108    // ###############################
     109    //!  The MetaObjectList contains ObjectListElements and their ObjectLists.
     110    /**
     111        The MetaObjectList is a single-linked list, containing all list-elements and their
     112        lists wherein the object that owns the MetaObjectList is registered.
     113        This allows much faster deletion of objects because no iteration is needed.
     114    */
    63115    class MetaObjectList
    64116    {
     
    69121            void add(ObjectList<T>* list, ObjectListElement<T>* element);
    70122
    71             BaseMetaObjectListElement* first_;
     123            BaseMetaObjectListElement* first_;      //!< The first element in the list
    72124    };
    73125
     126    /**
     127        @brief Adds an ObjectList and an element of that list to the MetaObjectList.
     128        @param list The ObjectList wherein the element is
     129        @param element The element wherein the object is
     130    */
    74131    template <class T>
    75132    void MetaObjectList::add(ObjectList<T>* list, ObjectListElement<T>* element)
     
    81138}
    82139
    83 #endif
     140#endif /* _MetaObjectList_H__ */
  • code/trunk/src/orxonox/core/ObjectList.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file ObjectList.h
     30    @brief Definition and implementation of the ObjectList class.
     31
     32    The ObjectList is a double-linked list, used by Identifiers to store all objects of a given class.
     33    Newly created objects are added through the RegisterObject-macro in its constructor.
     34    Use Iterator<class> to iterate through all objects of the class.
     35*/
     36
    137#ifndef _ObjectList_H__
    238#define _ObjectList_H__
    339
     40#include "CorePrereqs.h"
     41#include "Iterator.h"
     42
    443namespace orxonox
    544{
    6     class OrxonoxClass;
    7 
    845    // ###############################
    946    // ###    ObjectListElement    ###
    1047    // ###############################
     48    //! The list-element of the ObjectList
    1149    template <class T>
    1250    class ObjectListElement
     
    1452        public:
    1553            ObjectListElement(T* object);
    16             ~ObjectListElement();
    17 
    18             T* object_;
    19             ObjectListElement* next_;
    20             ObjectListElement* prev_;
     54
     55            T* object_;                     //!< The object
     56            ObjectListElement* next_;       //!< The next element in the list
     57            ObjectListElement* prev_;       //!< The previous element in the list
    2158    };
    2259
     60    /**
     61        @brief Constructor: Creates the list-element with an object.
     62        @param object The object to store
     63    */
    2364    template <class T>
    2465    ObjectListElement<T>::ObjectListElement(T* object)
     
    2970    }
    3071
    31     template <class T>
    32     ObjectListElement<T>::~ObjectListElement()
    33     {
    34     }
    35 
    3672
    3773    // ###############################
    3874    // ###       ObjectList        ###
    3975    // ###############################
    40     template <class T>
    41     class Iterator;
    42 
     76    //! The ObjectList contains all objects of a given class.
     77    /**
     78        The ObjectList is used by Identifiers to store all objects of a given class.
     79        Use Iterator<class> to iterate through all objects in the list.
     80    */
    4381    template <class T>
    4482    class ObjectList
    4583    {
    4684        public:
     85            static ObjectList<T>* getList();
     86
     87            ObjectListElement<T>* add(T* object);
     88//            void remove(OrxonoxClass* object, bool bIterateForwards = true);
     89
     90            /** @returns the first element in the list */
     91            inline static Iterator<T> start()
     92                { return Iterator<T>(getList()->first_); }
     93
     94            /** @returns the first element in the list */
     95            inline static Iterator<T> begin()
     96                { return Iterator<T>(getList()->first_); }
     97
     98            /** @returns the last element in the list */
     99            inline static Iterator<T> end()
     100                { return Iterator<T>(getList()->last_); }
     101
     102            ObjectListElement<T>* first_;       //!< The first element in the list
     103            ObjectListElement<T>* last_;        //!< The last element in the list
     104
     105        private:
    47106            ObjectList();
    48107            ~ObjectList();
    49             ObjectListElement<T>* add(T* object);
    50             void remove(OrxonoxClass* object, bool bIterateForwards = true);
    51 
    52             inline static Iterator<T> start()
    53                 { return Iterator<T>(pointer_s->first_); }
    54             inline static Iterator<T> end()
    55                 { return Iterator<T>(pointer_s->last_); }
    56 
    57             ObjectListElement<T>* first_;
    58             ObjectListElement<T>* last_;
    59 
    60         private:
    61             static ObjectList<T>* pointer_s;
    62108    };
    63109
    64     template <class T>
    65     ObjectList<T>* ObjectList<T>::pointer_s = 0;
    66 
     110    /**
     111        @brief Constructor: Sets default values.
     112    */
    67113    template <class T>
    68114    ObjectList<T>::ObjectList()
     
    70116        this->first_ = 0;
    71117        this->last_ = 0;
    72 
    73         this->pointer_s = this;
    74     }
    75 
     118    }
     119
     120    /**
     121        @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.
     122    */
    76123    template <class T>
    77124    ObjectList<T>::~ObjectList()
     
    86133    }
    87134
     135    /**
     136        @returns a pointer to the only existing instance for the given class T.
     137    */
     138    template <class T>
     139    ObjectList<T>* ObjectList<T>::getList()
     140    {
     141        static ObjectList<T> theOnlyObjectListObjectForClassT = ObjectList<T>();
     142        return &theOnlyObjectListObjectForClassT;
     143    }
     144
     145    /**
     146        @brief Adds a new object to the end of the list.
     147        @param object The object to add
     148        @return The pointer to the new ObjectListElement, needed by the MetaObjectList of the added object
     149    */
    88150    template <class T>
    89151    ObjectListElement<T>* ObjectList<T>::add(T* object)
     
    91153        if (!this->last_)
    92154        {
     155            // If the list is empty
    93156            this->last_ = new ObjectListElement<T>(object);
    94             this->first_ = this->last_;
     157            this->first_ = this->last_; // There's only one object in the list now
    95158        }
    96159        else
    97160        {
     161            // If the list isn't empty
    98162            ObjectListElement<T>* temp = this->last_;
    99163            this->last_ = new ObjectListElement<T>(object);
     
    105169    }
    106170
     171
     172//    /**
     173//        @brief Removes an object from the list.
     174//        @param object The object to remove
     175//        @param bIterateForwards If true: Start searching the object at the beginning of the list
     176//    */
     177    /*
    107178    template <class T>
    108179    void ObjectList<T>::remove(OrxonoxClass* object, bool bIterateForwards)
     
    111182            return;
    112183
     184        // If there's only one object in the list, we have to set first_ and last_ to zero
    113185        if (this->first_ == this->last_)
    114186        {
     
    123195        }
    124196
     197        // Now we are sure we have more than one element in the list
    125198        if (bIterateForwards)
    126199        {
     200            // Start at the beginning of the list
     201
     202            // Check if it's the first object
    127203            if (this->first_->object_ == object)
    128204            {
     
    135211            }
    136212
     213            // Iterate through the whole list
    137214            ObjectListElement<T>* temp = this->first_;
    138215            while (temp->next_)
     
    146223                        temp2->prev_ = temp;
    147224                    else
    148                         this->last_ = temp;
     225                        this->last_ = temp; // If there is no next_, we deleted the last element and have to update the last_ pointer.
    149226
    150227                    return;
     
    156233        else
    157234        {
     235            // Start at the end of the list
     236
     237            // Check if it's the last object
    158238            if (this->last_->object_ == object)
    159239            {
     
    166246            }
    167247
     248            // Iterate through the whole list
    168249            ObjectListElement<T>* temp = this->last_;
    169250            while (temp->prev_)
     
    177258                        temp2->next_ = temp;
    178259                    else
    179                         this->first_ = temp;
     260                        this->first_ = temp; // If there is no prev_, we deleted the first element and have to update the first_ pointer.
    180261
    181262                    return;
     
    186267        }
    187268    }
     269    */
    188270}
    189271
    190 #endif
     272#endif /* _ObjectList_H__ */
  • code/trunk/src/orxonox/core/OrxonoxClass.cc

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file OrxonoxClass.cc
     30    @brief Implementation of the OrxonoxClass Class.
     31*/
     32
    133#include "OrxonoxClass.h"
    234
    335namespace orxonox
    436{
     37    /** @brief Constructor: Sets the default values. */
    538    OrxonoxClass::OrxonoxClass()
    639    {
     40        this->setConfigValues();
     41
    742        this->identifier_ = 0;
    843        this->parents_ = 0;
    944
    10         this->metaList_ = new MetaObjectList;
     45        this->bActive_ = true;
     46        this->bVisible_ = true;
    1147    }
    1248
     49    /** @brief Destructor: Deletes, if existing, the list of the parents. */
    1350    OrxonoxClass::~OrxonoxClass()
    1451    {
     52        // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
    1553        if (this->parents_)
    1654            delete this->parents_;
    17 
    18         delete this->metaList_;
    1955    }
    2056}
  • code/trunk/src/orxonox/core/OrxonoxClass.h

    r258 r790  
     1/*
     2 *   ORXONOX - the hottest 3D action shooter ever to exist
     3 *
     4 *
     5 *   License notice:
     6 *
     7 *   This program is free software; you can redistribute it and/or
     8 *   modify it under the terms of the GNU General Public License
     9 *   as published by the Free Software Foundation; either version 2
     10 *   of the License, or (at your option) any later version.
     11 *
     12 *   This program is distributed in the hope that it will be useful,
     13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
     14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     15 *   GNU General Public License for more details.
     16 *
     17 *   You should have received a copy of the GNU General Public License
     18 *   along with this program; if not, write to the Free Software
     19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     20 *
     21 *   Author:
     22 *      Fabian 'x3n' Landau
     23 *   Co-authors:
     24 *      ...
     25 *
     26 */
     27
     28/*!
     29    @file OrxonoxClass.h
     30    @brief Definition of the OrxonoxClass Class.
     31
     32    All objects and interfaces of the game-logic (not the engine) are derived from OrxonoxClass.
     33    It stores the Identifier and the MetaObjectList and has all needed functions to create and use the class-hierarchy.
     34*/
     35
    136#ifndef _OrxonoxClass_H__
    237#define _OrxonoxClass_H__
    338
    4 #include "Identifier.h"
    5 #include "IdentifierList.h"
    6 #include "ObjectList.h"
     39#include <string>
     40
     41#include "CorePrereqs.h"
    742#include "MetaObjectList.h"
     43#include "Iterator.h"
    844
    945namespace orxonox
    1046{
    11     class OrxonoxClass
     47    //! The class all objects and interfaces of the game-logic (not the engine) are derived from.
     48    /**
     49        The BaseObject and Interaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass.
     50        OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList.
     51    */
     52    class _CoreExport OrxonoxClass
    1253    {
    1354        public:
    1455            OrxonoxClass();
    1556            virtual ~OrxonoxClass();
     57
     58            /** @brief Function to collect the SetConfigValue-macro calls. */
     59            void setConfigValues() {};
     60
     61            /** @returns the Identifier of the object */
    1662            inline Identifier* getIdentifier() const { return this->identifier_; }
     63
     64            /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
    1765            inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
     66
     67            /** @returns the list of all parents of the object */
    1868            inline IdentifierList* getParents() const { return this->parents_; }
     69
     70            /** @brief Sets the Parents of the object. Used by the RegisterObject-macro. */
    1971            inline void setParents(IdentifierList* parents) { this->parents_ = parents; }
    20             inline MetaObjectList* getMetaList() { return this->metaList_; }
     72
     73            /** @returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. */
     74            inline MetaObjectList& getMetaList() { return this->metaList_; }
     75
     76
     77            /** @returns true if the objects class is of the given type or a derivative. */
     78            inline bool isA(const Identifier* identifier)
     79                { return this->getIdentifier()->isA(identifier); }
     80            /** @returns true if the objects class is exactly of the given type. */
     81            inline bool isDirectlyA(const Identifier* identifier)
     82                { return this->getIdentifier()->isDirectlyA(identifier); }
     83            /** @returns true if the objects class is a child of the given type. */
     84            inline bool isChildOf(const Identifier* identifier)
     85                { return this->getIdentifier()->isChildOf(identifier); }
     86            /** @returns true if the objects class is a parent of the given type. */
     87            inline bool isParentOf(const Identifier* identifier)
     88                { return this->getIdentifier()->isParentOf(identifier); }
     89
     90
     91            /** @returns true if the objects class is of the given type or a derivative. */
     92            inline bool isA(const SubclassIdentifier<class B>* identifier)
     93                { return this->getIdentifier()->isA(identifier->getIdentifier()); }
     94            /** @returns true if the objects class is exactly of the given type. */
     95            inline bool isDirectlyA(const SubclassIdentifier<class B>* identifier)
     96                { return this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); }
     97            /** @returns true if the objects class is a child of the given type. */
     98            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
     99                { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
     100            /** @returns true if the objects class is a parent of the given type. */
     101            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
     102                { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
     103
     104
     105            /** @returns true if the objects class is of the given type or a derivative. */
     106            inline bool isA(const SubclassIdentifier<class B> identifier)
     107                { return this->getIdentifier()->isA(identifier.getIdentifier()); }
     108            /** @returns true if the objects class is exactly of the given type. */
     109            inline bool isDirectlyA(const SubclassIdentifier<class B> identifier)
     110                { return this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); }
     111            /** @returns true if the objects class is a child of the given type. */
     112            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
     113                { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
     114            /** @returns true if the objects class is a parent of the given type. */
     115            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
     116                { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
     117
     118
     119            /** @returns true if the objects class is of the given type or a derivative. */
     120            inline bool isA(const OrxonoxClass* object)
     121                { return this->getIdentifier()->isA(object->getIdentifier()); }
     122            /** @returns true if the objects class is exactly of the given type. */
     123            inline bool isDirectlyA(const OrxonoxClass* object)
     124                { return this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
     125            /** @returns true if the objects class is a child of the given type. */
     126            inline bool isChildOf(const OrxonoxClass* object)
     127                { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
     128            /** @returns true if the objects class is a parent of the given type. */
     129            inline bool isParentOf(const OrxonoxClass* object)
     130                { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
     131
     132
     133            /** @brief Sets the name of the object. @param name The name */
     134            inline virtual void setName(const std::string& name) { this->name_ = name; }
     135
     136            /** @returns the name of the object. */
     137            inline const std::string& getName() const { return this->name_; }
     138
     139            /** @brief Sets the state of the objects activity. @param bActive True = active */
     140            inline virtual void setActive(bool bActive) { this->bActive_ = bActive; }
     141
     142            /** @returns the state of the objects activity. */
     143            inline const bool isActive() const { return this->bActive_; }
     144
     145            /** @brief Sets the state of the objects visibility. @param bVisible True = visible */
     146            inline virtual void setVisible(bool bVisible) { this->bVisible_ = bVisible; }
     147
     148            /** @returns the state of the objects visibility. */
     149            inline const bool isVisible() const { return this->bVisible_; }
    21150
    22151        private:
    23             Identifier* identifier_;
    24             IdentifierList* parents_;
    25             MetaObjectList* metaList_;
     152            Identifier* identifier_;        //!< The Identifier of the object
     153            IdentifierList* parents_;       //!< List of all parents of the object
     154            MetaObjectList metaList_;       //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
     155
     156            std::string name_;              //!< The name of the object
     157            bool bActive_;                  //!< True = the object is active
     158            bool bVisible_;                 //!< True = the object is visible
    26159    };
     160    template class _CoreExport orxonox::ClassIdentifier<OrxonoxClass>;
     161    template class _CoreExport orxonox::ObjectList<OrxonoxClass>;
    27162}
    28163
    29 #endif
     164#endif /* _OrxonoxClass_H__ */
Note: See TracChangeset for help on using the changeset viewer.