diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-12 14:54:30 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-04-12 14:54:30 +0000 |
commit | c600d247096bfeefc6bf98e9de349c16d42ae7b3 (patch) | |
tree | 8d4afea22101d64ee78209179a1261d1d44fcad1 /TAO/tao/Policy_Manager.cpp | |
parent | 1c9023bd7db3dc52534ef9b828967e0fc250aeae (diff) | |
download | ATCD-c600d247096bfeefc6bf98e9de349c16d42ae7b3.tar.gz |
ChangeLogTag:Mon Apr 12 09:52:58 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO/tao/Policy_Manager.cpp')
-rw-r--r-- | TAO/tao/Policy_Manager.cpp | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/TAO/tao/Policy_Manager.cpp b/TAO/tao/Policy_Manager.cpp new file mode 100644 index 00000000000..ab5aab9c9e4 --- /dev/null +++ b/TAO/tao/Policy_Manager.cpp @@ -0,0 +1,182 @@ +// $Id$ + +#if defined (TAO_HAS_CORBA_MESSAGING) + +#include "tao/Policy_Manager.h" +#include "tao/Environment.h" + +#if !defined (__ACE_INLINE__) +# include "tao/Policy_Manager.i" +#endif /* ! __ACE_INLINE__ */ + +ACE_RCSID(tao, Policy_Manager, "$Id$") + +void +TAO_Policy_Manager_Impl::set_policy_overrides ( + const CORBA::PolicyList & policies, + CORBA::SetOverrideType set_add, + CORBA::Environment &ACE_TRY_ENV) +{ + // @@ The spec does not say what to do on this case. + if (set_add != CORBA::SET_OVERRIDE + && set_add != CORBA::ADD_OVERRIDE) + ACE_THROW (CORBA::BAD_PARAM (CORBA::COMPLETED_NO)); + + CORBA::InvalidPolicies invalid_policies; + invalid_policies.indices.length (policies.length ()); + int n = 0; + for (CORBA::ULong i = 0; i < policies.length (); ++i) + { + CORBA::Policy_ptr policy = policies[i]; + if (CORBA::is_nil (policy)) + continue; + + CORBA::ULong index = policy->policy_type (ACE_TRY_ENV); + ACE_CHECK; + + if (TAO_MIN_PROPIETARY_POLICY <= index + && index < TAO_MAX_PROPIETARY_POLICY) + index -= TAO_MIN_PROPIETARY_POLICY; + + if (index >= TAO_MAX_POLICIES) + invalid_policies.indices[n++] = CORBA::UShort (i); + } + if (n != 0) + { + invalid_policies.indices.length (n); + ACE_THROW (CORBA::InvalidPolicies (invalid_policies)); + } + + if (set_add == CORBA::SET_OVERRIDE) + { + for (int i = 0; i < TAO_MAX_POLICIES; ++i) + { + this->policies_[i] = CORBA::Policy::_nil (); + } + this->count_ = 0; + } + + for (CORBA::ULong j = 0; j < policies.length (); ++j) + { + CORBA::Policy_ptr policy = policies[j]; + if (CORBA::is_nil (policy)) + continue; + + CORBA::ULong index = policy->policy_type (ACE_TRY_ENV); + ACE_CHECK; + + if (TAO_MIN_PROPIETARY_POLICY <= index + && index < TAO_MAX_PROPIETARY_POLICY) + index -= TAO_MIN_PROPIETARY_POLICY; + + // No need to validate the index... + if (CORBA::is_nil (this->policies_[index].in ())) + this->count_++; + + this->policies_[index] = + CORBA::Policy::_duplicate (policy); + } +} + +CORBA::PolicyList * +TAO_Policy_Manager_Impl::get_policy_overrides ( + const CORBA::PolicyTypeSeq & types, + CORBA::Environment &ACE_TRY_ENV) +{ + CORBA::ULong l = types.length (); + + CORBA::ULong slots = l; + if (slots == 0) + slots = this->count_; + + CORBA::PolicyList_var policy_list = + new CORBA::PolicyList (slots); + policy_list->length (slots); + + int n = 0; + if (types.length () == 0) + { + for (int i = 0; i < TAO_MAX_POLICIES; ++i) + { + if (CORBA::is_nil (this->policies_[i].in ())) + continue; + policy_list[n++] = + CORBA::Policy::_duplicate (this->policies_[i].in ()); + } + } + else + { + for (CORBA::ULong j = 0; j < types.length (); ++j) + { + CORBA::ULong index = types[j]; + + if (TAO_MIN_PROPIETARY_POLICY <= index + && index < TAO_MAX_PROPIETARY_POLICY) + index -= TAO_MIN_PROPIETARY_POLICY; + + if (index < TAO_MAX_POLICIES) + policy_list[n++] = + CORBA::Policy::_duplicate (this->policies_[index].in ()); + } + } + + policy_list->length (n); + return policy_list._retn (); +} + +CORBA::Policy_ptr +TAO_Policy_Manager_Impl::get_policy ( + CORBA::PolicyType type, + CORBA::Environment &ACE_TRY_ENV) +{ + CORBA::ULong index = type; + + if (TAO_MIN_PROPIETARY_POLICY <= index + && index < TAO_MAX_PROPIETARY_POLICY) + index -= TAO_MIN_PROPIETARY_POLICY; + + if (index >= TAO_MAX_POLICIES) + return CORBA::Policy::_nil (); + + return CORBA::Policy::_duplicate (this->policies_[index].in ()); +} + +// **************************************************************** + +CORBA::PolicyList * +TAO_Policy_Manager::get_policy_overrides ( + const CORBA::PolicyTypeSeq & ts, + CORBA::Environment &ACE_TRY_ENV) +{ + return this->impl_.get_policy_overrides (ts, ACE_TRY_ENV); +} + +void +TAO_Policy_Manager::set_policy_overrides ( + const CORBA::PolicyList & policies, + CORBA::SetOverrideType set_add, + CORBA::Environment &ACE_TRY_ENV) +{ + this->impl_.set_policy_overrides (policies, set_add, ACE_TRY_ENV); +} + +// **************************************************************** + +CORBA::PolicyList * +TAO_Policy_Current::get_policy_overrides ( + const CORBA::PolicyTypeSeq & ts, + CORBA::Environment &ACE_TRY_ENV) +{ + return this->impl_.get_policy_overrides (ts, ACE_TRY_ENV); +} + +void +TAO_Policy_Current::set_policy_overrides ( + const CORBA::PolicyList & policies, + CORBA::SetOverrideType set_add, + CORBA::Environment &ACE_TRY_ENV) +{ + this->impl_.set_policy_overrides (policies, set_add, ACE_TRY_ENV); +} + +#endif /* TAO_HAS_CORBA_MESSAGING */ |