Last change
on this file since 376 was
363,
checked in by landauf, 17 years ago
|
added NetworkID
small tutorial for oli and dumeni:
every Identifier generates its own NetworkID, but it can be changed:
→ (Identifier)→setNetworkID(unsigned int)
be careful: after changing the NetworkID, there are probably 2 Identifiers with the same ID, so always change ALL Identifiers before using ID(unsigned int).
get an Identifier with a specific NetworkID:
→ ID(unsigned int)
get the name:
→ ID(unsigned int)→getName()
create an object:
→ ID(unsigned int)→fabricate()
get an Identifier with a specific name:
→ ID(std::string&)
get the NetworkID:
→ ID(std::string&)→getNetworkID()
create an object:
→ ID(std::string&)→fabricate()
|
File size:
1.2 KB
|
Line | |
---|
1 | #ifndef _Factory_H__ |
---|
2 | #define _Factory_H__ |
---|
3 | |
---|
4 | #include <map> |
---|
5 | #include <string> |
---|
6 | |
---|
7 | namespace orxonox |
---|
8 | { |
---|
9 | class BaseObject; |
---|
10 | class Identifier; |
---|
11 | |
---|
12 | // ############################### |
---|
13 | // ### Factory ### |
---|
14 | // ############################### |
---|
15 | class Factory |
---|
16 | { |
---|
17 | public: |
---|
18 | static Identifier* getIdentifier(const std::string& name); |
---|
19 | static Identifier* getIdentifier(const unsigned int id); |
---|
20 | static void add(const std::string& name, Identifier* identifier); |
---|
21 | static void changeNetworkID(Identifier* identifier, const unsigned int oldID, const unsigned int newID); |
---|
22 | |
---|
23 | private: |
---|
24 | Factory() {} |
---|
25 | Factory(const Factory& factory) {} |
---|
26 | ~Factory() {} |
---|
27 | |
---|
28 | static Factory* pointer_s; |
---|
29 | std::map<std::string, Identifier*> identifierStringMap_; |
---|
30 | std::map<unsigned int, Identifier*> identifierNetworkIDMap_; |
---|
31 | }; |
---|
32 | |
---|
33 | // ############################### |
---|
34 | // ### BaseFactory ### |
---|
35 | // ############################### |
---|
36 | class BaseFactory |
---|
37 | { |
---|
38 | public: |
---|
39 | virtual BaseObject* fabricate() = 0; |
---|
40 | }; |
---|
41 | } |
---|
42 | |
---|
43 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.