Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

CodecFactory.cpp

Go to the documentation of this file.
00001 #include "tao_pch.h"
00002 // -*- C++ -*-
00003 //
00004 // $Id: CodecFactory.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $
00005 
00006 #include "CodecFactory.h"
00007 #include "CDR_Encaps_Codec.h"
00008 
00009 ACE_RCSID (TAO_CodecFactory,
00010            CodecFactory,
00011            "$Id: CodecFactory.cpp,v 1.1.1.2.2.1 2003/03/14 16:05:12 chad Exp $")
00012 
00013 TAO_CodecFactory::TAO_CodecFactory (TAO_ORB_Core * orb_core)
00014   : orb_core_ (orb_core)
00015 {
00016 }
00017 
00018 IOP::Codec_ptr
00019 TAO_CodecFactory::create_codec (const IOP::Encoding & enc
00020                                 ACE_ENV_ARG_DECL)
00021   ACE_THROW_SPEC ((CORBA::SystemException,
00022                    IOP::CodecFactory::UnknownEncoding))
00023 {
00024   // @todo: Ideally we should have some sort of CodecFactory
00025   //        registry to make it possible to add factories
00026   //        dynamically.  However, there currently isn't a need to
00027   //        support anything other than CDR encapsulations yet so we
00028   //        hardcode its Codec.  This may change once TAO starts to
00029   //        support messaging formats other than GIOP.
00030 
00031   IOP::Codec_ptr codec = IOP::Codec::_nil ();
00032 
00033   switch (enc.format)
00034     {
00035 
00036       // @@ MSVC 6 gets confused and thinks that
00037       //    IOP::ENCODING_CDR_ENCAPS is not a constant, so its actual
00038       //    value (0) is used instead.
00039     case 0 /* IOP::ENCODING_CDR_ENCAPS */:
00040       if (enc.major_version < 1)
00041         {
00042           // There is no such thing as a "0.x" CDR encapsulation.
00043           ACE_THROW_RETURN (CORBA::BAD_PARAM (
00044                               CORBA_SystemException::_tao_minor_code (
00045                                 TAO_DEFAULT_MINOR_CODE,
00046                                 EINVAL),
00047                               CORBA::COMPLETED_NO),
00048                             IOP::Codec::_nil ());
00049         }
00050 
00051       ACE_NEW_THROW_EX (codec,
00052                         TAO_CDR_Encaps_Codec (enc.major_version,
00053                                               enc.minor_version,
00054                                               this->orb_core_),
00055                         CORBA::NO_MEMORY (
00056                           CORBA_SystemException::_tao_minor_code (
00057                             TAO_DEFAULT_MINOR_CODE,
00058                             ENOMEM),
00059                           CORBA::COMPLETED_MAYBE));
00060       ACE_CHECK_RETURN (IOP::Codec::_nil ());
00061       break;
00062 
00063     default:
00064       ACE_THROW_RETURN (IOP::CodecFactory::UnknownEncoding (),
00065                         IOP::Codec::_nil ());
00066 
00067     }
00068 
00069   return codec;
00070 }

Generated on Mon Jun 16 13:48:04 2003 for TAO by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002