Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.