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

default_resource.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   default_resource.h
00006  *
00007  *  $Id: default_resource.h,v 1.1.1.4.2.2 2003/04/21 19:10:25 chad Exp $
00008  *
00009  *  @author Chris Cleeland
00010  *  @author Carlos O'Ryan
00011  */
00012 //=============================================================================
00013 
00014 
00015 #ifndef TAO_DEFAULT_RESOURCE_H
00016 #define TAO_DEFAULT_RESOURCE_H
00017 #include "ace/pre.h"
00018 
00019 #include "tao/Resource_Factory.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "ace/Service_Config.h"
00026 #include "tao/CONV_FRAMEC.h"
00027 
00028 class TAO_Object_Adapter;
00029 class TAO_IOR_Parser;
00030 class TAO_LF_Strategy;
00031 
00032 /**
00033  * @class TAO_Default_Resource_Factory
00034  *
00035  * @brief TAO's default resource factory
00036  *
00037  * Using a <{resource source specifier}> as a discriminator, the
00038  * factory can return resource instances which are, e.g., global,
00039  * stored in thread-specific storage, stored in shared memory,
00040  * etc.
00041  *
00042  * @note When using an ORB created by a dynamically loaded object, it
00043  *       is generally necessary to pre-load a "Resource_Factory" prior
00044  *       to initializing the ORB.  In the case of the
00045  *       TAO_Default_Resource_Factory, this can be done by adding the
00046  *       following Service Configurator directive to your `svc.conf'
00047  *       file before your the directive that loads the object that
00048  *       initialized your ORB:
00049  * @par
00050  *           static Resource_Factory ""
00051  * @par
00052  *       Alternatively, explicitly pre-load the Resource_Factory using
00053  *       the following in your code:
00054  * @par
00055  *           ACE_Service_Config::process_directive (
00056  *             ACE_TEXT ("static Resource_Factory \"\"") );
00057  * @par
00058  *       In both cases, place the appropriate resource factory
00059  *       arguments, if any, between the quotes immediately following
00060  *       "Resource_Factory."
00061  */
00062 class TAO_Export TAO_Default_Resource_Factory
00063   : public TAO_Resource_Factory
00064 {
00065 public:
00066 
00067   /// Constructor.
00068   TAO_Default_Resource_Factory (void);
00069 
00070   /// Destructor.
00071   virtual ~TAO_Default_Resource_Factory (void);
00072 
00073   /**
00074    * @name Service Configurator Hooks
00075    */
00076   //@{
00077   /// Dynamic linking hook
00078   virtual int init (int argc, ACE_TCHAR *argv[]);
00079 
00080   /// Parse svc.conf arguments
00081   int parse_args (int argc, ACE_TCHAR* argv[]);
00082   //@}
00083 
00084   /**
00085    * @name Member Accessors
00086    */
00087   //@{
00088 
00089   int get_parser_names (char **&names,
00090                         int &number_of_names);
00091   enum
00092   {
00093     TAO_ALLOCATOR_THREAD_LOCK
00094   };
00095 
00096   // Translator type
00097   enum TRANSLATOR_TYPE
00098   {
00099     CHAR_TRANSLATOR,
00100     WCHAR_TRANSLATOR
00101   };
00102 
00103   /// Modify and get the source for the CDR allocators
00104   int cdr_allocator_source (void);
00105 
00106   // = Resource Retrieval
00107 #if 0
00108   // @@@todo: Need to go at a later date
00109   virtual int use_tss_resources (void) const;
00110 #endif /*if 0*/
00111   virtual int use_locked_data_blocks (void) const;
00112   virtual ACE_Reactor *get_reactor (void);
00113   virtual void reclaim_reactor (ACE_Reactor *);
00114   virtual TAO_Acceptor_Registry  *get_acceptor_registry (void);
00115   virtual TAO_Connector_Registry *get_connector_registry (void);
00116   virtual ACE_Allocator* input_cdr_dblock_allocator (void);
00117   virtual ACE_Allocator* input_cdr_buffer_allocator (void);
00118   virtual ACE_Allocator* input_cdr_msgblock_allocator (void);
00119   virtual int input_cdr_allocator_type_locked (void);
00120   virtual ACE_Allocator* output_cdr_dblock_allocator (void);
00121   virtual ACE_Allocator* output_cdr_buffer_allocator (void);
00122   virtual ACE_Allocator* output_cdr_msgblock_allocator (void);
00123   virtual TAO_ProtocolFactorySet *get_protocol_factories (void);
00124 
00125   virtual TAO_Codeset_Manager *get_codeset_manager ();
00126 
00127   virtual int init_protocol_factories (void);
00128 
00129   virtual int cache_maximum (void) const;
00130   virtual int purge_percentage (void) const;
00131   virtual int max_muxed_connections (void) const;
00132   virtual ACE_Lock *create_cached_connection_lock (void);
00133   virtual int locked_transport_cache (void);
00134   virtual TAO_Flushing_Strategy *create_flushing_strategy (void);
00135   virtual TAO_Connection_Purging_Strategy *create_purging_strategy (void);
00136   virtual TAO_LF_Strategy *create_lf_strategy (void);
00137 
00138   virtual void disable_factory (void);
00139   //@}
00140 
00141 protected:
00142 
00143   /// Obtain the reactor implementation
00144   virtual ACE_Reactor_Impl *allocate_reactor_impl (void) const;
00145 
00146   /// Add a Parser name to the list of Parser names.
00147   int add_to_ior_parser_names (const char *);
00148 
00149   void report_option_value_error (const ACE_TCHAR* option_name,
00150                                   const ACE_TCHAR* option_value);
00151 
00152 protected:
00153 
00154   /// The type of data blocks that the ORB should use
00155   int use_locked_data_blocks_;
00156 
00157   /// The number of the different types of Parsers.
00158   int parser_names_count_;
00159 
00160   /// Array consisting of the names of the parsers
00161   char **parser_names_;
00162 
00163   /// Index of the current element in the parser_names_ array
00164   int index_;
00165 
00166   /// list of loaded protocol factories.
00167   TAO_ProtocolFactorySet protocol_factories_;
00168 
00169   /// Specifies the typeof purging strategy we should use for cleaning
00170   /// up unused connections
00171   TAO_Resource_Factory::Purging_Strategy connection_purging_type_;
00172 
00173   /// Specifies the maximum number of connections which should get cached
00174   /// in the ORB.
00175   int cache_maximum_;
00176 
00177   /// Specifies the percentage of entries which should get purged on
00178   /// demand.
00179   int purge_percentage_;
00180 
00181   /// Specifies the limit on the number of muxed connections
00182   /// allowed per-property for the ORB. A value of 0 indicates no
00183   /// limit
00184   int max_muxed_connections_;
00185 
00186   /// If <0> then we create reactors with signal handling disabled.
00187   int reactor_mask_signals_;
00188 
00189   /**
00190    * Flag that is set to 1 if the reactor obtained from the
00191    * get_reactor() method is dynamically allocated.  If this flag is
00192    * set to 1, then the reclaim_reactor() method with call the delete
00193    * operator on the given reactor.  This flag is necessary to make
00194    * sure that a reactor not allocated by the default resource factory
00195    * is not reclaimed by the default resource factory.  Such a
00196    * situation can occur when a resource factory derived from the
00197    * default one overrides the get_reactor() method but does not
00198    * override the reclaim_reactor() method.
00199    */
00200   int dynamically_allocated_reactor_;
00201 
00202   virtual int load_default_protocols (void);
00203 
00204   /// This flag is used to determine whether options have been
00205   /// processed via the init() function.  It is necessary to
00206   /// properly report errors when the default factory is replaced.
00207   int options_processed_;
00208 
00209   /// This flag specifies whether the factory has been disabled.
00210   /// If it has been disabled we should print warnings if options
00211   /// were processed before (or later).
00212   int factory_disabled_;
00213 
00214 private:
00215   enum Lock_Type
00216   {
00217     TAO_NULL_LOCK,
00218     TAO_THREAD_LOCK
00219   };
00220 
00221   /// Type of lock used by the cached connector.
00222   Lock_Type cached_connection_lock_type_;
00223 
00224   enum Flushing_Strategy_Type
00225   {
00226     TAO_LEADER_FOLLOWER_FLUSHING,
00227     TAO_REACTIVE_FLUSHING,
00228     TAO_BLOCKING_FLUSHING
00229   };
00230 
00231   /// Type of flushing strategy configured
00232   int flushing_strategy_type_;
00233 
00234   TAO_Codeset_Manager *codeset_manager_;
00235 
00236 };
00237 
00238 #if defined (__ACE_INLINE__)
00239 #include "tao/default_resource.i"
00240 #endif /* __ACE_INLINE__ */
00241 
00242 ACE_STATIC_SVC_DECLARE_EXPORT (TAO, TAO_Default_Resource_Factory)
00243 ACE_FACTORY_DECLARE (TAO, TAO_Default_Resource_Factory)
00244 
00245 #include "ace/post.h"
00246 #endif /* TAO_DEFAULT_CLIENT_H */

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