TAO::Transport_Selection_Guard Class Reference

Used by the Transport Current feature to keep track of which Transport is currently active. More...

#include <Transport_Selection_Guard.h>

Collaboration diagram for TAO::Transport_Selection_Guard:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Transport_Selection_Guard (TAO_Transport *t)
 Ctor.
 ~Transport_Selection_Guard (void)
 Dtor.
TAO_Transportoperator-> (void) const
 getter
TAO_Transportoperator * (void) const
 getter
TAO_Transportget (void) const
 Getter.
Transport_Selection_Guardset (TAO_Transport *t)
 Setter.
Transport_Selection_Guardoperator= (const Transport_Selection_Guard &rhs)

Static Public Member Functions

static Transport_Selection_Guardcurrent (TAO_ORB_Core *core, size_t tss_slot_id)

Private Member Functions

 Transport_Selection_Guard (const Transport_Selection_Guard &)
bool operator! () const

Private Attributes

Transport_Selection_Guardprev_
TAO_Transportcurr_
 The "real" Transport, i.e. the one selected at present.

Friends

bool operator== (const Transport_Selection_Guard &lhs, const TAO_Transport *rhs)
bool operator== (const TAO_Transport *lhs, const Transport_Selection_Guard &rhs)
bool operator!= (const Transport_Selection_Guard &lhs, const TAO_Transport *rhs)
bool operator!= (const TAO_Transport *lhs, const Transport_Selection_Guard &rhs)
template<class U>
bool operator== (const Transport_Selection_Guard &lhs, const U *rhs)
template<class U>
bool operator== (const U *lhs, const Transport_Selection_Guard &rhs)
template<class U>
bool operator!= (const Transport_Selection_Guard &lhs, const U *rhs)
template<class U>
bool operator!= (const U *lhs, const Transport_Selection_Guard &rhs)

Detailed Description

Used by the Transport Current feature to keep track of which Transport is currently active.

Whenever a Transport is selected: during an upcall, or prior to a client invocation an instance of this class is created [on the stack, or as a member of another class] to keep track of the said Transport. The class implements the RAII idiom, which makes it possible to build a stack of these instances as the thread is doing nested upcalls or client invocations.

It utilizes TAO_TSS_Resources::tsg_ member pointer to keep track of stack-linked Transport_Selection_Guard instances.

If the Transport Current feature is disabled most methods are no-ops and add no overhead on the critical path.

See Also:

https://svn.dre.vanderbilt.edu/viewvc/Middleware/trunk/TAO/docs/transport_current/index.html?revision=HEAD

Definition at line 58 of file Transport_Selection_Guard.h.


Constructor & Destructor Documentation

TAO::Transport_Selection_Guard::Transport_Selection_Guard ( TAO_Transport t  ) 

Ctor.

Definition at line 46 of file Transport_Selection_Guard.cpp.

References TAO_TSS_Resources::instance(), and TAO_TSS_Resources::tsg_.

00047     :
00048 #if TAO_HAS_TRANSPORT_CURRENT == 1
00049 
00050     prev_ (TAO_TSS_Resources::instance ()->tsg_)
00051     ,
00052 
00053 #endif  /* TAO_HAS_TRANSPORT_CURRENT == 1 */
00054     curr_ (t)
00055   {
00056 #if TAO_HAS_TRANSPORT_CURRENT == 1
00057 
00058     TAO_TSS_Resources::instance ()->tsg_ = this;
00059 
00060 #endif  /* TAO_HAS_TRANSPORT_CURRENT == 1 */
00061 
00062   }

TAO::Transport_Selection_Guard::~Transport_Selection_Guard ( void   ) 

Dtor.

Definition at line 65 of file Transport_Selection_Guard.cpp.

References curr_, TAO_TSS_Resources::instance(), prev_, and TAO_TSS_Resources::tsg_.

00066   {
00067 
00068 #if TAO_HAS_TRANSPORT_CURRENT == 1
00069 
00070     TAO_TSS_Resources::instance ()->tsg_ = prev_;
00071     this->prev_ = 0;
00072 
00073 #endif  /* TAO_HAS_TRANSPORT_CURRENT == 1 */
00074     this->curr_ = 0;
00075   }

TAO::Transport_Selection_Guard::Transport_Selection_Guard ( const Transport_Selection_Guard  )  [private]


Member Function Documentation

Transport_Selection_Guard * TAO::Transport_Selection_Guard::current ( TAO_ORB_Core core,
size_t  tss_slot_id 
) [static]

Definition at line 16 of file Transport_Selection_Guard.cpp.

References TAO_TSS_Resources::instance(), and TAO_TSS_Resources::tsg_.

