summaryrefslogtreecommitdiff
path: root/TAO/tao/default_resource.h
blob: 9df0760d36b53a201607b144bbe9106e7d24936c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// -*- C++ -*-

//=============================================================================
/**
 *  @file   default_resource.h
 *
 *  $Id$
 *
 *  @author Chris CleelandCarlos O'Ryan
 */
//=============================================================================


#ifndef TAO_DEFAULT_RESOURCE_H
#define TAO_DEFAULT_RESOURCE_H
#include "ace/pre.h"

#include "tao/Resource_Factory.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/Service_Config.h"

class TAO_Object_Adapter;
class TAO_IOR_Parser;

/**
 * @class TAO_Default_Resource_Factory
 *
 * @brief TAO's default resource factory
 *
 * Using a <{resource source specifier}> as a discriminator, the
 * factory can return resource instances which are, e.g., global,
 * stored in thread-specific storage, stored in shared memory,
 * etc.
 */
class TAO_Export TAO_Default_Resource_Factory : public TAO_Resource_Factory
{
public:
  // = Initialization and termination methods.
  /// Constructor.
  TAO_Default_Resource_Factory (void);

  /// Destructor.
  virtual ~TAO_Default_Resource_Factory (void);

  // = Service Configurator hooks.
  /// Dynamic linking hook
  virtual int init (int argc, char* argv[]);

  /// Parse svc.conf arguments
  int parse_args (int argc, char* argv[]);

  /// = Member Accessors
  int get_parser_names (char **&names,
                        int &number_of_names);
  enum
  {
    TAO_ALLOCATOR_THREAD_LOCK
  };

  // = Reactor mappings strategy
  enum
  {
    TAO_SINGLE_REACTOR,
    TAO_REACTOR_PER_PRIORITY
  };

  /// Modify and get the source for the CDR allocators
  int cdr_allocator_source (void);

  // = Resource Retrieval
  virtual int use_tss_resources (void) const;
  virtual int use_locked_data_blocks (void) const;
  virtual TAO_Reactor_Registry *get_reactor_registry (void);
  virtual ACE_Reactor *get_reactor (void);
  virtual void reclaim_reactor (ACE_Reactor *);
  virtual TAO_Acceptor_Registry  *get_acceptor_registry (void);
  virtual TAO_Connector_Registry *get_connector_registry (void);
  virtual ACE_Allocator* input_cdr_dblock_allocator (void);
  virtual ACE_Allocator* input_cdr_buffer_allocator (void);
  virtual int input_cdr_allocator_type_locked (void);
  virtual ACE_Allocator* output_cdr_dblock_allocator (void);
  virtual ACE_Allocator* output_cdr_buffer_allocator (void);
  virtual TAO_ProtocolFactorySet *get_protocol_factories (void);

  virtual int init_protocol_factories (void);

  virtual TAO_Resource_Factory::Caching_Strategy connection_caching_strategy_type (void) const;
  virtual double purge_percentage (void) const;
  virtual TAO_Priority_Mapping *get_priority_mapping (void);
  virtual ACE_Lock *create_cached_connection_lock (void);

protected:
  /// Obtain the reactor implementation
  virtual ACE_Reactor_Impl *allocate_reactor_impl (void) const;

  /// Add a Parser name to the list of Parser names.
  int add_to_ior_parser_names (const char *);

protected:
  /// Flag indicating whether resources should be global or
  /// thread-specific.
  int use_tss_resources_;

  /// The type of data blocks that the ORB should use
  int use_locked_data_blocks_;

  /// The number of the different types of Parsers.
  int parser_names_count_;

  /// Array consisting of the names of the parsers
  char **parser_names_;

  /// Index of the current element in the parser_names_ array
  int index_;

  /// list of loaded protocol factories.
  TAO_ProtocolFactorySet protocol_factories_;

  /// Specifies the typeof caching strategy we should use for
  /// connection management.
  TAO_Resource_Factory::Caching_Strategy connection_caching_type_;

  /// Specifies the percentage of entries which should get purged on
  /// demand.
  double purge_percentage_;

  /// If <0> then we create reactors with signal handling disabled.
  int reactor_mask_signals_;

  /// The scheduling policy used to initialize the priority mapping
  /// strategy.
  int sched_policy_;

  /// The type of priority mapping class created by this factory.
  int priority_mapping_type_;

  /**
   * Flag that is set to 1 if the reactor obtained from the
   * get_reactor() method is dynamically allocated.  If this flag is
   * set to 1, then the reclaim_reactor() method with call the delete
   * operator on the given reactor.  This flag is necessary to make
   * sure that a reactor not allocated by the default resource factory
   * is not reclaimed by the default resource factory.  Such a
   * situation can occur when a resource factory derived from the
   * default one overrides the get_reactor() method but does not
   * override the reclaim_reactor() method.
   */
  int dynamically_allocated_reactor_;

  virtual int load_default_protocols (void);

private:
  enum Lock_Type
  {
    TAO_NULL_LOCK,
    TAO_THREAD_LOCK
  };

  /// Type of lock used by the cached connector.
  Lock_Type cached_connection_lock_type_;
};

#if defined (__ACE_INLINE__)
#include "tao/default_resource.i"
#endif /* __ACE_INLINE__ */

ACE_STATIC_SVC_DECLARE_EXPORT (TAO, TAO_Default_Resource_Factory)
ACE_FACTORY_DECLARE (TAO, TAO_Default_Resource_Factory)

#include "ace/post.h"
#endif /* TAO_DEFAULT_CLIENT_H */