Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/core/Factory.h @ 384

Last change on this file since 384 was 384, checked in by landauf, 17 years ago

copied changed files from objecthierarchy-branch

File size: 2.2 KB
RevLine 
[384]1/*!
2    @file Factory.h
3    @brief Definition of the Factory and the BaseFactory class.
4
5    The Factory is a singleton, containing two maps to map either the name or the networkID
6    of a class with the corresponding Identifier.
7
8    Usage:
9    ID(classname) or ID(networkID) returns the corresponding Identifier.
10
11
12    BaseObject is the parent of ClassFactory which is defined in ClassFactory.h.
13    It can't be defined in ClassFactory.h, because of circular dependencies.
14*/
15
[218]16#ifndef _Factory_H__
17#define _Factory_H__
18
19#include <map>
20#include <string>
21
22namespace orxonox
23{
[384]24    class BaseObject; // Forward declaration
25    class Identifier; // Forward declaration
[218]26
[244]27    // ###############################
28    // ###         Factory         ###
29    // ###############################
[384]30    //! The Factory is used to map name or networkID of a class with its Identifier.
[244]31    class Factory
[218]32    {
33        public:
[244]34            static Identifier* getIdentifier(const std::string& name);
[363]35            static Identifier* getIdentifier(const unsigned int id);
[218]36            static void add(const std::string& name, Identifier* identifier);
[363]37            static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID);
[218]38
39        private:
[384]40            Factory() {}                        // don't create
41            Factory(const Factory& factory) {}  // don't copy
42            ~Factory() {}                       // don't delete
[218]43
[384]44            static Factory* pointer_s;                                          //!< The pointer to the singleton
45            std::map<std::string, Identifier*> identifierStringMap_;            //!< The map mapping string with Identifier
46            std::map<unsigned int, Identifier*> identifierNetworkIDMap_;        //!< The map mapping networkID with Identifier
[218]47    };
[244]48
49    // ###############################
50    // ###       BaseFactory       ###
51    // ###############################
[384]52    //! Base-class of ClassFactory. Has to be defined separate because of circular dependencies.
[244]53    class BaseFactory
54    {
55        public:
56            virtual BaseObject* fabricate() = 0;
[384]57            virtual ~BaseFactory() {};
[244]58    };
[218]59}
60
61#endif
Note: See TracBrowser for help on using the repository browser.