Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/core/Factory.h @ 1076

Last change on this file since 1076 was 1064, checked in by rgrieder, 17 years ago
  • replaced all String2Number with ConvertValue
  • replaced all tokenize with SubString
  • dealt with warnings under msvc
  • removed some warnings by placing casts
  • bugfix in audio: local variable pushed into member variable std::vector
  • updated StableHeaders.h
File size: 3.4 KB
RevLine 
[790]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
[1056]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/**
[790]30    @file Factory.h
31    @brief Definition of the Factory and the BaseFactory class.
32
33    The Factory is a singleton, containing two maps to map either the name or the network ID
34    of a class with the corresponding Identifier.
35
36    Usage:
37    ID(classname) or ID(networkID) returns the corresponding Identifier.
38
39
40    BaseObject is the parent of ClassFactory which is defined in ClassFactory.h.
41    It can't be defined in ClassFactory.h, because of circular dependencies.
42*/
43
[218]44#ifndef _Factory_H__
45#define _Factory_H__
46
[1062]47#include "CorePrereqs.h"
48
[218]49#include <map>
50#include <string>
51
52namespace orxonox
53{
[244]54    // ###############################
55    // ###         Factory         ###
56    // ###############################
[790]57    //! The Factory is used to map the name or the network ID of a class with its Identifier.
58    class _CoreExport Factory
[218]59    {
60        public:
[244]61            static Identifier* getIdentifier(const std::string& name);
[790]62            static Identifier* getIdentifier(const unsigned int id);
[218]63            static void add(const std::string& name, Identifier* identifier);
[790]64            static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
65            static void createClassHierarchy();
[218]66
[790]67            static Factory* getFactoryPointer();    // avoid overriding order problem in the static intialisation process
[871]68            static std::map<std::string, Identifier*>::const_iterator getFactoryBegin();
69            static std::map<std::string, Identifier*>::const_iterator getFactoryEnd();
[790]70
[218]71        private:
[790]72            Factory() {}                            // don't create
[1064]73            Factory(const Factory& factory);        // don't copy
[790]74            ~Factory() {}                           // don't delete
[218]75
[790]76            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map, mapping the name with the Identifier
77            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map, mapping the network ID with the Identifier
[218]78    };
[244]79
80    // ###############################
81    // ###       BaseFactory       ###
82    // ###############################
[790]83    //! Base-class of ClassFactory. Has to be defined separate because of circular dependencies.
84    class _CoreExport BaseFactory
[244]85    {
86        public:
87            virtual BaseObject* fabricate() = 0;
[790]88            virtual ~BaseFactory() {};
[244]89    };
[218]90}
91
[790]92#endif /* _Factory_H__ */
Note: See TracBrowser for help on using the repository browser.