summaryrefslogtreecommitdiff
path: root/CIAO/ciao/Containers/Generic/Generic_Container.h
blob: 221786f6ccdee6cf39e6bec16acf2b81cef17c73 (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
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Generic_Container.h
 *
 *  $Id$
 *
 *  Header file for CIAO's container implementations
 *
 *  @author Johnny Willemsen  <jwillemsen@remedy.nl>
 */
//=============================================================================

#ifndef CIAO_GENERIC_CONTAINER_H
#define CIAO_GENERIC_CONTAINER_H

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

#include "ciao/Containers/Generic/Generic_Container_export.h"

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

#include "tao/PortableServer/Servant_Base.h"
#include "ciao/Containers/Container_Base_T.h"
#include "ciao/Containers/Generic/Generic_ContainerC.h"
#include "ccm/CCM_HomeExecutorBaseC.h"
#include "ccm/CCM_EnterpriseComponentC.h"

#include <map>

namespace CIAO
{
  class ClientContainerInterceptorRegistration_Impl;
  class ServantContainerInterceptorRegistration_Impl;
  class ServerContainerInterceptorRegistration_Impl;
  class StubContainerInterceptorRegistration_Impl;

  class Servant_Activator;

  typedef ::Components::HomeExecutorBase_ptr (*HomeFactory) (void);
  typedef ::PortableServer::Servant (*HomeServantFactory) (::Components::HomeExecutorBase_ptr p,
                                                           ::CIAO::Generic_Container_ptr c,
                                                           const char *ins_name);
  typedef ::Components::EnterpriseComponent_ptr (*ComponentFactory) (void);
  typedef ::PortableServer::Servant (*ComponentServantFactory) (::Components::EnterpriseComponent_ptr,
                                                                ::CIAO::Generic_Container_ptr,
                                                                const char *);

  typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                  HomeFactory,
                                  ACE_Hash<ACE_CString>,
                                  ACE_Equal_To<ACE_CString>,
                                  ACE_Null_Mutex>
    HOMECREATOR_FUNCPTR_MAP;

  typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                  HomeServantFactory,
                                  ACE_Hash<ACE_CString>,
                                  ACE_Equal_To<ACE_CString>,
                                  ACE_Null_Mutex>
  HOMESERVANTCREATOR_FUNCPTR_MAP;

  typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                  ComponentFactory,
                                  ACE_Hash<ACE_CString>,
                                  ACE_Equal_To<ACE_CString>,
                                  ACE_Null_Mutex>
    COMPONENTCREATOR_FUNCPTR_MAP;

  typedef ACE_Hash_Map_Manager_Ex<ACE_CString,
                                  ComponentServantFactory,
                                  ACE_Hash<ACE_CString>,
                                  ACE_Equal_To<ACE_CString>,
                                  ACE_Null_Mutex>
  COMPONENTSERVANTCREATOR_FUNCPTR_MAP;


  class GENERIC_CONTAINER_Export Generic_Container_i :
    public Container_i < ::CIAO::Generic_Container>
  {
  public:
    Generic_Container_i (CORBA::ORB_ptr o,
                           PortableServer::POA_ptr poa);

    virtual ~Generic_Container_i (void);

    /// Initialize the container with a name.
    virtual void init (const char *name);

    virtual void fini (void);

    /**
     * @brief Simply installing a home executor into the component.
     *
     * This operation install a home executor into the component.  It
     * requires the name of the DLLs to executor and the servant glue
     * code, and the entry points to the respective DLLs.  Currently,
     * we don't try to manage the lifetime of DLL objects, but we
     * should at some later point.
     *
     * @retval Home objref of the installed home.
     */
    /// Install a new home
    virtual Components::CCMHome_ptr install_home (const char *primary_artifact,
                                                  const char *entry_point,
                                                  const char *servant_artifact,
                                                  const char *servant_entrypoint,
                                                  const char *name);

    /// Install a new component
    virtual Components::CCMObject_ptr install_component (const char *primary_artifact,
                                                         const char *entry_point,
                                                         const char *servant_artifact,
                                                         const char *servant_entrypoint,
                                                         const char *name);

    // @{
    /// Inherited from generic context.
    Components::Cookie * install_service_reference (const char * service_id,
                                                    CORBA::Object_ptr objref);

    CORBA::Object_ptr uninstall_service_reference (Components::Cookie * ck);

    CORBA::Object_ptr resolve_service_reference (const char *service_id);
    // @}

    // @{
    /**
     * Getters for the Containter Portable Interceptor registration
     * Objects.
     */
    Components::ContainerPortableInterceptor::ClientContainerInterceptorRegistration_ptr
    get_client_interceptor_registration (void);

    Components::ContainerPortableInterceptor::ServantContainerInterceptorRegistration_ptr
    get_servant_interceptor_registration (void);

    Components::ContainerPortableInterceptor::ServerContainerInterceptorRegistration_ptr
    get_server_interceptor_registration (void);

    Components::ContainerPortableInterceptor::StubContainerInterceptorRegistration_ptr
    get_stub_interceptor_registration (void);
    // @}

  private:
    /// Not allowed to be
    Generic_Container_i (void);

    /// Administration of installed CCM services
    typedef std::map<const char *,
                     std::pair<Components::Cookie *, CORBA::Object_ptr>
                    > InstalledServices;
    InstalledServices installed_services_;

    // @{
    /// Caching of the COPI registration objects
    /// When a component want to register a Portable Interceptor, it'll
    /// need the registration object.
    ClientContainerInterceptorRegistration_Impl *client_copi_registration_;
    ServantContainerInterceptorRegistration_Impl *servant_copi_registration_;
    ServerContainerInterceptorRegistration_Impl *server_copi_registration_;
    StubContainerInterceptorRegistration_Impl *stub_copi_registration_;
    // @}
  };
}

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

#endif /* CIAO_GENERIC_CONTAINER_H */