API Guides > ConceptRT 3.x
OwningPointer< T > Class Template Reference

Owning pointer. Object that contains a pointer to an object. This object is owned by the OwningPointer therefore delete the OwningPointer will delete the owned object. More...

Detailed Description

template<typename T>
class ConceptRT::OwningPointer< T >

Owning pointer. Object that contains a pointer to an object. This object is owned by the OwningPointer therefore delete the OwningPointer will delete the owned object.

Helper class that enables us to use pointer safely.

Template Parameters
TType of the pointer.

The object is owned by the OwningPointer therefore delete the OwningPointer will delete the owned object. Example :

void myFunction()
{
OwningPointer<Gripper> newGripper;
newGripper = new Gripper();
newGripper->Open();
// ...
// ... if exception => OwningPointer will be deleted and the newGripper as well
newGripper.Clear(); // force delete
//(not necessary here because the end of context will delete the owningPointer and its pointed object.)
};
+ Inheritance diagram for OwningPointer< T >:

Public Member Methods

 OwningPointer ()
 Default constructor. More...
 
 OwningPointer (OwningPointer< T > &value)
 Default constructor. More...
 
 OwningPointer (T *value)
 Default constructor. More...
 
virtual ~OwningPointer ()
 Destructor. More...
 
OwningPointer< T > & operator= (OwningPointer< T > &value)
 Assignment operator. More...
 
OwningPointer< T > & operator= (T *value)
 Assignment operator. More...
 
void Clear ()
 Clears the owned object (delete). More...
 
- Public Member Methods inherited from BaseOwningPointer< T >
T * GetPointer () const
 Gets the owned object pointer. More...
 
T * DetachPointer ()
 Gets the owned object pointer and detach it from this owner. More...
 
T & operator* () const
 Indirection operator. More...
 
T * operator-> () const
 Gets the owned object pointer. More...
 
bool operator== (T *right) const
 Equality operator. More...
 
bool operator!= (T *right) const
 Not Equality operator. More...
 

Additional Inherited Members

- Public Attributes inherited from BaseOwningPointer< T >
T * __internalTarget
 The internal target More...
 

Constructor & Destructor Documentation

Default constructor.

OwningPointer ( OwningPointer< T > &  value)

Default constructor.

Parameters
value[in,out] The value.
OwningPointer ( T *  value)

Default constructor.

Parameters
value[in,out] The object to own.
~OwningPointer ( )
virtual

Destructor.

Warning
Non-Deterministic: May delete the object if not null. Determinism when using ConceptRT library can be ensure by using Context Time Critical mechanisms.

Methods Documentation

void Clear ( )

Clears the owned object (delete).

Warning
Non-Deterministic: May delete the object if not null. Determinism when using ConceptRT library can be ensure by using Context Time Critical mechanisms.
OwningPointer< T > & operator= ( OwningPointer< T > &  value)

Assignment operator.

Parameters
value[in,out] The value.
Returns
A shallow copy of this object.
OwningPointer< T > & operator= ( T *  value)

Assignment operator.

Parameters
value[in,out] The object to own.
Returns
A shallow copy of this object.