|
Elm
2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
|
21 #ifndef ELM_UTIL_SHAREDPTR_H_
22 #define ELM_UTIL_SHAREDPTR_H_
25 #include <elm/types.h>
31 typedef struct cell_t {
32 inline cell_t(T *
p): cnt(1),
ptr(
p) { }
42 inline bool isEmpty(
void)
const {
return c->ptr; }
43 inline T *
ptr(
void)
const {
return c->ptr; }
44 inline T&
ref(
void)
const {
return *(c->ptr); }
47 inline operator T *(
void)
const {
return ptr(); }
60 inline void lock(
void) { c->cnt++; }
61 inline void unlock(
void) { c->cnt--;
if(c->cnt == 0) clear(); }
62 void clear(
void) {
if(c->ptr)
delete c->ptr;
delete c; }
68 template <
class T>
typename SharedPtr<T>::cell_t SharedPtr<T>::null(0);
T * operator->(void) const
Definition: SharedPtr.h:48
SharedPtr< T > & operator=(const SharedPtr< T > &p)
Definition: SharedPtr.h:51
Printable< T, M > p(const T &data, const M &man)
Definition: Output.h:302
SharedPtr(T *p)
Definition: SharedPtr.h:39
T * ptr(void) const
Definition: SharedPtr.h:43
bool operator==(T *p) const
Definition: SharedPtr.h:56
T * operator&(void) const
Definition: SharedPtr.h:50
bool operator==(const SharedPtr< T > &p) const
Definition: SharedPtr.h:54
bool operator!=(T *p) const
Definition: SharedPtr.h:57
SharedPtr< T > & operator=(T *p)
Definition: SharedPtr.h:52
SharedPtr(const SharedPtr< T > &p)
Definition: SharedPtr.h:40
SharedPtr(void)
Definition: SharedPtr.h:38
unsigned int uint32
Definition: arch.h:31
T & operator*(void) const
Definition: SharedPtr.h:49
bool isEmpty(void) const
Definition: SharedPtr.h:42
bool operator!=(const SharedPtr< T > &p) const
Definition: SharedPtr.h:55
T & ref(void) const
Definition: SharedPtr.h:44
Definition: SharedPtr.h:30
~SharedPtr(void)
Definition: SharedPtr.h:41