Rogue Wave Views
Foundation Package API Reference Guide
Product Documentation:

Rogue Wave Views
Documentation Home
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions
IlvOwnership< OBJECT, HASHSIZE > Class Template Reference

This class is a smart pointer with the additional property of dealing with the ownership of the object. More...

#include <ilviews/util/refcount.h>

Public Member Functions

 ~IlvOwnership ()
 The destructor just cleans the resource used by this instance.
 
OBJECT * get () const
 This function returns a pointer to the object pointed to by this instance. More...
 
IlBoolean isOwner () const
 This functions returns the ownership property. More...
 
OBJECT & operator* () const
 The dereference operator. More...
 
OBJECT * operator-> () const
 The structure pointer dereference operator. More...
 
void setOwner (IlBoolean owner=IlTrue)
 This function modifies the ownership property. More...
 

Static Public Member Functions

static CntPtr Factory (OBJECT *object, IlBoolean owner=IlTrue)
 This function is a factory for the IlvOwnership class. More...
 

Protected Member Functions

 IlvOwnership (OBJECT *object, IlBoolean owner)
 Constructor. More...
 

Detailed Description

template<class OBJECT, int HASHSIZE = 7>
class IlvOwnership< OBJECT, HASHSIZE >

This class is a smart pointer with the additional property of dealing with the ownership of the object.

Library: xviews or winviews or mviews (mutually exclusive)

This class behaves as a pointer except that if it has the ownership property set to IlTrue, when it is deleted it also deletes the object pointed to. If the ownership property is not set the object pointed to is not deleted.
The type of the object is given as parameter of the class.

Constructor & Destructor Documentation

§ IlvOwnership()

template<class OBJECT, int HASHSIZE = 7>
IlvOwnership< OBJECT, HASHSIZE >::IlvOwnership ( OBJECT *  object,
IlBoolean  owner 
)
protected

Constructor.

The constructor builds a new object that points to the object given as first parameter and the ownership property given as second parameter. This constructor is protected and should be called only through the Factory function.

Parameters
objectA pointer to an OBJECT (type given as parameter of the template) that will be pointed to by the current instance.
ownerA Boolean value that gives the initial ownership of the object pointed to by this instance.

Member Function Documentation

§ Factory()

template<class OBJECT, int HASHSIZE = 7>
static CntPtr IlvOwnership< OBJECT, HASHSIZE >::Factory ( OBJECT *  object,
IlBoolean  owner = IlTrue 
)
static

This function is a factory for the IlvOwnership class.

This function returns an IlvRefCountPtr to an instance of IlvOwnership that was either created if none already existed that pointed to the object given as parameter, or either a previous one. In the latter case, the ownership property is the result Boolean or between the ownership given as parameter and the previous ownership of the instance.

Parameters
objectA pointer to an OBJECT that will be the object to be pointed to.
ownerA Boolean value that is the ownership property.
Returns
An IlvRefCountPtr that points to an IlvOwnership that points to the object. The ownership depends on the value given as parameter and the previous value of the ownership property of the IlvOwnership instance if it already existed.

§ get()

template<class OBJECT, int HASHSIZE = 7>
OBJECT* IlvOwnership< OBJECT, HASHSIZE >::get ( ) const

This function returns a pointer to the object pointed to by this instance.

Returns
A pointer to a LOCKABLE that is to the object pointed to by this instance.

§ isOwner()

template<class OBJECT, int HASHSIZE = 7>
IlBoolean IlvOwnership< OBJECT, HASHSIZE >::isOwner ( ) const

This functions returns the ownership property.

Returns
A Boolean value that is the ownership property.

§ operator*()

template<class OBJECT, int HASHSIZE = 7>
OBJECT& IlvOwnership< OBJECT, HASHSIZE >::operator* ( ) const

The dereference operator.

This operator returns a reference to the object pointed to by this instance. This lets this class behave as if it were a pointer.

Returns
A reference to the object pointed to by this instance.

§ operator->()

template<class OBJECT, int HASHSIZE = 7>
OBJECT* IlvOwnership< OBJECT, HASHSIZE >::operator-> ( ) const

The structure pointer dereference operator.

This operator returns a pointer to the object pointed to by this instance. It lets this class behave as if it was a pointer.

Returns
A pointer to the object pointed to by this instance.

§ setOwner()

template<class OBJECT, int HASHSIZE = 7>
void IlvOwnership< OBJECT, HASHSIZE >::setOwner ( IlBoolean  owner = IlTrue)

This function modifies the ownership property.

Parameters
ownerA Boolean value that is the new ownership property.

© Copyright 2018, Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave is a registered trademark of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.