3 //=============================================================================
5 * @file Resource_Factory.h
7 * @author Chris Cleeland
8 * @author Carlos O'Ryan
10 //=============================================================================
12 #ifndef TAO_RESOURCE_FACTORY_H
13 #define TAO_RESOURCE_FACTORY_H
15 #include /**/ "ace/pre.h"
17 #include /**/ "tao/TAO_Export.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 #include /**/ "tao/Versioned_Namespace.h"
24 #include "tao/Basic_Types.h"
27 #include "ace/Service_Object.h"
28 #include "ace/Unbounded_Set.h"
29 #include "ace/SString.h"
30 #include "ace/CDR_Base.h"
33 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
35 ACE_END_VERSIONED_NAMESPACE_DECL
37 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
39 class TAO_Protocol_Factory
;
40 class TAO_Acceptor_Registry
;
41 class TAO_Connector_Registry
;
43 class TAO_Flushing_Strategy
;
44 class TAO_Connection_Purging_Strategy
;
45 class TAO_LF_Strategy
;
46 class TAO_Codeset_Manager
;
47 class TAO_GIOP_Fragmentation_Strategy
;
50 // ****************************************************************
52 class TAO_Export TAO_Protocol_Item
55 /// Creator method, the protocol name can only be set when the
56 /// object is created.
57 TAO_Protocol_Item (const ACE_CString
&name
);
59 /// Destructor that deallocates the factory object if the
60 /// Protocol_Item retains ownership.
61 ~TAO_Protocol_Item ();
63 /// Return a reference to the character representation of the protocol
65 const ACE_CString
&protocol_name ();
67 /// Return a pointer to the protocol factory.
68 TAO_Protocol_Factory
*factory ();
70 /// Set the factory pointer's value.
71 void factory (TAO_Protocol_Factory
*factory
, int owner
= 0);
74 TAO_Protocol_Item (const TAO_Protocol_Item
&) = delete;
75 void operator= (const TAO_Protocol_Item
&) = delete;
76 TAO_Protocol_Item (TAO_Protocol_Item
&&) = delete;
77 void operator= (TAO_Protocol_Item
&&) = delete;
80 /// Protocol factory name.
83 /// Pointer to factory object.
84 TAO_Protocol_Factory
*factory_
;
86 /// Whether we own (and therefore have to delete) the factory object.
90 // typedefs for containers containing the list of loaded protocol
92 typedef ACE_Unbounded_Set
<TAO_Protocol_Item
*>
93 TAO_ProtocolFactorySet
;
95 typedef ACE_Unbounded_Set_Iterator
<TAO_Protocol_Item
*>
96 TAO_ProtocolFactorySetItor
;
98 // ****************************************************************
101 * @class TAO_Resource_Factory
103 * @brief Factory which manufacturers resources for use by the ORB Core.
105 * This class is a factory/repository for critical ORB Core
108 class TAO_Export TAO_Resource_Factory
: public ACE_Service_Object
111 enum Purging_Strategy
113 /// Least Recently Used
116 /// Least Frequently Used
119 /// First In First Out
122 /// Dont use any strategy.
128 /// Use resources in an eager fashion
131 /// Use resources in a lazy manner
135 TAO_Resource_Factory ();
136 virtual ~TAO_Resource_Factory ();
138 // = Resource Retrieval
140 /// @@ Backwards compatibility, return 1 if the ORB core should use
141 /// Locked_Data_Blocks
142 virtual int use_locked_data_blocks () const;
144 /// Return an ACE_Reactor to be utilized.
145 virtual ACE_Reactor
*get_reactor ();
147 /// Reclaim reactor resources (e.g. deallocate, etc).
148 virtual void reclaim_reactor (ACE_Reactor
*reactor
);
150 /// Return a reference to the acceptor registry.
151 virtual TAO_Acceptor_Registry
*get_acceptor_registry ();
153 /// Return a connector to be utilized.
154 virtual TAO_Connector_Registry
*get_connector_registry ();
156 /// Return the Allocator's memory pool type
157 virtual void use_local_memory_pool (bool);
159 /// @name Access the input CDR allocators.
161 virtual ACE_Allocator
* input_cdr_dblock_allocator ();
162 virtual ACE_Allocator
* input_cdr_buffer_allocator ();
163 virtual ACE_Allocator
* input_cdr_msgblock_allocator ();
166 // Return 1 when the input CDR allocator uses a lock else 0.
167 virtual int input_cdr_allocator_type_locked ();
169 /// @name Access the output CDR allocators.
171 virtual ACE_Allocator
* output_cdr_dblock_allocator ();
172 virtual ACE_Allocator
* output_cdr_buffer_allocator ();
173 virtual ACE_Allocator
* output_cdr_msgblock_allocator ();
176 /// Access the AMH response handler allocator
177 virtual ACE_Allocator
* amh_response_handler_allocator ();
179 /// Access the AMI response handler allocator
180 virtual ACE_Allocator
* ami_response_handler_allocator ();
183 * The protocol factory list is implemented in this class since
184 * a) it will be a global resource and
185 * b) it is initialized at start up and then not altered.
186 * Returns a container holding the list of loaded protocols.
188 virtual TAO_ProtocolFactorySet
*get_protocol_factories ();
191 * This method will loop through the protocol list and
192 * using the protocol name field this method will
193 * retrieve a pointer to the associated protocol factory
194 * from the service configurator. It is assumed
195 * that only one thread will call this method at ORB initialization.
198 virtual int init_protocol_factories ();
200 /// Gets the codeset manager.
201 virtual TAO_Codeset_Manager
* codeset_manager ();
203 /// This denotes the maximum number of connections that can be cached.
204 virtual int cache_maximum () const;
206 /// This denotes the amount of entries to remove from the connection
208 virtual int purge_percentage () const;
210 /// Return the number of muxed connections that are allowed for a
212 virtual int max_muxed_connections () const;
214 virtual int get_parser_names (char **&names
,
215 int &number_of_names
);
217 /// Creates the lock for the lock needed in the Cache Map
219 virtual ACE_Lock
*create_cached_connection_lock ();
221 /// Should the transport cache have a lock or not? Return 1 if the
222 /// transport cache needs to be locked else return 0
223 virtual int locked_transport_cache ();
225 /// Creates the flushing strategy. The new instance is owned by the
227 virtual TAO_Flushing_Strategy
*create_flushing_strategy () = 0;
229 /// Creates the connection purging strategy.
230 virtual TAO_Connection_Purging_Strategy
*create_purging_strategy () = 0;
232 /// Creates the leader followers strategy. The new instance is owned by the
234 virtual TAO_LF_Strategy
*create_lf_strategy () = 0;
236 /// Outgoing fragment creation strategy.
237 virtual TAO_GIOP_Fragmentation_Strategy
*
238 create_fragmentation_strategy (TAO_Transport
* transport
,
239 CORBA::ULong max_message_size
) const = 0;
241 /// Disables the factory. When a new factory is installed and used,
242 /// this function should be called on the previously used (default)
243 /// factory. This should result in proper error reporting if the
244 /// user attempts to set options on an unused factory.
245 virtual void disable_factory () = 0;
247 /// Return the resource usage strategy.
249 TAO_Resource_Factory::Resource_Usage
250 resource_usage_strategy () const = 0;
252 /// Return the value of the strategy that indicates whether
253 /// the ORB should wait for the replies during shutdown or drop
254 /// replies during shutdown.
255 virtual bool drop_replies_during_shutdown () const = 0;
259 * Loads the default protocols. This method is used so that the
260 * advanced_resource.cpp can call the one in default_resource.cpp
261 * without calling unnecessary functions.
263 virtual int load_default_protocols ();
266 TAO_END_VERSIONED_NAMESPACE_DECL
268 #include /**/ "ace/post.h"
270 #endif /* TAO_RESOURCE_FACTORY_H */