Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / TAO / tao / Policy_Set.h
blob04cf7bd28db31365d474fc6a65d0a6a8e8ae6d0c
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Policy_Set.h
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)
24 # pragma once
25 #endif /* ACE_LACKS_PRAGMA_ONCE */
27 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
29 /**
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
39 public:
40 /** Creates a TAO_Policy_Set that has a given scope. The
41 * scope is used to determinate whether or not a given policy can
42 * be set for the given Policy Manager Implementation.
44 TAO_Policy_Set (TAO_Policy_Scope scope);
46 /// Copy constructor.
47 TAO_Policy_Set (const TAO_Policy_Set &rhs);
49 /// Destructor
50 ~TAO_Policy_Set ();
52 /// Copy the state from @a source, it uses the copy() operator to
53 /// obtain independent copies of all the policies.
54 void copy_from (TAO_Policy_Set* source);
56 /**
57 * Modify the list of policies to include @a policies.
58 * If @a set_add is @c CORBA::SET_OVERRIDE then we replace all the
59 * old policies. If it is @c CORBA::ADD_OVERRIDE we simply add the
60 * policies in @a policies.
61 * No attempt is made to validate the policies for consistency.
63 void set_policy_overrides (const CORBA::PolicyList & policies,
64 CORBA::SetOverrideType set_add);
66 /// Get the values (if any) for the policies in @a types, if @a
67 /// types is an empty list the method returns *all* the current
68 /// policies.
69 CORBA::PolicyList * get_policy_overrides (const CORBA::PolicyTypeSeq & types);
71 /// Obtain a single policy.
72 CORBA::Policy_ptr get_policy (CORBA::PolicyType policy);
74 /// Obtain a cached policy for speedy lookups.
75 /**
76 * This method just returns a const reference to the policy to avoid
77 * obtaining a lock to increment the reference count. As such, it
78 * can only be used for single threaded cases or cases where the
79 * policies cannot be removed such as at the object and thread level
80 * scopes. This method is most likely not appropriate for accessing
81 * policies at the ORB level scope in any situation.
83 CORBA::Policy_ptr get_cached_const_policy (TAO_Cached_Policy_Type type) const;
85 /// Obtain a single cached policy.
86 CORBA::Policy_ptr get_cached_policy (TAO_Cached_Policy_Type type);
88 /// Utility method to set a single policy.
89 void set_policy (const CORBA::Policy_ptr policy);
91 /// Returns the policy at the specified index.
92 /// @c CORBA::Policy::_nil () is returned if the policy doesn't
93 /// exist.
94 CORBA::Policy *get_policy_by_index (CORBA::ULong index) const;
95 CORBA::ULong num_policies () const;
97 private:
98 TAO_Policy_Set & operator= (const TAO_Policy_Set&);
100 /// Remove and destroy all the policy objects owned by this policy
101 /// manager.
102 void cleanup_i ();
104 /// Utility method to determine if a policy's scope is compatible with ours.
105 CORBA::Boolean compatible_scope (TAO_Policy_Scope policy_scope) const;
107 private:
108 /// Policies set for this Policy_Manager
109 CORBA::PolicyList policy_list_;
111 /// List of caches.
112 CORBA::Policy *cached_policies_[TAO_CACHED_POLICY_MAX_CACHED];
114 /// Scope associated to the Policy Manager Impl
115 TAO_Policy_Scope scope_;
118 TAO_END_VERSIONED_NAMESPACE_DECL
120 #if defined (__ACE_INLINE__)
121 # include "tao/Policy_Set.inl"
122 #endif /* __ACE_INLINE__ */
124 #include /**/ "ace/post.h"
126 #endif /* TAO_POLICY_SET_H */