Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 384


Ignore:
Timestamp:
Dec 4, 2007, 11:48:28 PM (17 years ago)
Author:
landauf
Message:

copied changed files from objecthierarchy-branch

Location:
code/branches/FICN/src/orxonox
Files:
2 added
19 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/orxonox/core/ClassFactory.h

    r258 r384  
     1/*!
     2    @file ClassFactory.h
     3    @brief Definition of the ClassFactory class
     4
     5    The ClassFactory is able to create new objects of a specific class.
     6*/
     7
    18#ifndef _ClassFactory_H__
    29#define _ClassFactory_H__
     
    916    // ###      ClassFactory       ###
    1017    // ###############################
     18    //! The ClassFactory is able to create new objects of a specific class.
    1119    template <class T>
    1220    class ClassFactory : public BaseFactory
     
    1725
    1826        private:
    19             ClassFactory() {}
    20             ClassFactory(const ClassFactory& factory) {}
    21             ~ClassFactory() {}
     27            ClassFactory() {}                               // Don't create
     28            ClassFactory(const ClassFactory& factory) {}    // Don't copy
     29            ~ClassFactory() {}                              // Don't delete
    2230
    2331            static T* createNewObject();
    2432    };
    2533
     34    /**
     35        @brief Adds the ClassFactory to the Identifier of the same type and creates a new object to retrieve the parents.
     36        @return True, because the compiler only allows assignments before main()
     37    */
    2638    template <class T>
    2739    bool ClassFactory<T>::create()
    2840    {
     41        // Add the ClassFactory to the Classidentifier of type T
    2942        ClassIdentifier<T>::getIdentifier()->addFactory(new ClassFactory<T>);
    3043
     44        // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
    3145        ClassIdentifier<T>::getIdentifier()->startCreatingHierarchy();
    3246#if HIERARCHY_VERBOSE
     
    4054    }
    4155
     56    /**
     57        @brief Creates and returns a new object of class T.
     58        @return The new object
     59    */
    4260    template <class T>
    4361    BaseObject* ClassFactory<T>::fabricate()
     
    4664    }
    4765
     66    /**
     67        @brief Creates and returns a new object of class T; this is a wrapper for the new operator.
     68        @return The new object
     69    */
    4870    template <class T>
    4971    T* ClassFactory<T>::createNewObject()
  • code/branches/FICN/src/orxonox/core/Factory.cc

    r363 r384  
     1/*!
     2    @file Factory.cc
     3    @brief Implementation of the Factory class.
     4*/
     5
    16#include "Factory.h"
    27#include "Identifier.h"
     
    49namespace orxonox
    510{
    6     Factory* Factory::pointer_s = NULL;
     11    Factory* Factory::pointer_s = NULL; // Set the static member variable pointer_s to zero
    712
     13    /**
     14        @returns the Identifier with a given name.
     15        @param name The name of the wanted Identifier
     16    */
    817    Identifier* Factory::getIdentifier(const std::string& name)
    918    {
     
    1423    }
    1524
     25    /**
     26        @returns the Identifier with a given networkID.
     27        @param id The networkID of the wanted Identifier
     28    */
    1629    Identifier* Factory::getIdentifier(const unsigned int id)
    1730    {
     
    2235    }
    2336
     37    /**
     38        @brief Adds a new Identifier to both maps.
     39        @param name The name of the identifier
     40        @param identifier The identifier to add
     41    */
    2442    void Factory::add(const std::string& name, Identifier* identifier)
    2543    {
     
    3149    }
    3250
     51    /**
     52        @brief Removes the entry with the old networkID and adds a new one.
     53        @param identifier The identifier to change
     54        @param oldID The old networkID
     55        @param newID The new networkID
     56    */
    3357    void Factory::changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID)
    3458    {
  • code/branches/FICN/src/orxonox/core/Factory.h

    r363 r384  
     1/*!
     2    @file Factory.h
     3    @brief Definition of the Factory and the BaseFactory class.
     4
     5    The Factory is a singleton, containing two maps to map either the name or the networkID
     6    of a class with the corresponding Identifier.
     7
     8    Usage:
     9    ID(classname) or ID(networkID) returns the corresponding Identifier.
     10
     11
     12    BaseObject is the parent of ClassFactory which is defined in ClassFactory.h.
     13    It can't be defined in ClassFactory.h, because of circular dependencies.
     14*/
     15
    116#ifndef _Factory_H__
    217#define _Factory_H__
     
    722namespace orxonox
    823{
    9     class BaseObject;
    10     class Identifier;
     24    class BaseObject; // Forward declaration
     25    class Identifier; // Forward declaration
    1126
    1227    // ###############################
    1328    // ###         Factory         ###
    1429    // ###############################
     30    //! The Factory is used to map name or networkID of a class with its Identifier.
    1531    class Factory
    1632    {
     
    2238
    2339        private:
    24             Factory() {}
    25             Factory(const Factory& factory) {}
    26             ~Factory() {}
     40            Factory() {}                        // don't create
     41            Factory(const Factory& factory) {}  // don't copy
     42            ~Factory() {}                       // don't delete
    2743
    28             static Factory* pointer_s;
    29             std::map<std::string, Identifier*> identifierStringMap_;
    30             std::map<unsigned int, Identifier*> identifierNetworkIDMap_;
     44            static Factory* pointer_s;                                          //!< The pointer to the singleton
     45            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map mapping string with Identifier
     46            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map mapping networkID with Identifier
    3147    };
    3248
     
    3450    // ###       BaseFactory       ###
    3551    // ###############################
     52    //! Base-class of ClassFactory. Has to be defined separate because of circular dependencies.
    3653    class BaseFactory
    3754    {
    3855        public:
    3956            virtual BaseObject* fabricate() = 0;
     57            virtual ~BaseFactory() {};
    4058    };
    4159}
  • code/branches/FICN/src/orxonox/core/Identifier.cc

    r363 r384  
     1/*!
     2    @file Identifier.cc
     3    @brief Implementation of the Identifier class.
     4*/
     5
    16#include "Identifier.h"
    27
     
    611    // ###       Identifier        ###
    712    // ###############################
    8     int Identifier::hierarchyCreatingCounter_s = 0;
    9     unsigned int Identifier::classIDcounter_s = 0;
     13    int Identifier::hierarchyCreatingCounter_s = 0; // Set the static member variable hierarchyCreatingCounter_s to zero
     14    unsigned int Identifier::classIDcounter_s = 0; // Set the static member variable classIDcounter_s to zero
    1015
     16    /**
     17        @brief Constructor: No factory, no object created, new ObjectList and a unique networkID.
     18    */
    1119    Identifier::Identifier()
    1220    {
     
    1826    }
    1927
     28    /**
     29        @brief Destructor: Deletes the name and the IdentifierList containing the children.
     30    */
    2031    Identifier::~Identifier()
    2132    {
    2233        delete &this->name_;
    23 
    2434        delete this->children_;
    2535    }
    2636
     37    /**
     38        @brief Initializes the Identifier with an IdentifierList containing all parents of the class the Identifier belongs to.
     39        @param parents The IdentifierList containing all parents
     40    */
    2741    void Identifier::initialize(const IdentifierList* parents)
    2842    {
     
    3852            {
    3953                this->parents_.add(temp1->identifier_);
    40                 temp1->identifier_->getChildren().add(this);
     54                temp1->identifier_->getChildren().add(this); // We're a child of our parents
    4155
    4256                temp1 = temp1->next_;
     
    4559    }
    4660
     61    /**
     62        @brief Creates an object of the type the Identifier belongs to.
     63        @return The new object
     64    */
    4765    BaseObject* Identifier::fabricate()
    4866    {
    4967        if (this->factory_)
    5068        {
    51             return this->factory_->fabricate();
     69            return this->factory_->fabricate(); // We have to return a BaseObject, because we don't know the exact type.
    5270        }
    5371        else
    5472        {
     73            // Abstract classes don't have a factory and therefore can't create new objects
    5574            std::cout << "Error: Cannot create an object of type '" << this->name_ << "'. Class is abstract.\n";
    5675            std::cout << "Aborting...";
     
    5978    }
    6079
     80    /**
     81        @brief Sets the networkID to a new value and changes the entry in the Factory.
     82        @param id The new networkID
     83    */
    6184    void Identifier::setNetworkID(unsigned int id)
    6285    {
     
    6588    }
    6689
     90    /**
     91        @returns true, if the Identifier is at least of the given type.
     92        @param identifier The identifier to compare with
     93    */
    6794    bool Identifier::isA(const Identifier* identifier) const
    6895    {
     
    7097    }
    7198
     99    /**
     100        @returns true, if the Identifier is exactly of the given type.
     101        @param identifier The identifier to compare with
     102    */
    72103    bool Identifier::isDirectlyA(const Identifier* identifier) const
    73104    {
     
    75106    }
    76107
     108    /**
     109        @returns true, if the assigned identifier is a child of the given identifier.
     110        @param identifier The identifier to compare with
     111    */
    77112    bool Identifier::isChildOf(const Identifier* identifier) const
    78113    {
     
    80115    }
    81116
     117    /**
     118        @returns true, if the assigned identifier is a parent of the given identifier.
     119        @param identifier The identifier to compare with
     120    */
    82121    bool Identifier::isParentOf(const Identifier* identifier) const
    83122    {
  • code/branches/FICN/src/orxonox/core/Identifier.h

    r367 r384  
     1/*!
     2    @file Identifier.h
     3    @brief Definition of the Identifier, ClassIdentifier and SubclassIdentifier classes.
     4
     5    The Identifier contains all needed informations about the class it belongs to:
     6     - the name
     7     - a list with all objects
     8     - parents and childs
     9     - the factory, if available
     10     - the networkID that can be synchronised with the server
     11
     12    Every object has a pointer to the Identifier of its class. This allows the use isA(...),
     13    isDirectlyA(...), isChildOf(...) and isParentOf(...).
     14
     15    To create the class-hierarchy, the Identifier has some intern functions and variables.
     16
     17    Every Identifier is in fact a ClassIdentifier, but they are derived from Identifier.
     18
     19    SubclassIdentifier is a separated class, acting like an Identifier, but has a given class.
     20    You can only assign Identifiers of the given class or a derivative to a SubclassIdentifier.
     21*/
     22
    123#ifndef _Identifier_H__
    224#define _Identifier_H__
     
    830#include "Factory.h"
    931
    10 #ifdef WIN32
    11 #define HIERARCHY_VERBOSE 0
    12 #else
    1332#define HIERARCHY_VERBOSE false
    14 #endif
    1533
    1634
    1735namespace orxonox
    1836{
    19     class BaseObject;
     37    class BaseObject; // Forward declaration
    2038
    2139    // ###############################
    2240    // ###       Identifier        ###
    2341    // ###############################
     42    //! The Identifier is used to identify the class of an object and to store informations about the class.
     43    /**
     44        The Identifier contains all needed informations about the class it belongs to:
     45         - the name
     46         - a list with all objects
     47         - parents and childs
     48         - the factory, if available
     49         - the networkID that can be synchronised with the server
     50
     51        Every object has a pointer to the Identifier of its class. This allows the use isA(...),
     52        isDirectlyA(...), isChildOf(...) and isParentOf(...).
     53
     54        You can't directly create an Identifier, it's just the base-class for ClassIdentifier.
     55    */
    2456    class Identifier
    2557    {
    2658        template <class T>
    27         friend class ClassIdentifier;
     59        friend class ClassIdentifier; // Forward declaration
    2860
    2961        template <class T>
    30         friend class SubclassIdentifier;
     62        friend class SubclassIdentifier; // Forward declaration
    3163
    3264        template <class T>
    33         friend class ClassFactory;
     65        friend class ClassFactory; // Forward declaration
    3466
    3567        public:
     68            /** @brief Sets the Factory. @param facotry The factory to assign */
    3669            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
     70
    3771            BaseObject* fabricate();
    3872
     
    4276            bool isParentOf(const Identifier* identifier) const;
    4377
     78            /** @returns the name of the class the Identifier belongs to. */
    4479            inline const std::string& getName() const { return this->name_; }
     80
     81            /** @returns the parents of the class the Identifier belongs to. */
    4582            inline const IdentifierList& getParents() const { return this->parents_; }
     83
     84            /** @returns the children of the class the Identifier belongs to. */
    4685            inline IdentifierList& getChildren() const { return *this->children_; }
    4786
     87            /** @returns true, if a branch of the class-hierarchy is getting created, causing all new objects to store their parents. */
    4888            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
    4989
     90            /** @returns the NetworkID to identify a class through the network. */
    5091            inline const unsigned int getNetworkID() const { return this->classID_; }
     92
    5193            void setNetworkID(unsigned int id);
    5294
    5395        private:
    5496            Identifier();
    55             Identifier(const Identifier& identifier) {}
     97            Identifier(const Identifier& identifier) {} // don't copy
    5698            virtual ~Identifier();
    5799            void initialize(const IdentifierList* parents);
    58100
     101            /**
     102                @brief Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
     103            */
    59104            inline static void startCreatingHierarchy()
    60105            {
     
    65110            }
    66111
     112            /**
     113                @brief Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
     114            */
    67115            inline static void stopCreatingHierarchy()
    68116            {
     
    73121            }
    74122
    75             IdentifierList parents_;
    76             IdentifierList* children_;
    77 
    78             std::string name_;
    79 
    80             BaseFactory* factory_;
    81             bool bCreatedOneObject_;
    82             static int hierarchyCreatingCounter_s;
    83             static unsigned int classIDcounter_s;
    84             unsigned int classID_;
     123            IdentifierList parents_;                    //!< The Parents of the class the Identifier belongs to
     124            IdentifierList* children_;                  //!< The Children of the class the Identifier belongs to
     125
     126            std::string name_;                          //!< The name of the class the Identifier belongs to
     127
     128            BaseFactory* factory_;                      //!< The Factory, able to create new objects of the given class
     129            bool bCreatedOneObject_;                    //!< True if at least one object of the given type was created (used to determine the need of storing the parents)
     130            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)
     131            static unsigned int classIDcounter_s;       //!< The number of unique Identifiers
     132            unsigned int classID_;                      //!< The networkID to identify a class through the network
    85133    };
    86134
     
    89137    // ###     ClassIdentifier     ###
    90138    // ###############################
     139    //! The ClassIdentifier is derived from Identifier and holds all class-specific functions and variables the Identifier cannot have.
     140    /**
     141        ClassIdentifier is a Singleton, which means that only one object of a given type T exists.
     142        This makes it possible to store informations about a class, sharing them with all
     143        objects of that class without defining static variables in every class.
     144    */
    91145    template <class T>
    92146    class ClassIdentifier : public Identifier
     
    99153        private:
    100154            ClassIdentifier();
    101             ClassIdentifier(const ClassIdentifier<T>& identifier) {}
     155            ClassIdentifier(const ClassIdentifier<T>& identifier) {} // don't copy
    102156            ~ClassIdentifier();
    103157
    104             static ClassIdentifier<T>* pointer_s;
    105             ObjectList<T>* objects_;
     158            static ClassIdentifier<T>* pointer_s;       //!< A pointer to the singleton-object
     159            ObjectList<T>* objects_;                    //!< The ObjectList, containing all objects of type T
    106160    };
    107161
    108162    template <class T>
    109     ClassIdentifier<T>* ClassIdentifier<T>::pointer_s = NULL;
    110 
     163    ClassIdentifier<T>* ClassIdentifier<T>::pointer_s = NULL; // Set the static member variable pointer_s to zero
     164
     165    /**
     166        @brief Constructor: Create the ObjectList.
     167    */
    111168    template <class T>
    112169    ClassIdentifier<T>::ClassIdentifier()
     
    115172    }
    116173
     174    /**
     175        @brief Destructor: Delete the ObjectList, set the singleton-pointer to zero.
     176    */
    117177    template <class T>
    118178    ClassIdentifier<T>::~ClassIdentifier()
     
    122182    }
    123183
     184    /**
     185        @brief Registers a class, which means that the name and the parents get stored.
     186        @param parents An IdentifierList, containing the Identifiers of all parents of the class
     187        @param name A string, containing exactly the name of the class
     188        @param bRootClass True if the class is either an Interface or BaseObject itself
     189        @return The ClassIdentifier itself
     190    */
    124191    template <class T>
    125192    ClassIdentifier<T>* ClassIdentifier<T>::registerClass(const IdentifierList* parents, const std::string& name, bool bRootClass)
     
    128195        std::cout << "*** Register Class in " << name << "-Singleton.\n";
    129196#endif
     197
     198        // It's a singleton, so maybe we have to create it first
    130199        if (!pointer_s)
    131200        {
     
    136205        }
    137206
     207        // Check if at least one object of the given type was created
    138208        if (!pointer_s->bCreatedOneObject_)
    139209        {
     210            // If no: We have to store the informations and initialize the Identifier
     211
    140212#if HIERARCHY_VERBOSE
    141213            std::cout << "*** Register Class in " << name << "-Singleton -> Initialize Singleton.\n";
    142214#endif
    143215            pointer_s->name_ = name;
    144             Factory::add(name, pointer_s);
     216            Factory::add(name, pointer_s); // Add the Identifier to the Factory
    145217
    146218            if (bRootClass)
    147                 pointer_s->initialize(NULL);
     219                pointer_s->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.
    148220            else
    149221                pointer_s->initialize(parents);
     
    153225    }
    154226
     227    /**
     228        @returns the Identifier itself
     229    */
    155230    template <class T>
    156231    ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
     
    167242    }
    168243
     244    /**
     245        @brief Adds an object of the given type to the ObjectList.
     246        @param object The object to add
     247    */
    169248    template <class T>
    170249    void ClassIdentifier<T>::addObject(T* object)
     
    173252        std::cout << "*** Added object to " << ClassIdentifier<T>::getIdentifier()->getName() << "-list.\n";
    174253#endif
    175         object->getMetaList()->add(ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object));
     254        object->getMetaList().add(ClassIdentifier<T>::getIdentifier()->objects_, ClassIdentifier<T>::getIdentifier()->objects_->add(object));
    176255    }
    177256
     
    180259    // ###   SubclassIdentifier    ###
    181260    // ###############################
    182     template <class B>
     261    //! The SubclassIdentifier acts almost like an Identifier, but has some prerequisites.
     262    /**
     263        You can only assign Identifiers that belong to a class of at least B (or derived) to a SubclassIdentifier<T>.
     264        If you assign something else, the program aborts.
     265        Because we know the minimal type, a dynamic_cast is done, which makes it easier to create a new object.
     266    */
     267    template <class T>
    183268    class SubclassIdentifier
    184269    {
    185270        public:
    186             SubclassIdentifier();
    187 
    188             SubclassIdentifier<B>& operator=(Identifier* identifier)
    189             {
    190                 if (!identifier->isA(ClassIdentifier<B>::getIdentifier()))
     271            /**
     272                @brief Constructor: Automaticaly assigns the Identifier of the given class.
     273            */
     274            SubclassIdentifier()
     275            {
     276                this->identifier_ = ClassIdentifier<T>::getIdentifier();
     277            }
     278
     279            /**
     280                @brief Overloading of the = operator: assigns the identifier and checks its type.
     281                @param identifier The Identifier to assign
     282                @return The SubclassIdentifier itself
     283            */
     284            SubclassIdentifier<T>& operator=(Identifier* identifier)
     285            {
     286                if (!identifier->isA(ClassIdentifier<T>::getIdentifier()))
    191287                {
    192                     std::cout << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<B>::getIdentifier()->getName() << "!\n";
    193                     std::cout << "Error: SubclassIdentifier<" << ClassIdentifier<B>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden.\n";
     288                    std::cout << "Error: Class " << identifier->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!\n";
     289                    std::cout << "Error: SubclassIdentifier<" << ClassIdentifier<T>::getIdentifier()->getName() << "> = Class(" << identifier->getName() << ") is forbidden.\n";
    194290                    std::cout << "Aborting...\n";
    195291                    abort();
     
    199295            }
    200296
     297            /**
     298                @brief Overloading of the * operator: returns the assigned identifier.
     299                @return The assigned identifier
     300            */
    201301            Identifier* operator*()
    202302            {
     
    204304            }
    205305
     306            /**
     307                @brief Overloading of the -> operator: returns the assigned identifier.
     308                @return The assigned identifier
     309            */
    206310            Identifier* operator->() const
    207311            {
     
    209313            }
    210314
    211             B* fabricate()
     315            /**
     316                @brief Creates a new object of the type of the assigned identifier and dynamic_casts it to the minimal type given by the SubclassIdentifier.
     317                @return The new object
     318            */
     319            T* fabricate()
    212320            {
    213321                BaseObject* newObject = this->identifier_->fabricate();
     322
     323                // Check if the creation worked
    214324                if (newObject)
    215325                {
    216                     return dynamic_cast<B*>(newObject);
     326                    // Do a dynamic_cast, because an object of type T is much better than of type BaseObject
     327                    return dynamic_cast<T*>(newObject);
    217328                }
    218329                else
    219330                {
     331                    // Something went terribly wrong
    220332                    if (this->identifier_)
    221333                    {
    222                         std::cout << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<B>::getIdentifier()->getName() << "!\n";
     334                        std::cout << "Error: Class " << this->identifier_->getName() << " is not a " << ClassIdentifier<T>::getIdentifier()->getName() << "!\n";
    223335                        std::cout << "Error: Couldn't fabricate a new Object.\n";
    224336                        std::cout << "Aborting...\n";
     
    234346            }
    235347
     348            /** @returns the assigned identifier. */
    236349            inline const Identifier* getIdentifier() const
    237350                { return this->identifier_; }
     351
     352            /** @returns true, if the assigned identifier is at least of the given type. @param identifier The identifier to compare with */
    238353            inline bool isA(const Identifier* identifier) const
    239354                { return this->identifier_->isA(identifier); }
     355
     356            /** @returns true, if the assigned identifier is exactly of the given type. @param identifier The identifier to compare with */
    240357            inline bool isDirectlyA(const Identifier* identifier) const
    241358                { return this->identifier_->isDirectlyA(identifier); }
     359
     360            /** @returns true, if the assigned identifier is a child of the given identifier. @param identifier The identifier to compare with */
    242361            inline bool isChildOf(const Identifier* identifier) const
    243362                { return this->identifier_->isChildOf(identifier); }
     363
     364            /** @returns true, if the assigned identifier is a parent of the given identifier. @param identifier The identifier to compare with */
    244365            inline bool isParentOf(const Identifier* identifier) const
    245366                { return this->identifier_->isParentOf(identifier); }
    246367
    247368        private:
    248             Identifier* identifier_;
     369            Identifier* identifier_;        //!< The assigned identifier
    249370    };
    250 
    251     template <class B>
    252     SubclassIdentifier<B>::SubclassIdentifier()
    253     {
    254         this->identifier_ = ClassIdentifier<B>::getIdentifier();
    255     }
    256371}
    257372
  • code/branches/FICN/src/orxonox/core/IdentifierIncludes.h

    r363 r384  
     1/**
     2    @file IDentifierIncludes.h
     3    @brief Definition of macros for the class-hierarchy and the factory.
     4
     5    Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface
     6    or the BaseObject itself, it needs the macro RegisterRootObject(class) instead.
     7
     8    To allow the object being created through the factory, use the CreateFactory(class) macro outside
     9    the of the class implementation, so it gets executed before main().
     10*/
     11
     12// All needed header-files
    113#include "Identifier.h"
    214#include "Factory.h"
     
    618
    719
     20// Intern macro, containing the common parts of RegisterObject and RegisterRootObject
    821#define InternRegisterObject(ClassName, bRootClass) \
    922    this->setIdentifier(ClassIdentifier<ClassName>::registerClass(this->getParents(), #ClassName, bRootClass)); \
     
    1225    ClassIdentifier<ClassName>::addObject(this)
    1326
     27// Intern macro, containing the specific part of RegisterRootObject
    1428#define InternRegisterRootObject(ClassName) \
    1529    if (Identifier::isCreatingHierarchy() && !this->getParents()) \
     
    1731    InternRegisterObject(ClassName, true)
    1832
     33// RegisterObject - with and without debug output
    1934#if HIERARCHY_VERBOSE
    2035#define RegisterObject(ClassName) \
     
    2641#endif
    2742
     43// RegisterRootObject - with and without debug output
    2844#if HIERARCHY_VERBOSE
    2945#define RegisterRootObject(ClassName) \
     
    3551#endif
    3652
     53// Class(ClassName) returns the Identifier of the given class
    3754#define Class(ClassName) \
    3855    ClassIdentifier<ClassName>::getIdentifier()
    3956
     57// Creates the entry in the Factory
    4058#define CreateFactory(ClassName) \
    4159    bool bCreated##ClassName##Factory = ClassFactory<ClassName>::create()
    4260
    43 #define ID(NameOrID) \
    44     Factory::getIdentifier(NameOrID)
     61// ID(StringOrInt) returns the Identifier with either a given name or a given NetworkID through the factory
     62#define ID(StringOrInt) \
     63    Factory::getIdentifier(StringOrInt)
  • code/branches/FICN/src/orxonox/core/IdentifierList.cc

    r258 r384  
     1/*!
     2    @file IdentifierList.cc
     3    @brief Implementation of the IdentifierList class.
     4*/
     5
    16#include "IdentifierList.h"
    27#include "Identifier.h"
     
    712    // ###     IdentifierList      ###
    813    // ###############################
     14    /**
     15        @brief Constructor: Sets first_ to zero.
     16    */
    917    IdentifierList::IdentifierList()
    1018    {
     
    1220    }
    1321
     22    /**
     23        @brief Destructor: Deletes all elements in the list, but NOT THE IDENTIFIERS.
     24    */
    1425    IdentifierList::~IdentifierList()
    1526    {
     
    2334    }
    2435
     36    /**
     37        @brief Adds an Identifier to the list.
     38        @param identifier The Identifier to add
     39    */
    2540    void IdentifierList::add(const Identifier* identifier)
    2641    {
     
    3045    }
    3146
     47    /**
     48        @brief Removes an Identifier from the list.
     49        @param identifier The Identifier to remove
     50    */
    3251    void IdentifierList::remove(const Identifier* identifier)
    3352    {
     
    3554            return;
    3655
     56        // Check if we have to delete the first element
    3757        if (this->first_->identifier_ == identifier)
    3858        {
     
    4464        }
    4565
     66        // Iterate through the list
    4667        IdentifierListElement* temp = this->first_;
    4768        while (temp->next_)
     
    6081    }
    6182
     83    /**
     84        @brief Checks if a given Identifier is in the list and returns true if yes.
     85        @param identifier The Identifier to check
     86        @return True if the Identifier is in the list
     87    */
    6288    bool IdentifierList::isInList(const Identifier* identifier) const
    6389    {
     
    74100    }
    75101
     102    /**
     103        @returns a string, containing the names of all Identifiers in the list.
     104    */
    76105    std::string IdentifierList::toString() const
    77106    {
     
    94123    // ###  IdentifierListElement  ###
    95124    // ###############################
     125    /**
     126        @brief Constructor: Creates the list-element with a given identifier.
     127        @param identifier The Identifier to store
     128    */
    96129    IdentifierListElement::IdentifierListElement(const Identifier* identifier)
    97130    {
     
    99132        this->next_ = 0;
    100133    }
    101 
    102     IdentifierListElement::~IdentifierListElement()
    103     {
    104     }
    105134}
  • code/branches/FICN/src/orxonox/core/IdentifierList.h

    r258 r384  
    11#ifndef _IdentifierList_H__
     2/*!
     3    @file IdentifierList.h
     4    @brief Definition of the IdentifierList class
     5
     6    The IdentifierList is a single-linked list, containing Identifiers.
     7    The IdentifierList is used to store parents and childs of each Identifier.
     8*/
     9
    210#define _IdentifierList_H__
    311
     
    614namespace orxonox
    715{
    8     class Identifier;
     16    class Identifier; // Forward declaration
    917
     18    //! The list-element of the IdentifierList
    1019    class IdentifierListElement
    1120    {
    1221        public:
    1322            IdentifierListElement(const Identifier* identifier);
    14             ~IdentifierListElement();
    1523
    16             const Identifier* identifier_;
    17             IdentifierListElement* next_;
     24            const Identifier* identifier_;      //!< The identifier
     25            IdentifierListElement* next_;       //!< The next element in the list
    1826    };
    1927
     28    //! The IdentifierList contains Identifiers
    2029    class IdentifierList
    2130    {
     
    2837            std::string toString() const;
    2938
    30             IdentifierListElement* first_;
     39            IdentifierListElement* first_;      //!< The first element in the list
    3140    };
    3241}
  • code/branches/FICN/src/orxonox/core/Iterator.h

    r337 r384  
    1 #ifndef _Iterator_H2__
    2 #define _Iterator_H2__
     1/*!
     2    @file Iterator.h
     3    @brief Definition of the Iterator class.
     4
     5    The Iterator of a given class allows to iterate through an ObjectList, containing all objects of that type.
     6    This is the only way to access the objects in an ObjectList.
     7
     8    Usage:
     9    for (Iterator<class> it = ObjectList<class>::start(); it != 0; ++it)
     10    {
     11        it->someFunction(...);
     12        class* myObject = *it;
     13    }
     14
     15    Warning: Don't delete an object directly through the iterator.
     16*/
     17
     18#ifndef _Iterator_H__
     19#define _Iterator_H__
    320
    421namespace orxonox
    522{
     23    //! The iterator allows to iterate through an ObjectList of a given class.
    624    template <class T>
    725    class Iterator
    826    {
    927        public:
     28            /**
     29                @brief Constructor: Sets the element whereon the iterator points to zero.
     30            */
    1031            Iterator()
    1132            {
     
    1334            }
    1435
     36            /**
     37                @brief Constructor: Sets the element whereon the iterator points to a given element.
     38                @param element The element to start with
     39            */
    1540            Iterator(ObjectListElement<T>* element)
    1641            {
     
    1843            }
    1944
     45            /**
     46                @brief Overloading of the ++it operator: Iterator iterates to the next object in the list.
     47                @return The Iterator itself
     48            */
    2049            Iterator<T> operator++()
    2150            {
     
    2453            }
    2554
     55            /**
     56                @brief Overloading of the --it operator: Iterator iterates to the previous object in the list.
     57                @return The Iterator itself
     58            */
    2659            Iterator<T> operator--()
    2760            {
     
    3063            }
    3164
     65            /**
     66                @brief Overloading of the *it operator: returns the pointer to the object.
     67                @return The object the Iterator points at
     68            */
    3269            T* operator*()
    3370            {
     
    3572            }
    3673
     74            /**
     75                @brief Overloading of the it-> operator: returns the pointer to the object.
     76                @return The object the Iterator points at
     77            */
    3778            T* operator->() const
    3879            {
     
    4182            }
    4283
     84            /**
     85                @brief Overloading of the typecast-operator to bool: returns true if the iterator points to an existing object.
     86                @return True if the iterator points to an existing object.
     87            */
    4388            operator bool()
    4489            {
     
    4691            }
    4792
     93            /**
     94                @brief Overloading of the (it != int) operator: Used for (it != 0) instead of typecast-operator to bool.
     95                @param compare The integer (must be zero, everything else makes no sense).
     96                @return True if the iterator points to an existing object.
     97            */
    4898            bool operator!=(int compare)
    4999            {
     100                // Comparing with something except zero makes no sense
    50101                if (compare != 0)
    51102                    std::cout << "Warning: Comparing the " << ClassIdentifier<T>::getIdentifier()->getName() << "-List-Iterator with " << compare << " has no effect. Only comparison with 0 works.\n";
     
    55106
    56107        private:
    57             ObjectListElement<T>* element_;
     108            ObjectListElement<T>* element_;     //!< The element the Iterator points to
    58109    };
    59110}
  • code/branches/FICN/src/orxonox/core/MetaObjectList.cc

    r258 r384  
     1/*!
     2    @file MetaObjectList.cc
     3    @brief Implementation of the MetaObjectList class.
     4*/
     5
    16#include "MetaObjectList.h"
    27
    38namespace orxonox
    49{
     10    /**
     11        @brief Constructor: Sets first_ to zero.
     12    */
    513    MetaObjectList::MetaObjectList()
    614    {
     
    816    }
    917
     18    /**
     19        @brief Destructor: Removes all elements from the list, causing them to remove the stored ObjectListElement from the ObjectList.
     20    */
    1021    MetaObjectList::~MetaObjectList()
    1122    {
  • code/branches/FICN/src/orxonox/core/MetaObjectList.h

    r258 r384  
     1/*!
     2    @file MetaObjectList.h
     3    @brief Definition of the MetaObjectList class.
     4
     5    The MetaObjectList is a single-linked list, containing all list-elements and their
     6    lists wherein the object that owns the MetaObjectList is registered.
     7    This allows much faster deleting of objects.
     8*/
     9
    110#ifndef _MetaObjectList_H__
    211#define _MetaObjectList_H__
     
    716namespace orxonox
    817{
     18    //! Base-class of MetaObjectListElement, because those is a template
    919    class BaseMetaObjectListElement
    1020    {
    1121        public:
     22            /** @brief Defaultdestructor */
    1223            virtual ~BaseMetaObjectListElement() {};
    1324
    14             BaseMetaObjectListElement* next_;
     25            BaseMetaObjectListElement* next_;       //!< The next Element in the list
    1526    };
    1627
     
    1829    // ###  MetaObjectListElement  ###
    1930    // ###############################
     31    //! The list-element of the MetaObjectList
    2032    template <class T>
    2133    class MetaObjectListElement : public BaseMetaObjectListElement
     
    2537            ~MetaObjectListElement();
    2638
    27             ObjectListElement<T>* element_;
    28             ObjectList<T>* list_;
     39            ObjectListElement<T>* element_;         //!< The list element, containing the object
     40            ObjectList<T>* list_;                   //!< The list, containing the element
    2941    };
    3042
     43    /**
     44        @brief Constructor: Creates the list-element with given list and element.
     45    */
    3146    template <class T>
    3247    MetaObjectListElement<T>::MetaObjectListElement(ObjectList<T>* list, ObjectListElement<T>* element)
     
    3752    }
    3853
     54    /**
     55        @brief Destructor: Removes the ObjectListElement from the ObjectList by linking next_ and prev_ of the ObjectListElement.
     56    */
    3957    template <class T>
    4058    MetaObjectListElement<T>::~MetaObjectListElement()
     
    4361            this->element_->next_->prev_ = this->element_->prev_;
    4462        else
    45             this->list_->last_ = this->element_->prev_;
     63            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
    4664
    4765        if (this->element_->prev_)
    4866            this->element_->prev_->next_ = this->element_->next_;
    4967        else
    50             this->list_->first_ = this->element_->next_;
     68            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
    5169
    5270
     
    6179    // ###       ObjectList        ###
    6280    // ###############################
     81    //!  The MetaObjectList contains ObjectListElements and their ObjectLists.
     82    /**
     83        The MetaObjectList is a single-linked list, containing all list-elements and their
     84        lists wherein the object that owns the MetaObjectList is registered.
     85        This allows much faster deleting of objects.
     86    */
    6387    class MetaObjectList
    6488    {
     
    6993            void add(ObjectList<T>* list, ObjectListElement<T>* element);
    7094
    71             BaseMetaObjectListElement* first_;
     95            BaseMetaObjectListElement* first_;      //!< The first element in the list
    7296    };
    7397
     98    /**
     99        @brief Adds an ObjectList and an element of that list to the MetaObjectList.
     100        @param list The ObjectList wherein the element is
     101        @param element The element wherein the object is
     102    */
    74103    template <class T>
    75104    void MetaObjectList::add(ObjectList<T>* list, ObjectListElement<T>* element)
  • code/branches/FICN/src/orxonox/core/ObjectList.h

    r258 r384  
     1/*!
     2    @file ObjectList.h
     3    @brief Definition of the ObjectList class.
     4
     5    The ObjectList is a double-linked list, used by Identifiers to store all objects of a specific class in it.
     6    Created objects are added through the RegisterObject-macro in its constructor.
     7    Use Iterator<class> to iterate through all objects of the class.
     8*/
     9
    110#ifndef _ObjectList_H__
    211#define _ObjectList_H__
     
    413namespace orxonox
    514{
    6     class OrxonoxClass;
     15    class OrxonoxClass; // Forward declaration
    716
    817    // ###############################
    918    // ###    ObjectListElement    ###
    1019    // ###############################
     20    //! The list-element of the ObjectList
    1121    template <class T>
    1222    class ObjectListElement
     
    1424        public:
    1525            ObjectListElement(T* object);
    16             ~ObjectListElement();
    17 
    18             T* object_;
    19             ObjectListElement* next_;
    20             ObjectListElement* prev_;
     26
     27            T* object_;                     //!< The object
     28            ObjectListElement* next_;       //!< The next element in the list
     29            ObjectListElement* prev_;       //!< The previous element in the list
    2130    };
    2231
     32    /**
     33        @brief Constructor: Creates the list-element with an object.
     34        @param Object The object to store
     35    */
    2336    template <class T>
    2437    ObjectListElement<T>::ObjectListElement(T* object)
     
    2942    }
    3043
    31     template <class T>
    32     ObjectListElement<T>::~ObjectListElement()
    33     {
    34     }
    35 
    3644
    3745    // ###############################
     
    3947    // ###############################
    4048    template <class T>
    41     class Iterator;
    42 
     49    class Iterator; // Forward declaration
     50
     51    //! The ObjectList contains all objects of a specific class.
     52    /**
     53        The ObjectList is used by Identifiers to store all objects of a specific class in it.
     54        Use Iterator<class> to iterate through all objects in the list.
     55    */
    4356    template <class T>
    4457    class ObjectList
     
    4861            ~ObjectList();
    4962            ObjectListElement<T>* add(T* object);
    50             void remove(OrxonoxClass* object, bool bIterateForwards = true);
    51 
     63//            void remove(OrxonoxClass* object, bool bIterateForwards = true);
     64
     65            /** @returns the first element in the list */
    5266            inline static Iterator<T> start()
    5367                { return Iterator<T>(pointer_s->first_); }
     68
     69            /** @returns the last element in the list */
    5470            inline static Iterator<T> end()
    5571                { return Iterator<T>(pointer_s->last_); }
    5672
    57             ObjectListElement<T>* first_;
    58             ObjectListElement<T>* last_;
     73            ObjectListElement<T>* first_;       //!< The first element in the list
     74            ObjectListElement<T>* last_;        //!< The last element in the list
    5975
    6076        private:
    61             static ObjectList<T>* pointer_s;
     77            static ObjectList<T>* pointer_s;    //!< A static pointer to the last created list (different for all T)
    6278    };
    6379
    6480    template <class T>
    65     ObjectList<T>* ObjectList<T>::pointer_s = 0;
    66 
     81    ObjectList<T>* ObjectList<T>::pointer_s = 0; // Set the static member variable pointer_s to zero
     82
     83    /**
     84        @brief Constructor: Sets first_ and last_ to zero and the static member variable pointer_s to _this_
     85    */
    6786    template <class T>
    6887    ObjectList<T>::ObjectList()
     
    7190        this->last_ = 0;
    7291
     92        // ObjectLists are only created by Identifiers and therefore only one ObjectList of each T will exist.
     93        // Thats why pointer_s is in fact a pointer to the only ObjectList for a type, which makes it almost a singleton.
    7394        this->pointer_s = this;
    7495    }
    7596
     97    /**
     98        @brief Destructor: Deletes all list-elements, but NOT THE OBJECTS.
     99    */
    76100    template <class T>
    77101    ObjectList<T>::~ObjectList()
     
    86110    }
    87111
     112    /**
     113        @brief Adds a new object to the end of the list.
     114        @param object The object to add
     115        @return The pointer to the new ObjectListElement, needed by the MetaObjectList of the added object
     116    */
    88117    template <class T>
    89118    ObjectListElement<T>* ObjectList<T>::add(T* object)
     
    91120        if (!this->last_)
    92121        {
     122            // If the list is empty
    93123            this->last_ = new ObjectListElement<T>(object);
    94             this->first_ = this->last_;
     124            this->first_ = this->last_; // There's only one object in the list now
    95125        }
    96126        else
    97127        {
     128            // If the list isn't empty
    98129            ObjectListElement<T>* temp = this->last_;
    99130            this->last_ = new ObjectListElement<T>(object);
     
    105136    }
    106137
     138
     139//    /**
     140//        @brief Removes an object from the list.
     141//        @param object The object to remove
     142//        @param bIterateForwards If true: Start searching the object at the beginning of the list
     143//    */
     144    /*
    107145    template <class T>
    108146    void ObjectList<T>::remove(OrxonoxClass* object, bool bIterateForwards)
     
    111149            return;
    112150
     151        // If there's only one object in the list, we have to set first_ and last_ to zero
    113152        if (this->first_ == this->last_)
    114153        {
     
    123162        }
    124163
     164        // Now we are sure we have more than one element in the list
    125165        if (bIterateForwards)
    126166        {
     167            // Start at the beginning of the list
     168
     169            // Check if it's the first object
    127170            if (this->first_->object_ == object)
    128171            {
     
    135178            }
    136179
     180            // Iterate through the whole list
    137181            ObjectListElement<T>* temp = this->first_;
    138182            while (temp->next_)
     
    146190                        temp2->prev_ = temp;
    147191                    else
    148                         this->last_ = temp;
     192                        this->last_ = temp; // If there is no next_, we deleted the last element and have to update the last_ pointer.
    149193
    150194                    return;
     
    156200        else
    157201        {
     202            // Start at the end of the list
     203
     204            // Check if it's the last object
    158205            if (this->last_->object_ == object)
    159206            {
     
    166213            }
    167214
     215            // Iterate through the whole list
    168216            ObjectListElement<T>* temp = this->last_;
    169217            while (temp->prev_)
     
    177225                        temp2->next_ = temp;
    178226                    else
    179                         this->first_ = temp;
     227                        this->first_ = temp; // If there is no prev_, we deleted the first element and have to update the first_ pointer.
    180228
    181229                    return;
     
    186234        }
    187235    }
     236    */
    188237}
    189238
  • code/branches/FICN/src/orxonox/core/OrxonoxClass.cc

    r258 r384  
     1/*!
     2    @file OrxonoxClass.cc
     3    @brief Implementation of the OrxonoxClass Class.
     4*/
     5
    16#include "OrxonoxClass.h"
    27
    38namespace orxonox
    49{
     10    /** @brief Constructor: Sets the default values. */
    511    OrxonoxClass::OrxonoxClass()
    612    {
     
    814        this->parents_ = 0;
    915
    10         this->metaList_ = new MetaObjectList;
     16        this->bActive_ = true;
     17        this->bVisible_ = true;
    1118    }
    1219
     20    /** @brief Destructor: Deletes, if existing, the list of the parents. */
    1321    OrxonoxClass::~OrxonoxClass()
    1422    {
     23        // parents_ exists only if isCreatingHierarchy() of the associated Identifier returned true while creating the class
    1524        if (this->parents_)
    1625            delete this->parents_;
    17 
    18         delete this->metaList_;
    1926    }
    2027}
  • code/branches/FICN/src/orxonox/core/OrxonoxClass.h

    r258 r384  
     1/*!
     2    @file OrxonoxClass.h
     3    @brief Definition of the OrxonoxClass Class.
     4
     5    All objects and interfaces of the game-logic are derived from OrxonoxClass.
     6    It stores the Identifier and the MetaObjectList and has all needed functions to create the class-hierarchy.
     7*/
     8
    19#ifndef _OrxonoxClass_H__
    210#define _OrxonoxClass_H__
     
    917namespace orxonox
    1018{
     19    //! The class all objects and interfaces of the game-logic are derived from.
     20    /**
     21        BaseObject and Interaces are derived with 'virtual public OrxonoxClass' from OrxonoxClass.
     22        OrxonoxClass is needed to create the class-hierarchy at startup and to store the Identifier and the MetaObjectList.
     23    */
    1124    class OrxonoxClass
    1225    {
     
    1427            OrxonoxClass();
    1528            virtual ~OrxonoxClass();
     29
     30            /** @returns the Identifier of the object */
    1631            inline Identifier* getIdentifier() const { return this->identifier_; }
     32
     33            /** @brief Sets the Identifier of the object. Used by the RegisterObject-macro. */
    1734            inline void setIdentifier(Identifier* identifier) { this->identifier_ = identifier; }
     35
     36            /** @returns the list of all parents of the object */
    1837            inline IdentifierList* getParents() const { return this->parents_; }
     38
     39            /** @brief Sets the Parents of the object. Used by the RegisterObject-macro. */
    1940            inline void setParents(IdentifierList* parents) { this->parents_ = parents; }
    20             inline MetaObjectList* getMetaList() { return this->metaList_; }
     41
     42            /** @returns the MetaObjectList of the object, containing a link to all ObjectLists and ObjectListElements the object is registered in. */
     43            inline MetaObjectList& getMetaList() { return this->metaList_; }
     44
     45            inline bool isA(const Identifier* identifier)
     46                { return this->getIdentifier()->isA(identifier); }
     47            inline bool isDirectlyA(const Identifier* identifier)
     48                { return this->getIdentifier()->isDirectlyA(identifier); }
     49            inline bool isChildOf(const Identifier* identifier)
     50                { return this->getIdentifier()->isChildOf(identifier); }
     51            inline bool isParentOf(const Identifier* identifier)
     52                { return this->getIdentifier()->isParentOf(identifier); }
     53
     54            inline bool isA(const SubclassIdentifier<class B>* identifier)
     55                { return this->getIdentifier()->isA(identifier->getIdentifier()); }
     56            inline bool isDirectlyA(const SubclassIdentifier<class B>* identifier)
     57                { return this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); }
     58            inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
     59                { return this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
     60            inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
     61                { return this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
     62
     63            inline bool isA(const SubclassIdentifier<class B> identifier)
     64                { return this->getIdentifier()->isA(identifier.getIdentifier()); }
     65            inline bool isDirectlyA(const SubclassIdentifier<class B> identifier)
     66                { return this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); }
     67            inline bool isChildOf(const SubclassIdentifier<class B> identifier)
     68                { return this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
     69            inline bool isParentOf(const SubclassIdentifier<class B> identifier)
     70                { return this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
     71
     72            inline bool isA(const OrxonoxClass* object)
     73                { return this->getIdentifier()->isA(object->getIdentifier()); }
     74            inline bool isDirectlyA(const OrxonoxClass* object)
     75                { return this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
     76            inline bool isChildOf(const OrxonoxClass* object)
     77                { return this->getIdentifier()->isChildOf(object->getIdentifier()); }
     78            inline bool isParentOf(const OrxonoxClass* object)
     79                { return this->getIdentifier()->isParentOf(object->getIdentifier()); }
     80
     81
     82            inline void setName(const std::string& name) { this->name_ = name; }
     83            inline const std::string& getName() const { return this->name_; }
     84
     85            inline void setActive(bool bActive) { this->bActive_ = bActive; }
     86            inline const bool isActive() const { return this->bActive_; }
     87
     88            inline void setVisible(bool bVisible) { this->bVisible_ = bVisible; }
     89            inline const bool isVisible() const { return this->bVisible_; }
    2190
    2291        private:
    23             Identifier* identifier_;
    24             IdentifierList* parents_;
    25             MetaObjectList* metaList_;
     92            Identifier* identifier_;        //!< The Identifier of the object
     93            IdentifierList* parents_;       //!< List of all parents of the object
     94            MetaObjectList metaList_;       //!< MetaObjectList, containing all ObjectLists and ObjectListElements the object is registered in
     95
     96            std::string name_;
     97            bool bActive_;
     98            bool bVisible_;
    2699    };
    27100}
  • code/branches/FICN/src/orxonox/objects/BaseObject.h

    r341 r384  
    22#define _BaseObject_H__
    33
    4 #include "orxonox/core/IdentifierIncludes.h"
     4#include "../core/IdentifierIncludes.h"
    55
    66namespace orxonox
     
    1111            BaseObject();
    1212            virtual ~BaseObject();
    13 
    14             inline bool isA(const Identifier* identifier)
    15                 { this->getIdentifier()->isA(identifier); }
    16             inline bool isDirectlyA(const Identifier* identifier)
    17                 { this->getIdentifier()->isDirectlyA(identifier); }
    18             inline bool isChildOf(const Identifier* identifier)
    19                 { this->getIdentifier()->isChildOf(identifier); }
    20             inline bool isParentOf(const Identifier* identifier)
    21                 { this->getIdentifier()->isParentOf(identifier); }
    22 
    23             inline bool isA(const SubclassIdentifier<class B>* identifier)
    24                 { this->getIdentifier()->isA(identifier->getIdentifier()); }
    25             inline bool isDirectlyA(const SubclassIdentifier<class B>* identifier)
    26                 { this->getIdentifier()->isDirectlyA(identifier->getIdentifier()); }
    27             inline bool isChildOf(const SubclassIdentifier<class B>* identifier)
    28                 { this->getIdentifier()->isChildOf(identifier->getIdentifier()); }
    29             inline bool isParentOf(const SubclassIdentifier<class B>* identifier)
    30                 { this->getIdentifier()->isParentOf(identifier->getIdentifier()); }
    31 
    32             inline bool isA(const SubclassIdentifier<class B> identifier)
    33                 { this->getIdentifier()->isA(identifier.getIdentifier()); }
    34             inline bool isDirectlyA(const SubclassIdentifier<class B> identifier)
    35                 { this->getIdentifier()->isDirectlyA(identifier.getIdentifier()); }
    36             inline bool isChildOf(const SubclassIdentifier<class B> identifier)
    37                 { this->getIdentifier()->isChildOf(identifier.getIdentifier()); }
    38             inline bool isParentOf(const SubclassIdentifier<class B> identifier)
    39                 { this->getIdentifier()->isParentOf(identifier.getIdentifier()); }
    40 
    41             inline bool isA(const OrxonoxClass* object)
    42                 { this->getIdentifier()->isA(object->getIdentifier()); }
    43             inline bool isDirectlyA(const OrxonoxClass* object)
    44                 { this->getIdentifier()->isDirectlyA(object->getIdentifier()); }
    45             inline bool isChildOf(const OrxonoxClass* object)
    46                 { this->getIdentifier()->isChildOf(object->getIdentifier()); }
    47             inline bool isParentOf(const OrxonoxClass* object)
    48                 { this->getIdentifier()->isParentOf(object->getIdentifier()); }
    49 
    50             std::string name_; // test
    51 
    5213    };
    5314}
  • code/branches/FICN/src/orxonox/objects/test1.cc

    r258 r384  
    1818    Test1::~Test1()
    1919    {
     20    }
     21
     22    void Test1::tick(float dt)
     23    {
     24        std::cout << "Test1: " << this << "\n";
    2025    }
    2126
  • code/branches/FICN/src/orxonox/objects/test1.h

    r258 r384  
    33
    44#include "BaseObject.h"
     5#include "Tickable.h"
    56#include "test3.h"
    67
    78namespace orxonox
    89{
    9     class Test1 : public BaseObject
     10    class Test1 : public BaseObject, public Tickable
    1011    {
    1112        public:
    1213            Test1();
    1314            virtual ~Test1();
     15
     16            virtual void tick(float dt);
    1417
    1518            bool usefullClass1isA(Identifier* identifier);
  • code/branches/FICN/src/orxonox/objects/test2.cc

    r258 r384  
    1414        this->usefullClass2_ = Class(Test2);
    1515        this->usefullClass3_ = Class(Test3);
     16
     17        timer1.setTimer(1, true, this, &Test2::timerFunction1);
     18        timer2.setTimer(5, true, this, &Test2::timerFunction2);
     19        timer3.setTimer(10, false, this, &Test2::timerFunction3);
    1620    }
    1721
    1822    Test2::~Test2()
    1923    {
     24    }
     25
     26    void Test2::timerFunction1()
     27    {
     28        std::cout << "Test2: 1 Sekunde\n";
     29    }
     30
     31    void Test2::timerFunction2()
     32    {
     33        std::cout << "Test2: 5 Sekunden\n";
     34    }
     35
     36    void Test2::timerFunction3()
     37    {
     38        std::cout << "Test2: 10 Sekunden sind um!\n";
    2039    }
    2140
  • code/branches/FICN/src/orxonox/objects/test2.h

    r258 r384  
    33
    44#include "BaseObject.h"
     5#include "Timer.h"
    56
    67namespace orxonox
     
    2122            void setUsefullClassOfTypeTest3(Identifier* identifier);
    2223
     24            void timerFunction1();
     25            void timerFunction2();
     26            void timerFunction3();
     27
    2328        private:
    2429            Identifier* usefullClass1_;
     
    2631            SubclassIdentifier<Test3> usefullClass3_;
    2732
     33            Timer<Test2> timer1;
     34            Timer<Test2> timer2;
     35            Timer<Test2> timer3;
    2836    };
    2937}
Note: See TracChangeset for help on using the changeset viewer.