Go to the documentation of this file.00001
00002
00003 #include "tao/PI/PI_includeC.h"
00004 #include "tao/ORB_Constants.h"
00005 #include "tao/debug.h"
00006
00007 #include "ace/os_include/os_stddef.h"
00008 #include "ace/OS_NS_string.h"
00009 #include "ace/Log_Msg.h"
00010
00011 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00012
00013 namespace TAO
00014 {
00015 template <typename InterceptorType, typename DetailsType>
00016 Interceptor_List<InterceptorType,DetailsType>::Interceptor_List (void)
00017 {
00018 }
00019
00020 template <typename InterceptorType, typename DetailsType>
00021 typename Interceptor_List<InterceptorType,DetailsType>::RegisteredInterceptor&
00022 Interceptor_List<InterceptorType,DetailsType>::registered_interceptor (
00023 size_t index)
00024 {
00025 return this->interceptors_[index];
00026 }
00027
00028 template <typename InterceptorType, typename DetailsType>
00029 typename Interceptor_List<InterceptorType,DetailsType>::InterceptorType_ptr_type
00030 Interceptor_List<InterceptorType,DetailsType>::interceptor (size_t index)
00031 {
00032 return this->interceptors_[index].interceptor_.in ();
00033 }
00034
00035 template <typename InterceptorType, typename DetailsType>
00036 size_t
00037 Interceptor_List<InterceptorType,DetailsType>::size (void) const
00038 {
00039 return this->interceptors_.size ();
00040 }
00041
00042 template <typename InterceptorType, typename DetailsType>
00043 void
00044 Interceptor_List<InterceptorType,DetailsType>::add_interceptor (
00045 InterceptorType_ptr_type interceptor)
00046 {
00047 if (!CORBA::is_nil (interceptor))
00048 {
00049 size_t const old_len = this->interceptors_.size ();
00050
00051
00052
00053
00054 if (old_len > 0)
00055 {
00056
00057
00058 CORBA::String_var name =
00059 interceptor->name ();
00060
00061 if (ACE_OS::strlen (name.in ()) != 0)
00062 {
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
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
00093 size_t const new_len = old_len + 1;
00094 this->interceptors_.size (new_len);
00095
00096
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 }
00111
00112 template <typename InterceptorType, typename DetailsType>
00113 void
00114 Interceptor_List<InterceptorType,DetailsType>::add_interceptor (
00115 InterceptorType_ptr_type interceptor,
00116 const CORBA::PolicyList& policies
00117 )
00118 {
00119 if (!CORBA::is_nil (interceptor))
00120 {
00121 size_t const old_len = this->interceptors_.size ();
00122
00123
00124
00125
00126 if (old_len > 0)
00127 {
00128
00129
00130 CORBA::String_var name =
00131 interceptor->name ();
00132
00133 if (ACE_OS::strlen (name.in ()) != 0)
00134 {
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
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
00165 DetailsType details;
00166 details.apply_policies(policies);
00167
00168
00169 size_t const new_len = old_len + 1;
00170 this->interceptors_.size (new_len);
00171
00172
00173 this->interceptors_[old_len].interceptor_ =
00174 InterceptorType::_duplicate (interceptor);
00175
00176
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 }
00191
00192 template <typename InterceptorType, typename DetailsType>
00193 void
00194 Interceptor_List<InterceptorType,DetailsType>::destroy_interceptors (
00195 void)
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
00205
00206
00207 --ilen;
00208
00209 this->interceptor (k)->destroy ();
00210
00211
00212
00213
00214
00215
00216 this->interceptors_.size (ilen);
00217 }
00218 }
00219 catch (...)
00220 {
00221
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 }
00231 }
00232
00233 TAO_END_VERSIONED_NAMESPACE_DECL