]>
Commit | Line | Data |
---|---|---|
4534c364 | 1 | #ifndef __GS__GAMEOBJECT_H__\r |
2 | #define __GS__GAMEOBJECT_H__\r | |
3 | #include <functional>\r | |
4 | #include <string>\r | |
5 | using std::string;\r | |
6 | using std::unary_function;\r | |
7 | \r | |
8 | #include <boost/shared_ptr.hpp>\r | |
9 | using boost::shared_ptr;\r | |
10 | \r | |
11 | namespace GameServ { namespace GameLayer { namespace GameObjects\r | |
12 | {\r | |
13 | class GameObject\r | |
14 | {\r | |
15 | public:\r | |
16 | GameObject(void);\r | |
17 | GameObject(const string &Id);\r | |
18 | virtual ~GameObject();\r | |
19 | \r | |
20 | //! Returns the Id of this Game Object\r | |
21 | string Id(void) const;\r | |
22 | //! Set the Id for this Game Object\r | |
23 | void Id(const string &value);\r | |
24 | \r | |
25 | //! Clone the entire game object\r | |
26 | /*! \r | |
27 | Overridden to allow deep cloning to prevent slicing.\r | |
28 | \return Pointer to new Game object\r | |
29 | */\r | |
30 | virtual GameObject *Clone(void) const = 0;\r | |
31 | \r | |
32 | bool operator==(const GameObject &right) const;\r | |
33 | bool operator!=(const GameObject &right) const;\r | |
34 | \r | |
35 | private:\r | |
36 | string mId;\r | |
37 | friend class GameObjectIds_Eq;\r | |
38 | };\r | |
39 | \r | |
40 | //! Functor to compare Id's of Game Objects\r | |
41 | class GameObjectIds_Eq : public unary_function<shared_ptr<GameObject>, bool>\r | |
42 | {\r | |
43 | public:\r | |
44 | explicit GameObjectIds_Eq(const string &Id);\r | |
45 | \r | |
46 | //! Comparison against shared_ptr types\r | |
47 | bool operator()(const shared_ptr<GameObject> &BO) const;\r | |
48 | \r | |
49 | private:\r | |
50 | string mId;\r | |
51 | };\r | |
52 | }}}\r | |
53 | #endif\r | |
54 | \r | |
55 | \r | |
56 | \r | |
57 | \r | |
58 | \r | |
59 | \r | |
60 | \r | |
61 | \r | |
62 | \r |