Public Member Functions | Private Member Functions | Private Attributes

TAO_CodecFactory Class Reference

Implementation of the IOP::CodecFactory interface. More...

#include <CodecFactory_impl.h>

Inheritance diagram for TAO_CodecFactory:
Inheritance graph
[legend]
Collaboration diagram for TAO_CodecFactory:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_CodecFactory (TAO_ORB_Core *orb_core)
 Constructor.
virtual IOP::Codec_ptr create_codec (const IOP::Encoding &enc)
 Create a Coder/Decoder for the given type of encoding.
virtual IOP::Codec_ptr create_codec_with_codesets (const IOP::Encoding_1_2 &enc)
 Create a Coder/Decoder for the given type of encoding and codesets.

Private Member Functions

 TAO_CodecFactory (const TAO_CodecFactory &)
void operator= (const TAO_CodecFactory &)
IOP::Codec_ptr create_codec_i (CORBA::Octet major, CORBA::Octet minor, IOP::EncodingFormat encoding_format, TAO_Codeset_Translator_Base *char_trans, TAO_Codeset_Translator_Base *wchar_trans)

Private Attributes

TAO_ORB_Core *const orb_core_
 Pointer to the ORB Core.

Detailed Description

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.

Definition at line 45 of file CodecFactory_impl.h.


Constructor & Destructor Documentation

TAO_CodecFactory::TAO_CodecFactory ( TAO_ORB_Core orb_core  ) 

Constructor.

Definition at line 20 of file CodecFactory_impl.cpp.

  : orb_core_ (orb_core)
{
}

TAO_CodecFactory::TAO_CodecFactory ( const TAO_CodecFactory  )  [private]

Prevent copying through the copy constructor and the assignment operator.


Member Function Documentation

IOP::Codec_ptr TAO_CodecFactory::create_codec ( const IOP::Encoding &  enc  )  [virtual]

Create a Coder/Decoder for the given type of encoding.

Definition at line 68 of file CodecFactory_impl.cpp.

{
  return this->create_codec_i (enc.major_version,
                               enc.minor_version,
                               enc.format,
                               0,
                               0);
}

IOP::Codec_ptr TAO_CodecFactory::create_codec_i ( CORBA::Octet  major,
CORBA::Octet  minor,
IOP::EncodingFormat  encoding_format,
TAO_Codeset_Translator_Base char_trans,
TAO_Codeset_Translator_Base wchar_trans 
) [private]

Definition at line 78 of file CodecFactory_impl.cpp.

{
  // @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 (encoding_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 (major < 1)
        {
          // There is no such thing as a "0.x" CDR encapsulation.
          throw ::CORBA::BAD_PARAM (
            CORBA::SystemException::_tao_minor_code (
              0,
              EINVAL),
            CORBA::COMPLETED_NO);
        }

      ACE_NEW_THROW_EX (codec,
                        TAO_CDR_Encaps_Codec (major,
                                              minor,
                                              this->orb_core_,
                                              char_trans,
                                              wchar_trans),
                        CORBA::NO_MEMORY (
                          CORBA::SystemException::_tao_minor_code (
                            0,
                            ENOMEM),
                          CORBA::COMPLETED_MAYBE));
      break;

    default:
      throw IOP::CodecFactory::UnknownEncoding ();

    }

  return codec;
}

IOP::Codec_ptr TAO_CodecFactory::create_codec_with_codesets ( const IOP::Encoding_1_2 &  enc  )  [virtual]

Create a Coder/Decoder for the given type of encoding and codesets.

Definition at line 26 of file CodecFactory_impl.cpp.

{
  TAO_Codeset_Translator_Base *char_trans = 0;
  TAO_Codeset_Translator_Base *wchar_trans = 0;
  CONV_FRAME::CodeSetId ncsc;
  CONV_FRAME::CodeSetId ncsw;

  TAO_Codeset_Manager *csm = this->orb_core_->codeset_manager ();

  if (csm)
    {
      char_trans = csm->get_char_trans (enc.char_codeset);
      wchar_trans = csm->get_wchar_trans (enc.wchar_codeset);
      csm->get_ncs (ncsc,ncsw); // pass by reference
    }
  else
    {
      // No codeset manager, so also raise an unsupported codeset
      throw IOP::CodecFactory::UnsupportedCodeset (enc.wchar_codeset);
    }

  if (wchar_trans == 0 &&
      enc.wchar_codeset != ACE_CODESET_ID_ISO_UTF_16 &&
      enc.wchar_codeset != ncsw)
    {
      throw IOP::CodecFactory::UnsupportedCodeset (enc.wchar_codeset);
    }

  if (char_trans == 0 &&
      enc.char_codeset != ncsc)
    {
      throw IOP::CodecFactory::UnsupportedCodeset (enc.char_codeset);
    }

  return this->create_codec_i (enc.major_version,
                               enc.minor_version,
                               enc.format,
                               char_trans,
                               wchar_trans);
}

void TAO_CodecFactory::operator= ( const TAO_CodecFactory  )  [private]

Member Data Documentation

Pointer to the ORB Core.

Some Codec implementations may need access to the ORB Core with which they are associated.

Reimplemented from CORBA::Object.

Definition at line 78 of file CodecFactory_impl.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines