library of assembled shared sources |
http://lass.cocamware.com |
Data Structures | |
class | lass::util::SmartI< I > |
smart pointer to COM interfaces More... | |
class | lass::util::ObjectStorage< T, Cascade > |
Default storage policy for single objects, implementation of StoragePolicy concept. More... | |
class | lass::util::ArrayStorage< T, Cascade > |
Default storage policy for arrays, implementation of StoragePolicy concept. More... | |
class | lass::util::DefaultCounter |
The default counter for the shared pointers, implementation of CounterPolicy concept. More... | |
class | lass::util::IntrusiveCounter< T, CounterType, referenceCounter > |
implementation of CounterPolicy concept, using a counter in the managed object itself. More... |
..
new
and arrays allocated by new
[], but it should be possible to write special storage policies to embed other smart pointers in our lass::util smart pointer classes.at(size_t)
should only be implemented for array-like pointees. So they can safely be ommited if pointee does not act like an array.
template <typename T> class StoragePolicy { public: typedef ... TStorage; // the type of the storage_ object (usually T*) typedef ... TPointer; // return type of pointer() or operator-> (usually T*) typedef ... TReference; // return type of operator* or operator[] (usually T&) TStorage& storage(); // return reference to storage object (usualy to a pointer) const TStorage& storage() const; // return const-reference to storage object protected: StoragePolicy(); // should initialize with default storage object (in most cases: NULL) StoragePolicy(T* pointee); // should initialize to store given pointee. TPointer pointer() const; // should return a pointer to the pointee TReference at(size_t iIndex) const; // for arrays only: should return reference to iIndex'th object in array // (YOU CAN OMMIT THIS FOR NON-ARRAYS) void dispose(); // deallocate the pointee (e.g. by a delete or delete []) bool isNull() const; // return true if storage contains equivalent of NULL pointer. void swap(StoragePolicy<T>& other); // swap storage object with other policy. };
new
.new
[].TStorage
is of the same type as TStorage
in the used storage policy. It will useually be a pointer to the pointee.
class CounterPolicy { public: typedef ... TCount; // type of reference counter variable (should be an integer) protected: DefaultCounter(); // brings object in valid state without setting any counter. template <typename TStorage> void init(TStorage& pointee); // initialize reference count one one. This is called on acquring of object by first owner // (increment isn't called for first owner). template <typename TStorage> void dispose(TStorage& pointee); // clean up the counter (not the pointee). This is called when reference count drops to // zero (thus on release by last owner). template <typename TStorage> void increment(TStorage& pointee); // increment the reference count by one. This is called on acquiring of object by any owner // except the first (the first one calls init(TStorage&) instead). template <typename TStorage> bool decrement(TStorage& pointee); // decrement the reference count by one and returns true if it drops below one. This is // called on every release of the object by any owner. It should return true if @e after // the decrement the reference count turns out the be less than one (i.e. there are no more // owners, this was the last one), to indicate the pointee should be deallocated now. In // all other cases, it should return false @e after the (i.e. if the reference count is // still non-zero after the decrement). template <typename TStorage> TCount count(TStorage& pointee) const; // return the reference count, i.e. number of owners of the pointee void swap(DefaultCounter& other); // swap any reference counters with other policy. };
Generated on Mon Nov 10 14:22:07 2008 for Library of Assembled Shared Sources by 1.5.7.1 |