Policy_Set.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Policy_Set.h
00006  *
00007  *  Policy_Set.h,v 1.12 2006/04/19 08:50:40 jwillemsen Exp
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                   ACE_ENV_ARG_DECL);
00059 
00060   /**
00061    * Modify the list of policies to include @a policies.
00062    * If @a set_add is @c CORBA::SET_OVERRIDE then we replace all the
00063    * old policies. If it is @c CORBA::ADD_OVERRIDE we simply add the
00064    * policies in @a policies.
00065    * No attempt is made to validate the policies for consistency.
00066    */
00067   void set_policy_overrides (const CORBA::PolicyList & policies,
00068                              CORBA::SetOverrideType set_add
00069                              ACE_ENV_ARG_DECL);
00070 
00071   /// Get the values (if any) for the policies in @a types, if @a
00072   /// types is an empty list the method returns *all* the current
00073   /// policies.
00074   CORBA::PolicyList * get_policy_overrides (const CORBA::PolicyTypeSeq & types
00075                                             ACE_ENV_ARG_DECL);
00076 
00077   /// Obtain a single policy.
00078   CORBA::Policy_ptr get_policy (CORBA::PolicyType policy
00079                                 ACE_ENV_ARG_DECL);
00080 
00081   /// Obtain a cached policy for speedy lookups.
00082   /**
00083    * This method just returns a const reference to the policy to avoid
00084    * obtaining a lock to increment the reference count.  As such, it
00085    * can only be used for single threaded cases or cases where the
00086    * policies cannot be removed such as at the object and thread level
00087    * scopes.  This method is most likely not appropriate for accessing
00088    * policies at the ORB level scope in any situation.
00089    */
00090   CORBA::Policy_ptr get_cached_const_policy (TAO_Cached_Policy_Type type) const;
00091 
00092   /// Obtain a single cached policy.
00093   CORBA::Policy_ptr get_cached_policy (TAO_Cached_Policy_Type type
00094                                        ACE_ENV_ARG_DECL);
00095 
00096   /// Utility method to set a single policy.
00097   void set_policy (const CORBA::Policy_ptr policy
00098                    ACE_ENV_ARG_DECL);
00099 
00100   /// Returns the policy at the specified index.
00101   /// @c CORBA::Policy::_nil () is returned if the policy doesn't
00102   /// exist.
00103   CORBA::Policy *get_policy_by_index (CORBA::ULong index) const;
00104   CORBA::ULong num_policies (void) const;
00105 
00106 private:
00107   TAO_Policy_Set & operator= (const TAO_Policy_Set&);
00108 
00109   /// Remove and destroy all the policy objects owned by this policy
00110   /// manager.
00111   void cleanup_i (ACE_ENV_SINGLE_ARG_DECL);
00112 
00113   /// Utility method to determine if a policy's scope is compatible with ours.
00114   CORBA::Boolean compatible_scope (TAO_Policy_Scope policy_scope) const;
00115 
00116 private:
00117 
00118   /// Policies set for this Policy_Manager
00119   CORBA::PolicyList policy_list_;
00120 
00121   /// List of caches.
00122   CORBA::Policy *cached_policies_[TAO_CACHED_POLICY_MAX_CACHED];
00123 
00124   /// Scope associated to the Policy Manager Impl
00125   TAO_Policy_Scope scope_;
00126 };
00127 
00128 TAO_END_VERSIONED_NAMESPACE_DECL
00129 
00130 #if defined (__ACE_INLINE__)
00131 # include "tao/Policy_Set.i"
00132 #endif /* __ACE_INLINE__ */
00133 
00134 #include /**/ "ace/post.h"
00135 
00136 #endif /* TAO_POLICY_SET_H */

Generated on Thu Nov 9 11:54:20 2006 for TAO by doxygen 1.3.6