Eris 1.3.18
|
00001 #ifndef ERIS_ENTITY_REF_H 00002 #define ERIS_ENTITY_REF_H 00003 00004 #include <sigc++/trackable.h> 00005 #include <sigc++/signal.h> 00006 #include <string> 00007 00008 namespace Eris 00009 { 00010 00011 class Entity; 00012 class View; 00013 00014 class EntityRef : public sigc::trackable 00015 { 00016 public: 00017 EntityRef() : m_inner(NULL) 00018 { 00019 } 00020 00021 EntityRef(View* v, const std::string& eid); 00022 00023 EntityRef(Entity*); 00024 00025 ~EntityRef() 00026 { 00027 } 00028 00029 EntityRef(const EntityRef& ref); 00030 00031 EntityRef& operator=(const EntityRef& ref); 00032 00033 const Entity& operator*() const 00034 { 00035 return *m_inner; 00036 } 00037 00038 Entity& operator*() 00039 { 00040 return *m_inner; 00041 } 00042 00043 const Entity* operator->() const 00044 { 00045 return m_inner; 00046 } 00047 00048 Entity* operator->() 00049 { 00050 return m_inner; 00051 } 00052 00053 Entity* get() const 00054 { 00055 return m_inner; 00056 } 00057 00058 operator bool() const 00059 { 00060 return (m_inner != NULL); 00061 } 00062 00063 bool operator!() const 00064 { 00065 return (m_inner == NULL); 00066 } 00067 00068 bool operator==(const EntityRef& e) const 00069 { 00070 return (m_inner == e.m_inner); 00071 } 00072 00073 bool operator==(const Entity* e) const 00074 { 00075 return (m_inner == e); 00076 } 00077 00078 bool operator<(const EntityRef& e) const 00079 { 00080 return (m_inner < e.m_inner); 00081 } 00082 00083 sigc::signal0<void> Changed; 00084 private: 00085 void onEntityDeleted(); 00086 void onEntitySeen(Entity* e); 00087 00088 Entity* m_inner; 00089 }; 00090 00091 } // of namespace Eris 00092 00093 #endif // of ERIS_ENTITY_REF_H