3 //=============================================================================
7 * A Policy Container that provides O(1) time access for policy that
8 * support caching (see orbconf.h).
10 * @author Angelo Cosaro (corsaro@cs.wustl.edu)
11 * @author Frank Hunleth (fhunleth@cs.wustl.edu)
12 * @author Carlos O'Ryan (coryan@cs.wustl.edu)
14 //=============================================================================
16 #ifndef TAO_POLICY_SET_H
17 #define TAO_POLICY_SET_H
19 #include /**/ "ace/pre.h"
21 #include "tao/PolicyC.h"
23 #if !defined (ACE_LACKS_PRAGMA_ONCE)
25 #endif /* ACE_LACKS_PRAGMA_ONCE */
27 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
30 * @class TAO_Policy_Set
32 * @brief The policy manager implementation.
34 * This class is used to implement both the CORBA::PolicyManager
35 * and the CORBA::PolicyCurrent interfaces.
37 class TAO_Export TAO_Policy_Set
41 /** Creates a TAO_Policy_Set that has a given scope. The
42 * scope is used to determinate whether or not a given policy can
43 * be set for the given Policy Manager Implementation.
45 TAO_Policy_Set (TAO_Policy_Scope scope
);
48 TAO_Policy_Set (const TAO_Policy_Set
&rhs
);
51 ~TAO_Policy_Set (void);
53 /// Copy the state from @a source, it uses the copy() operator to
54 /// obtain independent copies of all the policies.
55 void copy_from (TAO_Policy_Set
* source
);
58 * Modify the list of policies to include @a policies.
59 * If @a set_add is @c CORBA::SET_OVERRIDE then we replace all the
60 * old policies. If it is @c CORBA::ADD_OVERRIDE we simply add the
61 * policies in @a policies.
62 * No attempt is made to validate the policies for consistency.
64 void set_policy_overrides (const CORBA::PolicyList
& policies
,
65 CORBA::SetOverrideType set_add
);
67 /// Get the values (if any) for the policies in @a types, if @a
68 /// types is an empty list the method returns *all* the current
70 CORBA::PolicyList
* get_policy_overrides (const CORBA::PolicyTypeSeq
& types
);
72 /// Obtain a single policy.
73 CORBA::Policy_ptr
get_policy (CORBA::PolicyType policy
);
75 /// Obtain a cached policy for speedy lookups.
77 * This method just returns a const reference to the policy to avoid
78 * obtaining a lock to increment the reference count. As such, it
79 * can only be used for single threaded cases or cases where the
80 * policies cannot be removed such as at the object and thread level
81 * scopes. This method is most likely not appropriate for accessing
82 * policies at the ORB level scope in any situation.
84 CORBA::Policy_ptr
get_cached_const_policy (TAO_Cached_Policy_Type type
) const;
86 /// Obtain a single cached policy.
87 CORBA::Policy_ptr
get_cached_policy (TAO_Cached_Policy_Type type
);
89 /// Utility method to set a single policy.
90 void set_policy (const CORBA::Policy_ptr policy
);
92 /// Returns the policy at the specified index.
93 /// @c CORBA::Policy::_nil () is returned if the policy doesn't
95 CORBA::Policy
*get_policy_by_index (CORBA::ULong index
) const;
96 CORBA::ULong
num_policies (void) const;
99 TAO_Policy_Set
& operator= (const TAO_Policy_Set
&);
101 /// Remove and destroy all the policy objects owned by this policy
103 void cleanup_i (void);
105 /// Utility method to determine if a policy's scope is compatible with ours.
106 CORBA::Boolean
compatible_scope (TAO_Policy_Scope policy_scope
) const;
109 /// Policies set for this Policy_Manager
110 CORBA::PolicyList policy_list_
;
113 CORBA::Policy
*cached_policies_
[TAO_CACHED_POLICY_MAX_CACHED
];
115 /// Scope associated to the Policy Manager Impl
116 TAO_Policy_Scope scope_
;
119 TAO_END_VERSIONED_NAMESPACE_DECL
121 #if defined (__ACE_INLINE__)
122 # include "tao/Policy_Set.inl"
123 #endif /* __ACE_INLINE__ */
125 #include /**/ "ace/post.h"
127 #endif /* TAO_POLICY_SET_H */