TAO::Interceptor_List< InterceptorType, DetailsType > Class Template Reference

Template for portable interceptor lists. More...

#include <Interceptor_List_T.h>

Collaboration diagram for TAO::Interceptor_List< InterceptorType, DetailsType >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef InterceptorType::_var_type InterceptorType_var_type
 Define the traits for the underlying portable interceptor array.
typedef InterceptorType::_ptr_type InterceptorType_ptr_type

Public Member Functions

 Interceptor_List (void)
 Constructor.
void add_interceptor (InterceptorType_ptr_type i)
void add_interceptor (InterceptorType_ptr_type i, const CORBA::PolicyList &policies)
 Register an interceptor with policies.
void destroy_interceptors (void)
RegisteredInterceptorregistered_interceptor (size_t index)
 Return the registered interceptor in sequence element index.
InterceptorType_ptr_type interceptor (size_t index)
 Return the interceptor in sequence element index.
size_t size (void) const

Private Types

typedef ACE_Array_Base< RegisteredInterceptorRegisteredArray

Private Attributes

RegisteredArray interceptors_
 Dynamic array of registered interceptors.

Classes

struct  RegisteredInterceptor

Detailed Description

template<typename InterceptorType, typename DetailsType>
class TAO::Interceptor_List< InterceptorType, DetailsType >

Template for portable interceptor lists.

Template for the various portable interceptor lists used internally by TAO.

Definition at line 51 of file Interceptor_List_T.h.


Member Typedef Documentation

template<typename InterceptorType, typename DetailsType>
typedef InterceptorType::_ptr_type TAO::Interceptor_List< InterceptorType, DetailsType >::InterceptorType_ptr_type

Definition at line 56 of file Interceptor_List_T.h.

template<typename InterceptorType, typename DetailsType>
typedef InterceptorType::_var_type TAO::Interceptor_List< InterceptorType, DetailsType >::InterceptorType_var_type

Define the traits for the underlying portable interceptor array.

Definition at line 55 of file Interceptor_List_T.h.

template<typename InterceptorType, typename DetailsType>
typedef ACE_Array_Base<RegisteredInterceptor > TAO::Interceptor_List< InterceptorType, DetailsType >::RegisteredArray [private]

Definition at line 84 of file Interceptor_List_T.h.


Constructor & Destructor Documentation

template<typename InterceptorType, typename DetailsType>
TAO::Interceptor_List< InterceptorType, DetailsType >::Interceptor_List ( void   ) 

Constructor.

Definition at line 16 of file Interceptor_List_T.cpp.

00017   {
00018   }


Member Function Documentation

template<typename InterceptorType, typename DetailsType>
void TAO::Interceptor_List< InterceptorType, DetailsType >::add_interceptor ( InterceptorType_ptr_type  i,
const CORBA::PolicyList &  policies 
)

Register an interceptor with policies.

If the Interceptor is not anonymous, make sure an Interceptor with the same isn't already registered.

Increase the length of the Interceptor sequence by one.

Definition at line 114 of file Interceptor_List_T.cpp.

References CORBA::SystemException::_tao_minor_code(), CORBA::COMPLETED_NO, TAO::Interceptor_List< InterceptorType, DetailsType >::interceptors_, CORBA::is_nil(), ACE_Array_Base< T >::size(), ACE_OS::strcmp(), and ACE_OS::strlen().

