Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

TAO_Object_Manager Class Template Reference

Manager for Objects. More...

#include <Sequence_T.h>

Collaboration diagram for TAO_Object_Manager:

Collaboration graph
[legend]
List of all members.

Public Methods

 TAO_Object_Manager (const TAO_Object_Manager< T, T_var > &rhs)
 TAO_Object_Manager (T **, CORBA::Boolean release)
 ~TAO_Object_Manager (void)
 Destructor, only releases the object if <release_> is true. More...

TAO_Object_Manager< T, T_var > & operator= (const TAO_Object_Manager< T, T_var > &rhs)
TAO_Object_Manager< T, T_var > & operator= (T *)
 Assignment from T *. More...

TAO_Object_Manager< T, T_var > & operator= (const T_var &)
 Assignment from T_var. More...

T * operator-> (void) const
 Return pointer. More...

 operator const T * () const
 Cast (read-only). More...

 operator T *& ()
 Cast. More...

 operator const T_var () const
 Cast (read-only) so that assignment from a structured type to a T_var will make a copy. More...

T * in (void) const
 for in parameter. More...

T *& inout (void)
 for inout parameter. More...

T *& out (void)
 for out parameter. More...

T * _retn (void)
 for return type. More...


Private Attributes

T ** ptr_
 data member, notice that it is a pointer, to implement the reference behavior for assignment. More...

CORBA::Boolean release_
 release flag based on parent's flag. More...


Friends

class TAO_Unbounded_Object_Sequence< T, T_var >

Detailed Description

template<class T, class T_var>
class TAO_Object_Manager< T, T_var >

Manager for Objects.

The mapping for sequences of objects (and other pseudo objects) requires an auxiliar class or <Manager> to handle the reference count on the object, (a kind of smart pointer). The main difference with respect to T_var classes is that automatic release is not controlled on a per-item basis, but for the sequence as a whole. Further the class must implement "transparent" assignment into the sequence, for instance, operator[] returns a managed object, but: object_sequence[i] = foo; must change the state of the sequence. This class implements the generic object manager and is used to instantiate the proper sequence types. = NOTES It has been proposed that the class should be parametric on both T and T_ptr, IMHO this is no necesary: though the IDL spec says that T_ptr *could* map to a type different to T* in the particular case of TAO it does map to <T*>.

Definition at line 278 of file Sequence_T.h.


Constructor & Destructor Documentation

template<class T, class T_var>
ACE_INLINE TAO_Object_Manager< T, T_var >::TAO_Object_Manager const TAO_Object_Manager< T, T_var > &    rhs
 

Copy constructor, the semantics are non-trivial: + The referenced element is duplicated or not according to the release value on the <rhs>. + In any case a new reference to the same object is created.

Definition at line 221 of file Sequence_T.i.

00222   : ptr_ (rhs.ptr_),
00223     release_ (rhs.release_)
00224 {
00225 }

template<class T, class T_var>
ACE_INLINE TAO_Object_Manager< T, T_var >::TAO_Object_Manager T **   ,
CORBA::Boolean    release
 

Constructor from address of an element, it should be private and only TAO_*_Object_Sequence would use it, but we have some problems with friendship and templates.

Definition at line 228 of file Sequence_T.i.

00229   : ptr_ (buffer),
00230     release_ (release)
00231 {
00232 }

template<class T, class T_var>
ACE_INLINE TAO_Object_Manager< T, T_var >::~TAO_Object_Manager void   
 

Destructor, only releases the object if <release_> is true.

Definition at line 216 of file Sequence_T.i.

00217 {
00218 }


Member Function Documentation

template<class T, class T_var>
T * TAO_Object_Manager< T, T_var >::_retn void   
 

for return type.

Definition at line 330 of file Sequence_T.cpp.

References ptr_.

00331 {
00332   T *temp = *this->ptr_;
00333   *this->ptr_ = T_var::tao_nil ();
00334   return temp;
00335 }

template<class T, class T_var>
ACE_INLINE T * TAO_Object_Manager< T, T_var >::in void    const
 

for in parameter.

Definition at line 259 of file Sequence_T.i.

References ptr_.

00260 {
00261   return *this->ptr_;
00262 }

template<class T, class T_var>
ACE_INLINE T *& TAO_Object_Manager< T, T_var >::inout void   
 

for inout parameter.

Definition at line 265 of file Sequence_T.i.

References ptr_.

00266 {
00267   return *this->ptr_;
00268 }

