00001 // -*- C++ -*- 00002 00003 //============================================================================= 00004 /** 00005 * @file CDR_Encaps_Codec.h 00006 * 00007 * $Id: CDR_Encaps_Codec.h 81429 2008-04-24 18:49:54Z johnnyw $ 00008 * 00009 * @author Ossama Othman <ossama@uci.edu> 00010 */ 00011 //============================================================================= 00012 00013 #ifndef TAO_CDR_ENCAPS_CODEC_H 00014 #define TAO_CDR_ENCAPS_CODEC_H 00015 00016 #include /**/ "ace/pre.h" 00017 00018 #include "tao/CodecFactory/IOP_Codec_includeC.h" 00019 00020 #if !defined (ACE_LACKS_PRAGMA_ONCE) 00021 # pragma once 00022 #endif /* ACE_LACKS_PRAGMA_ONCE */ 00023 00024 #include "tao/LocalObject.h" 00025 00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL 00027 00028 class TAO_Codeset_Translator_Base; 00029 00030 /** 00031 * @class TAO_CDR_Encaps_Codec 00032 * 00033 * @brief Implementation of a CDR encapsulation coder/decoder 00034 * (Codec). 00035 * 00036 * This coder/decoder (Codec) class encodes and decodes data to and 00037 * from a CDR encapsulation, respectively. It is useful for creation 00038 * of octet sequences that contain CDR encapsulations. Those octet 00039 * sequences can then be placed in a IOP::ServiceContext or an 00040 * IOP::TaggedComponent, for example. 00041 * 00042 * @note This Codec should not be used for operations internal to the 00043 * ORB core since it uses interpretive marshaling rather than compiled 00044 * marshaling. 00045 */ 00046 class TAO_CDR_Encaps_Codec 00047 : public virtual IOP::Codec, 00048 public virtual ::CORBA::LocalObject 00049 { 00050 public: 00051 00052 /// Constructor. 00053 TAO_CDR_Encaps_Codec (CORBA::Octet major, 00054 CORBA::Octet minor, 00055 TAO_ORB_Core * orb_core, 00056 TAO_Codeset_Translator_Base * char_trans, 00057 TAO_Codeset_Translator_Base * wchar_trans); 00058 00059 /// Encode the given data, including the TypeCode, into an octet 00060 /// sequence. 00061 virtual CORBA::OctetSeq * encode (const CORBA::Any & data); 00062 00063 /// Extract the TypeCode and the value from the octet sequence and 00064 /// place them into an Any. 00065 virtual CORBA::Any * decode (const CORBA::OctetSeq & data); 00066 00067 /// Encode the given data, excluding the TypeCode, into an octet 00068 /// sequence. 00069 virtual CORBA::OctetSeq * encode_value (const CORBA::Any & data); 00070 00071 /// Extract the value from the octet sequence, based on the given 00072 /// TypeCode, and place it into an Any. 00073 virtual CORBA::Any * decode_value (const CORBA::OctetSeq & data, 00074 CORBA::TypeCode_ptr tc); 00075 00076 protected: 00077 00078 /// Destructor. 00079 /** 00080 * Only allow this class to be instantiated on the heap since it is 00081 * reference counted. 00082 */ 00083 virtual ~TAO_CDR_Encaps_Codec (void); 00084 00085 /// Verify that it is possible to encode the given data using this 00086 /// Codec. 00087 /** 00088 * Typical reasons for failure include attempting to encode a type 00089 * that isn't supported for the version of GIOP associated with this 00090 * Codec. 00091 */ 00092 void check_type_for_encoding (const CORBA::Any & data); 00093 00094 private: 00095 00096 /// Prevent copying through the copy constructor and the assignment 00097 /// operator. 00098 TAO_CDR_Encaps_Codec (const TAO_CDR_Encaps_Codec &); 00099 void operator= (const TAO_CDR_Encaps_Codec &); 00100 00101 private: 00102 00103 /// The major GIOP version associated with this Codec. 00104 CORBA::Octet const major_; 00105 00106 /// The minor GIOP version associated with this Codec. 00107 CORBA::Octet const minor_; 00108 00109 /// The ORB Core to be used when decoding values from a CDR 00110 /// encapsulation. 00111 TAO_ORB_Core * const orb_core_; 00112 00113 /// Char codeset translator 00114 TAO_Codeset_Translator_Base * char_translator_; 00115 00116 /// WChar codeset translator 00117 TAO_Codeset_Translator_Base * wchar_translator_; 00118 }; 00119 00120 TAO_END_VERSIONED_NAMESPACE_DECL 00121 00122 #include /**/ "ace/post.h" 00123 00124 #endif /* TAO_CDR_ENCAPS_CODEC_H */