PG_Properties_Support.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    PG_Properties_Support.h
00006  *
00007  *  PG_Properties_Support.h,v 1.8 2006/03/14 06:14:34 jtc Exp
00008  *
00009  *  This file declares classes to help manage the PortableGroup::Properties
00010  *  It serves roughly the same purpose as PG_PropertiesManager, but takes a
00011  *  different approach that suits the needs of FT CORBA.
00012  *  It would be possible to replace PG_PropertiesManager, or implement it in
00013  *  terms of PG_Properties_Support at some time in the future.
00014  *
00015  *  @author Dale Wilson <wilson_d@ociweb.com>
00016  */
00017 //=============================================================================
00018 #ifndef TAO_PG_PROPERTIES_SUPPORT_H
00019 #define TAO_PG_PROPERTIES_SUPPORT_H
00020 
00021 #include "orbsvcs/PortableGroup/PG_Property_Set.h"
00022 #include "orbsvcs/PortableGroup/portablegroup_export.h"
00023 
00024 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00025 
00026 namespace TAO
00027 {
00028   /**
00029    *  This Properties Support object manages Property Sets (TAO::PG_Property_Set).
00030    *
00031    *  One set, default_properties_,
00032    *  acts as a "global" default set of properties.
00033    *
00034    *  The collection, properties_map_, contains a set of properties for each
00035    *  PortableGroup::type_id.  The default set acts as a "parent" for each of
00036    *  these type_id sets.
00037    *
00038    *  Expected use: When an object group is created that implements the interface
00039    *  identified by type_id, the corresponding typed_id propery set acts as a
00040    *  parent to the Property set contained in the PG_Object_Group.
00041    *
00042    *  This heirarchy of property sets provides the correct property behavior.  A
00043    *  request for a propery to an ObjectGroup will be satisfied from:
00044    *    by the object group group property set, or
00045    *    the typed_id property set, or
00046    *    the default property set, or
00047    *    the request will fail..
00048    *
00049    *  Note that changes to type_id or default properties will be visible
00050    *  immediately at the ObjectGroup level.
00051    */
00052 
00053   class TAO_PortableGroup_Export PG_Properties_Support
00054   {
00055     typedef ACE_Hash_Map_Manager<
00056       ACE_CString,
00057       ::TAO::PG_Property_Set *,
00058       TAO_SYNCH_MUTEX> Properties_Map;
00059     typedef ACE_Hash_Map_Iterator<
00060       ACE_CString,
00061       ::TAO::PG_Property_Set *,
00062       TAO_SYNCH_MUTEX> Properties_Map_Iterator;
00063 
00064   public:
00065     PG_Properties_Support ();
00066     ~PG_Properties_Support ();
00067 
00068     /**
00069      * Set a single default property.
00070      * Overwriting any value previously set for that property.
00071      * Leaving all other properties untouched.
00072      * @param name the name of the property to set
00073      * @value an Any containing the value.
00074      */
00075     void set_default_property (const char * name,
00076           const PortableGroup::Value & value
00077           ACE_ENV_ARG_DECL)
00078         ACE_THROW_SPEC ((CORBA::SystemException));
00079 
00080     /**
00081      * Update the default property set.
00082      *
00083      * Properties that appear in props are replaced in or added to the default
00084      * property set.  Properties that do not appear in props are unchanged.
00085      *
00086      * @param props the set of properties to update the defaults.
00087      */
00088     void set_default_properties (const PortableGroup::Properties & props
00089          ACE_ENV_ARG_DECL)
00090         ACE_THROW_SPEC ((CORBA::SystemException));
00091 
00092     /**
00093      * Export the default properties in PortableGroup::Properties format.
00094      *
00095      * This produces the properties in a format suitable for use across
00096      * a CORBA interface.
00097      * The caller owns the resulting Properties and must release it to avoid
00098      * resource leaks.
00099      * @returns a newly allocated PortableGroup::Properties.
00100      */
00101     PortableGroup::Properties * get_default_properties (ACE_ENV_SINGLE_ARG_DECL)
00102       ACE_THROW_SPEC ( (CORBA::SystemException,
00103                    PortableGroup::InvalidProperty,
00104                    PortableGroup::UnsupportedProperty));
00105 
00106     /**
00107      * Undefine default properties that appear in props.
00108      *
00109      * Properties that are defined in props are removed from the default
00110      * property set.  Removal is done by name.  The property values do not
00111      * have to match.  There is no penalty for attempting to remove a property
00112      * that does not exist.
00113      * @param props a set of propertys to be removed by name.
00114      */
00115     void remove_default_properties (
00116         const PortableGroup::Properties & props
00117         ACE_ENV_ARG_DECL)
00118       ACE_THROW_SPEC ((CORBA::SystemException));
00119 
00120     /**
00121      * Override or define properties associated with a type_id.
00122      *
00123      * If a property set does not exist for type_id, a new one will be created.
00124      * Any property included in overrides will be set or replaced in the type_id
00125      * property set.  Any property not in overrides will be unchanged.
00126      *
00127      * Contrary to the "throws" specification, this method does not attempt
00128      * to validate the properties because doing so would unnecessarily constrain
00129      * the uses to which this class could be put (although one could strategize the
00130      * validation.)
00131      */
00132     void set_type_properties (
00133         const char *type_id,
00134         const PortableGroup::Properties & overrides
00135         ACE_ENV_ARG_DECL)
00136       ACE_THROW_SPEC ((
00137         CORBA::SystemException,
00138         PortableGroup::InvalidProperty,
00139         PortableGroup::UnsupportedProperty));
00140 
00141     /**
00142      * Export the property set in a PortableGroup::Properties format.
00143      *
00144      * This produces the properties associated with a type_id -- including
00145      * any default properties that have not been overridden at the type_id level
00146      * in a format suitable for use across a CORBA interface.
00147      *
00148      * The caller owns the resulting Properties and must release it to avoid
00149      * resource leaks.
00150      *
00151      * Compare this method to find_typeid_properties which returns a pointer
00152      * to the internal representation of the properties in TAO::PG_Property_Set
00153      * format.  This is more efficient, but suitable only for internal use.
00154      *
00155      * @param type_id identifies the set of properties to be exported.
00156      * @returns a newly allocated PortableGroup::Properties that must be released by the caller.
00157      */
00158     PortableGroup::Properties * get_type_properties (
00159         const char *type_id
00160         ACE_ENV_ARG_DECL)
00161       ACE_THROW_SPEC ( (CORBA::SystemException));
00162 
00163     /**
00164      * Export the property set in a PortableGroup::Properties format.
00165      *
00166      * This method is intended to provide a parent
00167      * for the property set in a newly-created Object Group of the given
00168      * type_id.
00169      *
00170      * Callers who intend to send the property set across a CORBA interface
00171      * should use the get_type_properties method.
00172      *
00173      * @param type_id identifies the set of properties to be found.
00174      * @returns a pointer to a Property_Set owned by this Properties_Support object.
00175      */
00176     TAO::PG_Property_Set *  find_typeid_properties (
00177         const char *type_id
00178         ACE_ENV_ARG_DECL)
00179       ACE_THROW_SPEC ((CORBA::SystemException));
00180 
00181     /**
00182      * Undefine default properties that appear in props.
00183      *
00184      * Properties that are defined in props are removed from the type_id
00185      * property set.  Removal is done by name.  The property values do not
00186      * have to match.  There is no penalty for attempting to remove a property
00187      * that does not exist.
00188      * @param props a set of propertys to be removed by name from the type_id set.
00189      */
00190     void remove_type_properties (
00191         const char *type_id,
00192         const PortableGroup::Properties & props
00193         ACE_ENV_ARG_DECL)
00194       ACE_THROW_SPEC ( (CORBA::SystemException));
00195 
00196     ///////////////
00197     // Data Members
00198   private:
00199     /**
00200      * Protect internal state.
00201      */
00202     TAO_SYNCH_MUTEX internals_;
00203 
00204     /// The default property set.
00205     TAO::PG_Property_Set default_properties_;
00206 
00207     /// A collection of property sets indexed by type_id.
00208     Properties_Map properties_map_;
00209   };
00210 } //namespace TAO_PG
00211 
00212 TAO_END_VERSIONED_NAMESPACE_DECL
00213 
00214 #endif // TAO_PG_PROPERTIES_SUPPORT_H

Generated on Thu Nov 9 14:03:34 2006 for TAO_PortableGroup by doxygen 1.3.6