#include <Policy_Set.h>
Collaboration diagram for TAO_Policy_Set:
Public Member Functions | |
TAO_Policy_Set (TAO_Policy_Scope scope) | |
TAO_Policy_Set (const TAO_Policy_Set &rhs) | |
Copy constructor. | |
~TAO_Policy_Set (void) | |
Destructor. | |
void | copy_from (TAO_Policy_Set *source) |
void | set_policy_overrides (const CORBA::PolicyList &policies, CORBA::SetOverrideType set_add) |
CORBA::PolicyList * | get_policy_overrides (const CORBA::PolicyTypeSeq &types) |
CORBA::Policy_ptr | get_policy (CORBA::PolicyType policy) |
Obtain a single policy. | |
CORBA::Policy_ptr | get_cached_const_policy (TAO_Cached_Policy_Type type) const |
Obtain a cached policy for speedy lookups. | |
CORBA::Policy_ptr | get_cached_policy (TAO_Cached_Policy_Type type) |
Obtain a single cached policy. | |
void | set_policy (const CORBA::Policy_ptr policy) |
Utility method to set a single policy. | |
CORBA::Policy * | get_policy_by_index (CORBA::ULong index) const |
CORBA::ULong | num_policies (void) const |
Private Member Functions | |
TAO_Policy_Set & | operator= (const TAO_Policy_Set &) |
void | cleanup_i () |
CORBA::Boolean | compatible_scope (TAO_Policy_Scope policy_scope) const |
Utility method to determine if a policy's scope is compatible with ours. | |
Private Attributes | |
CORBA::PolicyList | policy_list_ |
Policies set for this Policy_Manager. | |
CORBA::Policy * | cached_policies_ [TAO_CACHED_POLICY_MAX_CACHED] |
List of caches. | |
TAO_Policy_Scope | scope_ |
Scope associated to the Policy Manager Impl. |
This class is used to implement both the CORBA::PolicyManager and the CORBA::PolicyCurrent interfaces.
Definition at line 39 of file Policy_Set.h.
|
Creates a TAO_Policy_Set that has a given scope. The scope is used to determinate whether or not a given policy can be set for the given Policy Manager Implementation. Definition at line 20 of file Policy_Set.cpp. References cached_policies_, and TAO_CACHED_POLICY_MAX_CACHED.
00021 : scope_ (scope) 00022 { 00023 for (unsigned int i = 0; i < TAO_CACHED_POLICY_MAX_CACHED; ++i) 00024 this->cached_policies_[i] = 0; 00025 } |
|
Copy constructor.
Definition at line 42 of file Policy_Set.cpp. References TAO_Objref_Var_T< T >::_retn(), ACE_ANY_EXCEPTION, ACE_CATCHANY, ACE_CHECK, ACE_ENDTRY, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_PRINT_EXCEPTION, ACE_TRY_CHECK, ACE_TRY_NEW_ENV, cached_policies_, CORBA::Policy::copy(), CORBA::is_nil(), TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), policy_list_, CORBA::Policy_ptr, CORBA::Policy_var, TAO_Objref_Var_T< T >::ptr(), TAO_CACHED_POLICY_MAX_CACHED, TAO_CACHED_POLICY_UNCACHED, and TAO_debug_level.
00043 : scope_ (rhs.scope_) 00044 { 00045 // Initialize the cache. 00046 for (int i = 0; i < TAO_CACHED_POLICY_MAX_CACHED; ++i) 00047 { 00048 this->cached_policies_[i] = 0; 00049 } 00050 00051 // Copy over the policy list. 00052 this->policy_list_.length (rhs.policy_list_.length ()); 00053 00054 ACE_TRY_NEW_ENV 00055 { 00056 for (CORBA::ULong i = 0; i < rhs.policy_list_.length (); ++i) 00057 { 00058 CORBA::Policy_ptr policy = rhs.policy_list_[i]; 00059 00060 if (CORBA::is_nil (policy)) 00061 { 00062 continue; 00063 } 00064 00065 CORBA::Policy_var copy = 00066 policy->copy (ACE_ENV_SINGLE_ARG_PARAMETER); 00067 ACE_CHECK; 00068 00069 // Add the "cacheable" policies into the cache. 00070 if (copy->_tao_cached_type () != TAO_CACHED_POLICY_UNCACHED) 00071 { 00072 this->cached_policies_[copy->_tao_cached_type ()] = 00073 copy.ptr (); 00074 } 00075 00076 this->policy_list_[i] = copy._retn (); 00077 } 00078 00079 ACE_TRY_CHECK; 00080 } 00081 ACE_CATCHANY 00082 { 00083 if (TAO_debug_level > 4) 00084 ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, 00085 "TAO_Policy_Set::TAO_Policy_Set"); 00086 00087 // "Try" to make this recoverable as we must have run out of memory. 00088 this->policy_list_.length (0); 00089 } 00090 ACE_ENDTRY; 00091 } |
|
Destructor.
Definition at line 27 of file Policy_Set.cpp. References ACE_CATCHANY, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_TRY, ACE_TRY_CHECK, and cleanup_i().
00028 { 00029 ACE_DECLARE_NEW_CORBA_ENV; 00030 ACE_TRY 00031 { 00032 this->cleanup_i (ACE_ENV_SINGLE_ARG_PARAMETER); 00033 ACE_TRY_CHECK; 00034 } 00035 ACE_CATCHANY 00036 { 00037 // Ignore exceptions... 00038 } 00039 ACE_ENDTRY; 00040 } |
|
Remove and destroy all the policy objects owned by this policy manager. Definition at line 137 of file Policy_Set.cpp. References CORBA::Policy::_nil(), ACE_CHECK, ACE_ENV_SINGLE_ARG_PARAMETER, cached_policies_, TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), and TAO_CACHED_POLICY_MAX_CACHED. Referenced by copy_from(), set_policy_overrides(), and ~TAO_Policy_Set().
00138 { 00139 const CORBA::ULong len = this->policy_list_.length (); 00140 // Cleanup the policy list. 00141 for (CORBA::ULong i = 0; i < len; ++i) 00142 { 00143 this->policy_list_[i]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); 00144 ACE_CHECK; 00145 this->policy_list_[i] = CORBA::Policy::_nil (); 00146 } 00147 00148 this->policy_list_.length (0); 00149 00150 // Cleanup the cache. 00151 for (CORBA::ULong j = 0; j < TAO_CACHED_POLICY_MAX_CACHED; ++j) 00152 { 00153 this->cached_policies_[j] = 0; 00154 } 00155 } |
|
Utility method to determine if a policy's scope is compatible with ours.
Definition at line 8 of file Policy_Set.i. Referenced by copy_from(), and set_policy().
00009 { 00010 return 00011 ((static_cast<unsigned int> (policy_scope) 00012 & static_cast<unsigned int> (this->scope_)) > 0); 00013 } |
|
Copy the state from source, it uses the copy() operator to obtain independent copies of all the policies. Definition at line 94 of file Policy_Set.cpp. References TAO_Objref_Var_T< T >::_retn(), CORBA::Policy::_tao_scope(), ACE_CHECK, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW, cached_policies_, cleanup_i(), compatible_scope(), CORBA::Policy::copy(), CORBA::is_nil(), TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), CORBA::Policy_ptr, CORBA::Policy_var, TAO_Objref_Var_T< T >::ptr(), and TAO_CACHED_POLICY_UNCACHED.
00096 { 00097 if (source == 0) 00098 { 00099 return; 00100 } 00101 00102 this->cleanup_i (ACE_ENV_SINGLE_ARG_PARAMETER); 00103 ACE_CHECK; 00104 00105 for (CORBA::ULong i = 0; i < source->policy_list_.length (); ++i) 00106 { 00107 CORBA::Policy_ptr policy = source->policy_list_[i]; 00108 00109 if (CORBA::is_nil (policy)) 00110 { 00111 continue; 00112 } 00113 00114 if (! this->compatible_scope (policy->_tao_scope())) 00115 { 00116 ACE_THROW (CORBA::NO_PERMISSION ()); 00117 } 00118 00119 CORBA::Policy_var copy = 00120 policy->copy (ACE_ENV_SINGLE_ARG_PARAMETER); 00121 ACE_CHECK; 00122 00123 CORBA::ULong const length = this->policy_list_.length (); 00124 this->policy_list_.length (length + 1); 00125 00126 // Add the "cacheable" policies into the cache. 00127 if (copy->_tao_cached_type () != TAO_CACHED_POLICY_UNCACHED) 00128 { 00129 this->cached_policies_[copy->_tao_cached_type ()] = copy.ptr (); 00130 } 00131 00132 this->policy_list_[length] = copy._retn (); 00133 } 00134 } |
|
Obtain a cached policy for speedy lookups. This method just returns a const reference to the policy to avoid obtaining a lock to increment the reference count. As such, it can only be used for single threaded cases or cases where the policies cannot be removed such as at the object and thread level scopes. This method is most likely not appropriate for accessing policies at the ORB level scope in any situation. Definition at line 349 of file Policy_Set.cpp. References CORBA::Policy::_nil(), cached_policies_, TAO_CACHED_POLICY_MAX_CACHED, and TAO_CACHED_POLICY_UNCACHED.
00350 { 00351 if (type != TAO_CACHED_POLICY_UNCACHED 00352 && type < TAO_CACHED_POLICY_MAX_CACHED) 00353 { 00354 return this->cached_policies_[type]; 00355 } 00356 00357 return CORBA::Policy::_nil (); 00358 } |
|
Obtain a single cached policy.
Definition at line 361 of file Policy_Set.cpp. References CORBA::Policy::_duplicate(), CORBA::Policy::_nil(), TAO_CACHED_POLICY_MAX_CACHED, and TAO_CACHED_POLICY_UNCACHED. Referenced by TAO_Stub::get_cached_policy(), TAO_Policy_Manager::get_cached_policy(), TAO_Policy_Current_Impl::get_cached_policy(), and TAO_ORB_Core::get_cached_policy().
00363 { 00364 if (type != TAO_CACHED_POLICY_UNCACHED 00365 && type < TAO_CACHED_POLICY_MAX_CACHED) 00366 { 00367 return CORBA::Policy::_duplicate (this->cached_policies_[type]); 00368 } 00369 00370 return CORBA::Policy::_nil (); 00371 } |
|
Obtain a single policy.
Definition at line 326 of file Policy_Set.cpp. References CORBA::Policy::_duplicate(), CORBA::Policy::_nil(), ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_PARAMETER, TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), and CORBA::PolicyType. Referenced by TAO_Stub::get_policy(), TAO_Policy_Manager::get_policy(), TAO_Policy_Current_Impl::get_policy(), and TAO_ORB_Core::get_policy().
00328 { 00329 const CORBA::ULong length = this->policy_list_.length (); 00330 00331 for (CORBA::ULong i = 0; i < length; ++i) 00332 { 00333 const CORBA::ULong current = 00334 this->policy_list_[i]->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); 00335 ACE_CHECK_RETURN (0); 00336 00337 if (current != type) 00338 { 00339 continue; 00340 } 00341 00342 return CORBA::Policy::_duplicate (this->policy_list_[i]); 00343 } 00344 00345 return CORBA::Policy::_nil (); 00346 } |
|
Returns the policy at the specified index. Definition at line 16 of file Policy_Set.i. References CORBA::Policy::_duplicate().
00017 { 00018 return CORBA::Policy::_duplicate (this->policy_list_[index]); 00019 } |
|
Get the values (if any) for the policies in types, if types is an empty list the method returns *all* the current policies. Definition at line 272 of file Policy_Set.cpp. References CORBA::Policy::_duplicate(), TAO_Seq_Var_Base_T< T >::_retn(), ACE_CHECK_RETURN, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_NEW_THROW_EX, TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), and CORBA::PolicyList_var. Referenced by TAO_Stub::get_policy_overrides(), and TAO_Policy_Current_Impl::get_policy_overrides().
00274 { 00275 const CORBA::ULong slots = types.length (); 00276 CORBA::PolicyList *policy_list_ptr; 00277 00278 if (slots == 0) 00279 { 00280 // Copy our own policy list. 00281 ACE_NEW_THROW_EX (policy_list_ptr, 00282 CORBA::PolicyList (this->policy_list_), 00283 CORBA::NO_MEMORY ()); 00284 ACE_CHECK_RETURN (0); 00285 00286 return policy_list_ptr; 00287 } 00288 00289 ACE_NEW_THROW_EX (policy_list_ptr, 00290 CORBA::PolicyList (slots), 00291 CORBA::NO_MEMORY ()); 00292 ACE_CHECK_RETURN (0); 00293 00294 CORBA::PolicyList_var policy_list (policy_list_ptr); 00295 policy_list->length (slots); 00296 CORBA::ULong n = 0; 00297 00298 for (CORBA::ULong j = 0; j < slots; ++j) 00299 { 00300 const CORBA::ULong slot = types[j]; 00301 const CORBA::ULong length = this->policy_list_.length (); 00302 00303 for (CORBA::ULong i = 0; i < length; ++i) 00304 { 00305 const CORBA::ULong current = 00306 this->policy_list_[i]->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); 00307 ACE_CHECK_RETURN (0); 00308 00309 if (current != slot) 00310 { 00311 continue; 00312 } 00313 00314 policy_list[n++] = 00315 CORBA::Policy::_duplicate (this->policy_list_[i]); 00316 break; 00317 } 00318 } 00319 00320 policy_list->length (n); // Truncate buffer if necessary. 00321 00322 return policy_list._retn (); 00323 } |
|
Definition at line 22 of file Policy_Set.i. References TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length().
00023 { 00024 return this->policy_list_.length(); 00025 } |
|
|
|
Utility method to set a single policy.
Definition at line 216 of file Policy_Set.cpp. References TAO_Objref_Var_T< T >::_retn(), ACE_CHECK, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW, cached_policies_, compatible_scope(), TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), CORBA::Policy_ptr, CORBA::Policy_var, CORBA::PolicyType, TAO_Objref_Var_T< T >::ptr(), TAO_Cached_Policy_Type, and TAO_CACHED_POLICY_UNCACHED. Referenced by set_policy_overrides().
00218 { 00219 if (! this->compatible_scope (policy->_tao_scope())) 00220 { 00221 ACE_THROW (CORBA::NO_PERMISSION ()); 00222 } 00223 00224 const CORBA::PolicyType policy_type = 00225 policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); 00226 ACE_CHECK; 00227 00228 CORBA::Policy_var copy = policy->copy (ACE_ENV_SINGLE_ARG_PARAMETER); 00229 ACE_CHECK; 00230 00231 CORBA::ULong j = 0; 00232 const CORBA::ULong length = this->policy_list_.length (); 00233 00234 while (j != length) 00235 { 00236 CORBA::ULong current = 00237 this->policy_list_[j]->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); 00238 ACE_CHECK; 00239 00240 if (current == policy_type) 00241 { 00242 this->policy_list_[j]->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); 00243 ACE_CHECK; 00244 00245 this->policy_list_[j] = copy.ptr (); 00246 break; 00247 } 00248 00249 ++j; 00250 } 00251 00252 if (j == length) 00253 { 00254 this->policy_list_.length (length + 1); 00255 this->policy_list_[j] = copy.ptr (); 00256 } 00257 00258 // If this is a policy that gets accessed on the critical path, 00259 // save a pointer to it in the cache. 00260 TAO_Cached_Policy_Type cached_policy_type = policy->_tao_cached_type (); 00261 00262 if (cached_policy_type != TAO_CACHED_POLICY_UNCACHED) 00263 { 00264 this->cached_policies_[cached_policy_type] = copy.ptr (); 00265 } 00266 00267 // Transfer ownership to the policy list. 00268 (void) copy._retn (); 00269 } |
|
Modify the list of policies to include policies. If set_add is Definition at line 159 of file Policy_Set.cpp. References ACE_CHECK, ACE_ENV_ARG_PARAMETER, ACE_ENV_SINGLE_ARG_PARAMETER, ACE_THROW, cleanup_i(), CORBA::is_nil(), TAO::unbounded_object_reference_sequence< Policy, Policy_var >::length(), CORBA::Policy_ptr, CORBA::Policy::policy_type, CORBA::PolicyType, set_policy(), and TAO_RT_SERVER_PROTOCOL_POLICY_TYPE. Referenced by TAO_Policy_Current_Impl::set_policy_overrides().
00162 { 00163 // @@ The spec does not say what to do on this case. 00164 if (set_add != CORBA::SET_OVERRIDE && set_add != CORBA::ADD_OVERRIDE) 00165 { 00166 ACE_THROW (CORBA::BAD_PARAM ()); 00167 } 00168 00169 if (set_add == CORBA::SET_OVERRIDE) 00170 { 00171 this->cleanup_i (ACE_ENV_SINGLE_ARG_PARAMETER); 00172 ACE_CHECK; 00173 } 00174 00175 // Flag, indicating whether we have already overridden 00176 // RTCORBA::ServerProtocolPolicy during this call. 00177 bool server_protocol_set = false; 00178 00179 const CORBA::ULong plen = policies.length (); 00180 00181 for (CORBA::ULong i = 0; i < plen; ++i) 00182 { 00183 CORBA::Policy_ptr policy = policies[i]; 00184 00185 if (CORBA::is_nil (policy)) 00186 { 00187 continue; 00188 } 00189 00190 const CORBA::PolicyType policy_type = 00191 policy->policy_type (ACE_ENV_SINGLE_ARG_PARAMETER); 00192 ACE_CHECK; 00193 00194 if (policy_type == TAO_RT_SERVER_PROTOCOL_POLICY_TYPE) 00195 { 00196 // Only one ServerProtocolPolicy should be included in a 00197 // given PolicyList (section 4.15.2 of RTCORBA 1.0, i.e., 00198 // ptc/99-05-03). 00199 // User-caused exceptional conditions can leave the Policy 00200 // Manager in an inconsistent state. It is the 00201 // responsibility of the user to return it to consistent state. 00202 if (server_protocol_set) 00203 { 00204 ACE_THROW (CORBA::INV_POLICY ()); 00205 } 00206 00207 server_protocol_set = true; 00208 } 00209 00210 this->set_policy (policy ACE_ENV_ARG_PARAMETER); 00211 ACE_CHECK; 00212 } 00213 } |
|
List of caches.
Definition at line 122 of file Policy_Set.h. Referenced by cleanup_i(), copy_from(), get_cached_const_policy(), set_policy(), and TAO_Policy_Set(). |
|
Policies set for this Policy_Manager.
Definition at line 119 of file Policy_Set.h. Referenced by TAO_Policy_Set(). |
|
Scope associated to the Policy Manager Impl.
Definition at line 125 of file Policy_Set.h. |