Server
API Reference Guide
Product Documentation:

Rogue Wave Server
Documentation Home
List of all members | Public Member Functions
IlsSmartPointer< PointedType > Class Template Reference

This class lets you declare smart pointers to objects of a given type. Objects referenced by smart pointers are automatically destroyed when their reference counter drops to zero. More...

#include <ilserver/refcount.h>

Public Member Functions

 IlsSmartPointer (const IlsSmartPointer< PointedType > &rhs)
 This is the copy constructor of IlsSmartPointer.
 
 IlsSmartPointer (PointedType *pointer=0)
 This constructor increments the reference counter of the object to which the smart pointer points.
 
 ~IlsSmartPointer ()
 This destructor decrements the reference counter of the object to which the smart pointer points.
 
PointedType * getValue () const
 This member function returns the value of the smart pointer. More...
 
IlsSmartPointer< PointedType > & set (PointedType *rhs)
 This member function assigns a new value to the smart pointer.
 
Operators

The operators below let you handle a smart pointer as if it were an ordinary pointer.

Note
IlsSmartPointer operators insure that the reference counter of an object remains equal to the number of smart pointers to the object at any time.
IlsSmartPointer< PointedType > & operator= (const IlsSmartPointer< PointedType > &rhs)
 This operator assigns a new smart pointer to the smart pointer.
 
IlsSmartPointer< PointedType > & operator= (PointedType *rhs)
 This operator assigns an ordinary pointer to the smart pointer.
 
PointedType * operator-> () const
 This operator returns the value of the smart pointer. More...
 
 operator PointedType * () const
 This operator converts a smart pointer to an ordinary pointer. More...
 
PointedType & operator* () const
 This operator returns a reference to the pointed object. More...
 
IlsBoolean operator! () const
 This operator returns IlsTrue if the smart pointer is null.
 
IlsBoolean operator== (PointedType *rhs) const
 This operator compares two pointers and returns IlsTrue if they are equal.
 
IlsBoolean operator!= (PointedType *rhs) const
 
IlsBoolean operator== (const IlsSmartPointer< PointedType > &rhs) const
 This operator compares two smart pointers and returns IlsTrue if they are equal.
 
IlsBoolean operator!= (const IlsSmartPointer< PointedType > &rhs) const
 

Detailed Description

template<class PointedType>
class IlsSmartPointer< PointedType >

This class lets you declare smart pointers to objects of a given type. Objects referenced by smart pointers are automatically destroyed when their reference counter drops to zero.

PointedType must derive from IlsRefCounted. In case of multiple inheritance, we recommend that you make the derivation virtual to avoid the creation of multiple reference counters to the same object.

Note
server and mvcomp
Related Pattern
Proxy, flyweight
See also
IlsException, IlsEntity.

Member Function Documentation

◆ getValue()

template<class PointedType >
PointedType* IlsSmartPointer< PointedType >::getValue ( ) const

This member function returns the value of the smart pointer.

It is useful especially when the conversion operator, described below, cannot be used or when the compiler is likely to encounter multiple user-defined conversions.

◆ operator PointedType *()

template<class PointedType >
IlsSmartPointer< PointedType >::operator PointedType * ( ) const

This operator converts a smart pointer to an ordinary pointer.

Exceptions
IlsNullPointerDereferencingIf the smart pointer is null.

◆ operator!=() [1/2]

template<class PointedType >
IlsBoolean IlsSmartPointer< PointedType >::operator!= ( const IlsSmartPointer< PointedType > &  rhs) const

This operator compares two smart pointers and returns IlsTrue if they are not equal.

◆ operator!=() [2/2]

template<class PointedType >
IlsBoolean IlsSmartPointer< PointedType >::operator!= ( PointedType *  rhs) const

This operator compares two pointers and returns IlsTrue if they are not equal.

◆ operator*()

template<class PointedType >
PointedType& IlsSmartPointer< PointedType >::operator* ( ) const

This operator returns a reference to the pointed object.

Exceptions
IlsNullPointerDereferencingIf the smart pointer is null.

◆ operator->()

template<class PointedType >
PointedType* IlsSmartPointer< PointedType >::operator-> ( ) const

This operator returns the value of the smart pointer.

Exceptions
IlsNullPointerDereferencingIf the smart pointer is null.