Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/core6/src/libraries/core/class/IdentifierManager.h @ 9608

Last change on this file since 9608 was 9564, checked in by landauf, 11 years ago

moved static functions from Identifier.cc/h to IdentifierManager.cc/h (still static though)

  • Property svn:eol-style set to native
File size: 6.2 KB
RevLine 
[790]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1505]3 *                    > www.orxonox.net <
[790]4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
[871]29/**
[2171]30    @file
[7401]31    @ingroup Class Identifier
[790]32*/
33
[9564]34#ifndef _IdentifierManager_H__
35#define _IdentifierManager_H__
[1052]36
[9563]37#include "core/CorePrereqs.h"
[1062]38
[3196]39#include <map>
[790]40#include <string>
41
42namespace orxonox
43{
[9564]44    class _CoreExport IdentifierManager
45    {
46        friend class Identifier;
47        template <class T> friend class ClassIdentifier;
[790]48
[5929]49        public:
50            /////////////////////////////
51            ////// Class Hierarchy //////
52            /////////////////////////////
53            static void createClassHierarchy();
[790]54
[7401]55            /// Returns true, if a branch of the class-hierarchy is being created, causing all new objects to store their parents.
[9564]56            inline static bool isCreatingHierarchy()
57                { return (hierarchyCreatingCounter_s > 0); }
[790]58
[1052]59
[5929]60            //////////////////////////
61            ///// Identifier Map /////
62            //////////////////////////
63            static void destroyAllIdentifiers();
[1052]64
[5929]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();
70
[7401]71            /// Returns the map that stores all Identifiers with their names.
[9564]72            static inline const std::map<std::string, Identifier*>& getStringIdentifierMap()
73                { return IdentifierManager::getStringIdentifierMapIntern(); }
[7401]74            /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names.
[9564]75            static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapBegin()
76                { return IdentifierManager::getStringIdentifierMap().begin(); }
[7401]77            /// Returns a const_iterator to the end of the map that stores all Identifiers with their names.
[9564]78            static inline std::map<std::string, Identifier*>::const_iterator getStringIdentifierMapEnd()
79                { return IdentifierManager::getStringIdentifierMap().end(); }
[5929]80
[7401]81            /// Returns the map that stores all Identifiers with their names in lowercase.
[9564]82            static inline const std::map<std::string, Identifier*>& getLowercaseStringIdentifierMap()
83                { return IdentifierManager::getLowercaseStringIdentifierMapIntern(); }
[7401]84            /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their names in lowercase.
[9564]85            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapBegin()
86                { return IdentifierManager::getLowercaseStringIdentifierMap().begin(); }
[7401]87            /// Returns a const_iterator to the end of the map that stores all Identifiers with their names in lowercase.
[9564]88            static inline std::map<std::string, Identifier*>::const_iterator getLowercaseStringIdentifierMapEnd()
89                { return IdentifierManager::getLowercaseStringIdentifierMap().end(); }
[1052]90
[7401]91            /// Returns the map that stores all Identifiers with their IDs.
[9564]92            static inline const std::map<uint32_t, Identifier*>& getIDIdentifierMap()
93                { return IdentifierManager::getIDIdentifierMapIntern(); }
[7401]94            /// Returns a const_iterator to the beginning of the map that stores all Identifiers with their IDs.
[9564]95            static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapBegin()
96                { return IdentifierManager::getIDIdentifierMap().begin(); }
[7401]97            /// Returns a const_iterator to the end of the map that stores all Identifiers with their IDs.
[9564]98            static inline std::map<uint32_t, Identifier*>::const_iterator getIDIdentifierMapEnd()
99                { return IdentifierManager::getIDIdentifierMap().end(); }
[1052]100
101        protected:
[1747]102            static Identifier* getIdentifierSingleton(const std::string& name, Identifier* proposal);
103
[7401]104            /// Returns the map that stores all Identifiers with their names.
[5929]105            static std::map<std::string, Identifier*>& getStringIdentifierMapIntern();
[7401]106            /// Returns the map that stores all Identifiers with their names in lowercase.
[5929]107            static std::map<std::string, Identifier*>& getLowercaseStringIdentifierMapIntern();
[7401]108            /// Returns the map that stores all Identifiers with their network IDs.
[5929]109            static std::map<uint32_t, Identifier*>& getIDIdentifierMapIntern();
[1052]110
[1747]111        private:
[7401]112            /// Increases the hierarchyCreatingCounter_s variable, causing all new objects to store their parents.
[9564]113            inline static void startCreatingHierarchy()
114                { hierarchyCreatingCounter_s++; }
[7401]115            /// Decreases the hierarchyCreatingCounter_s variable, causing the objects to stop storing their parents.
[9564]116            inline static void stopCreatingHierarchy()
117                { hierarchyCreatingCounter_s--; }
[790]118
[2662]119            static std::map<std::string, Identifier*>& getTypeIDIdentifierMap();
120
[1052]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)
[3325]122            static unsigned int classIDCounter_s;                          //!< Static counter for the unique classIDs
[790]123    };
124}
125
[9564]126#endif /* _IdentifierManager_H__ */
Note: See TracBrowser for help on using the repository browser.