AI_Referenced.h

Go to the documentation of this file.
00001 #ifndef AI_REFERENCED_H
00002 #define AI_REFERENCED_H
00003 //------------------------------------------------------------------------------
00012 #include "AI_List.h"
00013 
00014 //------------------------------------------------------------------------------
00015 template<class TYPE> class AI_Ref;
00016 
00017 class AI_Referenced
00018 {
00019 public:
00020     AI_Referenced();
00021 
00023     virtual bool Release();
00024 
00026     int AddRef();
00028     int GetRefCount() const;
00029 
00031     void AddObjectRef(AI_Ref<AI_Referenced> *);
00033     void RemObjectRef(AI_Ref<AI_Referenced> *);
00035     AI_List *GetRefs();
00036 
00037     
00038 protected:
00040     virtual ~AI_Referenced();
00042     void InvalidateAllRefs();
00043     
00044     AI_List refList;
00045     int refCount;
00046 };
00047 
00048 //------------------------------------------------------------------------------
00051 inline
00052 int
00053 AI_Referenced::GetRefCount() const
00054 {
00055     return this->refCount;
00056 }
00057 
00058 //------------------------------------------------------------------------------
00061 inline
00062 int
00063 AI_Referenced::AddRef()
00064 {
00065     return ++this->refCount;
00066 }
00067 
00068 //------------------------------------------------------------------------------
00072 inline
00073 void 
00074 AI_Referenced::AddObjectRef(AI_Ref<AI_Referenced> *r)
00075 {
00076     this->refList.AddTail((AI_Node *)r);
00077 }
00078 
00079 //------------------------------------------------------------------------------
00083 inline
00084 void 
00085 AI_Referenced::RemObjectRef(AI_Ref<AI_Referenced> *r)
00086 {
00087     ((AI_Node*)r)->Remove();
00088 }
00089 
00090 //------------------------------------------------------------------------------
00093 inline
00094 AI_List*
00095 AI_Referenced::GetRefs()
00096 {
00097     return &(this->refList);
00098 }
00099 
00100 //------------------------------------------------------------------------------
00101 #endif // N_REFERENCED_H