00118   {
00119     if (!CORBA::is_nil (interceptor))
00120       {
00121         size_t const old_len = this->interceptors_.size ();
00122 
00123         // Don't bother checking the name for duplicates if no
00124         // interceptors have been registered.  This saves an
00125         // allocation.
00126         if (old_len > 0)
00127           {
00128             /// If the Interceptor is not anonymous, make sure an
00129             /// Interceptor with the same isn't already registered.
00130             CORBA::String_var name =
00131               interceptor->name ();
00132 
00133             if (ACE_OS::strlen (name.in ()) != 0)
00134               {
00135                 // @@ This simple search algorithm isn't the greatest
00136                 //    thing in the world, but since we only register
00137                 //    interceptors when bootstrapping an ORB, there will
00138                 //    be no runtime penalty.
00139                 //
00140                 //    Another source of inefficiency is that
00141                 //    Interceptors duplicate their name each time the
00142                 //    name() accessor is called!  This can slow down
00143                 //    bootstrap time noticeably when registering a huge
00144                 //    number of interceptors.  We could cache the names
00145                 //    somewhere, but since this is only a bootstrapping
00146                 //    issue there's no rush to implement such a scheme.
00147 
00148                 // Prevent interceptors with the same name from being
00149                 // registered.  Anonymous interceptors are okay.
00150                 for (size_t i = 0; i < old_len; ++i)
00151                   {
00152                     CORBA::String_var existing_name =
00153                       this->interceptor (i)->name ();
00154 
00155                     if (ACE_OS::strcmp (existing_name.in (),
00156                                         name.in ()) == 0)
00157                       {
00158                         throw PortableInterceptor::ORBInitInfo::DuplicateName ();
00159                       }
00160                   }
00161               }
00162           }
00163 
00164         // Create a DetailsType object, and attempt to apply the policies.
00165         DetailsType details;
00166         details.apply_policies(policies);
00167 
00168         /// Increase the length of the Interceptor sequence by one.
00169         size_t const new_len = old_len + 1;
00170         this->interceptors_.size (new_len);
00171 
00172         // Add the interceptor
00173         this->interceptors_[old_len].interceptor_ =
00174           InterceptorType::_duplicate (interceptor);
00175 
00176         // Set the details
00177         this->interceptors_[old_len].details_ = details;
00178       }
00179     else
00180       {
00181         throw
00182             CORBA::INV_OBJREF (
00183                 CORBA::SystemException::_tao_minor_code (
00184                     0,
00185                     EINVAL
00186                   ),
00187                 CORBA::COMPLETED_NO
00188             );
00189       }
00190   }

template<typename InterceptorType, typename DetailsType>
void TAO::Interceptor_List< InterceptorType, DetailsType >::add_interceptor ( InterceptorType_ptr_type  i  ) 

Definition at line 44 of file Interceptor_List_T.cpp.

References CORBA::SystemException::_tao_minor_code(), CORBA::COMPLETED_NO, TAO::Interceptor_List< InterceptorType, DetailsType >::interceptors_, CORBA::is_nil(), ACE_Array_Base< T >::size(), ACE_OS::strcmp(), and ACE_OS::strlen().

Referenced by TAO::ClientRequestInterceptor_Adapter_Impl::add_interceptor().

00046   {
00047     if (!CORBA::is_nil (interceptor))
00048       {
00049         size_t const old_len = this->interceptors_.size ();
00050 
00051         // Don't bother checking the name for duplicates if no
00052         // interceptors have been registered.  This saves an
00053         // allocation.
00054         if (old_len > 0)
00055           {
00056             /// If the Interceptor is not anonymous, make sure an
00057             /// Interceptor with the same isn't already registered.
00058             CORBA::String_var name =
00059               interceptor->name ();
00060 
00061             if (ACE_OS::strlen (name.in ()) != 0)
00062               {
00063                 // @@ This simple search algorithm isn't the greatest
00064                 //    thing in the world, but since we only register
00065                 //    interceptors when bootstrapping an ORB, there will
00066                 //    be no runtime penalty.
00067                 //
00068                 //    Another source of inefficiency is that
00069                 //    Interceptors duplicate their name each time the
00070                 //    name() accessor is called!  This can slow down
00071                 //    bootstrap time noticeably when registering a huge
00072                 //    number of interceptors.  We could cache the names
00073                 //    somewhere, but since this is only a bootstrapping
00074                 //    issue there's no rush to implement such a scheme.
00075 
00076                 // Prevent interceptors with the same name from being
00077                 // registered.  Anonymous interceptors are okay.
00078                 for (size_t i = 0; i < old_len; ++i)
00079                   {
00080                     CORBA::String_var existing_name =
00081                       this->interceptor (i)->name ();
00082 
00083                     if (ACE_OS::strcmp (existing_name.in (),
00084                                         name.in ()) == 0)
00085                       {
00086                         throw PortableInterceptor::ORBInitInfo::DuplicateName ();
00087                       }
00088                   }
00089               }
00090           }
00091 
00092         /// Increase the length of the Interceptor sequence by one.
00093         size_t const new_len = old_len + 1;
00094         this->interceptors_.size (new_len);
00095 
00096         // Add the interceptor
00097         this->interceptors_[old_len].interceptor_ =
00098           InterceptorType::_duplicate (interceptor);
00099       }
00100     else
00101       {
00102         throw
00103             CORBA::INV_OBJREF (
00104                 CORBA::SystemException::_tao_minor_code (
00105                     0,
00106                     EINVAL
00107                   ),
00108                 CORBA::COMPLETED_NO);
00109       }
00110   }

