summaryrefslogtreecommitdiff
path: root/CIAO/ciao/Containers/Container_Base_T.h
blob: 8bc3ae4176ae8c22df905fc517f81cd7069ef3b4 (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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
// -*- C++ -*-

//=============================================================================
/**
 *  @file    Container_Base_T.h
 *
 *  $Id$
 *
 *  Header file for CIAO's container implementations
 *
 *  @author Nanbor Wang <nanbor@cs.wustl.edu>
 *  @author Gan Deng <dengg@dre.vanderbilt.edu>
 */
//=============================================================================

#ifndef CIAO_CONTAINER_BASE_T_H
#define CIAO_CONTAINER_BASE_T_H

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

#include "tao/LocalObject.h"

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

#include "tao/PortableServer/PortableServer.h"
#include "ciao/Containers/Container_BaseC.h"
#include "tao/PortableServer/Servant_Base.h"

namespace CIAO
{
  /**
   * @class Container_i
   *
   * @brief Common container interface definition.
   *
   * Perhaps we can use local interface to define these interfaces as
   * we will also get reference counting automatically.
   */

  template <typename BASE>
  class Container_i :
    public virtual BASE,
    public virtual ::CORBA::LocalObject
  {
  public:
    Container_i (CORBA::ORB_ptr o, PortableServer::POA_ptr root_poa);

    virtual ~Container_i (void);

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

    /// Cleanup method
    virtual void fini (void);

    /// Get component's POA.
    /**
     * This operation does *NOT* increase the reference count of the
     * POA. Look at the const qualifier in the method.
     */
    virtual PortableServer::POA_ptr the_POA (void);
    virtual PortableServer::POA_ptr the_port_POA (void);

    /// 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) = 0;

    /// Uninstall a servant for component or home.
    virtual void uninstall_home (Components::CCMHome_ptr homeref);

    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) = 0;

    virtual void set_attributes (CORBA::Object_ptr compref,
                                 const ::Components::ConfigValues & values);

    /// Activate component
    virtual void activate_component (Components::CCMObject_ptr compref);

    /// Passivate a component
    virtual void passivate_component (Components::CCMObject_ptr compref);

    /// Uninstall a given component
    virtual void uninstall_component (Components::CCMObject_ptr compref);

    /// Connect a local facet
    virtual ::Components::Cookie *
    connect_local_facet (::Components::CCMObject_ptr provider,
                         const char * provider_port,
                         ::Components::CCMObject_ptr user,
                         const char * user_port);

    /// Disconnect a local facet
    virtual void
    disconnect_local_facet (::Components::Cookie * cookie,
                            ::Components::CCMObject_ptr provider,
                            const char * provider_port,
                            ::Components::CCMObject_ptr user,
                            const char * user_port);

    virtual CORBA::Object_ptr install_servant (PortableServer::Servant objref,
                                               Container_Types::OA_Type type,
                                               PortableServer::ObjectId_out oid);

    /// Uninstall a servant for component.
    virtual void uninstall_servant (PortableServer::Servant objref,
                                    Container_Types::OA_Type type,
                                    PortableServer::ObjectId_out oid);

    /// Return the servant activator factory that activates the
    /// servants for facets and consumers.
    virtual ::CIAO::Servant_Activator_ptr ports_servant_activator (void);

    virtual CORBA::Object_ptr get_objref (PortableServer::Servant p);

    /// Analog of the POA method that creates an object reference from
    /// an object id string.
    virtual CORBA::Object_ptr generate_reference (const char *obj_id,
                                          const char *repo_id,
                                          Container_Types::OA_Type t);

    /// Get a reference to the underlying ORB.
    CORBA::ORB_ptr the_ORB (void) const;

    virtual CORBA::Object_ptr resolve_service_reference (const char *service_id);

  protected:
    /// Reference to the ORB
    CORBA::ORB_var orb_;

    /// POA used as root
    PortableServer::POA_var root_poa_;

    /// POA within which all the components in this container will be
    /// activated.
    PortableServer::POA_var component_poa_;

    /// POA within which all the facets and receptacles will be
    /// activated.
    /**
     * Having two POA's allows us to associate different policies that
     * are distinct from the component.
     */
    PortableServer::POA_var facet_cons_poa_;

    /// The servant activator factory used to activate facets and
    /// consumer servants.
    Servant_Activator_var sa_;

    /// Uninstall a servant for component or home.
    void uninstall (CORBA::Object_ptr objref, Container_Types::OA_Type t);

    void prepare_installation (const char *entity,
                            const char *primary_artifact,
                            const char *entry_point,
                            const char *servant_artifact,
                            const char *servant_entrypoint,
                            const char *name,
                            ACE_DLL &executor_dll,
                            ACE_DLL &servant_dll);

  private:
    /// Not allowed to be used
    Container_i (void);

    /// Create POA for the component.
    /**
     * This is the POA that is returned to the component applications
     * if they need one.
     */
    void create_component_POA (const char *name,
                               PortableServer::POA_ptr root);

    /// Create POA for the facets and consumers alone.
    void create_facet_consumer_POA (const char *name,
                                    PortableServer::POA_ptr root);
  };
}

#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
#include "ciao/Containers/Container_Base_T.cpp"
#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */

#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
#pragma implementation ("ciao/Containers/Container_Base_T.cpp")
#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */

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

#endif /* CIAO_CONTAINER_BASE_T_H */