18 #ifndef _LOG4CXX_HELPERS_OBJECT_PTR_H 19 #define _LOG4CXX_HELPERS_OBJECT_PTR_H 21 #include <log4cxx/log4cxx.h> 31 #define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase() { exchange(x); 33 #define _LOG4CXX_OBJECTPTR_INIT(x) : ObjectPtrBase(), p(x) { 47 static void checkNull(
const int& null);
48 static void* exchange(
void** destination,
void* newValue);
49 virtual void* cast(
const Class& cls)
const = 0;
58 _LOG4CXX_OBJECTPTR_INIT(0)
59 ObjectPtrBase::checkNull(null);
63 _LOG4CXX_OBJECTPTR_INIT(0)
67 _LOG4CXX_OBJECTPTR_INIT(p1)
77 _LOG4CXX_OBJECTPTR_INIT(p1.p)
86 _LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
95 _LOG4CXX_OBJECTPTR_INIT(reinterpret_cast<T*>(p1.cast(T::getStaticClass())))
121 T* oldPtr = exchange(newPtr);
125 oldPtr->releaseRef();
136 ObjectPtrBase::checkNull(null);
137 T* oldPtr = exchange(0);
141 oldPtr->releaseRef();
154 T* oldPtr = exchange(p1);
158 oldPtr->releaseRef();
167 T* newPtr =
reinterpret_cast<T*
>(p1.cast(T::getStaticClass()));
168 return operator=(newPtr);
173 T* newPtr =
reinterpret_cast<T*
>(p1.cast(T::getStaticClass()));
174 return operator=(newPtr);
179 return (this->p == p1.p);
183 return (this->p != p1.p);
187 return (this->p < p1.p);
189 bool operator==(
const T* p1)
const 191 return (this->p == p1);
193 bool operator!=(
const T* p1)
const 195 return (this->p != p1);
197 bool operator<(
const T* p1)
const 199 return (this->p < p1);
201 T* operator->()
const 218 virtual void* cast(
const Class& cls)
const 222 return const_cast<void*
>(p->cast(cls));
227 T* exchange(
const T* newValue)
235 return static_cast<T*
>(ObjectPtrBase::exchange(
237 const_cast<T*>(newValue)));
246 #endif //_LOG4CXX_HELPERS_OBJECT_PTR_H
Definition: appender.h:33
Definition: objectptr.h:42
smart pointer to a Object descendant
Definition: objectptr.h:54