PG_Properties_Support.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    PG_Properties_Support.cpp
00006  *
00007  *  PG_Properties_Support.cpp,v 1.8 2006/03/14 06:14:34 jtc Exp
00008  *
00009  *  This file implements classes to help manage PortableGroup::Properties
00010  *
00011  *  @author Dale Wilson <wilson_d@ociweb.com>
00012  */
00013 //=============================================================================
00014 
00015 #include "orbsvcs/PortableGroup/PG_Properties_Support.h"
00016 
00017 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00018 
00019 TAO::PG_Properties_Support::PG_Properties_Support ()
00020 {
00021 }
00022 
00023 TAO::PG_Properties_Support::~PG_Properties_Support ()
00024 {
00025 
00026 }
00027 
00028 void TAO::PG_Properties_Support::set_default_property (const char * name,
00029       const PortableGroup::Value & value
00030       ACE_ENV_ARG_DECL)
00031       ACE_THROW_SPEC ((CORBA::SystemException))
00032 {
00033   this->default_properties_.set_property(name, value ACE_ENV_ARG_PARAMETER);
00034 }
00035 
00036 void TAO::PG_Properties_Support::set_default_properties (const PortableGroup::Properties & props
00037     ACE_ENV_ARG_DECL)
00038     ACE_THROW_SPEC ((CORBA::SystemException))
00039 {
00040   this->default_properties_.decode (props ACE_ENV_ARG_PARAMETER);
00041 }
00042 
00043 PortableGroup::Properties *
00044 TAO::PG_Properties_Support::get_default_properties (
00045       ACE_ENV_SINGLE_ARG_DECL)
00046   ACE_THROW_SPEC ((
00047     CORBA::SystemException,
00048     PortableGroup::InvalidProperty,
00049     PortableGroup::UnsupportedProperty))
00050 {
00051   PortableGroup::Properties_var result;
00052   ACE_NEW_THROW_EX ( result, PortableGroup::Properties(), CORBA::NO_MEMORY());
00053   ACE_CHECK_RETURN (0);
00054   this->default_properties_.export_properties (*result);
00055   return result._retn ();
00056 }
00057 
00058 void TAO::PG_Properties_Support::remove_default_properties (
00059     const PortableGroup::Properties & props
00060     ACE_ENV_ARG_DECL_NOT_USED)
00061   ACE_THROW_SPEC ((CORBA::SystemException))
00062 {
00063   this->default_properties_.remove (props);
00064 }
00065 
00066 void
00067 TAO::PG_Properties_Support::set_type_properties (
00068     const char *type_id,
00069     const PortableGroup::Properties & overrides
00070     ACE_ENV_ARG_DECL)
00071   ACE_THROW_SPEC ( (CORBA::SystemException,
00072                    PortableGroup::InvalidProperty,
00073                    PortableGroup::UnsupportedProperty))
00074 {
00075   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00076 
00077   TAO::PG_Property_Set * typeid_properties;
00078   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00079   {
00080     ACE_NEW_THROW_EX (
00081       typeid_properties,
00082       TAO::PG_Property_Set (overrides, & this->default_properties_),
00083       CORBA::NO_MEMORY());
00084     this->properties_map_.bind (type_id, typeid_properties);
00085   }
00086   typeid_properties->clear ();
00087   typeid_properties->decode (overrides ACE_ENV_ARG_PARAMETER);
00088 }
00089 
00090 PortableGroup::Properties *
00091 TAO::PG_Properties_Support::get_type_properties (
00092     const char *type_id
00093     ACE_ENV_ARG_DECL)
00094   ACE_THROW_SPEC ( (CORBA::SystemException))
00095 {
00096   PortableGroup::Properties_var result;
00097   ACE_NEW_THROW_EX (result, PortableGroup::Properties(), CORBA::NO_MEMORY ());
00098 
00099   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->internals_, 0);
00100 
00101   TAO::PG_Property_Set * typeid_properties = 0;
00102   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00103   {
00104     typeid_properties->export_properties (*result);
00105   }
00106   return result._retn ();
00107 }
00108 
00109 void
00110 TAO::PG_Properties_Support::remove_type_properties (
00111     const char *type_id,
00112     const PortableGroup::Properties & props
00113     ACE_ENV_ARG_DECL_NOT_USED)
00114   ACE_THROW_SPEC ( (CORBA::SystemException))
00115 {
00116   // NOTE: do not actually delete the properties for this type.
00117   // There may be object groups depending on these.
00118   // Reference counted pointers could be used to allow property sets
00119   // for unused typeids to be deleted.
00120 
00121   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00122 
00123   TAO::PG_Property_Set * typeid_properties = 0;
00124   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00125   {
00126     typeid_properties->remove (props);
00127   }
00128 }
00129 
00130 
00131 TAO::PG_Property_Set *
00132 TAO::PG_Properties_Support::find_typeid_properties (
00133     const char *type_id
00134     ACE_ENV_ARG_DECL)
00135   ACE_THROW_SPEC ((CORBA::SystemException))
00136 {
00137   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->internals_, 0);
00138 
00139   TAO::PG_Property_Set * typeid_properties = 0;
00140   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00141   {
00142     ACE_NEW_THROW_EX (
00143       typeid_properties,
00144       TAO::PG_Property_Set (& this->default_properties_),
00145       CORBA::NO_MEMORY());
00146     this->properties_map_.bind (type_id, typeid_properties);
00147   }
00148   return typeid_properties;
00149 }
00150 
00151 TAO_END_VERSIONED_NAMESPACE_DECL

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