This template class implements a smart object reference which is a specialization of an ObjectRef object.
More...
|
| SmartObjectRef ()=default |
| Creates a new SmartObjectRef with no internal object. More...
|
|
| SmartObjectRef (T *object) |
| Creates a new SmartObjectRef by a given object. More...
|
|
| SmartObjectRef (T *object, const ReleaseCallback &releaseCallback) |
| Creates a new SmartObjectRef by a given object. More...
|
|
| SmartObjectRef (const SmartObjectRef< T, TBase > &smartObjectRef) |
| Copy constructor. More...
|
|
| SmartObjectRef (SmartObjectRef< T, TBase > &&smartObjectRef) |
| Move constructor. More...
|
|
| SmartObjectRef (const ObjectRef< TBase > &objectRef) |
| Creates a new SmartObjectRef by a given ObjectRef. More...
|
|
template<typename T2 > |
| SmartObjectRef (const SmartObjectRef< T2, TBase > &smartObjectRef) |
| Copies a SmartObjectRef object. More...
|
|
SmartObjectRef< T, TBase > & | operator= (const SmartObjectRef< T, TBase > &smartObjectRef) |
| Assign operator. More...
|
|
SmartObjectRef< T, TBase > & | operator= (SmartObjectRef< T, TBase > &&smartObjectRef) |
| Moves a smart object reference object to this smart object reference. More...
|
|
SmartObjectRef< T, TBase > & | operator= (const ObjectRef< TBase > &objectRef) |
| Assigns a ObjectRef to this smart object reference. More...
|
|
void | release () |
| Releases the internal object, if any. More...
|
|
T * | pointer () const |
| Returns a pointer to the objects that is encapsulated by this wrapper. More...
|
|
T * | operator-> () const |
| Returns a point to the internal object if existing. More...
|
|
T & | operator* () const |
| Returns a reference to the internal object if existing. More...
|
|
| ObjectRef ()=default |
| Creates an empty ObjectRef object. More...
|
|
| ObjectRef (const ObjectRef< TBase > &objectRef) |
| Copy constructor. More...
|
|
| ObjectRef (ObjectRef< TBase > &&object) noexcept |
| Move constructor. More...
|
|
| ObjectRef (TBase *object) |
| Creates a new ObjectRef holding a given object. More...
|
|
| ObjectRef (TBase *object, const ReleaseCallback &releaseCallback) |
| Creates a new ObjectRef holding and managing a given object. More...
|
|
| ~ObjectRef () |
| Destructs an object reference object and releases the internal object if possible. More...
|
|
T2 & | force () const |
| Returns a reference to the internal object forcing to a specified type. More...
|
|
TBase * | operator-> () const |
| Returns a point to the internal object if existing. More...
|
|
TBase & | operator* () const |
| Returns a reference to the internal object if existing. More...
|
|
bool | isUnique () const |
| Returns whether there is no other object reference but this one. More...
|
|
bool | isNull () const |
| Returns whether this object reference holds no internal object. More...
|
|
void | release () |
| Releases the internal object, if any. More...
|
|
TBase * | pointer () const |
| Returns a pointer to the objects that is encapsulated by this wrapper. More...
|
|
ObjectRef< TBase > & | operator= (const ObjectRef< TBase > &objectRef) |
| Assign operator. More...
|
|
ObjectRef< TBase > & | operator= (ObjectRef< TBase > &&right) noexcept |
| Move operator. More...
|
|
bool | operator== (const ObjectRef< TBase > &objectRef) const |
| Returns whether two object references are holds the same internal object. More...
|
|
bool | operator!= (const ObjectRef< TBase > &objectRef) const |
| Returns whether two object references are not equal. More...
|
|
bool | operator< (const ObjectRef< TBase > &objectRef) const |
| Returns whether the left object is less than the right one. More...
|
|
| operator bool () const |
| Returns whether this object reference holds an internal object. More...
|
|
template<typename T, typename TBase>
class Ocean::SmartObjectRef< T, TBase >
This template class implements a smart object reference which is a specialization of an ObjectRef object.
In the following the application of the SmartObjectRef class together with the ObjectRef class is shown:
class Base
{
public:
void baseFunction();
virtual void virtualFunction();
};
class Derived : public Base
{
public:
void derivedFunction();
virtual void virtualFunction();
};
void main()
{
ObjectRef<Base> base(new Base());
if (base)
{
base->baseFunction();
base->virtualFunction();
}
ObjectRef<Base> derived(new Derived());
if (derived)
{
derived->baseFunction();
derived->virtualFunction();
derived->derivedFunction();
}
SmartObjectRef<Derived, Base> smartDerived(derived);
if (smartDerived)
{
smartDerived->baseFunction();
smartDerived->virtualFunction();
smartDerived->derivedFunction();
}
}
- Template Parameters
-
T | Type of the encapsulated object of the smart object reference, must be derived from TBase |
TBase | Base type of the object to be encapsulated |
- See also
- ObjectRef.