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

Codeset_Manager.h

Go to the documentation of this file.
00001 // This may look like C, but it's really -*- C++ -*-
00002 
00003 //=============================================================================
00004 /*
00005  *  @file Codeset_Manager.h
00006  *
00007  *  $Id: Codeset_Manager.h,v 1.1.8.1 2003/04/10 14:04:03 phil Exp $
00008  *
00009  *  Interface for the TAO CodeSet Manager.
00010  *
00011  *  @author  Mahesh Vedantam <mahesh#ociweb.com>
00012  */
00013 //=============================================================================
00014 
00015 #ifndef TAO_CODESET_MANAGER_H
00016 #define TAO_CODESET_MANAGER_H
00017 #include "ace/pre.h"
00018 
00019 #include "tao/CONV_FRAMEC.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 class TAO_Profile;
00026 class TAO_Transport;
00027 class TAO_Operation_Details;
00028 
00029 class TAO_ServerRequest;
00030 class TAO_Tagged_Components;
00031 class TAO_Codeset_Translator_Factory;
00032 class TAO_Codeset_Manager;
00033 
00034 // ****************************************************************
00035 
00036 /**
00037  * @class TAO_Codeset_Item
00038  *
00039  * @brief A single element in the list of Codeset Translator Factories
00040  *
00041  * This class is used by the Codeset_Manager to store references to
00042  * individual codeset factories. Only those translators that match the
00043  * char or wchar native codeset will be kept in the list.
00044  *
00045  */
00046 
00047 class TAO_Codeset_Item
00048 {
00049 public:
00050   friend class TAO_Codeset_Manager;
00051   /// creator method, the codeset name can only be set when the
00052   /// object is created.
00053   TAO_Codeset_Item (const char *name);
00054 
00055   /// destructor that deallocates the factory object if the
00056   /// CodeSet_Item retains ownership.
00057   ~TAO_Codeset_Item (void);
00058 
00059   /// return a reference to the character representation of the codeset
00060   /// factories name.
00061   const char *codeset_name (void);
00062 
00063   /// return a pointer to the codeset factory.
00064   TAO_Codeset_Translator_Factory *factory (void);
00065 
00066   /// set the factory pointer's value.
00067   void factory (TAO_Codeset_Translator_Factory *factory);
00068 
00069 private:
00070   // Prohibited
00071   ACE_UNIMPLEMENTED_FUNC (TAO_Codeset_Item (const TAO_Codeset_Item&))
00072   ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_Codeset_Item&))
00073 
00074 private:
00075   /// factory name.
00076   char *name_;
00077 
00078   /// pointer to factory object.
00079   TAO_Codeset_Translator_Factory *factory_;
00080 };
00081 
00082 // ****************************************************************
00083 
00084 /**
00085  * @class TAO_Codeset_Manager
00086  *
00087  * @brief The encapsulation of logic for codeset negotiation
00088  *
00089  * The Codeset Manager is owned by the ORB_Core, initialized through Resource
00090  * Factory configuration options. The codeset manager participates in profile
00091  * creation by servers and connection establishment by clients. The involvement
00092  * is necessary to supply a codeset component to the profile including for both
00093  * chars and wide chars the native code set and any conversion code sets for
00094  * which translators are available. The codeset manager is also responsible for
00095  * determining the transmission codesets based an the local and remote codeset
00096  * information. The transmission codesets are communicated via a service
00097  * context attached to the first request sent on the new connection.
00098  *
00099  */
00100 
00101 class TAO_Export TAO_Codeset_Manager
00102 {
00103 
00104 public:
00105   /// NCS for char is defaulted to ISO 8859-1:1987; Latin Alphabet No. 1
00106   static CONV_FRAME::CodeSetId default_char_codeset;
00107   /// NCS for wchar is defaulted to 0 (not used), but people wishing to
00108   /// provide a non-compliant default wchar codeset may do so.
00109   static CONV_FRAME::CodeSetId default_wchar_codeset;
00110 
00111   TAO_Codeset_Manager ();
00112   ~TAO_Codeset_Manager();
00113 
00114   ///  Called by an object of TAO_Acceptor to set NCS and CCS values for
00115   ///  Char/Wchar in to the Object Reference.
00116   void set_codeset (TAO_Tagged_Components& ) const;
00117   ///
00118   /// Called from an object of "TAO_GIOP_Invocation" to set TCS on the
00119   /// Transport
00120   void set_tcs (TAO_Profile &theProfile, TAO_Transport &);
00121 
00122   /// Called from an Object of TAO_Messaging for every request at server side
00123   /// to process service context and set TCS for Char/WChar
00124   void process_service_context (TAO_ServerRequest &);
00125 
00126   /// Called by a client object to generate service context
00127   /// at this time Transport has the TCS for Char and WChar
00128   void generate_service_context (TAO_Operation_Details&, TAO_Transport & );
00129 
00130 
00131   /// Called by the resource factory to set the native char codeset id
00132   void set_ncs_c (CONV_FRAME::CodeSetId ncs);
00133 
00134   /// Called by the resource factory to set the native wchar codeset id. The
00135   /// maxbytes value is used to communicate the width of untranslated wide
00136   /// characters on the stream. This size may be smaller than the size of a
00137   /// wchar_t.
00138   void set_ncs_w (CONV_FRAME::CodeSetId ncs, int maxbytes = 0);
00139 
00140   /// Called by the resource factory to add a potential codeset translator
00141   /// for char data. The actual factory will be added to the list later, if its
00142   /// ncs matches that of the codeset manager.
00143   int add_char_translator (const char *name);
00144 
00145   /// Called by the resource factory to add a potential codeset translator
00146   /// for wchar data. The actual factory will be added to the list later, if
00147   /// its ncs matches that of the codeset manager.
00148   int add_wchar_translator (const char *name);
00149 
00150   /// Called by the resource factory to signify the end of initialization.
00151   /// This will traverse the list of named codeset translator factories and add
00152   /// any of those that have a native codeset id matching the manager's native
00153   /// codeset id.
00154   void configure_codeset_factories();
00155 
00156 private:
00157 
00158 // typedefs for containers containing the list of codesets
00159 // factories for character and wide character.
00160 typedef ACE_Unbounded_Set<TAO_Codeset_Item*>
00161         TAO_CodesetFactorySet;
00162 
00163 // Iterators
00164 typedef ACE_Unbounded_Set_Iterator<TAO_Codeset_Item*>
00165         TAO_CodesetFactorySetItor;
00166 
00167 
00168 
00169   // Compute the TCS for Char/WChar asper the CORBA Specification
00170   CONV_FRAME::CodeSetId computeTCS (CONV_FRAME::CodeSetComponent &,
00171                                     CONV_FRAME::CodeSetComponent &);
00172 
00173   // Find CodesetId in the codeset component
00174   int isElementOf (CONV_FRAME::CodeSetId,
00175                    CONV_FRAME::CodeSetComponent & );
00176 
00177   // find the intersection of CodesetIds between Client and Server CCS
00178   CONV_FRAME::CodeSetId intersectionOf (CONV_FRAME::CodeSetComponent &,
00179                                         CONV_FRAME::CodeSetComponent &);
00180 
00181   // determine compatibility between two codesets via the codeset registry
00182   int isCompatible (CONV_FRAME::CodeSetId,  CONV_FRAME::CodeSetId);
00183 
00184   // traverse the list of codeset factories, populating the list of conversion
00185   // codeset values with the translated codeset id from each factory that has
00186   // a matching native codeset. Those factories that do not have a matching
00187   // codeset are not retained in the list.
00188   int init_codeset_factories_i (TAO_CodesetFactorySet&,
00189                                 CONV_FRAME::CodeSetComponent&);
00190 
00191   // get the translator between our ncs_c and the supplied tcs_c
00192   TAO_Codeset_Translator_Factory * get_char_trans (CONV_FRAME::CodeSetId);
00193 
00194   // get the translator between our ncs_w and the supplied tcs_w
00195   TAO_Codeset_Translator_Factory * get_wchar_trans (CONV_FRAME::CodeSetId);
00196 
00197   TAO_Codeset_Translator_Factory * get_translator_i (TAO_CodesetFactorySet&,
00198                                                      CONV_FRAME::CodeSetId);
00199 
00200   // The CodeSetComponentInfo struct contains all of the information regarding
00201   // the code sets this application recognizes. This is where the native code
00202   // set for both char and wchar are stored.
00203   CONV_FRAME::CodeSetComponentInfo codeset_info_;
00204 
00205   // The lists of available translators for both chars and wchars.
00206   TAO_CodesetFactorySet char_factories_;
00207   TAO_CodesetFactorySet wchar_factories_;
00208 };
00209 
00210 #include "ace/post.h"
00211 #endif /* TAO_CODESET_MANAGER_H */

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