summaryrefslogtreecommitdiff
path: root/TAO/CIAO/examples/handcrafted/Hello/hello_servants.h
blob: 02cb8dc18f60b7cf2fa962dbed07f050a6d5864f (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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
// $Id$

// ===========================================================
//
//
// = LIBRARY
//    CIAO/examples/handcrafted/hello
//
// = FILENAME
//    hello_servants.h
//
// = DESCRIPTION
//    Generic Servant implementations for hello world example.
//    This file is currently handcrafted but it should really
//    be generated by the CCIDL compiler.
//
//    This example demonstrates how a servant implementation for a
//    session component should look like.
//
// @author Nanbor Wang <nanbor@cs.wustl.edu>
//
// ===========================================================

#include "helloS.h"
#include "helloEC.h"
#include "ciao/Container_Base.h"

class CIAO_HelloWorld_Servant;

class HELLO_SERVANT_Export CIAO_HelloWorld_Context :
  public virtual CCM_HelloWorld_Context
{
public:
  // Ctor.
  CIAO_HelloWorld_Context (::Components::CCMHome_ptr h,
                           ::CIAO::Session_Container *c,
                           CIAO_HelloWorld_Servant *sv);

  // Dtor.
  virtual ~CIAO_HelloWorld_Context ();

  // We need to overwrite the following method to avoid ambiguity
  // This is strange, but thankfully, this is generated code so it's
  // okay (?) to mess with this.

  // Operations for HellowWorld attributes, event source, and
  // receptable defined in CCM_HelloWorld_Context.

  // Operations for ::Components::CCMContext
  virtual ::Components::Principal_ptr get_caller_principal (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::CCMHome_ptr get_CCM_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual CORBA::Boolean get_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::IllegalState));
  virtual ::Components::Transaction::UserTransaction_ptr get_user_transaction (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::IllegalState));
  virtual CORBA::Boolean is_caller_in_role (const char * role
                                            ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual void set_rollback_only (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::IllegalState));


protected:
  ::Components::CCMHome_var home_;

  ::CIAO::Session_Container *container_;

  CIAO_HelloWorld_Servant *servant_;

  HelloWorld_var component_;
};

