+template<class T>
+class eUsePtr
+{
+protected:
+ T *ptr;
+public:
+ T &operator*() { return *ptr; }
+ eUsePtr(): ptr(0)
+ {
+ }
+ eUsePtr(T *c): ptr(c)
+ {
+ if (c)
+ {
+ c->AddRef();
+ c->AddUse();
+ }
+ }
+ eUsePtr(const eUsePtr &c)
+ {
+ ptr=c.ptr;
+ if (ptr)
+ {
+ ptr->AddRef();
+ ptr->AddUse();
+ }
+ }
+ eUsePtr &operator=(T *c)
+ {
+ if (c)
+ {
+ c->AddRef();
+ c->AddUse();
+ }
+ if (ptr)
+ {
+ ptr->ReleaseUse();
+ ptr->Release();
+ }
+ ptr=c;
+ return *this;
+ }
+ eUsePtr &operator=(eUsePtr<T> &c)
+ {
+ if (c.ptr)
+ {
+ c.ptr->AddRef();
+ c.ptr->AddUse();
+ }
+ if (ptr)
+ {
+ ptr->ReleaseUse();
+ ptr->Release();
+ }
+ ptr=c.ptr;
+ return *this;
+ }
+ ~eUsePtr()
+ {
+ if (ptr)
+ {
+ ptr->ReleaseUse();
+ ptr->Release();
+ }
+ }
+#ifndef SWIG
+ T* grabRef() { if (!ptr) return 0; ptr->AddRef(); ptr->AddUse(); return ptr; }
+ T* &ptrref() { ASSERT(!ptr); return ptr; }
+#endif
+ T* operator->() const { ptrAssert(ptr); return ptr; }
+ operator T*() const { return this->ptr; }
+};
+
+
+
+#ifndef SWIG
+template<class T>
+class eMutablePtr: public ePtr<T>
+{
+ /* read doc/iObject about the ePtrHelper */
+ template<class T1>
+ class ePtrHelper
+ {
+ T1 *m_obj;
+ public:
+ inline ePtrHelper(T1 *obj): m_obj(obj)
+ {
+ m_obj->AddRef();
+ }
+ inline ~ePtrHelper()
+ {
+ m_obj->Release();
+ }
+ inline T1* operator->() { return m_obj; }
+ };
+protected:
+ T *ptr;
+public:
+ eMutablePtr(): ePtr<T>(0)
+ {
+ }
+ eMutablePtr(T *c): ePtr<T>(c)
+ {
+ }
+ eMutablePtr(const eMutablePtr &c): ePtr<T>(c)
+ {
+ }
+ eMutablePtr &operator=(T *c)
+ {
+ ePtr<T>::operator=(c);
+ return *this;
+ }
+ ePtrHelper<T> operator->() { ptrAssert(ptr); return ePtrHelper<T>(ptr); }