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 . | |
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_ |
Provides a type safe counted reference to servants.
Definition at line 41 of file Servant_var.h.
typedef T PortableServer::Servant_var< T >::servant_type |
Definition at line 44 of file Servant_var.h.
PortableServer::Servant_var< T >::Servant_var | ( | T * | p = 0 |
) |
PortableServer::Servant_var< T >::Servant_var | ( | Servant_var< T > const & | rhs | ) |
Copy constructor. Adds reference to rhs
.
Definition at line 27 of file Servant_var.inl.
: ptr_ (Servant_var<T>::_duplicate(rhs.ptr_)) { }
PortableServer::Servant_var< T >::~Servant_var | ( | void | ) |
Destructor. Removes a reference from the underlying object, possibly destroying it. This destructor doesn't throw exceptions.
Definition at line 36 of file Servant_var.cpp.
{ // Unfortunately, there is no throw spec on _remove_ref, so we // can't assume that it will not throw. If it does, then we are in // trouble. In any event, we can't let the exception escape our // destructor. try { if (this->ptr_ != 0) { this->ptr_->_remove_ref (); } } catch (...) { // Forget the exception.. } }
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.
Definition at line 18 of file Servant_var.cpp.
{ try { if (p != 0) { p->_add_ref (); } } catch (...) { throw; } return p; }
T * PortableServer::Servant_var< T >::_retn | ( | void | ) |
Return a pointer to the underlying object, and this counted reference will no longer own the object.
Definition at line 154 of file Servant_var.inl.
T * PortableServer::Servant_var< T >::in | ( | void | ) | const |
T *& PortableServer::Servant_var< T >::inout | ( | void | ) |
PortableServer::Servant_var< T >::operator void const * | ( | ) | const |
Return a void pointer to the underlying object. This allows it to be used in conditional code and tested against 0.
Definition at line 124 of file Servant_var.inl.
{ return this->ptr_; }
T & PortableServer::Servant_var< T >::operator* | ( | void | ) |
Dereference the underlying object.
Definition at line 118 of file Servant_var.inl.
{ return *this->ptr_; }
T const & PortableServer::Servant_var< T >::operator* | ( | void | ) | const |
Dereference the underlying object.
Definition at line 111 of file Servant_var.inl.
{ return *this->ptr_; }
T * PortableServer::Servant_var< T >::operator-> | ( | void | ) | const |
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.
Definition at line 104 of file Servant_var.inl.
{ return this->ptr_; }
PortableServer::Servant_var< T > & PortableServer::Servant_var< T >::operator= | ( | T * | p | ) |
Assignment operator. Assumes ownership of p
.
Definition at line 43 of file Servant_var.inl.
{ if (this->ptr_ != p) { // This constructor doesn't increase the reference count, nor is // it a copy constructor, so we must check for self-assignment. // Otherwise the reference count would be prematurely // decremented upon exiting this scope. PortableServer::Servant_var<T> tmp (p); this->swap (tmp); } return *this; }
PortableServer::Servant_var< T > & PortableServer::Servant_var< T >::operator= | ( | Servant_var< T > const & | rhs | ) |
Assignment operator. Adds reference to rhs
.
Definition at line 34 of file Servant_var.inl.
{ PortableServer::Servant_var<T> tmp (rhs); this->swap (tmp); return *this; }
T *& PortableServer::Servant_var< T >::out | ( | void | ) |
As an OUT parameter.
Definition at line 145 of file Servant_var.inl.
{ PortableServer::Servant_var<T> tmp; this->swap (tmp); return this->ptr_; }
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.
Definition at line 11 of file Servant_var.inl.
T* PortableServer::Servant_var< T >::ptr_ [private] |
Definition at line 150 of file Servant_var.h.