diff options
Diffstat (limited to 'TAO/tao/TypeCode_Case.h')
-rw-r--r-- | TAO/tao/TypeCode_Case.h | 159 |
1 files changed, 159 insertions, 0 deletions
diff --git a/TAO/tao/TypeCode_Case.h b/TAO/tao/TypeCode_Case.h new file mode 100644 index 00000000000..7b5042b6a14 --- /dev/null +++ b/TAO/tao/TypeCode_Case.h @@ -0,0 +1,159 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file TypeCode_Case.h + * + * $Id$ + * + * Header file for @c TAO::TypeCode::Case type. + * + * @author Ossama Othman + */ +//============================================================================= + +#ifndef TAO_TYPECODE_CASE_H +#define TAO_TYPECODE_CASE_H + +#include /**/ "ace/pre.h" + +#include "ace/config.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + + +namespace CORBA +{ + class TypeCode; + typedef TypeCode* TypeCode_ptr; + + class Any; +} + +namespace TAO +{ + namespace TypeCode + { + + /** + * @class Case + * + * @brief Abstract base class for that represents an IDL @c union + * case/member. + * + * This class hides the actual IDL @c union member label value + * from the @c TAO::TypeCode::Union class by relying on a + * CORBA::Any return value that corresponds to the @c + * CORBA::TypeCode::member_label() return type. It also allows + * the @c TAO::TypeCode::Union class to marshal the member label + * values into a CDR stream without knowledge of the underlying + * member label values. + */ + template <typename STRING_TYPE> + class Case + { + public: + + /// Constructor. + Case (char const * name, + CORBA::TypeCode_ptr * tc); + + /// Destructor. + virtual ~Case (void); + + /// Return the IDL @c union case label value embedded within a + /// @c CORBA::Any. + virtual CORBA::Any * label (ACE_ENV_SINGLE_ARG_DECL) const = 0; + + /// Get the name of the @c union case/member. + char const * name (void) const; + + /// Get the @c CORBA::TypeCode of the @c union case/member. + /** + * @note The reference count is not manipulated by this method, + * i.e., ownership is retained by this class. + */ + CORBA::TypeCode_ptr type (void) const; + + /// Marshal this IDL @c union member into the given output CDR + /// stream. + bool marshal (TAO_OutputCDR & cdr) const; + + /// Check for equality of the @c case attributes contained by this + /// class and the corresponding member attributes at index "@a + /// index" in the given @c TypeCode @a tc. + bool equal (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + + /// Check for equivalence of the @c case attributes contained by + /// this class and the corresponding member attributes at index + /// "@a index" in the given @c TypeCode @a tc. + bool equivalent (CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const; + + protected: + + /// Marshal the IDL @c union @c case label value into the given + /// output CDR stream. + virtual bool marshal_label (TAO_OutputCDR & cdr) const = 0; + + /// Verify equality of member labels. + /** + * Performing member label equality comparisons in the @c Case + * subclass allows us to avoid performing interpretive + * extraction of the value from the @c Any returned from the + * "right hand side" operand @c TypeCode since the @c Case + * subclass already knows what type and value should be + * extracted from the @c Any. + * + * @param index Member index of given @c TypeCode @a tc being + * tested. + * @param tc The @c TypeCode whose member "@a index" label is + * being tested. + */ + virtual bool equal_label (CORBA::ULong index, + CORBA::TypeCode_ptr tc + ACE_ENV_ARG_DECL) const = 0; + + private: + + /// The name of the case. + STRING_TYPE const name_; + + /// Pointer to the @c CORBA::TypeCode of the case. + /** + * A pointer to the @c CORBA::TypeCode_ptr rather than the + * @c CORBA::TypeCode_ptr itself is stored since that address is + * well-defined. We may not know the value of the @c + * CORBA::TypeCode_ptr when creating this @c Case statically at + * compile-time, hence the indirection. + * + * @note This @c TypeCode is released upon destruction of this + * @c Case. + */ + CORBA::TypeCode_ptr * const type_; + + }; + + } // End namespace TypeCode +} // End namespace TAO + + +#ifdef __ACE_INLINE__ +# include "tao/TypeCode_Case.inl" +#endif /* __ACE_INLINE__ */ + +#ifdef ACE_TEMPLATES_REQUIRE_SOURCE +# include "tao/TypeCode_Case.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#ifdef ACE_TEMPLATES_REQUIRE_PRAGMA +# pragma implementation ("TypeCode_Case.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#include /**/ "ace/post.h" + +#endif /* TAO_TYPECODE_CASE_H */ |