template<class T, class T_var>
ACE_INLINE TAO_Object_Manager< T, T_var >::operator const T *   const
 

Cast (read-only).

Definition at line 247 of file Sequence_T.i.

00248 {
00249   return *this->ptr_;
00250 }

template<class T, class T_var>
ACE_INLINE TAO_Object_Manager< T, T_var >::operator const T_var   const
 

Cast (read-only) so that assignment from a structured type to a T_var will make a copy.

Definition at line 241 of file Sequence_T.i.

00242 {
00243   return T_var::tao_duplicate (*this->ptr_);
00244 }

template<class T, class T_var>
ACE_INLINE TAO_Object_Manager< T, T_var >::operator T *&  
 

Cast.

Definition at line 253 of file Sequence_T.i.

00254 {
00255   return *this->ptr_;
00256 }

template<class T, class T_var>
ACE_INLINE T * TAO_Object_Manager< T, T_var >::operator-> void    const
 

Return pointer.

Definition at line 235 of file Sequence_T.i.

References ptr_.

00236 {
00237   return *this->ptr_;
00238 }

template<class T, class T_var>
TAO_Object_Manager< T, T_var > & TAO_Object_Manager< T, T_var >::operator= const T_var &   
 

Assignment from T_var.

Definition at line 302 of file Sequence_T.cpp.

References ptr_, and release_.

00303 {
00304   if (this->release_)
00305     {
00306       // The semantics of the elements of a sequence are the same as
00307       // that of a var variable.  Therefore we duplicate p's
00308       // pointer before assigning it to the internal
00309       // variable.
00310       T_var::tao_release (*this->ptr_);
00311       *this->ptr_ = T_var::tao_duplicate (p.in ());
00312     }
00313   else
00314     {
00315       *this->ptr_ = p.in ();
00316     }
00317 
00318   return *this;
00319 }

template<class T, class T_var>
TAO_Object_Manager< T, T_var > & TAO_Object_Manager< T, T_var >::operator= T *   
 

Assignment from T *.

Definition at line 284 of file Sequence_T.cpp.

References ptr_, and release_.

00285 {
00286   if (this->release_)
00287     {
00288       // The semantics of the elements of a sequence are the same as
00289       // that of a var variable.  Therefore we will not duplicate the
00290       // user provided pointer before assigning it to the internal
00291       // variable.
00292       T_var::tao_release (*this->ptr_);
00293       *this->ptr_ = p;
00294     }
00295   else
00296     *this->ptr_ = p;
00297 
00298   return *this;
00299 }

template<class T, class T_var>
TAO_Object_Manager< T, T_var > & TAO_Object_Manager< T, T_var >::operator= const TAO_Object_Manager< T, T_var > &    rhs
 

Assignment from another managed type, only release if <this->release_> is true. @ TODO what happens if rhs.release_ is true an this->relase_ is false?

Definition at line 265 of file Sequence_T.cpp.

References ptr_, and release_.

00266 {
00267   if (this == &rhs)
00268     {
00269       return *this;
00270     }
00271 
00272   if (this->release_)
00273     {
00274       T_var::tao_release (*this->ptr_);
00275       *this->ptr_ = T_var::tao_duplicate (*rhs.ptr_);
00276     }
00277   else
00278     *this->ptr_ = *rhs.ptr_;
00279 
00280   return *this;
00281 }

template<class T, class T_var>
T *& TAO_Object_Manager< T, T_var >::out void   
 

for out parameter.

Definition at line 322 of file Sequence_T.cpp.

References ptr_.

00323 {
00324   T_var::tao_release (*this->ptr_);
00325   *this->ptr_ = T_var::tao_nil ();
00326   return *this->ptr_;
00327 }


Friends And Related Function Documentation

template<class T, class T_var>
friend class TAO_Unbounded_Object_Sequence< T, T_var > [friend]
 

Definition at line 280 of file Sequence_T.h.


Member Data Documentation

template<class T, class T_var>
T** TAO_Object_Manager::ptr_ [private]
 

data member, notice that it is a pointer, to implement the reference behavior for assignment.

Definition at line 348 of file Sequence_T.h.

Referenced by _retn, in, inout, operator->, operator=, and out.

template<class T, class T_var>
CORBA::Boolean TAO_Object_Manager::release_ [private]
 

release flag based on parent's flag.

Definition at line 351 of file Sequence_T.h.

Referenced by operator=.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 15:29:40 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002