Eris  1.4.0
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  EntityRef(Entity*);
24 
25  ~EntityRef() = default;
26 
27  EntityRef(const EntityRef& ref);
28 
29  EntityRef& operator=(const EntityRef& ref);
30 
31  const Entity& operator*() const
32  {
33  return *m_inner;
34  }
35 
36  Entity& operator*()
37  {
38  return *m_inner;
39  }
40 
41  const Entity* operator->() const
42  {
43  return m_inner;
44  }
45 
46  Entity* operator->()
47  {
48  return m_inner;
49  }
50 
51  Entity* get() const
52  {
53  return m_inner;
54  }
55 
56  operator bool() const
57  {
58  return (m_inner != nullptr);
59  }
60 
61  bool operator!() const
62  {
63  return (m_inner == nullptr);
64  }
65 
66  bool operator==(const EntityRef& e) const
67  {
68  return (m_inner == e.m_inner);
69  }
70 
71  bool operator==(const Entity* e) const
72  {
73  return (m_inner == e);
74  }
75 
76  bool operator<(const EntityRef& e) const
77  {
78  return (m_inner < e.m_inner);
79  }
80 
81  sigc::signal0<void> Changed;
82 private:
83  void onEntityDeleted();
84  void onEntitySeen(Entity* e);
85 
86  Entity* m_inner;
87 };
88 
89 } // of namespace Eris
90 
91 #endif // of ERIS_ENTITY_REF_H
Definition: EntityRef.h:14
View encapsulates the set of entities currently visible to an Avatar, as well as those that have rece...
Definition: View.h:37
Every Eris class and type lives inside the Eris namespace; certain utility functions live in the Util...
Definition: Account.cpp:34
Entity is a concrete (instantiable) class representing one game entity.
Definition: Entity.h:58