00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file Policy_Set.h 00006 * 00007 * $Id: Policy_Set.h 79256 2007-08-08 11:24:06Z johnnyw $ 00008 * 00009 * A Policy Container that provides O(1) time access for policy that 00010 * support caching (see orbconf.h). 00011 * 00012 * @author Angelo Cosaro (corsaro@cs.wustl.edu) 00013 * @author Frank Hunleth (fhunleth@cs.wustl.edu) 00014 * @author Carlos O'Ryan (coryan@cs.wustl.edu) 00015 */ 00016 //============================================================================= 00017 00018 #ifndef TAO_POLICY_SET_H 00019 #define TAO_POLICY_SET_H 00020 00021 #include /**/ "ace/pre.h" 00022 00023 #include "tao/PolicyC.h" 00024 00025 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00026 # pragma once 00027 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00028 00029 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00030 00031 /** 00032 * @class TAO_Policy_Set 00033 * 00034 * @brief The policy manager implementation. 00035 * 00036 * This class is used to implement both the CORBA::PolicyManager 00037 * and the CORBA::PolicyCurrent interfaces. 00038 */ 00039 class TAO_Export TAO_Policy_Set 00040 { 00041 public: 00042 00043 /** Creates a TAO_Policy_Set that has a given scope. The 00044 * scope is used to determinate whether or not a given policy can 00045 * be set for the given Policy Manager Implementation. 00046 */ 00047 TAO_Policy_Set (TAO_Policy_Scope scope); 00048 00049 /// Copy constructor. 00050 TAO_Policy_Set (const TAO_Policy_Set &rhs); 00051 00052 /// Destructor 00053 ~TAO_Policy_Set (void); 00054 00055 /// Copy the state from @a source, it uses the copy() operator to 00056 /// obtain independent copies of all the policies. 00057 void copy_from (TAO_Policy_Set* source); 00058 00059 /** 00060 * Modify the list of policies to include @a policies. 00061 * If @a set_add is @c CORBA::SET_OVERRIDE then we replace all the 00062 * old policies. If it is @c CORBA::ADD_OVERRIDE we simply add the 00063 * policies in @a policies. 00064 * No attempt is made to validate the policies for consistency. 00065 */ 00066 void set_policy_overrides (const CORBA::PolicyList & policies, 00067 CORBA::SetOverrideType set_add); 00068 00069 /// Get the values (if any) for the policies in @a types, if @a 00070 /// types is an empty list the method returns *all* the current 00071 /// policies. 00072 CORBA::PolicyList * get_policy_overrides (const CORBA::PolicyTypeSeq & types); 00073 00074 /// Obtain a single policy. 00075 CORBA::Policy_ptr get_policy (CORBA::PolicyType policy); 00076 00077 /// Obtain a cached policy for speedy lookups. 00078 /** 00079 * This method just returns a const reference to the policy to avoid 00080 * obtaining a lock to increment the reference count. As such, it 00081 * can only be used for single threaded cases or cases where the 00082 * policies cannot be removed such as at the object and thread level 00083 * scopes. This method is most likely not appropriate for accessing 00084 * policies at the ORB level scope in any situation. 00085 */ 00086 CORBA::Policy_ptr get_cached_const_policy (TAO_Cached_Policy_Type type) const; 00087 00088 /// Obtain a single cached policy. 00089 CORBA::Policy_ptr get_cached_policy (TAO_Cached_Policy_Type type); 00090 00091 /// Utility method to set a single policy. 00092 void set_policy (const CORBA::Policy_ptr policy); 00093 00094 /// Returns the policy at the specified index. 00095 /// @c CORBA::Policy::_nil () is returned if the policy doesn't 00096 /// exist. 00097 CORBA::Policy *get_policy_by_index (CORBA::ULong index) const; 00098 CORBA::ULong num_policies (void) const; 00099 00100 private: 00101 TAO_Policy_Set & operator= (const TAO_Policy_Set&); 00102 00103 /// Remove and destroy all the policy objects owned by this policy 00104 /// manager. 00105 void cleanup_i (void); 00106 00107 /// Utility method to determine if a policy's scope is compatible with ours. 00108 CORBA::Boolean compatible_scope (TAO_Policy_Scope policy_scope) const; 00109 00110 private: 00111 /// Policies set for this Policy_Manager 00112 CORBA::PolicyList policy_list_; 00113 00114 /// List of caches. 00115 CORBA::Policy *cached_policies_[TAO_CACHED_POLICY_MAX_CACHED]; 00116 00117 /// Scope associated to the Policy Manager Impl 00118 TAO_Policy_Scope scope_; 00119 }; 00120 00121 TAO_END_VERSIONED_NAMESPACE_DECL 00122 00123 #if defined (__ACE_INLINE__) 00124 # include "tao/Policy_Set.inl" 00125 #endif /* __ACE_INLINE__ */ 00126 00127 #include /**/ "ace/post.h" 00128 00129 #endif /* TAO_POLICY_SET_H */