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