PortableServer::Servant_var< T > Class Template Reference

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

#include <Servant_var.h>

Collaboration diagram for PortableServer::Servant_var< T >:

Collaboration graph
[legend]

List of all members.

Public Types

typedef T servant_type

Public Member Functions

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

Static Public Member Functions

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

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

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


Constructor & Destructor Documentation

template<class T>
ACE_INLINE PortableServer::Servant_var< T >::Servant_var ( T *  p = 0  )  [inline]

Constructor. Assumes ownership of p.

template<class T>
ACE_INLINE PortableServer::Servant_var< T >::Servant_var ( Servant_var< T > const &  rhs  )  [inline]

Copy constructor. Adds reference to rhs.

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

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


Member Function Documentation

template<class T>
ACE_INLINE PortableServer::Servant_var< T > & PortableServer::Servant_var< T >::operator= ( Servant_var< T > const &  rhs  )  [inline]

Assignment operator. Adds reference to rhs.

template<class T>
ACE_INLINE PortableServer::Servant_var< T > & PortableServer::Servant_var< T >::operator= ( T *  p  )  [inline]

Assignment operator. Assumes ownership of p.

template<class T>
ACE_INLINE T * PortableServer::Servant_var< T >::operator-> (  )  const [inline]

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

@ Ciju: The below member templates was commented out because: 1. gcc 2.95 doesn't support them. 2. Sun cc 5.8 member templates support is buggy (Bug Id: 6463114).

Once these have been fixed a decision can be made regards uncommenting them. My own openion is that they shouldn't be used since making implicit constructors, member templates, you could potentially get an unwanted conversion where one was unwarranted.

template<class T>
ACE_INLINE T const & PortableServer::Servant_var< T >::operator* (  )  const [inline]

Dereference the underlying object.

template<class T>
ACE_INLINE T & PortableServer::Servant_var< T >::operator* (  )  [inline]

Dereference the underlying object.

template<class T>
ACE_INLINE PortableServer::Servant_var< T >::operator void const * (  )  const [inline]

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

template<class T>
ACE_INLINE T * PortableServer::Servant_var< T >::in ( void   )  const [inline]

As an IN parameter.

template<class T>
ACE_INLINE T *& PortableServer::Servant_var< T >::inout ( void   )  [inline]

As an INOUT parameter.

template<class T>
ACE_INLINE T *& PortableServer::Servant_var< T >::out ( void   )  [inline]

As an OUT parameter.

template<class T>
ACE_INLINE T * PortableServer::Servant_var< T >::_retn ( void   )  [inline]

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

template<class T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL T * PortableServer::Servant_var< T >::_duplicate ( T *  p  )  [inline, 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...

template<class T>
TAO_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE void PortableServer::Servant_var< T >::swap ( Servant_var< T > &  rhs  )  [inline]

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

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


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

Generated on Thu Nov 27 05:20:00 2008 for TAO_PortableServer by  doxygen 1.5.6