summaryrefslogtreecommitdiff
path: root/TAO/tao/CodecFactory
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2005-06-10 10:21:12 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2005-06-10 10:21:12 +0000
commit2a52c550e3e569af4e1e2bad3f1726679d91270a (patch)
tree030d1d711ada3a07e17a5623c5cb8f2aa179678b /TAO/tao/CodecFactory
parent940ab4dba0771b0fec126fc330ad8d8989dcd904 (diff)
downloadATCD-2a52c550e3e569af4e1e2bad3f1726679d91270a.tar.gz
ChangeLogTag: Thu Jun 9 18:49:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'TAO/tao/CodecFactory')
-rw-r--r--TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp325
-rw-r--r--TAO/tao/CodecFactory/CDR_Encaps_Codec.h127
-rw-r--r--TAO/tao/CodecFactory/CodecFactory.cpp51
-rw-r--r--TAO/tao/CodecFactory/CodecFactory.h63
-rw-r--r--TAO/tao/CodecFactory/CodecFactory_impl.cpp71
-rw-r--r--TAO/tao/CodecFactory/CodecFactory_impl.h82
-rw-r--r--TAO/tao/CodecFactory/TAO_CodecFactory.pc.in11
-rw-r--r--TAO/tao/CodecFactory/TAO_CodecFactory.rc30
-rw-r--r--TAO/tao/CodecFactory/codecfactory_export.h40
9 files changed, 800 insertions, 0 deletions
diff --git a/TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp b/TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp
new file mode 100644
index 00000000000..35905f4fbe5
--- /dev/null
+++ b/TAO/tao/CodecFactory/CDR_Encaps_Codec.cpp
@@ -0,0 +1,325 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "CDR_Encaps_Codec.h"
+
+#include "tao/CDR.h"
+#include "tao/OctetSeqC.h"
+#include "tao/Any.h"
+#include "tao/Any_Impl.h"
+#include "tao/TypeCode.h"
+#include "tao/Marshal.h"
+#include "tao/Any_Unknown_IDL_Type.h"
+#include "tao/SystemException.h"
+#include "tao/ORB_Constants.h"
+#include "tao/TypeCode_Constants.h"
+
+#include "ace/Auto_Ptr.h"
+#include "ace/OS_NS_string.h"
+
+
+ACE_RCSID (tao,
+ CDR_Encaps_Codec,
+ "$Id$")
+
+
+TAO_CDR_Encaps_Codec::TAO_CDR_Encaps_Codec (CORBA::Octet major,
+ CORBA::Octet minor,
+ TAO_ORB_Core * orb_core)
+ : major_ (major),
+ minor_ (minor),
+ orb_core_ (orb_core)
+{
+}
+
+TAO_CDR_Encaps_Codec::~TAO_CDR_Encaps_Codec (void)
+{
+}
+
+CORBA::OctetSeq *
+TAO_CDR_Encaps_Codec::encode (const CORBA::Any & data
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::InvalidTypeForEncoding))
+{
+ this->check_type_for_encoding (data
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ // ----------------------------------------------------------------
+
+ TAO_OutputCDR cdr ((size_t) 0, // size
+ (int) TAO_ENCAP_BYTE_ORDER,
+ (ACE_Allocator *) 0, // buffer_allocator
+ (ACE_Allocator *) 0, // data_block_allocator
+ (ACE_Allocator *) 0, // message_block_allocator
+ 0, // memcpy_tradeoff
+ this->major_,
+ this->minor_);
+
+ if ((cdr << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER))
+ && (cdr << data))
+ {
+ CORBA::OctetSeq * octet_seq = 0;
+
+ ACE_NEW_THROW_EX (octet_seq,
+ CORBA::OctetSeq,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK_RETURN (0);
+
+ CORBA::OctetSeq_var safe_octet_seq = octet_seq;
+
+ octet_seq->length (static_cast<CORBA::ULong> (cdr.total_length ()));
+ CORBA::Octet *buf = octet_seq->get_buffer ();
+
+ for (const ACE_Message_Block *i = cdr.begin ();
+ i != 0;
+ i = i->cont ())
+ {
+ size_t len = i->length ();
+ ACE_OS::memcpy (buf, i->rd_ptr (), len);
+ buf += len;
+ }
+
+ return safe_octet_seq._retn ();
+ }
+
+ ACE_THROW_RETURN (CORBA::MARSHAL (), 0);
+}
+
+CORBA::Any *
+TAO_CDR_Encaps_Codec::decode (const CORBA::OctetSeq & data
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::FormatMismatch))
+{
+ // @todo How do we check for a format mismatch so that we can throw
+ // a IOP::Codec::FormatMismatch exception?
+ // @todo Is this the best way to extract the Any from the OctetSeq?
+
+ // Notice that we need to extract the TypeCode and the value from
+ // the octet sequence, and place them into the Any. We can't just
+ // insert the octet sequence into the Any.
+
+ ACE_Message_Block mb (data.length () + 2 * ACE_CDR::MAX_ALIGNMENT);
+ ACE_CDR::mb_align (&mb);
+
+ ACE_OS::memcpy (mb.rd_ptr (), data.get_buffer (), data.length ());
+
+ size_t rd_pos = mb.rd_ptr () - mb.base ();
+ size_t wr_pos = mb.wr_ptr () - mb.base () + data.length ();
+
+ TAO_InputCDR cdr (mb.data_block (),
+ ACE_Message_Block::DONT_DELETE,
+ rd_pos,
+ wr_pos,
+ ACE_CDR_BYTE_ORDER,
+ this->major_,
+ this->minor_,
+ this->orb_core_);
+
+ CORBA::Boolean byte_order;
+ if (cdr >> TAO_InputCDR::to_boolean (byte_order))
+ {
+ cdr.reset_byte_order (static_cast<int> (byte_order));
+
+ CORBA::Any * any = 0;
+ ACE_NEW_THROW_EX (any,
+ CORBA::Any,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ ACE_CHECK_RETURN (0);
+
+ CORBA::Any_var safe_any = any;
+
+ if (cdr >> (*any))
+ return safe_any._retn ();
+ }
+
+ ACE_THROW_RETURN (IOP::Codec::FormatMismatch (),
+ 0);
+}
+
+CORBA::OctetSeq *
+TAO_CDR_Encaps_Codec::encode_value (const CORBA::Any & data
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::InvalidTypeForEncoding))
+{
+ this->check_type_for_encoding (data
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ // ----------------------------------------------------------------
+ TAO_OutputCDR cdr ((size_t) 0, // size
+ (int) TAO_ENCAP_BYTE_ORDER,
+ (ACE_Allocator *) 0, // buffer_allocator
+ (ACE_Allocator *) 0, // data_block_allocator
+ (ACE_Allocator *) 0, // message_block_allocator
+ 0, // memcpy_tradeoff
+ this->major_,
+ this->minor_);
+
+ if ((cdr << TAO_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER)))
+ {
+ TAO::Any_Impl *impl = data.impl ();
+
+ if (impl->encoded ())
+ {
+ TAO::Unknown_IDL_Type *unk =
+ dynamic_cast<TAO::Unknown_IDL_Type *> (impl);
+
+ // We don't want unk's rd_ptr to move, in case we are shared by
+ // another Any, so we use this to copy the state, not the buffer.
+ TAO_InputCDR for_reading (unk->_tao_get_cdr ());
+
+ TAO_Marshal_Object::perform_append (data._tao_get_typecode (),
+ &for_reading,
+ &cdr
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+ }
+ else
+ {
+ impl->marshal_value (cdr);
+ }
+
+ // TAO extension: replace the contents of the octet sequence with
+ // the CDR stream.
+ CORBA::OctetSeq * octet_seq = 0;
+
+ ACE_NEW_THROW_EX (octet_seq,
+ CORBA::OctetSeq,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ ENOMEM
+ ),
+ CORBA::COMPLETED_NO
+ ));
+ ACE_CHECK_RETURN (0);
+
+ CORBA::OctetSeq_var safe_octet_seq = octet_seq;
+
+ octet_seq->length (static_cast<CORBA::ULong> (cdr.total_length ()));
+ CORBA::Octet *buf = octet_seq->get_buffer ();
+
+ for (const ACE_Message_Block *i = cdr.begin ();
+ i != 0;
+ i = i->cont ())
+ {
+ size_t len = i->length ();
+ ACE_OS::memcpy (buf,
+ i->rd_ptr (),
+ len);
+ buf += len;
+ }
+
+ return safe_octet_seq._retn ();
+ }
+
+ ACE_THROW_RETURN (CORBA::MARSHAL (),
+ 0);
+}
+
+CORBA::Any *
+TAO_CDR_Encaps_Codec::decode_value (const CORBA::OctetSeq & data,
+ CORBA::TypeCode_ptr tc
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::FormatMismatch,
+ IOP::Codec::TypeMismatch))
+{
+ // The ACE_CDR::mb_align() call can shift the rd_ptr by up
+ // to ACE_CDR::MAX_ALIGNMENT-1 bytes. Similarly, the offset
+ // adjustment can move the rd_ptr by up to the same amount.
+ // We accommodate this by including
+ // 2 * ACE_CDR::MAX_ALIGNMENT bytes of additional space in
+ // the message block.
+ ACE_Message_Block mb (data.length () + 2 * ACE_CDR::MAX_ALIGNMENT);
+ ACE_CDR::mb_align (&mb);
+
+ ACE_OS::memcpy (mb.rd_ptr (),
+ data.get_buffer (),
+ data.length ());
+
+ // @todo How do we check for a type mismatch so that we can
+ // throw a IOP::Codec::TypeMismatch exception?
+ // @@ I added a check below. See the comment. I'm not sure
+ // if it is a valid check.
+ // -Ossama
+
+ // @todo Most of this code was copied from
+ // operator>> (TAO_InputCDR &cdr, CORBA::Any &x)
+ // in Any.cpp. Rather than copy the code, the code should be
+ // refactored to make it possible to use the given TypeCode
+ // rather than attempt to extract it from the CDR
+ // encapsulation.
+
+ size_t rd_pos = mb.rd_ptr () - mb.base ();
+ size_t wr_pos = mb.wr_ptr () - mb.base () + data.length ();
+
+ TAO_InputCDR cdr (mb.data_block (),
+ ACE_Message_Block::DONT_DELETE,
+ rd_pos,
+ wr_pos,
+ ACE_CDR_BYTE_ORDER,
+ this->major_,
+ this->minor_,
+ this->orb_core_);
+
+ CORBA::Boolean byte_order;
+
+ if (cdr >> TAO_InputCDR::to_boolean (byte_order))
+ {
+ cdr.reset_byte_order (static_cast<int> (byte_order));
+
+ CORBA::Any * any = 0;
+ ACE_NEW_THROW_EX (any,
+ CORBA::Any,
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ ENOMEM
+ ),
+ CORBA::COMPLETED_NO
+ ));
+ ACE_CHECK_RETURN (0);
+
+ CORBA::Any_var safe_any = any;
+
+ // Stick it into the Any.
+ TAO::Unknown_IDL_Type *unk = 0;
+ ACE_NEW_RETURN (unk,
+ TAO::Unknown_IDL_Type (tc, cdr),
+ 0);
+ any->replace (unk);
+ return safe_any._retn ();
+ }
+
+ ACE_THROW_RETURN (IOP::Codec::FormatMismatch (),
+ 0);
+}
+
+void
+TAO_CDR_Encaps_Codec::check_type_for_encoding (
+ const CORBA::Any & data
+ ACE_ENV_ARG_DECL
+ )
+{
+ // @@ TODO: Are there any other conditions we need to check?
+
+ CORBA::TypeCode_var typecode = data.type ();
+ if (this->major_ == 1
+ && this->minor_ == 0
+ && typecode->equivalent (CORBA::_tc_wstring ACE_ENV_ARG_PARAMETER))
+ ACE_THROW (IOP::Codec::InvalidTypeForEncoding ());
+}
diff --git a/TAO/tao/CodecFactory/CDR_Encaps_Codec.h b/TAO/tao/CodecFactory/CDR_Encaps_Codec.h
new file mode 100644
index 00000000000..617f57d299d
--- /dev/null
+++ b/TAO/tao/CodecFactory/CDR_Encaps_Codec.h
@@ -0,0 +1,127 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file CDR_Encaps_Codec.h
+ *
+ * $Id$
+ *
+ * @author Ossama Othman <ossama@uci.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_CDR_ENCAPS_CODEC_H
+#define TAO_CDR_ENCAPS_CODEC_H
+
+#include /**/ "ace/pre.h"
+
+#include "codecfactory_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/IOP_CodecC.h"
+#include "tao/LocalObject.h"
+
+/**
+ * @class TAO_CDR_Encaps_Codec
+ *
+ * @brief Implementation of a CDR encapsulation coder/decoder
+ * (Codec).
+ *
+ * This coder/decoder (Codec) class encodes and decodes data to and
+ * from a CDR encapsulation, respectively. It is useful for creation
+ * of octet sequences that contain CDR encapsulations. Those octet
+ * sequences can then be placed in a IOP::ServiceContext or an
+ * IOP::TaggedComponent, for example.
+ *
+ * @note This Codec should not be used for operations internal to the
+ * ORB core since it uses interpretive marshaling rather than compiled
+ * marshaling.
+ */
+class TAO_CodecFactory_Export TAO_CDR_Encaps_Codec
+ : public virtual IOP::Codec,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ /// Constructor.
+ TAO_CDR_Encaps_Codec (CORBA::Octet major,
+ CORBA::Octet minor,
+ TAO_ORB_Core * orb_core);
+
+ /// Encode the given data, including the TypeCode, into an octet
+ /// sequence.
+ virtual CORBA::OctetSeq * encode (const CORBA::Any & data
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::InvalidTypeForEncoding));
+
+ /// Extract the TypeCode and the value from the octet sequence and
+ /// place them into an Any.
+ virtual CORBA::Any * decode (const CORBA::OctetSeq & data
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::FormatMismatch));
+
+ /// Encode the given data, excluding the TypeCode, into an octet
+ /// sequence.
+ virtual CORBA::OctetSeq * encode_value (const CORBA::Any & data
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::InvalidTypeForEncoding));
+
+ /// Extract the value from the octet sequence, based on the given
+ /// TypeCode, and place it into an Any.
+ virtual CORBA::Any * decode_value (const CORBA::OctetSeq & data,
+ CORBA::TypeCode_ptr tc
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::Codec::FormatMismatch,
+ IOP::Codec::TypeMismatch));
+
+protected:
+
+ /// Destructor.
+ /**
+ * Only allow this class to be instantiated on the heap since it is
+ * reference counted.
+ */
+ ~TAO_CDR_Encaps_Codec (void);
+
+ /// Verify that it is possible to encode the given data using this
+ /// Codec.
+ /**
+ * Typical reasons for failure include attempting to encode a type
+ * that isn't supported for the version of GIOP associated with this
+ * Codec.
+ */
+ void check_type_for_encoding (const CORBA::Any & data
+ ACE_ENV_ARG_DECL);
+
+private:
+
+ /// Prevent copying through the copy constructor and the assignment
+ /// operator.
+ ACE_UNIMPLEMENTED_FUNC (
+ TAO_CDR_Encaps_Codec (const TAO_CDR_Encaps_Codec &))
+ ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_CDR_Encaps_Codec &))
+
+private:
+
+ /// The major GIOP version associated with this Codec.
+ CORBA::Octet major_;
+
+ /// The minor GIOP version associated with this Codec.
+ CORBA::Octet minor_;
+
+ /// The ORB Core to be used when decoding values from a CDR
+ /// encapsulation.
+ TAO_ORB_Core * orb_core_;
+
+};
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_CDR_ENCAPS_CODEC_H */
diff --git a/TAO/tao/CodecFactory/CodecFactory.cpp b/TAO/tao/CodecFactory/CodecFactory.cpp
new file mode 100644
index 00000000000..646a88b28a2
--- /dev/null
+++ b/TAO/tao/CodecFactory/CodecFactory.cpp
@@ -0,0 +1,51 @@
+/* -*- C++ -*- */
+
+// =================================================================
+/**
+ * @file CodecFactory.cpp
+ *
+ * $Id$
+ *
+ * @author Johnny Willemsen <jwillemsen@remedy.nl>
+ *
+ */
+// =================================================================
+
+#include "CodecFactory.h"
+#include "CodecFactory_impl.h"
+
+#include "tao/ORB.h"
+#include "tao/debug.h"
+
+ACE_RCSID (CodecFactory,
+ CodecFactory,
+ "$Id$")
+
+CORBA::Object_ptr
+TAO_CodecFactory_Loader::create_object (
+ CORBA::ORB_ptr orb,
+ int,
+ ACE_TCHAR *[]
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException))
+{
+ CORBA::Object_ptr obj = CORBA::Object::_nil ();
+ ACE_NEW_RETURN (obj,
+ TAO_CodecFactory (orb->orb_core ()),
+ CORBA::Object::_nil ());
+ return obj;
+}
+
+int
+TAO_CodecFactory_Loader::Initializer (void)
+{
+ return ACE_Service_Config::process_directive (ace_svc_desc_TAO_CodecFactory_Loader);
+}
+
+ACE_STATIC_SVC_DEFINE (TAO_CodecFactory_Loader,
+ ACE_TEXT ("CodecFactory_Loader"),
+ ACE_SVC_OBJ_T,
+ &ACE_SVC_NAME (TAO_CodecFactory_Loader),
+ ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
+ 0)
+ACE_FACTORY_DEFINE (TAO_CodecFactory, TAO_CodecFactory_Loader)
diff --git a/TAO/tao/CodecFactory/CodecFactory.h b/TAO/tao/CodecFactory/CodecFactory.h
new file mode 100644
index 00000000000..2961204afbb
--- /dev/null
+++ b/TAO/tao/CodecFactory/CodecFactory.h
@@ -0,0 +1,63 @@
+/* -*- C++ -*- */
+
+
+//=============================================================================
+/**
+ * @file CodecFactory.h
+ *
+ * $Id$
+ *
+ * @author Carlos O'Ryan <coryan@uci.edu>
+ */
+//=============================================================================
+
+
+#ifndef TAO_CODECFACTORY_H
+#define TAO_CODECFACTORY_H
+
+#include /**/ "ace/pre.h"
+
+#include "codecfactory_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/Object_Loader.h"
+#include "ace/Service_Config.h"
+
+class TAO_CodecFactory_Export TAO_CodecFactory_Loader
+ : public TAO_Object_Loader
+{
+public:
+ /// Creates a Codec factory and returns it.
+ virtual CORBA::Object_ptr create_object (CORBA::ORB_ptr orb,
+ int argc,
+ ACE_TCHAR *argv []
+ ACE_ENV_ARG_DECL_NOT_USED)
+ ACE_THROW_SPEC ((CORBA::SystemException));
+
+ /// Used to force the initialization of the ORB code.
+ static int Initializer (void);
+};
+
+ACE_STATIC_SVC_DECLARE (TAO_CodecFactory_Loader)
+ACE_FACTORY_DECLARE (TAO_CodecFactory, TAO_CodecFactory_Loader)
+
+#if defined(ACE_HAS_BROKEN_STATIC_CONSTRUCTORS)
+
+typedef int (*TAO_Module_Initializer) (void);
+
+static TAO_Module_Initializer
+TAO_Requires_CodecFactory_Initializer = &TAO_CodecFactory_Loader::Initializer;
+
+#else
+
+static int
+TAO_Requires_CodecFactory_Initializer = TAO_CodecFactory_Loader::Initializer ();
+
+#endif /* ACE_HAS_BROKEN_STATIC_CONSTRUCTORS */
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_CODECFACTORY_H */
diff --git a/TAO/tao/CodecFactory/CodecFactory_impl.cpp b/TAO/tao/CodecFactory/CodecFactory_impl.cpp
new file mode 100644
index 00000000000..0a83515a15b
--- /dev/null
+++ b/TAO/tao/CodecFactory/CodecFactory_impl.cpp
@@ -0,0 +1,71 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#include "CodecFactory_impl.h"
+#include "CDR_Encaps_Codec.h"
+#include "tao/SystemException.h"
+#include "tao/ORB_Constants.h"
+
+ACE_RCSID (TAO_CodecFactory,
+ CodecFactory,
+ "$Id$")
+
+TAO_CodecFactory::TAO_CodecFactory (TAO_ORB_Core * orb_core)
+ : orb_core_ (orb_core)
+{
+}
+
+IOP::Codec_ptr
+TAO_CodecFactory::create_codec (const IOP::Encoding & enc
+ ACE_ENV_ARG_DECL)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::CodecFactory::UnknownEncoding))
+{
+ // @todo: Ideally we should have some sort of CodecFactory
+ // registry to make it possible to add factories
+ // dynamically. However, there currently isn't a need to
+ // support anything other than CDR encapsulations yet so we
+ // hardcode its Codec. This may change once TAO starts to
+ // support messaging formats other than GIOP.
+
+ IOP::Codec_ptr codec = IOP::Codec::_nil ();
+
+ switch (enc.format)
+ {
+
+ // @@ MSVC 6 gets confused and thinks that
+ // IOP::ENCODING_CDR_ENCAPS is not a constant, so its actual
+ // value (0) is used instead.
+ case 0 /* IOP::ENCODING_CDR_ENCAPS */:
+ if (enc.major_version < 1)
+ {
+ // There is no such thing as a "0.x" CDR encapsulation.
+ ACE_THROW_RETURN (CORBA::BAD_PARAM (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ EINVAL),
+ CORBA::COMPLETED_NO),
+ IOP::Codec::_nil ());
+ }
+
+ ACE_NEW_THROW_EX (codec,
+ TAO_CDR_Encaps_Codec (enc.major_version,
+ enc.minor_version,
+ this->orb_core_),
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (
+ 0,
+ ENOMEM),
+ CORBA::COMPLETED_MAYBE));
+ ACE_CHECK_RETURN (IOP::Codec::_nil ());
+ break;
+
+ default:
+ ACE_THROW_RETURN (IOP::CodecFactory::UnknownEncoding (),
+ IOP::Codec::_nil ());
+
+ }
+
+ return codec;
+}
diff --git a/TAO/tao/CodecFactory/CodecFactory_impl.h b/TAO/tao/CodecFactory/CodecFactory_impl.h
new file mode 100644
index 00000000000..4c897358bda
--- /dev/null
+++ b/TAO/tao/CodecFactory/CodecFactory_impl.h
@@ -0,0 +1,82 @@
+// -*- C++ -*-
+
+//=============================================================================
+/**
+ * @file CodecFactory.h
+ *
+ * $Id$
+ *
+ * @author Ossama Othman <ossama@uci.edu>
+ */
+//=============================================================================
+
+#ifndef TAO_CODEC_FACTORY_IMPL_H
+#define TAO_CODEC_FACTORY_IMPL_H
+
+#include /**/ "ace/pre.h"
+
+#include "codecfactory_export.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#include "tao/LocalObject.h"
+#include "tao/IOP_CodecC.h"
+
+// This is to remove "inherits via dominance" warnings from MSVC.
+// MSVC is being a little too paranoid.
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:4250)
+#endif /* _MSC_VER */
+
+/**
+ * @class TAO_CodecFactory
+ *
+ * @brief Implementation of the IOP::CodecFactory interface.
+ *
+ * This class can be used to create Codec (coder/decoder) of a given
+ * type, such as a CDR encapsulation Codec.
+ */
+class TAO_CodecFactory_Export TAO_CodecFactory
+ : public virtual IOP::CodecFactory,
+ public virtual TAO_Local_RefCounted_Object
+{
+public:
+
+ /// Constructor
+ TAO_CodecFactory (TAO_ORB_Core * orb_core);
+
+ /// Create a Coder/Decoder for the given type of encoding.
+ virtual IOP::Codec_ptr create_codec (const IOP::Encoding & enc
+ ACE_ENV_ARG_DECL_WITH_DEFAULTS)
+ ACE_THROW_SPEC ((CORBA::SystemException,
+ IOP::CodecFactory::UnknownEncoding));
+
+private:
+
+ /// Prevent copying through the copy constructor and the assignment
+ /// operator.
+ ACE_UNIMPLEMENTED_FUNC (
+ TAO_CodecFactory (const TAO_CodecFactory &))
+ ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_CodecFactory &))
+
+private:
+
+ /// Pointer to the ORB Core.
+ /**
+ * Some Codec implementations may need access to the ORB Core with
+ * which they are associated.
+ */
+ TAO_ORB_Core * orb_core_;
+
+};
+
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif /* _MSC_VER */
+
+#include /**/ "ace/post.h"
+
+#endif /* TAO_CODEC_FACTORY_IMPL_H */
diff --git a/TAO/tao/CodecFactory/TAO_CodecFactory.pc.in b/TAO/tao/CodecFactory/TAO_CodecFactory.pc.in
new file mode 100644
index 00000000000..81a384f3838
--- /dev/null
+++ b/TAO/tao/CodecFactory/TAO_CodecFactory.pc.in
@@ -0,0 +1,11 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: TAO_CodecFactory
+Description: TAO CodecFactory Library
+Requires: TAO
+Version: @VERSION@
+Libs: -L${libdir} -lTAO_CodecFactory
+Cflags: -I${includedir}
diff --git a/TAO/tao/CodecFactory/TAO_CodecFactory.rc b/TAO/tao/CodecFactory/TAO_CodecFactory.rc
new file mode 100644
index 00000000000..a234c757563
--- /dev/null
+++ b/TAO/tao/CodecFactory/TAO_CodecFactory.rc
@@ -0,0 +1,30 @@
+#include "..\Version.h"
+
+1 VERSIONINFO
+ FILEVERSION TAO_MAJOR_VERSION,TAO_MINOR_VERSION,TAO_BETA_VERSION,0
+ PRODUCTVERSION TAO_MAJOR_VERSION,TAO_MINOR_VERSION,TAO_BETA_VERSION,0
+ FILEFLAGSMASK 0x3fL
+ FILEFLAGS 0x0L
+ FILEOS 0x4L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904B0"
+ BEGIN
+ VALUE "FileDescription", "CodecFactory\0"
+ VALUE "FileVersion", TAO_VERSION "\0"
+ VALUE "InternalName", "TAO_CodecFactoryDLL\0"
+ VALUE "LegalCopyright", "\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "TAO_CodecFactory.DLL\0"
+ VALUE "ProductName", "TAO\0"
+ VALUE "ProductVersion", TAO_VERSION "\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1200
+ END
+END
diff --git a/TAO/tao/CodecFactory/codecfactory_export.h b/TAO/tao/CodecFactory/codecfactory_export.h
new file mode 100644
index 00000000000..7c93ff47968
--- /dev/null
+++ b/TAO/tao/CodecFactory/codecfactory_export.h
@@ -0,0 +1,40 @@
+
+// -*- C++ -*-
+// $Id$
+// Definition for Win32 Export directives.
+// This file is generated automatically by generate_export_file.pl
+// ------------------------------
+#ifndef TAO_CODECFACTORY_EXPORT_H
+#define TAO_CODECFACTORY_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if defined (TAO_AS_STATIC_LIBS)
+# if !defined (TAO_CODECFACTORY_HAS_DLL)
+# define TAO_CODECFACTORY_HAS_DLL 0
+# endif /* ! TAO_CODECFACTORY_HAS_DLL */
+#else
+# if !defined (TAO_CODECFACTORY_HAS_DLL)
+# define TAO_CODECFACTORY_HAS_DLL 1
+# endif /* ! TAO_CODECFACTORY_HAS_DLL */
+#endif
+
+#if defined (TAO_CODECFACTORY_HAS_DLL) && (TAO_CODECFACTORY_HAS_DLL == 1)
+# if defined (TAO_CODECFACTORY_BUILD_DLL)
+# define TAO_CodecFactory_Export ACE_Proper_Export_Flag
+# define TAO_CODECFACTORY_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T)
+# define TAO_CODECFACTORY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# else /* TAO_CODECFACTORY_BUILD_DLL */
+# define TAO_CodecFactory_Export ACE_Proper_Import_Flag
+# define TAO_CODECFACTORY_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T)
+# define TAO_CODECFACTORY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+# endif /* TAO_CODECFACTORY_BUILD_DLL */
+#else /* TAO_CODECFACTORY_HAS_DLL == 1 */
+# define TAO_CodecFactory_Export
+# define TAO_CODECFACTORY_SINGLETON_DECLARATION(T)
+# define TAO_CODECFACTORY_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK)
+#endif /* TAO_CODECFACTORY_HAS_DLL == 1 */
+
+#endif /* TAO_CODECFACTORY_EXPORT_H */
+
+// End of auto generated file.