21 INLINE CopyOnWritePointer::
26 _cow_object->cache_ref();
35 INLINE CopyOnWritePointer::
37 _cow_object(copy._cow_object)
40 _cow_object->cache_ref();
49 INLINE
void CopyOnWritePointer::
51 operator = (copy._cow_object);
59 INLINE
void CopyOnWritePointer::
61 if (_cow_object !=
object) {
63 cache_unref_delete(_cow_object);
77 INLINE CopyOnWritePointer::
78 ~CopyOnWritePointer() {
80 cache_unref_delete(_cow_object);
84 #ifdef USE_MOVE_SEMANTICS 90 INLINE CopyOnWritePointer::
92 _cow_object(move._cow_object)
103 INLINE
void CopyOnWritePointer::
106 if (move._cow_object != _cow_object) {
108 _cow_object = move._cow_object;
109 move._cow_object = NULL;
112 cache_unref_delete(old_object);
116 #endif // USE_MOVE_SEMANTICS 123 INLINE
bool CopyOnWritePointer::
125 return _cow_object == other._cow_object;
133 INLINE
bool CopyOnWritePointer::
135 return _cow_object != other._cow_object;
143 INLINE
bool CopyOnWritePointer::
145 return _cow_object < other._cow_object;
163 #endif // COW_THREADED 184 if (_cow_object->get_cache_ref_count() > 1) {
186 cache_unref_delete(_cow_object);
187 _cow_object = new_object;
188 _cow_object->cache_ref();
192 #endif // COW_THREADED 226 cache_unref_delete(_cow_object);
241 return _cow_object->test_ref_count_integrity();
254 return _cow_object->test_ref_count_nonzero();
292 CopyOnWritePointer::operator = (copy);
305 CopyOnWritePointer::operator = (
object);
309 #ifdef USE_MOVE_SEMANTICS 336 #endif // USE_MOVE_SEMANTICS 350 #else // COW_THREADED 361 #endif // COW_THREADED 376 #else // COW_THREADED 387 #endif // COW_THREADED A template wrapper around the above class, mainly to handle the little typecasting niceties...
bool is_null() const
Returns true if the CopyOnWritePointer contains a NULL pointer, false otherwise.
void clear()
Sets the pointer to NULL.
To * get_write_pointer()
See CopyOnWritePointer::get_write_pointer().
const CopyOnWriteObject * get_read_pointer() const
Returns a pointer locked for read.
bool test_ref_count_nonzero() const
Does some easy checks to make sure that the reference count isn't zero, or completely bogus...
CopyOnWriteObject * get_write_pointer()
Returns a pointer locked for write.
void cache_ref() const
Explicitly increments the cache reference count and the normal reference count simultaneously.
To * get_unsafe_pointer()
See CopyOnWritePointer::get_unsafe_pointer().
bool test_ref_count_integrity() const
Does some easy checks to make sure that the reference count isn't completely bogus.
This base class provides basic reference counting, but also can be used with a CopyOnWritePointer to ...
This safely stores the primary, owned pointer to a CopyOnWriteObject.
const To * get_read_pointer() const
See CopyOnWritePointer::get_read_pointer().
CopyOnWriteObject * get_unsafe_pointer()
Returns an unlocked pointer that you can write to.