Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 5778


Ignore:
Timestamp:
Sep 24, 2009, 2:47:53 AM (15 years ago)
Author:
landauf
Message:

Removed the Factory class.
Moved the networkID↔Identifier map from Factory to Identifier.
Replaced the name↔Identifier map from Factory with the already existing Identifier map in Identifier. This map additionally contains Identifiers without Factory. You can separate them with the new function identifier→hasFactory().

Location:
code/branches/core5/src/libraries
Files:
2 deleted
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core5/src/libraries/core/ArgumentCompletionFunctions.cc

    r5738 r5778  
    100100            ArgumentCompletionList classlist;
    101101
    102             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
     102            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
    103103                if ((*it).second->hasConfigValues())
    104104                    classlist.push_back(ArgumentCompletionListElement((*it).second->getName(), getLowercase((*it).first)));
     
    110110        {
    111111            ArgumentCompletionList configvalues;
    112             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getIdentifierMap().find(classname);
     112            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getStringIdentifierMap().find(classname);
    113113
    114             if (identifier != Identifier::getIdentifierMapEnd() && (*identifier).second->hasConfigValues())
     114            if (identifier != Identifier::getStringIdentifierMapEnd() && (*identifier).second->hasConfigValues())
    115115            {
    116116                for (std::map<std::string, ConfigValueContainer*>::const_iterator it = (*identifier).second->getConfigValueMapBegin(); it != (*identifier).second->getConfigValueMapEnd(); ++it)
     
    124124        {
    125125            ArgumentCompletionList oldvalue;
    126             std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    127             if (identifier != Identifier::getLowercaseIdentifierMapEnd())
     126            std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     127            if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    128128            {
    129129                std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
  • code/branches/core5/src/libraries/core/CMakeLists.txt

    r5738 r5778  
    4949
    5050  # hierarchy
    51   Factory.cc
    5251  Identifier.cc
    5352  MetaObjectList.cc
     
    6867  TclBind.cc
    6968  TclThreadManager.cc
    70  
     69
    7170  # multithreading
    7271  Thread.cc
  • code/branches/core5/src/libraries/core/ClassFactory.h

    r5777 r5778  
    4242
    4343#include "util/Debug.h"
    44 #include "Factory.h"
    4544#include "Identifier.h"
    4645
     
    7170
    7271    /**
    73         @brief Adds the ClassFactory to the Identifier of the same type and the Identifier to the Factory.
     72        @brief Adds the ClassFactory to the Identifier of the same type.
    7473        @param name The name of the class
    7574        @param bLoadable True if the class can be loaded through XML
    76         @return Always true (this is needed because the compiler only allows assignments before main())
    7775    */
    7876    template <class T>
     
    8280        ClassIdentifier<T>::getIdentifier(name)->addFactory(this);
    8381        ClassIdentifier<T>::getIdentifier()->setLoadable(bLoadable);
    84         Factory::add(name, ClassIdentifier<T>::getIdentifier());
    8582    }
    8683
  • code/branches/core5/src/libraries/core/CommandExecutor.cc

    r5738 r5778  
    468468        CommandExecutor::getEvaluation().listOfPossibleIdentifiers_.clear();
    469469        std::string lowercase = getLowercase(fragment);
    470         for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMapBegin(); it != Identifier::getLowercaseIdentifierMapEnd(); ++it)
     470        for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMapBegin(); it != Identifier::getLowercaseStringIdentifierMapEnd(); ++it)
    471471            if ((*it).second->hasConsoleCommands())
    472472                if ((*it).first.find(lowercase) == 0 || fragment == "")
     
    516516    {
    517517        std::string lowercase = getLowercase(name);
    518         std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseIdentifierMap().find(lowercase);
    519         if ((it != Identifier::getLowercaseIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
     518        std::map<std::string, Identifier*>::const_iterator it = Identifier::getLowercaseStringIdentifierMap().find(lowercase);
     519        if ((it != Identifier::getLowercaseStringIdentifierMapEnd()) && (*it).second->hasConsoleCommands())
    520520            return (*it).second;
    521521
  • code/branches/core5/src/libraries/core/ConfigFileManager.cc

    r5738 r5778  
    4848    bool config(const std::string& classname, const std::string& varname, const std::string& value)
    4949    {
    50         std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    51         if (identifier != Identifier::getLowercaseIdentifierMapEnd())
     50        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     51        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    5252        {
    5353            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
     
    6060    bool tconfig(const std::string& classname, const std::string& varname, const std::string& value)
    6161    {
    62         std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseIdentifierMap().find(getLowercase(classname));
    63         if (identifier != Identifier::getLowercaseIdentifierMapEnd())
     62        std::map<std::string, Identifier*>::const_iterator identifier = Identifier::getLowercaseStringIdentifierMap().find(getLowercase(classname));
     63        if (identifier != Identifier::getLowercaseStringIdentifierMapEnd())
    6464        {
    6565            std::map<std::string, ConfigValueContainer*>::const_iterator variable = (*identifier).second->getLowercaseConfigValueMap().find(getLowercase(varname));
     
    376376        for (std::list<ConfigFileSection*>::iterator it1 = this->sections_.begin(); it1 != this->sections_.end(); )
    377377        {
    378             std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getIdentifierMap().find((*it1)->getName());
    379             if (it2 != Identifier::getIdentifierMapEnd() && (*it2).second->hasConfigValues())
     378            std::map<std::string, Identifier*>::const_iterator it2 = Identifier::getStringIdentifierMap().find((*it1)->getName());
     379            if (it2 != Identifier::getStringIdentifierMapEnd() && (*it2).second->hasConfigValues())
    380380            {
    381381                // The section exists, delete comment
     
    455455        if (this->type_ == ConfigFileType::Settings)
    456456        {
    457             for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getIdentifierMapBegin(); it != Identifier::getIdentifierMapEnd(); ++it)
     457            for (std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin(); it != Identifier::getStringIdentifierMapEnd(); ++it)
    458458            {
    459459                if (it->second->hasConfigValues())
  • code/branches/core5/src/libraries/core/Core.cc

    r5759 r5778  
    6969#include "CoreIncludes.h"
    7070#include "DynLibManager.h"
    71 #include "Factory.h"
    7271#include "GameMode.h"
    7372#include "GraphicsManager.h"
     
    334333
    335334        // creates the class hierarchy for all classes with factories
    336         Factory::createClassHierarchy();
     335        Identifier::createClassHierarchy();
    337336
    338337        // Do this soon after the ConfigFileManager has been created to open up the
  • code/branches/core5/src/libraries/core/CoreIncludes.h

    r5777 r5778  
    2929/**
    3030    @file
    31     @brief Definition of macros for Identifier and Factory.
     31    @brief Definition of macros for Identifiers
    3232
    3333    Every class needs the RegisterObject(class) macro in its constructor. If the class is an interface
     
    4646#include "Identifier.h"
    4747#include "SubclassIdentifier.h"
    48 #include "Factory.h"
    4948#include "ClassFactory.h"
    5049#include "ObjectList.h"
     
    7776
    7877/**
    79     @brief Creates the entry in the Factory.
     78    @brief Creates the Factory.
    8079    @param ClassName The name of the class
    8180*/
     
    8483
    8584/**
    86     @brief Creates the entry in the Factory for classes which should not be loaded through XML.
     85    @brief Creates the Factory for classes which should not be loaded through XML.
    8786    @param ClassName The name of the class
    8887*/
     
    106105    inline Identifier* ClassByString(const std::string& name)
    107106    {
    108         return Factory::getIdentifier(name);
     107        return Identifier::getIdentifierByString(name);
    109108    }
    110109
     
    115114    inline Identifier* ClassByID(uint32_t id)
    116115    {
    117         return Factory::getIdentifier(id);
     116        return Identifier::getIdentifierByID(id);
    118117    }
    119118}
  • code/branches/core5/src/libraries/core/Identifier.cc

    r5777 r5778  
    196196
    197197    /**
     198        @brief Creates the class-hierarchy by creating and destroying one object of each type.
     199    */
     200    void Identifier::createClassHierarchy()
     201    {
     202        COUT(3) << "*** Identifier: Create class-hierarchy" << std::endl;
     203        std::map<std::string, Identifier*>::const_iterator it;
     204        it = Identifier::getStringIdentifierMap().begin();
     205        Identifier::getStringIdentifierMap().begin()->second->startCreatingHierarchy();
     206        for (it = Identifier::getStringIdentifierMap().begin(); it != Identifier::getStringIdentifierMap().end(); ++it)
     207        {
     208            // To create the new branch of the class-hierarchy, we create a new object and delete it afterwards.
     209            if (it->second->hasFactory())
     210            {
     211                BaseObject* temp = it->second->fabricate(0);
     212                delete temp;
     213            }
     214        }
     215        Identifier::getStringIdentifierMap().begin()->second->stopCreatingHierarchy();
     216        COUT(3) << "*** Identifier: Finished class-hierarchy creation" << std::endl;
     217    }
     218
     219    /**
    198220        @brief Destroys all Identifiers. Called when exiting the program.
    199221    */
     
    214236            this->name_ = name;
    215237            this->bSetName_ = true;
    216             Identifier::getIdentifierMapIntern()[name] = this;
    217             Identifier::getLowercaseIdentifierMapIntern()[getLowercase(name)] = this;
     238            Identifier::getStringIdentifierMapIntern()[name] = this;
     239            Identifier::getLowercaseStringIdentifierMapIntern()[getLowercase(name)] = this;
     240            Identifier::getIDIdentifierMapIntern()[this->networkID_] = this;
    218241        }
    219242    }
     
    240263
    241264    /**
    242         @brief Sets the network ID to a new value and changes the entry in the Factory.
     265        @brief Sets the network ID to a new value and changes the entry in the ID-Identifier-map.
    243266        @param id The new network ID
    244267    */
    245268    void Identifier::setNetworkID(uint32_t id)
    246269    {
    247         Factory::changeNetworkID(this, this->networkID_, id);
     270//        Identifier::getIDIdentifierMapIntern().erase(this->networkID_);
     271        Identifier::getIDIdentifierMapIntern()[id] = this;
    248272        this->networkID_ = id;
    249273    }
     
    304328
    305329    /**
    306         @brief Returns the map that stores all Identifiers.
     330        @brief Returns the map that stores all Identifiers with their names.
    307331        @return The map
    308332    */
    309     std::map<std::string, Identifier*>& Identifier::getIdentifierMapIntern()
     333    std::map<std::string, Identifier*>& Identifier::getStringIdentifierMapIntern()
    310334    {
    311335        static std::map<std::string, Identifier*> identifierMap;
     
    314338
    315339    /**
    316         @brief Returns the map that stores all Identifiers.
     340        @brief Returns the map that stores all Identifiers with their names in lowercase.
    317341        @return The map
    318342    */
    319     std::map<std::string, Identifier*>& Identifier::getLowercaseIdentifierMapIntern()
     343    std::map<std::string, Identifier*>& Identifier::getLowercaseStringIdentifierMapIntern()
    320344    {
    321345        static std::map<std::string, Identifier*> lowercaseIdentifierMap;
    322346        return lowercaseIdentifierMap;
     347    }
     348
     349    /**
     350        @brief Returns the map that stores all Identifiers with their network IDs.
     351        @return The map
     352    */
     353    std::map<uint32_t, Identifier*>& Identifier::getIDIdentifierMapIntern()
     354    {
     355        static std::map<uint32_t, Identifier*> identifierMap;
     356        return identifierMap;
     357    }
     358
     359    /**
     360        @brief Returns the Identifier with a given name.
     361        @param name The name of the wanted Identifier
     362        @return The Identifier
     363    */
     364    Identifier* Identifier::getIdentifierByString(const std::string& name)
     365    {
     366        std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapIntern().find(name);
     367        if (it != Identifier::getStringIdentifierMapIntern().end())
     368            return it->second;
     369        else
     370            return 0;
     371    }
     372
     373    /**
     374        @brief Returns the Identifier with a given network ID.
     375        @param id The network ID of the wanted Identifier
     376        @return The Identifier
     377    */
     378    Identifier* Identifier::getIdentifierByID(const uint32_t id)
     379    {
     380        std::map<uint32_t, Identifier*>::const_iterator it = Identifier::getIDIdentifierMapIntern().find(id);
     381        if (it != Identifier::getIDIdentifierMapIntern().end())
     382            return it->second;
     383        else
     384            return 0;
     385    }
     386
     387    /**
     388        @brief Cleans the NetworkID map (needed on clients for correct initialization)
     389    */
     390    void Identifier::clearNetworkIDs()
     391    {
     392        Identifier::getIDIdentifierMapIntern().clear();
    323393    }
    324394
  • code/branches/core5/src/libraries/core/Identifier.h

    r5776 r5778  
    8787    class _CoreExport Identifier
    8888    {
    89         template <class T>
    90         friend class SubclassIdentifier;
    91 
    92         friend class Factory;
    93 
    9489        public:
     90            /** @brief Returns the name of the class the Identifier belongs to. @return The name */
     91            inline const std::string& getName() const { return this->name_; }
     92            void setName(const std::string& name);
     93
     94            /** @brief Returns the network ID to identify a class through the network. @return the network ID */
     95            inline const uint32_t getNetworkID() const { return this->networkID_; }
     96            void setNetworkID(uint32_t id);
     97
     98            /** @brief Returns the unique ID of the class */
     99            FORCEINLINE unsigned int getClassID() const { return this->classID_; }
     100
     101            /** @brief Returns the list of all existing objects of this class. @return The list */
     102            inline ObjectListBase* getObjects() const { return this->objects_; }
     103
    95104            /** @brief Sets the Factory. @param factory The factory to assign */
    96105            inline void addFactory(BaseFactory* factory) { this->factory_ = factory; }
     106            /** @brief Returns true if the Identifier has a Factory. */
     107            inline bool hasFactory() const { return (this->factory_ != 0); }
    97108
    98109            BaseObject* fabricate(BaseObject* creator);
     110
     111            /** @brief Returns true if the class can be loaded through XML. */
     112            inline bool isLoadable() const { return this->bLoadable_; }
     113            /** @brief Set the class to be loadable through XML or not. */
     114            inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
     115
    99116            bool isA(const Identifier* identifier) const;
    100117            bool isExactlyA(const Identifier* identifier) const;
     
    104121            bool isDirectParentOf(const Identifier* identifier) const;
    105122
    106             /** @brief Returns true if the class can be loaded through XML. */
    107             inline bool isLoadable() const { return this->bLoadable_; }
    108             /** @brief Set the class to be loadable through XML or not. */
    109             inline void setLoadable(bool bLoadable) { this->bLoadable_ = bLoadable; }
    110 
    111             /** @brief Returns the list of all existing objects of this class. @return The list */
    112             inline ObjectListBase* getObjects() const
    113                 { return this->objects_; }
    114 
    115             /** @brief Returns the name of the class the Identifier belongs to. @return The name */
    116             inline const std::string& getName() const { return this->name_; }
    117             void setName(const std::string& name);
    118 
    119             virtual void updateConfigValues(bool updateChildren = true) const = 0;
     123
     124            /////////////////////////////
     125            ////// Class Hierarchy //////
     126            /////////////////////////////
     127            static void createClassHierarchy();
     128
     129            /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
     130            inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
    120131
    121132            /** @brief Returns the parents of the class the Identifier belongs to. @return The list of all parents */
     
    148159
    149160
    150             /** @brief Returns the map that stores all Identifiers. @return The map */
    151             static inline const std::map<std::string, Identifier*>& getIdentifierMap() { return Identifier::getIdentifierMapIntern(); }
    152             /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers. @return The const_iterator */
    153             static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapBegin() { return Identifier::getIdentifierMap().begin(); }
    154             /** @brief Returns a const_iterator to the end of the map that stores all Identifiers. @return The const_iterator */
    155             static inline std::map<std::string, Identifier*>::const_iterator getIdentifierMapEnd() { return Identifier::getIdentifierMap().end(); }
     161            //////////////////////////
     162            ///// Identifier Map /////
     163            //////////////////////////
     164            static void destroyAllIdentifiers();
     165
     166            static Identifier* getIdentifierByString(const std::string& name);
     167            static Identifier* getIdentifierByID(uint32_t id);
     168
     169            static void clearNetworkIDs();
     170
     171            /** @brief Returns the map that stores all Identifiers with their names. @return The map */
     172            static inline const std::map<std::string, Identifier*>& getStringIdentifierMap() { return Identifier::getStringIdentifierMapIntern(); }
     173            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names. @return The const_iterator */
     174            static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin() { return Identifier::getStringIdentifierMap().begin(); }
     175            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names. @return The const_iterator */
     176            static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd() { return Identifier::getStringIdentifierMap().end(); }
    156177
    157178            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
    158             static inline const std::map<std::string, Identifier*>& getLowercaseIdentifierMap() { return Identifier::getLowercaseIdentifierMapIntern(); }
     179            static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap() { return Identifier::getLowercaseStringIdentifierMapIntern(); }
    159180            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
    160             static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapBegin() { return Identifier::getLowercaseIdentifierMap().begin(); }
     181            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin() { return Identifier::getLowercaseStringIdentifierMap().begin(); }
    161182            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase. @return The const_iterator */
    162             static inline std::map<std::string, Identifier*>::const_iterator getLowercaseIdentifierMapEnd() { return Identifier::getLowercaseIdentifierMap().end(); }
    163 
     183            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd() { return Identifier::getLowercaseStringIdentifierMap().end(); }
     184
     185            /** @brief Returns the map that stores all Identifiers with their IDs. @return The map */
     186            static inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap() { return Identifier::getIDIdentifierMapIntern(); }
     187            /** @brief Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs. @return The const_iterator */
     188            static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin() { return Identifier::getIDIdentifierMap().begin(); }
     189            /** @brief Returns a const_iterator to the end of the map that stores all Identifiers with their IDs. @return The const_iterator */
     190            static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd() { return Identifier::getIDIdentifierMap().end(); }
     191
     192
     193            /////////////////////////
     194            ///// Config Values /////
     195            /////////////////////////
     196            virtual void updateConfigValues(bool updateChildren = true) const = 0;
     197
     198            /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
     199            inline bool hasConfigValues() const { return this->bHasConfigValues_; }
    164200
    165201            /** @brief Returns the map that stores all config values. @return The const_iterator */
     
    177213            inline std::map<std::string, ConfigValueContainer*>::const_iterator getLowercaseConfigValueMapEnd() const { return this->configValues_LC_.end(); }
    178214
     215            void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
     216            ConfigValueContainer* getConfigValueContainer(const std::string& varname);
     217            ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
     218
     219
     220            ////////////////////////////
     221            ///// Console Commands /////
     222            ////////////////////////////
     223            /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
     224            inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
    179225
    180226            /** @brief Returns the map that stores all console commands. @return The const_iterator */
     
    192238            inline std::map<std::string, ConsoleCommand*>::const_iterator getLowercaseConsoleCommandMapEnd() const { return this->consoleCommands_LC_.end(); }
    193239
     240            ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
     241            ConsoleCommand* getConsoleCommand(const std::string& name) const;
     242            ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
     243
     244
     245            ///////////////////
     246            ///// XMLPort /////
     247            ///////////////////
    194248            /** @brief Returns the map that stores all XMLPort params. @return The const_iterator */
    195249            inline const std::map<std::string, XMLPortParamContainer*>& getXMLPortParamMap() const { return this->xmlportParamContainers_; }
     
    213267            inline std::map<std::string, XMLPortObjectContainer*>::const_iterator getXMLPortEventMapEnd() const { return this->xmlportEventContainers_.end(); }
    214268
    215             /** @brief Returns true if this class has at least one config value. @return True if this class has at least one config value */
    216             inline bool hasConfigValues() const { return this->bHasConfigValues_; }
    217             /** @brief Returns true if this class has at least one console command. @return True if this class has at least one console command */
    218             inline bool hasConsoleCommands() const { return this->bHasConsoleCommands_; }
    219 
    220             /** @brief Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents. @return The status of the class-hierarchy creation */
    221             inline static bool isCreatingHierarchy() { return (hierarchyCreatingCounter_s > 0); }
    222 
    223             /** @brief Returns the network ID to identify a class through the network. @return the network ID */
    224             inline const uint32_t getNetworkID() const { return this->networkID_; }
    225 
    226             /** @brief Sets the network ID to a new value. @param id The new value */
    227             void setNetworkID(uint32_t id);
    228 
    229             /** @brief Returns the unique ID of the class */
    230             FORCEINLINE unsigned int getClassID() const { return this->classID_; }
    231 
    232             void addConfigValueContainer(const std::string& varname, ConfigValueContainer* container);
    233             ConfigValueContainer* getConfigValueContainer(const std::string& varname);
    234             ConfigValueContainer* getLowercaseConfigValueContainer(const std::string& varname);
    235 
    236269            void addXMLPortParamContainer(const std::string& paramname, XMLPortParamContainer* container);
    237270            XMLPortParamContainer* getXMLPortParamContainer(const std::string& paramname);
     
    243276            XMLPortObjectContainer* getXMLPortEventContainer(const std::string& eventname);
    244277
    245             ConsoleCommand& addConsoleCommand(ConsoleCommand* command, bool bCreateShortcut);
    246             ConsoleCommand* getConsoleCommand(const std::string& name) const;
    247             ConsoleCommand* getLowercaseConsoleCommand(const std::string& name) const;
    248 
    249             void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
    250 
    251             static void destroyAllIdentifiers();
    252278
    253279        protected:
     
    259285            virtual void createSuperFunctionCaller() const = 0;
    260286
    261             /** @brief Returns the map that stores all Identifiers. @return The map */
    262             static std::map<std::string, Identifier*>& getIdentifierMapIntern();
     287            void initializeClassHierarchy(std::set<const Identifier*>* parents, bool bRootClass);
     288
     289            /** @brief Returns the map that stores all Identifiers with their names. @return The map */
     290            static std::map<std::string, Identifier*>& getStringIdentifierMapIntern();
    263291            /** @brief Returns the map that stores all Identifiers with their names in lowercase. @return The map */
    264             static std::map<std::string, Identifier*>& getLowercaseIdentifierMapIntern();
     292            static std::map<std::string, Identifier*>& getLowercaseStringIdentifierMapIntern();
     293            /** @brief Returns the map that stores all Identifiers with their network IDs. @return The map */
     294            static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern();
    265295
    266296            /** @brief Returns the children of the class the Identifier belongs to. @return The list of all children */
     
    345375
    346376        public:
    347             static ClassIdentifier<T> *getIdentifier();
    348             static ClassIdentifier<T> *getIdentifier(const std::string& name);
     377            static ClassIdentifier<T>* getIdentifier();
     378            static ClassIdentifier<T>* getIdentifier(const std::string& name);
    349379
    350380            bool initialiseObject(T* object, const std::string& className, bool bRootClass);
     
    377407    inline ClassIdentifier<T>* ClassIdentifier<T>::getIdentifier()
    378408    {
    379         // check if the static field has already been filled
    380         if (ClassIdentifier<T>::classIdentifier_s == 0)
     409        // check if the Identifier already exists
     410        if (!ClassIdentifier<T>::classIdentifier_s)
    381411            ClassIdentifier<T>::initialiseIdentifier();
    382412
  • code/branches/core5/src/libraries/core/XMLPort.h

    r5747 r5778  
    5151#include "util/MultiType.h"
    5252#include "util/OrxAssert.h"
    53 #include "Factory.h"
    5453#include "Identifier.h"
    5554#include "Executor.h"
     
    548547                            for (ticpp::Iterator<ticpp::Element> child = xmlsubelement->FirstChildElement(false); child != child.end(); child++)
    549548                            {
    550                                 Identifier* identifier = Factory::getIdentifier(child->Value());
     549                                Identifier* identifier = Identifier::getIdentifierByString(child->Value());
    551550                                if (identifier)
    552551                                {
  • code/branches/core5/src/libraries/network/packet/ClassID.cc

    r5738 r5778  
    4949  Identifier *id;
    5050  std::string classname;
    51   unsigned int nrOfClasses=0; 
     51  unsigned int nrOfClasses=0;
    5252  unsigned int packetSize=2*sizeof(uint32_t); //space for the packetID and for the nrofclasses
    5353  uint32_t network_id;
    5454  flags_ = flags_ | PACKET_FLAGS_CLASSID;
    5555  std::queue<std::pair<uint32_t, std::string> > tempQueue;
    56  
     56
    5757  //calculate total needed size (for all strings and integers)
    58   std::map<std::string, Identifier*>::const_iterator it = Factory::getFactoryMapBegin();
    59   for(;it != Factory::getFactoryMapEnd();++it){
     58  std::map<std::string, Identifier*>::const_iterator it = Identifier::getStringIdentifierMapBegin();
     59  for(;it != Identifier::getStringIdentifierMapEnd();++it){
    6060    id = (*it).second;
    61     if(id == NULL)
     61    if(id == NULL || !id->hasFactory())
    6262      continue;
    6363    classname = id->getName();
     
    7070    packetSize += (classname.size()+1)+sizeof(uint32_t)+sizeof(uint32_t);
    7171  }
    72  
     72
    7373  this->data_=new uint8_t[ packetSize ];
    7474  //set the appropriate packet id
    7575  assert(this->data_);
    7676  *(Type::Value *)(this->data_ + _PACKETID ) = Type::ClassID;
    77  
     77
    7878  uint8_t *temp=data_+sizeof(uint32_t);
    7979  // save the number of all classes
    8080  *(uint32_t*)temp = nrOfClasses;
    8181  temp += sizeof(uint32_t);
    82  
     82
    8383  // now save all classids and classnames
    8484  std::pair<uint32_t, std::string> tempPair;
     
    9191    temp+=2*sizeof(uint32_t)+tempPair.second.size()+1;
    9292  }
    93  
     93
    9494  COUT(5) << "classid packetSize is " << packetSize << endl;
    95  
     95
    9696}
    9797
     
    111111  temp += sizeof(uint32_t);
    112112  totalsize += sizeof(uint32_t); // storage size for nr of all classes
    113  
     113
    114114  for(unsigned int i=0; i<nrOfClasses; i++){
    115115    totalsize += 2*sizeof(uint32_t) + *(uint32_t*)(temp + sizeof(uint32_t));
     
    125125  uint32_t stringsize;
    126126  unsigned char *classname;
    127  
    128  
    129   //clean the map of network ids
    130   Factory::cleanNetworkIDs();
    131  
     127
     128
     129  //clear the map of network ids
     130  Identifier::clearNetworkIDs();
     131
    132132  COUT(4) << "=== processing classids: " << endl;
    133133  std::pair<uint32_t, std::string> tempPair;
     
    136136  nrOfClasses = *(uint32_t*)temp;
    137137  temp += sizeof(uint32_t);
    138  
     138
    139139  for( int i=0; i<nrOfClasses; i++){
    140140    networkID = *(uint32_t*)temp;
Note: See TracChangeset for help on using the changeset viewer.