00017   {
00018     // @NOTE: (Iliyan) Started making this method aware of the core
00019     // and the tss slot that correspond to the "current" transport,
00020     // influenced by a general design preference to keep things
00021     // local. The idea was to make the current TSG part of the TSS
00022     // storage for a specific ORB Core, as opposed to using the global
00023     // TSS Resources. However, it really doesn't offer any benefit to
00024     // store a Transport pointer locally, for each ORB. There is
00025     // always only one current Transport per thread. Period. The
00026     // number of ORB Core instances in existence does not change that
00027     // fact, so keeping a separate pointer would have been an
00028     // over-kill.
00029     ACE_UNUSED_ARG (core);
00030     ACE_UNUSED_ARG (tss_slot_id);
00031 
00032 #if TAO_HAS_TRANSPORT_CURRENT == 1
00033 
00034     return TAO_TSS_Resources::instance ()->tsg_;
00035 
00036 #else  /* TAO_HAS_TRANSPORT_CURRENT != 1 */
00037 
00038     return 0;
00039 
00040 #endif  /* TAO_HAS_TRANSPORT_CURRENT == 1 */
00041   }

TAO_Transport* TAO::Transport_Selection_Guard::get ( void   )  const [inline]

Getter.

Definition at line 86 of file Transport_Selection_Guard.h.

00087     {
00088       return this->curr_;
00089     };

TAO_Transport& TAO::Transport_Selection_Guard::operator * ( void   )  const [inline]

getter

Definition at line 80 of file Transport_Selection_Guard.h.

00081     {
00082       return *this->get ();
00083     };

bool TAO::Transport_Selection_Guard::operator! (  )  const [inline, private]

Definition at line 124 of file Transport_Selection_Guard.h.

00125     {
00126       return curr_ == 0;
00127     }

TAO_Transport* TAO::Transport_Selection_Guard::operator-> ( void   )  const [inline]

getter

Definition at line 74 of file Transport_Selection_Guard.h.

00075     {
00076       return this->get ();
00077     };

Transport_Selection_Guard& TAO::Transport_Selection_Guard::operator= ( const Transport_Selection_Guard rhs  )  [inline]

Definition at line 98 of file Transport_Selection_Guard.h.

References curr_, and prev_.

00098                                                                              {
00099 #if TAO_HAS_TRANSPORT_CURRENT == 1
00100     prev_ = rhs.prev_;
00101 #endif  /* TAO_HAS_TRANSPORT_CURRENT == 1 */
00102     curr_ = rhs.curr_;
00103     return *this;
00104   }

Transport_Selection_Guard& TAO::Transport_Selection_Guard::set ( TAO_Transport t  )  [inline]

Setter.

Definition at line 92 of file Transport_Selection_Guard.h.

00093     {
00094       this->curr_ = t;
00095       return *this;
00096     };


Friends And Related Function Documentation

template<class U>
bool operator!= ( const U *  lhs,
const Transport_Selection_Guard rhs 
) [friend]

Definition at line 179 of file Transport_Selection_Guard.h.

00181     {
00182       return lhs != rhs.curr_;
00183     }

template<class U>
bool operator!= ( const Transport_Selection_Guard lhs,
const U *  rhs 
) [friend]

Definition at line 172 of file Transport_Selection_Guard.h.

00174     {
00175       return lhs.curr_ != rhs;
00176     }

bool operator!= ( const TAO_Transport lhs,
const Transport_Selection_Guard rhs 
) [friend]

Definition at line 151 of file Transport_Selection_Guard.h.

00153     {
00154       return lhs != rhs.curr_;
00155     }

bool operator!= ( const Transport_Selection_Guard lhs,
const TAO_Transport rhs 
) [friend]

Definition at line 144 of file Transport_Selection_Guard.h.

00146     {
00147       return lhs.curr_ != rhs;
00148     }

template<class U>
bool operator== ( const U *  lhs,
const Transport_Selection_Guard rhs 
) [friend]

Definition at line 165 of file Transport_Selection_Guard.h.

00167     {
00168       return lhs == rhs.curr_;
00169     }

template<class U>
bool operator== ( const Transport_Selection_Guard lhs,
const U *  rhs 
) [friend]

Definition at line 158 of file Transport_Selection_Guard.h.

00160     {
00161       return lhs.curr_ == rhs;
00162     }

bool operator== ( const TAO_Transport lhs,
const Transport_Selection_Guard rhs 
) [friend]

Definition at line 137 of file Transport_Selection_Guard.h.

00139     {
00140       return lhs == rhs.curr_;
00141     }

bool operator== ( const Transport_Selection_Guard lhs,
const TAO_Transport rhs 
) [friend]

Definition at line 130 of file Transport_Selection_Guard.h.

00132     {
00133       return lhs.curr_ == rhs;
00134     }


Member Data Documentation

TAO_Transport* TAO::Transport_Selection_Guard::curr_ [private]

The "real" Transport, i.e. the one selected at present.

Definition at line 120 of file Transport_Selection_Guard.h.

Referenced by operator=(), and ~Transport_Selection_Guard().

Transport_Selection_Guard* TAO::Transport_Selection_Guard::prev_ [private]

This is pointing to the guard that was active prior to instantiating us.

Definition at line 115 of file Transport_Selection_Guard.h.

Referenced by operator=(), and ~Transport_Selection_Guard().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:39:20 2010 for TAO by  doxygen 1.4.7