Resource_Factory.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file   Resource_Factory.h
00006  *
00007  *  Resource_Factory.h,v 1.59 2006/04/20 12:37:17 jwillemsen Exp
00008  *
00009  *  @author Chris Cleeland
00010  *  @author Carlos O'Ryan
00011  */
00012 //=============================================================================
00013 
00014 #ifndef TAO_RESOURCE_FACTORY_H
00015 #define TAO_RESOURCE_FACTORY_H
00016 
00017 #include /**/ "ace/pre.h"
00018 
00019 #include "tao/TAO_Export.h"
00020 
00021 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00022 # pragma once
00023 #endif /* ACE_LACKS_PRAGMA_ONCE */
00024 
00025 #include "tao/Versioned_Namespace.h"
00026 #include "tao/Basic_Types.h"
00027 
00028 #include "ace/Service_Object.h"
00029 #include "ace/Unbounded_Set.h"
00030 #include "ace/SString.h"
00031 #include "ace/CDR_Base.h"
00032 
00033 
00034 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00035 class ACE_Lock;
00036 ACE_END_VERSIONED_NAMESPACE_DECL
00037 
00038 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00039 
00040 class TAO_Protocol_Factory;
00041 class TAO_Acceptor_Registry;
00042 class TAO_Connector_Registry;
00043 
00044 class TAO_Flushing_Strategy;
00045 class TAO_Connection_Purging_Strategy;
00046 class TAO_LF_Strategy;
00047 class TAO_Codeset_Manager;
00048 class TAO_GIOP_Fragmentation_Strategy;
00049 class TAO_Transport;
00050 
00051 // ****************************************************************
00052 
00053 class TAO_Export TAO_Protocol_Item
00054 {
00055 public:
00056   /// Creator method, the protocol name can only be set when the
00057   /// object is created.
00058   TAO_Protocol_Item (const ACE_CString &name);
00059 
00060   /// Destructor that deallocates the factory object if the
00061   /// Protocol_Item retains ownership.
00062   ~TAO_Protocol_Item (void);
00063 
00064   /// Return a reference to the character representation of the protocol
00065   /// factories name.
00066   const ACE_CString &protocol_name (void);
00067 
00068   /// Return a pointer to the protocol factory.
00069   TAO_Protocol_Factory *factory (void);
00070 
00071   /// Set the factory pointer's value.
00072   void factory (TAO_Protocol_Factory *factory, int owner = 0);
00073 
00074 private:
00075 
00076   // Disallow copying and assignment.
00077   TAO_Protocol_Item (const TAO_Protocol_Item&);
00078   void operator= (const TAO_Protocol_Item&);
00079 
00080 private:
00081   /// Protocol factory name.
00082   ACE_CString name_;
00083 
00084   /// Pointer to factory object.
00085   TAO_Protocol_Factory *factory_;
00086 
00087   /// Whether we own (and therefore have to delete) the factory object.
00088   int factory_owner_;
00089 };
00090 
00091 // typedefs for containers containing the list of loaded protocol
00092 // factories.
00093 typedef ACE_Unbounded_Set<TAO_Protocol_Item*>
00094         TAO_ProtocolFactorySet;
00095 
00096 typedef ACE_Unbounded_Set_Iterator<TAO_Protocol_Item*>
00097         TAO_ProtocolFactorySetItor;
00098 
00099 // ****************************************************************
00100 
00101 /**
00102  * @class TAO_Resource_Factory
00103  *
00104  * @brief Factory which manufacturers resources for use by the ORB Core.
00105  *
00106  * This class is a factory/repository for critical ORB Core
00107  * resources.
00108  */
00109 class TAO_Export TAO_Resource_Factory : public ACE_Service_Object
00110 {
00111 public:
00112 
00113   enum Purging_Strategy
00114   {
00115     /// Least Recently Used
00116     LRU,
00117 
00118     /// Least Frequently Used
00119     LFU,
00120 
00121     /// First In First Out
00122     FIFO,
00123 
00124     /// Dont use any strategy.
00125     NOOP
00126   };
00127 
00128   enum Resource_Usage
00129     {
00130       /// Use resources in an eager fashion
00131       TAO_EAGER,
00132 
00133       /// Use resources in a lazy manner
00134       TAO_LAZY
00135     };
00136 
00137   // = Initialization and termination methods.
00138   TAO_Resource_Factory (void);
00139   virtual ~TAO_Resource_Factory (void);
00140 
00141   // = Resource Retrieval
00142 
00143   /// @@ Backwards compatibility, return 1 if the ORB core should use
00144   ///    Locked_Data_Blocks
00145   virtual int use_locked_data_blocks (void) const;
00146 
00147   /// Return an ACE_Reactor to be utilized.
00148   virtual ACE_Reactor *get_reactor (void);
00149 
00150   /// Reclaim reactor resources (e.g. deallocate, etc).
00151   virtual void reclaim_reactor (ACE_Reactor *reactor);
00152 
00153   /// Return a reference to the acceptor registry.
00154   virtual TAO_Acceptor_Registry *get_acceptor_registry (void);
00155 
00156   /// Return a connector to be utilized.
00157   virtual TAO_Connector_Registry *get_connector_registry (void);
00158 
00159   /// Return the Allocator's memory pool type
00160   virtual void use_local_memory_pool (bool);
00161 
00162   /// @name Access the input CDR allocators.
00163   //@{
00164   virtual ACE_Allocator* input_cdr_dblock_allocator (void);
00165   virtual ACE_Allocator* input_cdr_buffer_allocator (void);
00166   virtual ACE_Allocator* input_cdr_msgblock_allocator (void);
00167   //@}
00168 
00169   // Return 1 when the input CDR allocator uses a lock else 0.
00170   virtual int input_cdr_allocator_type_locked (void);
00171 
00172   /// @name Access the output CDR allocators.
00173   //@{
00174   virtual ACE_Allocator* output_cdr_dblock_allocator (void);
00175   virtual ACE_Allocator* output_cdr_buffer_allocator (void);
00176   virtual ACE_Allocator* output_cdr_msgblock_allocator (void);
00177   //@}
00178 
00179   /// Access the AMH response handler allocator
00180   virtual ACE_Allocator* amh_response_handler_allocator (void);
00181 
00182   /// Access the AMI response handler allocator
00183   virtual ACE_Allocator* ami_response_handler_allocator (void);
00184 
00185   /**
00186    * The protocol factory list is implemented in this class since
00187    * a) it will be a global resource and
00188    * b) it is initialized at start up and then not altered.
00189    * Returns a container holding the list of loaded protocols.
00190    */
00191   virtual TAO_ProtocolFactorySet *get_protocol_factories (void);
00192 
00193   /**
00194    * This method will loop through the protocol list and
00195    * using the protocol name field this method will
00196    * retrieve a pointer to the associated protocol factory
00197    * from the service configurator.  It is assumed
00198    * that only one thread will call this method at ORB initialization.
00199    * NON-THREAD-SAFE
00200    */
00201   virtual int init_protocol_factories (void);
00202 
00203   /// Gets the codeset manager.
00204   virtual TAO_Codeset_Manager* codeset_manager (void);
00205 
00206   /// This denotes the maximum number of connections that can be cached.
00207   virtual int cache_maximum (void) const;
00208 
00209   /// This denotes the amount of entries to remove from the connection
00210   /// cache.
00211   virtual int purge_percentage (void) const;
00212 
00213   /// Return the number of muxed connections that are allowed for a
00214   /// remote endpoint
00215   virtual int max_muxed_connections (void) const;
00216 
00217   virtual int get_parser_names (char **&names,
00218                                 int &number_of_names);
00219 
00220   /// Creates the lock for the lock needed in the Cache Map
00221   /// @deprecated
00222   virtual ACE_Lock *create_cached_connection_lock (void);
00223 
00224   /// Should the transport cache have a lock or not? Return 1 if the
00225   /// transport cache needs to be locked  else return 0
00226   virtual int locked_transport_cache (void);
00227 
00228   /// Creates a lock needed for the table that stores the object keys.
00229   virtual ACE_Lock *create_object_key_table_lock (void);
00230 
00231   /// Creates the lock for the CORBA Object
00232   virtual ACE_Lock *create_corba_object_lock (void);
00233 
00234   /// Creates the flushing strategy.  The new instance is owned by the
00235   /// caller.
00236   virtual TAO_Flushing_Strategy *create_flushing_strategy (void) = 0;
00237 
00238   /// Creates the connection purging strategy.
00239   virtual TAO_Connection_Purging_Strategy *create_purging_strategy (void) = 0;
00240 
00241   /// Creates the leader followers strategy.  The new instance is owned by the
00242   /// caller.
00243   virtual TAO_LF_Strategy *create_lf_strategy (void) = 0;
00244 
00245   /// Outgoing fragment creation strategy.
00246   virtual auto_ptr<TAO_GIOP_Fragmentation_Strategy>
00247     create_fragmentation_strategy (TAO_Transport * transport,
00248                                    CORBA::ULong max_message_size) const = 0;
00249 
00250   /// Disables the factory.  When a new factory is installed and used,
00251   /// this function should be called on the previously used (default)
00252   /// factory.  This should result in proper error reporting if the
00253   /// user attempts to set options on an unused factory.
00254   virtual void disable_factory (void) = 0;
00255 
00256   /// Return the resource usage strategy.
00257   virtual
00258   TAO_Resource_Factory::Resource_Usage
00259   resource_usage_strategy (void) const = 0;
00260 
00261   /// Return the value of the strategy that indicates whether
00262   /// the ORB should wait for the replies during shutdown or drop
00263   /// replies during shutdown.
00264   virtual bool drop_replies_during_shutdown () const = 0;
00265 protected:
00266   /**
00267    * Loads the default protocols. This method is used so that the
00268    * advanced_resource.cpp can call the one in default_resource.cpp
00269    * without calling unnecessary functions.
00270    */
00271   virtual int load_default_protocols (void);
00272 
00273 };
00274 
00275 TAO_END_VERSIONED_NAMESPACE_DECL
00276 
00277 #include /**/ "ace/post.h"
00278 
00279 #endif /* TAO_RESOURCE_FACTORY_H */

Generated on Thu Nov 9 11:54:21 2006 for TAO by doxygen 1.3.6