Revert "Minor modernization of DynamicAny code"
[ACE_TAO.git] / TAO / tao / CodecFactory / CDR_Encaps_Codec.h
blob5fb55923d4388e66ad46113900af79af78437af2
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file CDR_Encaps_Codec.h
7 * @author Ossama Othman <ossama@uci.edu>
8 */
9 //=============================================================================
11 #ifndef TAO_CDR_ENCAPS_CODEC_H
12 #define TAO_CDR_ENCAPS_CODEC_H
14 #include /**/ "ace/pre.h"
16 #include "tao/CodecFactory/IOP_Codec_includeC.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "tao/LocalObject.h"
24 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
26 class TAO_Codeset_Translator_Base;
28 /**
29 * @class TAO_CDR_Encaps_Codec
31 * @brief Implementation of a CDR encapsulation coder/decoder
32 * (Codec).
34 * This coder/decoder (Codec) class encodes and decodes data to and
35 * from a CDR encapsulation, respectively. It is useful for creation
36 * of octet sequences that contain CDR encapsulations. Those octet
37 * sequences can then be placed in a IOP::ServiceContext or an
38 * IOP::TaggedComponent, for example.
40 * @note This Codec should not be used for operations internal to the
41 * ORB core since it uses interpretive marshaling rather than compiled
42 * marshaling.
44 class TAO_CDR_Encaps_Codec
45 : public virtual IOP::Codec,
46 public virtual ::CORBA::LocalObject
48 public:
49 /// Constructor.
50 TAO_CDR_Encaps_Codec (CORBA::Octet major,
51 CORBA::Octet minor,
52 TAO_ORB_Core * orb_core,
53 TAO_Codeset_Translator_Base * char_trans,
54 TAO_Codeset_Translator_Base * wchar_trans);
56 /// Encode the given data, including the TypeCode, into an octet
57 /// sequence.
58 virtual CORBA::OctetSeq * encode (const CORBA::Any & data);
60 /// Extract the TypeCode and the value from the octet sequence and
61 /// place them into an Any.
62 virtual CORBA::Any * decode (const CORBA::OctetSeq & data);
64 /// Encode the given data, excluding the TypeCode, into an octet
65 /// sequence.
66 virtual CORBA::OctetSeq * encode_value (const CORBA::Any & data);
68 /// Extract the value from the octet sequence, based on the given
69 /// TypeCode, and place it into an Any.
70 virtual CORBA::Any * decode_value (const CORBA::OctetSeq & data,
71 CORBA::TypeCode_ptr tc);
73 protected:
74 /// Destructor.
75 /**
76 * Only allow this class to be instantiated on the heap since it is
77 * reference counted.
79 virtual ~TAO_CDR_Encaps_Codec ();
81 /// Verify that it is possible to encode the given data using this
82 /// Codec.
83 /**
84 * Typical reasons for failure include attempting to encode a type
85 * that isn't supported for the version of GIOP associated with this
86 * Codec.
88 void check_type_for_encoding (const CORBA::Any & data);
90 private:
91 TAO_CDR_Encaps_Codec (const TAO_CDR_Encaps_Codec &) = delete;
92 void operator= (const TAO_CDR_Encaps_Codec &) = delete;
94 private:
95 /// The major GIOP version associated with this Codec.
96 CORBA::Octet const major_;
98 /// The minor GIOP version associated with this Codec.
99 CORBA::Octet const minor_;
101 /// The ORB Core to be used when decoding values from a CDR
102 /// encapsulation.
103 TAO_ORB_Core * const orb_core_;
105 /// Char codeset translator
106 TAO_Codeset_Translator_Base * char_translator_;
108 /// WChar codeset translator
109 TAO_Codeset_Translator_Base * wchar_translator_;
112 TAO_END_VERSIONED_NAMESPACE_DECL
114 #include /**/ "ace/post.h"
116 #endif /* TAO_CDR_ENCAPS_CODEC_H */