Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 25, 2013, 9:08:42 PM (11 years ago)
Author:
landauf
Message:

merged core6 back to trunk

Location:
code/trunk
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/libraries/core/class/IdentifierManager.h

    r9564 r9667  
    3838
    3939#include <map>
     40#include <set>
    4041#include <string>
    4142
     
    4445    class _CoreExport IdentifierManager
    4546    {
    46         friend class Identifier;
    47         template <class T> friend class ClassIdentifier;
     47        public:
     48            static IdentifierManager& getInstance();
    4849
    49         public:
     50            Identifier* getGloballyUniqueIdentifier(Identifier* proposal);
     51            void addIdentifierToLookupMaps(Identifier* identifier);
     52
     53            unsigned int getUniqueClassId()
     54                { return this->classIDCounter_s++; }
     55
     56
    5057            /////////////////////////////
    5158            ////// Class Hierarchy //////
    5259            /////////////////////////////
    53             static void createClassHierarchy();
     60            void createClassHierarchy();
     61            void destroyAllIdentifiers();
     62
     63            void createdObject(Identifiable* identifiable);
    5464
    5565            /// Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents.
    56             inline static bool isCreatingHierarchy()
     66            inline bool isCreatingHierarchy()
    5767                { return (hierarchyCreatingCounter_s > 0); }
    5868
     
    6171            ///// Identifier Map /////
    6272            //////////////////////////
    63             static void destroyAllIdentifiers();
     73            Identifier* getIdentifierByString(const std::string& name);
     74            Identifier* getIdentifierByLowercaseString(const std::string& name);
     75            Identifier* getIdentifierByID(uint32_t id);
    6476
    65             static Identifier* getIdentifierByString(const std::string& name);
    66             static Identifier* getIdentifierByLowercaseString(const std::string& name);
    67             static Identifier* getIdentifierByID(uint32_t id);
    68 
    69             static void clearNetworkIDs();
     77            void clearNetworkIDs();
    7078
    7179            /// Returns the map that stores all Identifiers with their names.
    72             static inline const std::map<std::string, Identifier*>& getStringIdentifierMap()
    73                 { return IdentifierManager::getStringIdentifierMapIntern(); }
    74             /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names.
    75             static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin()
    76                 { return IdentifierManager::getStringIdentifierMap().begin(); }
    77             /// Returns a const_iterator to the end of the map that stores all Identifiers with their names.
    78             static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd()
    79                 { return IdentifierManager::getStringIdentifierMap().end(); }
    80 
     80            inline const std::map<std::string, Identifier*>& getIdentifierByStringMap()
     81                { return this->identifierByString_; }
    8182            /// Returns the map that stores all Identifiers with their names in lowercase.
    82             static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap()
    83                 { return IdentifierManager::getLowercaseStringIdentifierMapIntern(); }
    84             /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase.
    85             static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin()
    86                 { return IdentifierManager::getLowercaseStringIdentifierMap().begin(); }
    87             /// Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase.
    88             static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd()
    89                 { return IdentifierManager::getLowercaseStringIdentifierMap().end(); }
    90 
     83            inline const std::map<std::string, Identifier*>& getIdentifierByLowercaseStringMap()
     84                { return this->identifierByLowercaseString_; }
    9185            /// Returns the map that stores all Identifiers with their IDs.
    92             static inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap()
    93                 { return IdentifierManager::getIDIdentifierMapIntern(); }
    94             /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs.
    95             static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin()
    96                 { return IdentifierManager::getIDIdentifierMap().begin(); }
    97             /// Returns a const_iterator to the end of the map that stores all Identifiers with their IDs.
    98             static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd()
    99                 { return IdentifierManager::getIDIdentifierMap().end(); }
    100 
    101         protected:
    102             static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal);
    103 
    104             /// Returns the map that stores all Identifiers with their names.
    105             static std::map<std::string, Identifier*>& getStringIdentifierMapIntern();
    106             /// Returns the map that stores all Identifiers with their names in lowercase.
    107             static std::map<std::string, Identifier*>& getLowercaseStringIdentifierMapIntern();
    108             /// Returns the map that stores all Identifiers with their network IDs.
    109             static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern();
     86            inline const std::map<uint32_t, Identifier*>& getIdentifierByNetworkIdMap()
     87                { return this->identifierByNetworkId_; }
    11088
    11189        private:
     90            IdentifierManager();
     91            IdentifierManager(const IdentifierManager&);
     92            ~IdentifierManager() {}
     93
    11294            /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
    113             inline static void startCreatingHierarchy()
     95            inline void startCreatingHierarchy()
    11496                { hierarchyCreatingCounter_s++; }
    11597            /// Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
    116             inline static void stopCreatingHierarchy()
     98            inline void stopCreatingHierarchy()
    11799                { hierarchyCreatingCounter_s--; }
    118100
    119             static std::map<std::string, Identifier*>& getTypeIDIdentifierMap();
     101            std::map<std::string, Identifier*> identifierByTypeidName_;      //!< Map with the names as received by typeid(). This is only used internally.
    120102
    121             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)
    122             static unsigned int classIDCounter_s;                          //!< Static counter for the unique classIDs
     103            std::map<std::string, Identifier*> identifierByString_;          //!< Map that stores all Identifiers with their names.
     104            std::map<std::string, Identifier*> identifierByLowercaseString_; //!< Map that stores all Identifiers with their names in lowercase.
     105            std::map<uint32_t, Identifier*> identifierByNetworkId_;          //!< Returns the map that stores all Identifiers with their network IDs.
     106
     107            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)
     108            std::set<const Identifier*> identifiersOfNewObject_;    //!< Used while creating the object hierarchy to keep track of the identifiers of a newly created object
     109            unsigned int classIDCounter_s;                          //!< counter for the unique classIDs
    123110    };
    124111}
Note: See TracChangeset for help on using the changeset viewer.