template<typename InterceptorType, typename DetailsType>
void TAO::Interceptor_List< InterceptorType, DetailsType >::destroy_interceptors ( void   ) 

Definition at line 194 of file Interceptor_List_T.cpp.

References ACE_DEBUG, ACE_TEXT, TAO::Interceptor_List< InterceptorType, DetailsType >::interceptor(), TAO::Interceptor_List< InterceptorType, DetailsType >::interceptors_, LM_DEBUG, ACE_Array_Base< T >::size(), and TAO_debug_level.

Referenced by TAO::ClientRequestInterceptor_Adapter_Impl::destroy_interceptors().

00196   {
00197     size_t const len = this->interceptors_.size ();
00198     size_t ilen = len;
00199 
00200     try
00201       {
00202         for (size_t k = 0; k < len; ++k)
00203           {
00204             // Destroy the interceptors in reverse order in case the
00205             // array list is only partially destroyed and another
00206             // invocation occurs afterwards.
00207             --ilen;
00208 
00209             this->interceptor (k)->destroy ();
00210 
00211             // Since Interceptor::destroy() can throw an exception,
00212             // decrease the size of the interceptor array incrementally
00213             // since some interceptors may not have been destroyed yet.
00214             // Note that this size reduction is fast since no memory is
00215             // actually deallocated.
00216             this->interceptors_.size (ilen);
00217           }
00218       }
00219     catch (...)
00220       {
00221         // Exceptions should not be propagated beyond this call.
00222         if (TAO_debug_level > 3)
00223           {
00224             ACE_DEBUG ((LM_DEBUG,
00225                         ACE_TEXT ("TAO (%P|%t) - Exception in ")
00226                         ACE_TEXT ("Interceptor_List")
00227                         ACE_TEXT ("::destroy_interceptors () \n")));
00228           }
00229       }
00230   }

template<typename InterceptorType, typename DetailsType>
Interceptor_List< InterceptorType, DetailsType >::InterceptorType_ptr_type TAO::Interceptor_List< InterceptorType, DetailsType >::interceptor ( size_t  index  ) 

Return the interceptor in sequence element index.

Definition at line 30 of file Interceptor_List_T.cpp.

References TAO::Interceptor_List< InterceptorType, DetailsType >::interceptors_.

Referenced by TAO::Interceptor_List< InterceptorType, DetailsType >::destroy_interceptors().

00031   {
00032     return this->interceptors_[index].interceptor_.in ();
00033   }

template<typename InterceptorType, typename DetailsType>
Interceptor_List< InterceptorType, DetailsType >::RegisteredInterceptor & TAO::Interceptor_List< InterceptorType, DetailsType >::registered_interceptor ( size_t  index  ) 

Return the registered interceptor in sequence element index.

Definition at line 22 of file Interceptor_List_T.cpp.

References TAO::Interceptor_List< InterceptorType, DetailsType >::interceptors_.

Referenced by TAO::ClientRequestInterceptor_Adapter_Impl::receive_exception(), TAO::ClientRequestInterceptor_Adapter_Impl::receive_other(), and TAO::ClientRequestInterceptor_Adapter_Impl::receive_reply().

00024   {
00025     return this->interceptors_[index];
00026   }

template<typename InterceptorType, typename DetailsType>
size_t TAO::Interceptor_List< InterceptorType, DetailsType >::size ( void   )  const

Definition at line 37 of file Interceptor_List_T.cpp.

References TAO::Interceptor_List< InterceptorType, DetailsType >::interceptors_, and ACE_Array_Base< T >::size().

Referenced by TAO::ClientRequestInterceptor_Adapter_Impl::send_request().

00038   {
00039     return this->interceptors_.size ();
00040   }


Member Data Documentation

template<typename InterceptorType, typename DetailsType>
RegisteredArray TAO::Interceptor_List< InterceptorType, DetailsType >::interceptors_ [private]

Dynamic array of registered interceptors.

Definition at line 87 of file Interceptor_List_T.h.

Referenced by TAO::Interceptor_List< InterceptorType, DetailsType >::add_interceptor(), TAO::Interceptor_List< InterceptorType, DetailsType >::destroy_interceptors(), TAO::Interceptor_List< InterceptorType, DetailsType >::interceptor(), TAO::Interceptor_List< InterceptorType, DetailsType >::registered_interceptor(), and TAO::Interceptor_List< InterceptorType, DetailsType >::size().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:42:08 2010 for TAO_PI by  doxygen 1.4.7