Resource_Factory.h

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

Generated on Tue Feb 2 17:37:52 2010 for TAO by  doxygen 1.4.7