The CYISharedArray is a smart pointer that takes shared ownership of a dynamically allocated array of objects, and destroys the array when going out of scope using the delete [] operator only when no other CYISharedArray are referencing the array.
Very similar to the CYISharedPtr while deleting its internal pointer with the delete[] operator. It also provides the operator[] for your convenience.
Usage example:
Like the CYISharedPtr, the delete function object can be overridden
#include <smartptr/YiSharedArray.h>
Public Types | |
| typedef CYISharedPtr< YI_ARRAY_TYPE > | CYISharedArray< YI_ARRAY_TYPE >YI_UNSPECIFIED_BOOL_TYPE |
Public Member Functions | |
| CYISharedArray () | |
| CYISharedArray (YI_ARRAY_TYPE array[]) | |
| template<typename YI_FUNCTION_OBJECT > | |
| CYISharedArray (YI_ARRAY_TYPE array[], YI_FUNCTION_OBJECT functor) | |
| CYISharedArray (const CYISharedArray< YI_ARRAY_TYPE > &rOther) | |
| template<typename YI_OTHER_ARRAY_TYPE > | |
| CYISharedArray (const CYISharedArray< YI_OTHER_ARRAY_TYPE > &rOther) | |
| CYISharedArray (const CYIWeakArray< YI_ARRAY_TYPE > &rOther) | |
| template<typename YI_OTHER_ARRAY_TYPE > | |
| CYISharedArray (const CYIWeakArray< YI_OTHER_ARRAY_TYPE > &rOther) | |
| void | Reset () |
| YI_ARRAY_TYPE & | operator* () const |
| bool | operator! () const |
| operator YI_UNSPECIFIED_BOOL_TYPE () const | |
| CYISharedArray< YI_ARRAY_TYPE > & | operator= (const CYISharedArray< YI_ARRAY_TYPE > &rOther) |
| template<typename YI_OTHER_PTR_TYPE > | |
| CYISharedArray< YI_ARRAY_TYPE > & | operator= (const CYISharedArray< YI_OTHER_PTR_TYPE > &rOther) |
| CYISharedArray< YI_ARRAY_TYPE > & | operator= (const CYIWeakArray< YI_ARRAY_TYPE > &rOther) |
| template<typename YI_OTHER_PTR_TYPE > | |
| CYISharedArray< YI_ARRAY_TYPE > & | operator= (const CYIWeakArray< YI_OTHER_PTR_TYPE > &rOther) |
| YI_ARRAY_TYPE * | Get () const |
| bool | IsNull () const |
| bool | IsUnique () const |
| uint32_t | GetUseCount () const |
| void | Swap (CYISharedArray< YI_ARRAY_TYPE > &rPtr) |
| YI_ARRAY_TYPE & | operator[] (int32_t nIndex) |
| const YI_ARRAY_TYPE & | operator[] (int32_t nIndex) const |
| CYIWeakArray< YI_ARRAY_TYPE > | ToWeakArray () const |
Static Public Member Functions | |
| static const CYIRuntimeTypeInfo & | GetClassTypeInfo () |
Friends | |
| template<typename YI_OTHER_PTR_TYPE > | |
| class | CYIWeakArray |
| template<typename YI_OTHER_PTR_TYPE > | |
| class | CYISharedArray |
| typedef CYISharedPtr<YI_ARRAY_TYPE> CYISharedArray< YI_ARRAY_TYPE >::CYISharedArray< YI_ARRAY_TYPE >YI_UNSPECIFIED_BOOL_TYPE |
|
inline |
Constructs CYISharedArray and sets its internal array to nullptr
|
inline |
Constructs CYISharedArray and sets its internal array to the argument
| array | the array to take shared ownership |
|
inline |
Constructs CYISharedArray and sets its internal array to the provided parameter while using a user defined deletion functor (function object).
|
inline |
Copy-Constructor that constructs CYISharedArray and shares ownership of array instance from another CYISharedArray
| rOther | the pointer to share an array ownership with |
|
inline |
Constructs CYISharedArray and shares ownership of array instance from another CYISharedArray of a different type
| rOther | the CYISharedArray to share an array ownership with |
|
inline |
Constructs CYISharedArray and shares ownership of array instance from a CYIWeakArray
| rOther | the pointer to share an array ownership with |
|
inline |
Constructs CYISharedArray and shares ownership of array instance from a CYIWeakArray of a different type.
| rOther | the CYISharedArray to share an array ownership with |
|
inline |
Accesses the internal object without taking ownership. Mostly for legacy code compatibility.
Example:
|
inlinestatic |
A function that returns the YiRTTI type of the type of this shared array. The values pointed-to by this shared array are ignored.
|
inline |
Returns the number of CYISharedPtr<T> objects that manage the object T.
|
inline |
Syntactic sugar for the operator!()
Example:
|
inline |
Helper function to determine if this particular instance is the last reference
If this function returns true, it also means that the object will be deleted if this instance goes out-of-scope.
|
inline |
This operator tests if the instance is not null, and will work even when compiler does not support the 'bool' keyword Example:
|
inline |
This operator tests if the instance is null
Example:
|
inline |
Dereferences the internal object. If the internal object is null, the behavior is undefined.
Example:
|
inline |
This function resets the internal array to the one provided as a parameter.
If the previous instance was the last reference of its array, the previous array will be promptly deleted.
| rOther | the pointer to share ownership of its array with. |
|
inline |
This function resets the internal array to the one provided as a parameter.
If the previous instance was the last reference of its array, the previous array will be promptly deleted.
| rOther | the pointer to share ownership of its array with. |
|
inline |
This function resets the internal array to the one provided as a parameter.
If the previous instance was the last reference of its array, the previous array will be promptly deleted.
| rOther | the pointer to share ownership of its array with. |
|
inline |
This function resets the internal array to the one provided as a parameter.
If the previous instance was the last reference of its array, the previous array will be promptly deleted.
| rOther | the pointer to share ownership of its array with. |
|
inline |
Non-constant array element accessor/mutator for non-constant function
Example:
| nIndex | the position of the array element to retrieve |
|
inline |
Constant array element accessor for constant functions
Example:
| nIndex | the position of the array element to retrieve |
|
inline |
This function resets the internal object to nullptr.
If the previous instance was the last reference of its object, the previous object will be promptly deleted.
|
inline |
Swap function that will move the ownership of a object to a different CYISharedPtr that could be living in a completely different scope.
Example:
| rPtr | the CYISharedPtr to swap ownership with |
|
inline |
This function generates a weak reference of the array. A weak reference does not take ownership and will never delete the array. It is the user responsibility to make sure that the weak array is still valid (not null) when using it.
Example :
|
friend |
|
friend |