00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file TypeCode_Case_T.h 00006 * 00007 * $Id: TypeCode_Case_T.h 76551 2007-01-24 13:42:44Z johnnyw $ 00008 * 00009 * Header file for @c TAO::TypeCode::Case_T template. 00010 * 00011 * @author Ossama Othman 00012 */ 00013 //============================================================================= 00014 00015 #ifndef TAO_TYPECODE_CASE_T_H 00016 #define TAO_TYPECODE_CASE_T_H 00017 00018 #include /**/ "ace/pre.h" 00019 00020 #include "ace/config-all.h" 00021 00022 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00023 # pragma once 00024 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00025 00026 #include "tao/AnyTypeCode/TypeCode_Case_Base_T.h" 00027 00028 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00029 00030 namespace TAO 00031 { 00032 namespace TypeCode 00033 { 00034 /** 00035 * @class Case_T 00036 * 00037 * @brief Representation of an OMG IDL defined @c union @c case. 00038 * 00039 * A @c Case_T contains the corresponding case label value, name and 00040 * pointer to the @c CORBA::TypeCode for a given OMG IDL @c union 00041 * @c case. For 00042 * example, the cases in following OMG IDL @c union: 00043 * 00044 * \code 00045 * union Foo switch (short) 00046 * { 00047 * case 0: 00048 * case 1: short a; 00049 * case 2: long b; 00050 * default: octet c; 00051 * }; 00052 * \endcode 00053 * 00054 * would be represented using the following statically instantiated 00055 * @c TAO::TypeCode::Case_T array: 00056 * 00057 * \code 00058 * typedef TAO::TypeCode::Case_T<CORBA::Short, char const *> Foo_Case; 00059 * Foo_Case _tao_cases_Foo[] = 00060 * { 00061 * Foo_Case (0, "a", &CORBA::_tc_short), 00062 * Foo_Case (1, "a", &CORBA::_tc_short), 00063 * Foo_Case (2, "b", &CORBA::_tc_long), 00064 * Foo_Case (0, "c", &CORBA::_tc_octet) 00065 * }; 00066 * \endcode 00067 * 00068 * The @c default index is passed directly to the 00069 * @c TAO::TypeCode::Union constructor. 00070 * 00071 * The template parameter @a DISCRIMINATOR_TYPE is the 00072 * corresponding C++ type for the IDL defined @c union 00073 * discriminator type. For example, a @c union with an IDL @c 00074 * short discriminator will have a corresponding @c CORBA::Short 00075 * C++ type. This template parameter is necessary to allow the 00076 * actual @c case label value to be stored as its actual type, 00077 * which is particularly important when marshaling that value into 00078 * a CDR stream. 00079 * 00080 * The template parameter @a StringType is either @c char @c 00081 * const @c * or @c CORBA::String_var. The latter is only used 00082 * when creating @c CORBA::tk_union @c TypeCode dynamically, such 00083 * as through the TypeCodeFactory. 00084 */ 00085 template <typename DiscriminatorType, 00086 typename StringType, 00087 typename TypeCodeType> 00088 class Case_T : public Case<StringType, TypeCodeType> 00089 { 00090 public: 00091 00092 /// Constructor. 00093 Case_T (DiscriminatorType member_label, 00094 char const * member_name, 00095 TypeCodeType member_type); 00096 00097 /// Constructor. 00098 /** 00099 * Constructor only used in the dynamically constructed @c union 00100 * @c TypeCode case. 00101 */ 00102 Case_T (DiscriminatorType member_label); 00103 00104 /** 00105 * @name @c TAO::TypeCode::Case Methods 00106 * 00107 * Methods required by the @c TAO::TypeCode::Case abstract base 00108 * class. 00109 * 00110 * @see @c TAO::TypeCode::Case 00111 */ 00112 //@{ 00113 Case<StringType, TypeCodeType> * clone (void) const; 00114 virtual CORBA::Any * label (void) const; 00115 virtual bool marshal_label (TAO_OutputCDR & cdr) const; 00116 virtual bool equal_label (CORBA::ULong index, 00117 CORBA::TypeCode_ptr tc 00118 ) const; 00119 //@} 00120 00121 private: 00122 00123 /// IDL @c union case/member label value. 00124 DiscriminatorType const label_; 00125 00126 }; 00127 00128 } // End namespace TypeCode 00129 } // End namespace TAO 00130 00131 TAO_END_VERSIONED_NAMESPACE_DECL 00132 00133 #ifdef __ACE_INLINE__ 00134 # include "tao/AnyTypeCode/TypeCode_Case_T.inl" 00135 #endif /* __ACE_INLINE__ */ 00136 00137 #ifdef ACE_TEMPLATES_REQUIRE_SOURCE 00138 # include "tao/AnyTypeCode/TypeCode_Case_T.cpp" 00139 #endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ 00140 00141 #ifdef ACE_TEMPLATES_REQUIRE_PRAGMA 00142 # pragma implementation ("TypeCode_Case_T.cpp") 00143 #endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ 00144 00145 #include /**/ "ace/post.h" 00146 00147 #endif /* TAO_TYPECODE_CASE_T_H */