diff options
Diffstat (limited to 'TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h')
-rw-r--r-- | TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h new file mode 100644 index 00000000000..d1780105873 --- /dev/null +++ b/TAO/orbsvcs/orbsvcs/PortableGroup/PG_Properties_Encoder.h @@ -0,0 +1,101 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file PG_Properties_Encoder.h + * + * $Id$ + * + * This file declares a class to help manage PortableGroup::Properties + * + * @author Dale Wilson <wilson_d@ociweb.com> + */ +//============================================================================= +#ifndef TAO_PG_PROPERTIES_ENCODER_H +#define TAO_PG_PROPERTIES_ENCODER_H + +#include /**/ "ace/pre.h" +#include <ace/config-all.h> +#if !defined (ACE_LACKS_PRAGMA_ONCE) +#pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "orbsvcs/PortableGroupS.h" +#include "orbsvcs/CosNamingC.h" +#include "orbsvcs/PortableGroup/portablegroup_export.h" + +#include "ace/Vector_T.h" +#include "ace/SString.h" + +TAO_BEGIN_VERSIONED_NAMESPACE_DECL + +namespace TAO_PG +{ + /** + * A helper to assemble a set of properties into a PortableGroup::Properties structure. + * + * To use a Properties_Encoder: + * Create it. + * Add properties to it using the add method. + * Allocate a new PortableGroup::Properties. + * Use the encode method to transfer the properties into the + * PortableGroup::Properties. + */ + class TAO_PortableGroup_Export Properties_Encoder + { + // Originally NamedValue was an ACE_Pair, but ACE_Pair allows operator == + // (delegating to the member's operators ==.) Since CORBA::Any does + // not support operator ==, this confused gcc version 2.9-gnupro-98r2 + // on LynxOS pfadev04 3.0.1 110298-G PowerPC + struct NamedValue + { + public: + ACE_CString name_; + PortableGroup::Value value_; + NamedValue (); + NamedValue (const ACE_CString & name, const PortableGroup::Value & value); + NamedValue (const NamedValue & rhs); + NamedValue & operator = (const NamedValue & rhs); + /// Meaningless method to keep ACE_Vector happy + bool operator == (const NamedValue &rhs) const; + /// Meaningless method to keep ACE_Vector happy + bool operator != (const NamedValue &rhs) const; + }; + typedef ACE_Vector< NamedValue, 10 > NamedValueVec; + + public: + /** + * Construct an empty set of properties. + */ + Properties_Encoder (); + + /// standard destructor + ~Properties_Encoder (); + + /** + * add a name/value property to the Properties_Encoder. + */ + void add (const char * name, const PortableGroup::Value & value); + + /** + * Encode all properties in this Properties_Encoder into a PortableGroup::Properties. + * + */ + void encode (PortableGroup::Properties * property_set) const; + + private: + Properties_Encoder (const Properties_Encoder & rhs); + Properties_Encoder & operator = (const Properties_Encoder & rhs); + private: + NamedValueVec values_; + }; + +} //namespace TAO_PG + +TAO_END_VERSIONED_NAMESPACE_DECL + +#if defined (__ACE_INLINE__) +#include "orbsvcs/PortableGroup/PG_Properties_Encoder.inl" +#endif /* __ACE_INLINE__ */ +#include /**/ "ace/post.h" +#endif // TAO_PG_PROPERTIES_ENCODER_H |