eris  1.4.0
A WorldForge client library.
EntityRef.h
1 #ifndef ERIS_ENTITY_REF_H
2 #define ERIS_ENTITY_REF_H
3 
4 #include <sigc++/trackable.h>
5 #include <sigc++/signal.h>
6 #include <string>
7 
8 namespace Eris
9 {
10 
11 class Entity;
12 class View;
13 
14 class EntityRef : public sigc::trackable
15 {
16 public:
17  EntityRef() : m_inner(nullptr)
18  {
19  }
20 
21  EntityRef(View& v, const std::string& eid);
22 
23  explicit EntityRef(Entity*);
24 
25  ~EntityRef() = default;
26 
27  EntityRef(const EntityRef& ref);
28 
29  EntityRef(EntityRef&& ref) noexcept;
30 
31  EntityRef& operator=(const EntityRef& ref);
32 
33  const Entity& operator*() const
34  {
35  return *m_inner;
36  }
37 
38  Entity& operator*()
39  {
40  return *m_inner;
41  }
42 
43  const Entity* operator->() const
44  {
45  return m_inner;
46  }
47 
48  Entity* operator->()
49  {
50  return m_inner;
51  }
52 
53  Entity* get() const
54  {
55  return m_inner;
56  }
57 
58  operator bool() const
59  {
60  return (m_inner != nullptr);
61  }
62 
63  bool operator!() const
64  {
65  return (m_inner == nullptr);
66  }
67 
68  bool operator==(const EntityRef& e) const
69  {
70  return (m_inner == e.m_inner);
71  }
72 
73  bool operator==(const Entity* e) const
74  {
75  return (m_inner == e);
76  }
77 
78  bool operator<(const EntityRef& e) const
79  {
80  return (m_inner < e.m_inner);
81  }
82 
87  sigc::signal<void, Entity*, Entity*> Changed;
88 private:
89  void onEntityDeleted();
90  void onEntitySeen(Entity* e);
91 
92  Entity* m_inner;
93 };
94 
95 } // of namespace Eris
96 
97 #endif // of ERIS_ENTITY_REF_H
sigc::signal< void, Entity *, Entity * > Changed
Definition: EntityRef.h:87
Definition: Account.cpp:33
Entity is a concrete (instantiable) class representing one game entity.
Definition: Entity.h:55