00001 #include "orbsvcs/PortableGroup/PG_Property_Utils.h"
00002 #include "orbsvcs/PortableGroup/PG_Operators.h"
00003
00004 ACE_RCSID (PortableGroup,
00005 PG_Property_Utils,
00006 "PG_Property_Utils.cpp,v 1.4 2006/03/14 06:14:34 jtc Exp")
00007
00008 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00009
00010 CORBA::Boolean
00011 TAO_PG::get_property_value (const PortableGroup::Name & property_name,
00012 const PortableGroup::Properties & properties,
00013 PortableGroup::Value & property_value)
00014 {
00015 const CORBA::ULong len = properties.length ();
00016 for (CORBA::ULong i = 0; i < len; ++i)
00017 {
00018 const PortableGroup::Property & property = properties[i];
00019 if (property.nam == property_name)
00020 {
00021 property_value = property.val;
00022 return 1;
00023 }
00024 }
00025
00026 return 0;
00027 }
00028
00029 void
00030 TAO_PG::override_properties (
00031 const PortableGroup::Properties & overrides,
00032 PortableGroup::Properties &properties)
00033 {
00034 const CORBA::ULong num_overrides = overrides.length ();
00035 if (num_overrides == 0)
00036 return;
00037
00038 const CORBA::ULong old_length = properties.length ();
00039
00040 const CORBA::ULong new_length =
00041 (num_overrides > old_length ? num_overrides : old_length);
00042
00043
00044
00045
00046 properties.length (new_length);
00047
00048
00049
00050
00051
00052 for (CORBA::ULong i = 0; i < num_overrides; ++i)
00053 {
00054 const PortableGroup::Property &override = overrides[i];
00055
00056 CORBA::ULong j = 0;
00057 for ( ; j < old_length; ++j)
00058 if (properties[j].nam == override.nam)
00059 {
00060 properties[j].val = override.val;
00061 break;
00062 }
00063
00064
00065 if (j == old_length)
00066 {
00067
00068
00069
00070
00071
00072
00073
00074
00075 const CORBA::ULong current_length = properties.length ();
00076 properties.length (current_length + 1);
00077 properties[current_length] = override;
00078 }
00079 }
00080 }
00081
00082 TAO_END_VERSIONED_NAMESPACE_DECL