PG_Properties_Support.cpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    PG_Properties_Support.cpp
00006  *
00007  *  $Id: PG_Properties_Support.cpp 77001 2007-02-12 07:54:49Z johnnyw $
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 {
00031   this->default_properties_.set_property(name, value);
00032 }
00033 
00034 void TAO::PG_Properties_Support::set_default_properties (const PortableGroup::Properties & props)
00035 {
00036   this->default_properties_.decode (props);
00037 }
00038 
00039 PortableGroup::Properties *
00040 TAO::PG_Properties_Support::get_default_properties ()
00041 {
00042   PortableGroup::Properties_var result;
00043   ACE_NEW_THROW_EX ( result, PortableGroup::Properties(), CORBA::NO_MEMORY());
00044   this->default_properties_.export_properties (*result);
00045   return result._retn ();
00046 }
00047 
00048 void TAO::PG_Properties_Support::remove_default_properties (
00049     const PortableGroup::Properties & props)
00050 {
00051   this->default_properties_.remove (props);
00052 }
00053 
00054 void
00055 TAO::PG_Properties_Support::set_type_properties (
00056     const char *type_id,
00057     const PortableGroup::Properties & overrides)
00058 {
00059   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00060 
00061   TAO::PG_Property_Set * typeid_properties;
00062   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00063   {
00064     ACE_NEW_THROW_EX (
00065       typeid_properties,
00066       TAO::PG_Property_Set (overrides, & this->default_properties_),
00067       CORBA::NO_MEMORY());
00068     this->properties_map_.bind (type_id, typeid_properties);
00069   }
00070   typeid_properties->clear ();
00071   typeid_properties->decode (overrides);
00072 }
00073 
00074 PortableGroup::Properties *
00075 TAO::PG_Properties_Support::get_type_properties (
00076     const char *type_id)
00077 {
00078   PortableGroup::Properties_var result;
00079   ACE_NEW_THROW_EX (result, PortableGroup::Properties(), CORBA::NO_MEMORY ());
00080 
00081   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->internals_, 0);
00082 
00083   TAO::PG_Property_Set * typeid_properties = 0;
00084   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00085   {
00086     typeid_properties->export_properties (*result);
00087   }
00088   return result._retn ();
00089 }
00090 
00091 void
00092 TAO::PG_Properties_Support::remove_type_properties (
00093     const char *type_id,
00094     const PortableGroup::Properties & props)
00095 {
00096   // NOTE: do not actually delete the properties for this type.
00097   // There may be object groups depending on these.
00098   // Reference counted pointers could be used to allow property sets
00099   // for unused typeids to be deleted.
00100 
00101   ACE_GUARD (TAO_SYNCH_MUTEX, guard, this->internals_);
00102 
00103   TAO::PG_Property_Set * typeid_properties = 0;
00104   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00105   {
00106     typeid_properties->remove (props);
00107   }
00108 }
00109 
00110 
00111 TAO::PG_Property_Set *
00112 TAO::PG_Properties_Support::find_typeid_properties (
00113     const char *type_id)
00114 {
00115   ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, guard, this->internals_, 0);
00116 
00117   TAO::PG_Property_Set * typeid_properties = 0;
00118   if ( 0 != this->properties_map_.find (type_id, typeid_properties))
00119   {
00120     ACE_NEW_THROW_EX (
00121       typeid_properties,
00122       TAO::PG_Property_Set (& this->default_properties_),
00123       CORBA::NO_MEMORY());
00124     this->properties_map_.bind (type_id, typeid_properties);
00125   }
00126   return typeid_properties;
00127 }
00128 
00129 TAO_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 16:22:30 2008 for TAO_PortableGroup by doxygen 1.3.6