class HELLO_SERVANT_Export CIAO_HelloWorld_Servant
  : public virtual POA_HelloWorld,
  // @@ Perhaps we could implement a common component servant class
  //    which provide common functionality for operations defined in
  //    Navigation/Events/Receptacles interfaces.
    public virtual PortableServer::RefCountServantBase
{
public:
  // Ctor.
  CIAO_HelloWorld_Servant (CCM_HelloWorld_ptr executor,
                           ::Components::CCMHome_ptr h,
                           ::CIAO::Session_Container *c);

  // Dtor.
  ~CIAO_HelloWorld_Servant (void);

  // Operations for supported interfaces.
  // Explicit opereations and attribute operations.
  virtual char * sayhello (const char * username
                           ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));

  // Operations for provides interfaces.

  // Operations for receptacles interfaces.

  // Operations for emits interfaces.

  // Operations for consumers interfaces.

  // Operations for publishes interfaces.

  // Operations for Navigation interface
  virtual CORBA::Object_ptr provide_facet (const char * name
                                           ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException ,
                     Components::InvalidName)) ;
  virtual ::Components::FacetDescriptions * get_all_facets (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::FacetDescriptions * get_named_facets (const Components::NameList & names
                                                              ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException ,
                     Components::InvalidName));
  virtual CORBA::Boolean same_component (CORBA::Object_ptr object_ref
                                         ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));

  // Operations for Receptacles interface
  virtual ::Components::Cookie * connect (const char * name,
                                          CORBA::Object_ptr connection
                                          ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName,
                     Components::InvalidConnection,
                     Components::AlreadyConnected,
                     Components::ExceededConnectionLimit));
  virtual CORBA::Object_ptr disconnect (const char * name,
                                        Components::Cookie * ck
                                        ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName,
                     Components::InvalidConnection,
                     Components::CookieRequired,
                     Components::NoConnection));
  virtual ::Components::ConnectionDescriptions * get_connections (const char * name
                                                                  ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName));

  virtual ::Components::ReceptacleDescriptions * get_all_receptacles (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::ReceptacleDescriptions * get_named_receptacles (const Components::NameList & names
                                                                        ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName));

  // Operations for Events interface
  virtual ::Components::EventConsumerBase_ptr get_consumer (const char * sink_name
                                                            ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName));
  virtual ::Components::Cookie * subscribe (const char * publisher_name,
                                            Components::EventConsumerBase_ptr subscriber
                                            ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName,
                     Components::AlreadyConnected,
                     Components::InvalidConnection));
  virtual ::Components::EventConsumerBase_ptr unsubscribe (const char * publisher_name,
                                                           Components::Cookie * ck
                                                           ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName,
                     Components::InvalidConnection));
  virtual void connect_consumer (const char * emitter_name,
                                 Components::EventConsumerBase_ptr consumer
                                 ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName,
                     Components::AlreadyConnected,
                     Components::InvalidConnection));
  virtual ::Components::EventConsumerBase_ptr disconnect_consumer (const char * source_name
                                                                   ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName,
                     Components::NoConnection));
  virtual ::Components::ConsumerDescriptions * get_all_consumers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::ConsumerDescriptions * get_named_consumers (const Components::NameList & names
                                                                    ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName));
  virtual ::Components::EmitterDescriptions * get_all_emitters (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::EmitterDescriptions * get_named_emitters (const Components::NameList & names
                                                                  ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName));
  virtual ::Components::PublisherDescriptions * get_all_publishers (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::PublisherDescriptions * get_named_publishers (const Components::NameList & names
                                                                      ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidName));

  // Operations for CCMObject interface
  virtual ::CORBA::IRObject_ptr get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::CCMHome_ptr get_ccm_home (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::Components::PrimaryKeyBase * get_primary_key (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::NoKeyAvailable));
  virtual void configuration_complete (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::InvalidConfiguration));
  virtual void remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::RemoveFailure));
  virtual ::Components::ComponentPortDescription * get_all_ports (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));

  // From Servant_Base

  // get_component implementation.
  virtual CORBA::Object_ptr _get_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);

  // CIAO specific operations.

  // Activate the object in the container_
  HelloWorld_ptr _ciao_activate_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));

protected:
  // My Executor.
  CCM_HelloWorld_var executor_;

  // My Run-time Context.
  CCM_HelloWorld_Context_var context_;

  // Managing container.
  ::CIAO::Session_Container *container_;
};


class HELLO_SERVANT_Export CIAO_HelloHome_Servant :
  public virtual POA_HelloHome,
  public virtual PortableServer::RefCountServantBase
{
public:
  // Ctor.
  CIAO_HelloHome_Servant (CCM_HelloHome_ptr exe,
                          CIAO::Session_Container *c);

  // Dtor.
  ~CIAO_HelloHome_Servant (void);

  // User defined and inherited operations
  // (Factories, Finders, and explicit operations.)

  // Operations for KeylessHome interface
  virtual ::Components::CCMObject_ptr create_component (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::CreateFailure));

  // Operations for Implicit Home interface
  virtual ::HelloWorld_ptr create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::CreateFailure));

  // Operations for CCMHome interface
  virtual ::CORBA::IRObject_ptr get_component_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual ::CORBA::IRObject_ptr get_home_def (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException));
  virtual void remove_component (Components::CCMObject_ptr comp
                                 ACE_ENV_ARG_DECL_WITH_DEFAULTS)
    ACE_THROW_SPEC ((CORBA::SystemException,
                     Components::RemoveFailure));

protected:
  // My Executor.
  CCM_HelloHome_var executor_;

  // My Container
  CIAO::Session_Container *container_;
};

extern "C" HELLO_SERVANT_Export ::PortableServer::Servant
createHelloHome_Servant (::Components::HomeExecutorBase_ptr p,
                         CIAO::Session_Container *c
                         ACE_ENV_ARG_DECL_WITH_DEFAULTS);