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

Interceptor_List.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 // -*- C++ -*-
00003 //
00004 // $Id: Interceptor_List.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:13 chad Exp $
00005 
00006 #include "tao/Interceptor_List.h"
00007 
00008 #include "tao/CORBA_String.h"
00009 
00010 #if !defined (__ACE_INLINE__)
00011 # include "tao/Interceptor_List.inl"
00012 #endif /* ! __ACE_INLINE__ */
00013 
00014 ACE_RCSID(tao, Interceptor_List, "$Id: Interceptor_List.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:13 chad Exp $")
00015 
00016 // ****************************************************************
00017 
00018 TAO_Interceptor_List::TAO_Interceptor_List (void)
00019 {
00020 }
00021 
00022 TAO_Interceptor_List::~TAO_Interceptor_List (void)
00023 {
00024 }
00025 
00026 size_t
00027 TAO_Interceptor_List::add_interceptor_i (
00028     PortableInterceptor::Interceptor_ptr interceptor
00029     ACE_ENV_ARG_DECL)
00030   ACE_THROW_SPEC ((CORBA::SystemException,
00031                    PortableInterceptor::ORBInitInfo::DuplicateName))
00032 {
00033   if (!CORBA::is_nil (interceptor))
00034     {
00035       /// If the Interceptor is not anonymous, make sure an
00036       /// Interceptor with the same isn't already registered.
00037       CORBA::String_var name = interceptor->name (
00038         ACE_ENV_SINGLE_ARG_PARAMETER);
00039       ACE_CHECK_RETURN (0);
00040 
00041       size_t old_len = this->length ();
00042 
00043       if (ACE_OS_String::strlen (name.in ()) != 0)
00044         {
00045           // @@ This simple search algorithm isn't the greatest thing
00046           //    in the world, but since we only register interceptors
00047           //    when bootstrapping an ORB, there will be no run-time
00048           //    penalty.
00049           //
00050           //    Another source of inefficiency is that Interceptors
00051           //    duplicate their name each time the name() accessor is
00052           //    called!  This can slow down bootstrap time noticeably
00053           //    when registering a huge number of interceptors.  We
00054           //    could cache the names somewhere, but since this is
00055           //    only a bootstrapping issue there's no rush to
00056           //    implement such a scheme.
00057 
00058           /// Prevent interceptors with the same name from being
00059           /// registered.  Anonymous interceptors are okay.
00060           for (size_t i = 0; i < old_len; ++i)
00061             {
00062               CORBA::String_var existing_name =
00063                 this->interceptor (i)->name ();
00064               if (ACE_OS_String::strcmp (existing_name.in (),
00065                                          name.in ()) == 0)
00066                 ACE_THROW_RETURN
00067                   (PortableInterceptor::ORBInitInfo::DuplicateName (),
00068                    0);
00069             }
00070         }
00071 
00072       /// Increase the length of the Interceptor sequence by one.
00073       size_t new_len = old_len + 1;
00074       this->length (new_len);
00075           return old_len;
00076     }
00077   else
00078     ACE_THROW_RETURN (CORBA::INV_OBJREF (
00079                         CORBA_SystemException::_tao_minor_code (
00080                           TAO_DEFAULT_MINOR_CODE,
00081                           EINVAL),
00082                         CORBA::COMPLETED_NO),
00083                       0);
00084 }
00085 
00086 
00087 // -------------------------------------------------------------------
00088 
00089 #if TAO_HAS_INTERCEPTORS == 1
00090 
00091 TAO_ClientRequestInterceptor_List::TAO_ClientRequestInterceptor_List (void)
00092   : interceptors_ ()
00093 {
00094 }
00095 
00096 TAO_ClientRequestInterceptor_List::~TAO_ClientRequestInterceptor_List (void)
00097 {
00098   size_t len = this->interceptors_.size ();
00099 
00100   for (size_t i = 0; i < len; ++i)
00101     CORBA::release (this->interceptors_[i]);
00102 }
00103 
00104 size_t
00105 TAO_ClientRequestInterceptor_List::length (void)
00106 {
00107   return this->interceptors_.size ();
00108 }
00109 
00110 void
00111 TAO_ClientRequestInterceptor_List::length (size_t len)
00112 {
00113   this->interceptors_.size (len);
00114 }
00115 
00116 
00117 PortableInterceptor::Interceptor_ptr
00118 TAO_ClientRequestInterceptor_List::interceptor (size_t index)
00119 {
00120   return this->interceptors_[index];
00121 }
00122 
00123 void
00124 TAO_ClientRequestInterceptor_List::add_interceptor (
00125   PortableInterceptor::ClientRequestInterceptor_ptr interceptor
00126   ACE_ENV_ARG_DECL)
00127 {
00128   size_t index = this->add_interceptor_i (interceptor
00129                                            ACE_ENV_ARG_PARAMETER);
00130   ACE_CHECK;
00131 
00132   this->interceptors_[index] =
00133     PortableInterceptor::ClientRequestInterceptor::_duplicate (interceptor);
00134 }
00135 
00136 // -------------------------------------------------------------------
00137 
00138 TAO_ServerRequestInterceptor_List::TAO_ServerRequestInterceptor_List (void)
00139   : interceptors_ ()
00140 {
00141 }
00142 
00143 TAO_ServerRequestInterceptor_List::~TAO_ServerRequestInterceptor_List (void)
00144 {
00145   size_t len = this->interceptors_.size ();
00146 
00147   for (size_t i = 0; i < len; ++i)
00148     CORBA::release (this->interceptors_[i]);
00149 }
00150 
00151 size_t
00152 TAO_ServerRequestInterceptor_List::length (void)
00153 {
00154   return this->interceptors_.size ();
00155 }
00156 
00157 void
00158 TAO_ServerRequestInterceptor_List::length (size_t len)
00159 {
00160   this->interceptors_.size (len);
00161 }
00162 
00163 PortableInterceptor::Interceptor_ptr
00164 TAO_ServerRequestInterceptor_List::interceptor (size_t index)
00165 {
00166   return this->interceptors_[index];
00167 }
00168 
00169 void
00170 TAO_ServerRequestInterceptor_List::add_interceptor (
00171   PortableInterceptor::ServerRequestInterceptor_ptr interceptor
00172   ACE_ENV_ARG_DECL)
00173 {
00174   size_t index = this->add_interceptor_i (interceptor
00175                                            ACE_ENV_ARG_PARAMETER);
00176   ACE_CHECK;
00177 
00178   this->interceptors_[index] =
00179     PortableInterceptor::ServerRequestInterceptor::_duplicate (interceptor);
00180 }
00181 
00182 #endif  /* TAO_HAS_INTERCEPTORS == 1 */
00183 
00184 // -------------------------------------------------------------------
00185 
00186 TAO_IORInterceptor_List::TAO_IORInterceptor_List (void)
00187   : interceptors_ ()
00188 {
00189 }
00190 
00191 TAO_IORInterceptor_List::~TAO_IORInterceptor_List (void)
00192 {
00193   size_t len = this->interceptors_.size ();
00194 
00195   for (size_t i = 0; i < len; ++i)
00196     CORBA::release (this->interceptors_[i]);
00197 }
00198 
00199 size_t
00200 TAO_IORInterceptor_List::length (void)
00201 {
00202   return this->interceptors_.size ();
00203 }
00204 
00205 void
00206 TAO_IORInterceptor_List::length (size_t len)
00207 {
00208   this->interceptors_.size (len);
00209 }
00210 
00211 PortableInterceptor::Interceptor_ptr
00212 TAO_IORInterceptor_List::interceptor (size_t index)
00213 {
00214   return this->interceptors_[index];
00215 }
00216 
00217 void
00218 TAO_IORInterceptor_List::add_interceptor (
00219   PortableInterceptor::IORInterceptor_ptr interceptor
00220   ACE_ENV_ARG_DECL)
00221 {
00222   size_t index = this->add_interceptor_i (interceptor
00223                                            ACE_ENV_ARG_PARAMETER);
00224   ACE_CHECK;
00225 
00226   this->interceptors_[index] =
00227     PortableInterceptor::IORInterceptor::_duplicate (interceptor);
00228 }
00229 
00230 
00231 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00232 
00233 # if TAO_HAS_INTERCEPTORS == 1
00234 
00235 template class ACE_Array_Base<PortableInterceptor::ClientRequestInterceptor_ptr>;
00236 template class ACE_Array_Base<PortableInterceptor::ServerRequestInterceptor_ptr>;
00237 
00238 # endif  /* TAO_HAS_INTERCEPTORS == 1 */
00239 
00240 template class ACE_Array_Base<PortableInterceptor::IORInterceptor_ptr>;
00241 
00242 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00243 
00244 # if TAO_HAS_INTERCEPTORS == 1
00245 
00246 #pragma instantiate ACE_Array_Base<PortableInterceptor::ClientRequestInterceptor_ptr>
00247 #pragma instantiate ACE_Array_Base<PortableInterceptor::ServerRequestInterceptor_ptr>
00248 
00249 # endif  /* TAO_HAS_INTERCEPTORS == 1 */
00250 
00251 #pragma instantiate ACE_Array_Base<PortableInterceptor::IORInterceptor_ptr>
00252 
00253 #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
00254 

Generated on Mon Jun 16 13:48:36 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002