summaryrefslogtreecommitdiff
path: root/TAO/tao/ORBInitializer_Registry.h
blob: 7ca80da1c2a026d90d50e7b33b4c8827ecc06140 (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
// -*- C++ -*-

// ===================================================================
/**
 *  @file   ORBInitializer_Registry.h
 *
 *  $Id$
 *
 *  @author Ossama Othman <ossama@uci.edu>
 */
// ===================================================================

#ifndef TAO_ORB_INITIALIZER_REGISTRY_H
#define TAO_ORB_INITIALIZER_REGISTRY_H

#include /**/ "ace/pre.h"
#include "ace/Array_Base.h"

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

#include "CORBA_methods.h"
#include "Objref_VarOut_T.h"
#include "Environment.h"

namespace PortableInterceptor
{
  class ORBInitializer;
  typedef ORBInitializer *ORBInitializer_ptr;

  typedef
    TAO_Objref_Var_T<
        ORBInitializer
      >
    ORBInitializer_var;

  class ORBInitInfo;
  typedef ORBInitInfo *ORBInitInfo_ptr;

  /// Register an ORBInitializer with the global ORBInitializer
  /// table.
  TAO_Export void register_orb_initializer (
      ORBInitializer_ptr init
      ACE_ENV_ARG_DECL_WITH_DEFAULTS
    );
}

/**
 * @class TAO_ORBInitializer_Registry
 *
 * @brief Global list that contains all portable interceptor ORB
 *        initializers.
 *
 * @note This class should be instantiated via its instance() method.
 *       Normally this would be enforced by making the constructor
 *       protected but that forces a friend declaration containing a
 *       template type (TAO_Singleton) with a static member to be
 *       introduced.  In turn, this potentially introduces problems in
 *       MS Windows DLL environments due to the occurance of multiple
 *       singleton instances.  There should only be one!
 */
class TAO_ORBInitializer_Registry
{
  friend void PortableInterceptor::register_orb_initializer (
                  PortableInterceptor::ORBInitializer_ptr init
                  ACE_ENV_ARG_DECL);

  friend CORBA::ORB_ptr CORBA::ORB_init (int &,
                                         char *argv[],
                                         const char *,
                                         CORBA::Environment &);

public:
  /// Only allow this class to be instantiated as a singleton
  /// instance, so declare the constructor as protected.
  /**
   * @note See the note in the class description for an explanation of
   *       why this constructor is not protected.
   */
  TAO_ORBInitializer_Registry (void);

protected:
  /// Register an ORBInitializer with the underlying ORBInitializer
  /// array.
  void register_orb_initializer (
    PortableInterceptor::ORBInitializer_ptr init
    ACE_ENV_ARG_DECL);

  /// Begin initialization of all registered ORBInitializers before
  /// the ORB itself is initialized.
  void pre_init (PortableInterceptor::ORBInitInfo_ptr info
                 ACE_ENV_ARG_DECL);

  /// Complete initialization of all registered ORBInitializers after
  /// the ORB has been initialized.
  void post_init (PortableInterceptor::ORBInitInfo_ptr info
                  ACE_ENV_ARG_DECL);

  /// Return a unique singleton instance.
  static TAO_ORBInitializer_Registry *instance (void);

private:
  /// Prevent copying
  ACE_UNIMPLEMENTED_FUNC (
    TAO_ORBInitializer_Registry (const TAO_ORBInitializer_Registry &))
  ACE_UNIMPLEMENTED_FUNC (void operator= (const TAO_ORBInitializer_Registry &))

private:

  /// Dynamic array containing registered ORBInitializers.
  ACE_Array_Base<PortableInterceptor::ORBInitializer_var> initializers_;
};

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

#endif /* TAO_ORB_INITIALIZER_REGISTRY_H */