00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file PG_Properties_Encoder.h 00006 * 00007 * PG_Properties_Encoder.h,v 1.8 2006/03/14 06:14:34 jtc Exp 00008 * 00009 * This file declares a class to help manage PortableGroup::Properties 00010 * 00011 * @author Dale Wilson <wilson_d@ociweb.com> 00012 */ 00013 //============================================================================= 00014 #ifndef TAO_PG_PROPERTIES_ENCODER_H 00015 #define TAO_PG_PROPERTIES_ENCODER_H 00016 00017 #include /**/ "ace/pre.h" 00018 #include <ace/config-all.h> 00019 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00020 #pragma once 00021 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00022 00023 #include "orbsvcs/PortableGroupS.h" 00024 #include "orbsvcs/CosNamingC.h" 00025 #include "orbsvcs/PortableGroup/portablegroup_export.h" 00026 00027 #include "ace/Vector_T.h" 00028 #include "ace/SString.h" 00029 00030 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00031 00032 namespace TAO_PG 00033 { 00034 /** 00035 * A helper to assemble a set of properties into a PortableGroup::Properties structure. 00036 * 00037 * To use a Properties_Encoder: 00038 * Create it. 00039 * Add properties to it using the add method. 00040 * Allocate a new PortableGroup::Properties. 00041 * Use the encode method to transfer the properties into the 00042 * PortableGroup::Properties. 00043 */ 00044 class TAO_PortableGroup_Export Properties_Encoder 00045 { 00046 // Originally NamedValue was an ACE_Pair, but ACE_Pair allows operator == 00047 // (delegating to the member's operators ==.) Since CORBA::Any does 00048 // not support operator ==, this confused gcc version 2.9-gnupro-98r2 00049 // on LynxOS pfadev04 3.0.1 110298-G PowerPC 00050 struct NamedValue 00051 { 00052 public: 00053 ACE_CString name_; 00054 PortableGroup::Value value_; 00055 NamedValue (); 00056 NamedValue (const ACE_CString & name, const PortableGroup::Value & value); 00057 NamedValue (const NamedValue & rhs); 00058 NamedValue & operator = (const NamedValue & rhs); 00059 /// Meaningless method to keep ACE_Vector happy 00060 bool operator == (const NamedValue &rhs) const; 00061 /// Meaningless method to keep ACE_Vector happy 00062 bool operator != (const NamedValue &rhs) const; 00063 }; 00064 typedef ACE_Vector< NamedValue, 10 > NamedValueVec; 00065 00066 public: 00067 /** 00068 * Construct an empty set of properties. 00069 */ 00070 Properties_Encoder (); 00071 00072 /// standard destructor 00073 ~Properties_Encoder (); 00074 00075 /** 00076 * add a name/value property to the Properties_Encoder. 00077 */ 00078 void add (const char * name, const PortableGroup::Value & value); 00079 00080 /** 00081 * Encode all properties in this Properties_Encoder into a PortableGroup::Properties. 00082 * 00083 */ 00084 void encode (PortableGroup::Properties * property_set) const; 00085 00086 private: 00087 Properties_Encoder (const Properties_Encoder & rhs); 00088 Properties_Encoder & operator = (const Properties_Encoder & rhs); 00089 private: 00090 NamedValueVec values_; 00091 }; 00092 00093 } //namespace TAO_PG 00094 00095 TAO_END_VERSIONED_NAMESPACE_DECL 00096 00097 #if defined (__ACE_INLINE__) 00098 #include "orbsvcs/PortableGroup/PG_Properties_Encoder.inl" 00099 #endif /* __ACE_INLINE__ */ 00100 #include /**/ "ace/post.h" 00101 #endif // TAO_PG_PROPERTIES_ENCODER_H