TAO_PortableServer  3.0.0
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
PortableServer::Servant_var< T > Class Template Reference

Provides a type safe counted reference to servants. More...

#include <Servant_var.h>

Public Types

typedef T servant_type
 

Public Member Functions

 Servant_var (T *p=0)
 Constructor. Assumes ownership of p. More...
 
 Servant_var (Servant_var< T > const &rhs)
 Copy constructor. Adds reference to rhs. More...
 
Servant_var< T > & operator= (Servant_var< T > const &rhs)
 Assignment operator. Adds reference to rhs. More...
 
 ~Servant_var ()
 
Servant_var< T > & operator= (T *p)
 Assignment operator. Assumes ownership of p. More...
 
T * operator-> () const
 Smart pointer operator-> provides access to the underlying object. More...
 
T const & operator* () const
 Dereference the underlying object. More...
 
T & operator* ()
 Dereference the underlying object. More...
 
 operator void const * () const
 
T * in () const
 As an IN parameter. More...
 
T *& inout ()
 As an INOUT parameter. More...
 
T *& out ()
 As an OUT parameter. More...
 
T * _retn ()
 
void swap (Servant_var< T > &rhs)
 

Static Public Member Functions

static T * _duplicate (T *)
 Increment the reference count and return the servant. More...
 

Private Attributes

T * ptr_
 

Detailed Description

template<class T>
class PortableServer::Servant_var< T >

Provides a type safe counted reference to servants.

Author
Jody Hagins
Todo:
Life would be much easier if _add_ref() and _remove_ref() had throw specs of "throw ()", that can be hidden in static methods though.

Member Typedef Documentation

◆ servant_type

template<class T >
typedef T PortableServer::Servant_var< T >::servant_type

Constructor & Destructor Documentation

◆ Servant_var() [1/2]

template<class T >
PortableServer::Servant_var< T >::Servant_var ( T *  p = 0)

Constructor. Assumes ownership of p.

◆ Servant_var() [2/2]

template<class T >
PortableServer::Servant_var< T >::Servant_var ( Servant_var< T > const &  rhs)

Copy constructor. Adds reference to rhs.

◆ ~Servant_var()

template<class T >
PortableServer::Servant_var< T >::~Servant_var ( void  )

Destructor. Removes a reference from the underlying object, possibly destroying it. This destructor doesn't throw exceptions.

Member Function Documentation

◆ _duplicate()

template<class T >
T * PortableServer::Servant_var< T >::_duplicate ( T *  p)
static

Increment the reference count and return the servant.

It is safe to pass in a null pointer, the pointer is simply returned in that case.

Todo:
We might want to catch all (potential) exceptions in _add_ref().
Todo:
It might be useful to add a _release() method that handles any potential exceptions...

◆ _retn()

template<class T >
T * PortableServer::Servant_var< T >::_retn ( void  )

Return a pointer to the underlying object, and this counted reference will no longer own the object.

◆ in()

template<class T >
T * PortableServer::Servant_var< T >::in ( void  ) const

As an IN parameter.

◆ inout()

template<class T >
T *& PortableServer::Servant_var< T >::inout ( void  )

As an INOUT parameter.

◆ operator void const *()

template<class T >
PortableServer::Servant_var< T >::operator void const *

Return a void pointer to the underlying object. This allows it to be used in conditional code and tested against 0.

◆ operator*() [1/2]

template<class T >
T & PortableServer::Servant_var< T >::operator*

Dereference the underlying object.

◆ operator*() [2/2]

template<class T >
T const & PortableServer::Servant_var< T >::operator*

Dereference the underlying object.

◆ operator->()

template<class T >
T * PortableServer::Servant_var< T >::operator->

Smart pointer operator-> provides access to the underlying object.

◆ operator=() [1/2]

template<class T >
PortableServer::Servant_var< T > & PortableServer::Servant_var< T >::operator= ( Servant_var< T > const &  rhs)

Assignment operator. Adds reference to rhs.

◆ operator=() [2/2]

template<class T >
PortableServer::Servant_var< T > & PortableServer::Servant_var< T >::operator= ( T *  p)

Assignment operator. Assumes ownership of p.

◆ out()

template<class T >
T *& PortableServer::Servant_var< T >::out ( void  )

As an OUT parameter.

◆ swap()

template<class T >
void PortableServer::Servant_var< T >::swap ( Servant_var< T > &  rhs)

Swap the contents of a Servant_var<T> with another Servant_var<T> Non-throwing swap operation. Often used to implement strong exception safety.

Member Data Documentation

◆ ptr_

template<class T >
T* PortableServer::Servant_var< T >::ptr_
private

The documentation for this class was generated from the following files: