summaryrefslogtreecommitdiff
path: root/modules/CIAO/ciaosvcs/Events/CIAO_RTEC/CIAO_RTEvent.h
blob: 7737643b0a49736f2c85d3d2573e2e54816eacc0 (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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
// -*- C++ -*-

//=============================================================================
/**
 *  @file CIAO_RTEvent.h
 *
 *  $Id$
 *
 *  @author Gan Deng <dengg@dre.vanderbilt.edu>
 *  @author George Edwards <g.edwards@vanderbilt.edu>
 */
//=============================================================================

#ifndef CIAO_RTEVENT_H
#define CIAO_RTEVENT_H
#include /**/ "ace/pre.h"

#include "ace/config-all.h"

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

#include "CIAO_RTEVENT_Export.h"
#include "ciaosvcs/Events/CIAO_Events_Base/CIAO_EventServiceBase.h"
#include "CIAO_RTEventS.h"

#include "orbsvcs/orbsvcs/Event_Utilities.h"
#include "orbsvcs/orbsvcs/Event/EC_Event_Channel.h"
#include "orbsvcs/orbsvcs/Event/EC_Default_Factory.h"
#include "orbsvcs/Event/ECG_Mcast_EH.h"
#include "orbsvcs/Event/ECG_UDP_Sender.h"
#include "orbsvcs/Event/ECG_UDP_Receiver.h"
#include "orbsvcs/Event/ECG_UDP_Out_Endpoint.h"
#include "orbsvcs/Event/ECG_UDP_EH.h"
#include "ace/Hash_Map_Manager.h"

namespace CIAO
{

  /**
   * @class RTEventService
   *
   * An implementation of EventServiceBase using the RT event channel.
   *
   * @@ (GD) There should be a place where the deployment tool could
   *         specify the RT Event Channel service configuration file.
   *         This should be the place where the RtecEventChannel servant was
   *         first time initialized.
   */
  class CIAO_RTEVENT_Export RTEventService :
    public virtual EventServiceBase,
    public virtual POA_CIAO::CIAO_RT_Event_Service
  {
  public:

    RTEventService (CORBA::ORB_ptr orb,
                    PortableServer::POA_ptr poa,
                    const char * ec_name);

    virtual ~RTEventService (void);

    virtual Supplier_Config_ptr
    create_supplier_config (void)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual Consumer_Config_ptr
    create_consumer_config (void)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual void connect_event_supplier (
        CIAO::Supplier_Config_ptr supplier_config)
      ACE_THROW_SPEC ((
        CORBA::SystemException));

    virtual void connect_event_consumer (
        CIAO::Consumer_Config_ptr consumer_config)
      ACE_THROW_SPEC ((
        CORBA::SystemException));

    virtual void
    disconnect_event_supplier (
        const char * consumer_id)
      ACE_THROW_SPEC ((
        CORBA::SystemException,
        Components::InvalidConnection));

    virtual void disconnect_event_consumer (
        const char * connection_id)
      ACE_THROW_SPEC ((
        CORBA::SystemException,
        Components::InvalidConnection));

    virtual void push_event (
        Components::EventBase * ev)
      ACE_THROW_SPEC ((
        CORBA::SystemException));

    virtual void ciao_push_event (
        Components::EventBase * evt,
        const char * source_id,
        CORBA::TypeCode_ptr tc)
      ACE_THROW_SPEC ((
        ::CORBA::SystemException,
        ::Components::BadEventType));

    virtual ::CORBA::Boolean create_addr_serv (
        const char * name,
        ::CORBA::UShort port,
        const char * address)
      ACE_THROW_SPEC ((
        ::CORBA::SystemException));

    virtual ::CORBA::Boolean create_sender (
        const char * addr_serv_id)
      ACE_THROW_SPEC ((
        ::CORBA::SystemException));

    virtual ::CORBA::Boolean create_receiver (
        const char * addr_serv_id,
        ::CORBA::Boolean is_multicast,
        ::CORBA::UShort listen_port)
      ACE_THROW_SPEC ((
        ::CORBA::SystemException));

    virtual ::RtecEventChannelAdmin::EventChannel_ptr tao_rt_event_channel (
      )
      ACE_THROW_SPEC ((::CORBA::SystemException));

  private:
    // @@ (GD) This is the place where use could provide a parameter
    //         which specifies the event channel service configuration file.
    void create_rt_event_channel (const char * ec_name)
      ACE_THROW_SPEC ((
        CORBA::SystemException));

  private:

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

    /// Reference to the Root POA
    PortableServer::POA_var root_poa_;

    /**
     * @var RtecEventChannelAdmin::EventChannel_var rt_event_channel_
     *
     * Reference to the RT event channel.
     */
    RtecEventChannelAdmin::EventChannel_var rt_event_channel_;

    /**
     * @var ACE_Hash_Map_Manager<> proxy_supplier_map_
     *
     * Mapping of each event sink to a proxy supplier for disconnect purposes.
     */
    ACE_Hash_Map_Manager_Ex<ACE_CString,
                            RtecEventChannelAdmin::ProxyPushConsumer_var,
                            ACE_Hash<ACE_CString>,
                            ACE_Equal_To<ACE_CString>,
                            ACE_Null_Mutex> proxy_consumer_map_;

    /**
     * @var ACE_Hash_Map_Manager<> proxy_supplier_map_
     *
     * Mapping of each event sink to a proxy supplier for disconnect purposes.
     */
    ACE_Hash_Map_Manager_Ex<ACE_CString,
                            RtecEventChannelAdmin::ProxyPushSupplier_var,
                            ACE_Hash<ACE_CString>,
                            ACE_Equal_To<ACE_CString>,
                            ACE_Null_Mutex> proxy_supplier_map_;

    /**
     * @var ACE_Hash_Map_Manager<> addr_serv_map_
     *
     * A map which managers a set of address servers for event channel
     * federation purpose.
     */
    ACE_Hash_Map_Manager_Ex<ACE_CString,
                            RtecUDPAdmin::AddrServer_var,
                            ACE_Hash<ACE_CString>,
                            ACE_Equal_To<ACE_CString>,
                            ACE_Null_Mutex> addr_serv_map_;

  };

  /**
   * @class RTEventServiceSupplier_impl
   *
   * An implementation of the PushSupplier interface.
   */
  class RTEventServiceSupplier_impl :
    public virtual POA_RtecEventComm::PushSupplier
  {
  public:

    RTEventServiceSupplier_impl (
      PortableServer::POA_ptr poa);

    virtual void disconnect_push_supplier ()
      ACE_THROW_SPEC ((
        CORBA::SystemException));

  private:

    PortableServer::POA_var poa_;
  };

  /**
   * @class RTEventServiceConsumer_impl
   *
   * An implementation of the PushConsumer interface.
   */
  class RTEventServiceConsumer_impl :
    public virtual POA_RtecEventComm::PushConsumer
  {
  public:

    RTEventServiceConsumer_impl (
      PortableServer::POA_ptr poa,
      Components::EventConsumerBase_ptr consumer);

    virtual void push (
      const RtecEventComm::EventSet& events)
    ACE_THROW_SPEC ((
      CORBA::SystemException));

    virtual void disconnect_push_consumer ()
      ACE_THROW_SPEC ((
        CORBA::SystemException));

  private:

    PortableServer::POA_var poa_;

    Components::EventConsumerBase_var event_consumer_;
  };

  /**
   * @class RTEvent_Consumer_Config_impl
   *
   * Implementation of the RTEvent_Consumer_Config IDL interface that
   * configures TAO's RT event channel. An object of this type will be returned
   * from @c CIAO::Container::create_consumer_config () when @c RTEC is
   * specified as the event service type.
   */
  class RTEvent_Consumer_Config_impl :
    public virtual POA_CIAO::RTEvent_Consumer_Config,
    public virtual Event_Consumer_Config_Base
  {

  public:
    RTEvent_Consumer_Config_impl (PortableServer::POA_ptr poa);

    virtual ~RTEvent_Consumer_Config_impl (void);

    virtual void start_conjunction_group (CORBA::Long size)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual void start_disjunction_group (CORBA::Long size)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual void insert_source (const char * source_id)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual void insert_type (::CORBA::Long event_type)
      ACE_THROW_SPEC ((::CORBA::SystemException));

    virtual void consumer_id (const char * consumer_id)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual CONNECTION_ID consumer_id ()
      ACE_THROW_SPEC ((CORBA::SystemException));

    //virtual void supplier_id (const char * supplier_id)
    //  ACE_THROW_SPEC ((CORBA::SystemException));

    //virtual CONNECTION_ID supplier_id ()
    //  ACE_THROW_SPEC ((CORBA::SystemException));

    virtual void consumer (Components::EventConsumerBase_ptr consumer)
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual Components::EventConsumerBase_ptr consumer ()
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual EventServiceType service_type ()
      ACE_THROW_SPEC ((CORBA::SystemException));

    //@@ (GD) There should be a place where the deployment tool could
  //        set up the rt_event_qos properties for Consumer Config.

    virtual RtecEventChannelAdmin::ConsumerQOS * rt_event_qos ()
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual void destroy ()
      ACE_THROW_SPEC ((CORBA::SystemException));

  private:

    ACE_CString consumer_id_;

    Components::EventConsumerBase_var consumer_;

    EventServiceType service_type_;

    ACE_ConsumerQOS_Factory qos_;

    PortableServer::POA_var poa_;
  };

  /**
   * @class RTEvent_Supplier_Config_impl
   *
   * Implementation of the RTEvent_Supplier_Config IDL interface that
   * configures TAO's RT event channel. An object of this type will be returned
   * from @c CIAO::Container::create_supplier_config () when @c RTEC is
   * specified as the event service type.
   */
  class RTEvent_Supplier_Config_impl :
    public virtual POA_CIAO::RTEvent_Supplier_Config
  {
  public:
    RTEvent_Supplier_Config_impl (PortableServer::POA_ptr poa);

    virtual ~RTEvent_Supplier_Config_impl (void);

    void supplier_id (const char * supplier_id)
      ACE_THROW_SPEC ((CORBA::SystemException));

    CONNECTION_ID supplier_id ()
      ACE_THROW_SPEC ((CORBA::SystemException));

    EventServiceType service_type ()
      ACE_THROW_SPEC ((CORBA::SystemException));

    //@@ (GD) There should be a place where the deployment tool could
    //        set up the rt_event_qos properties for Supplier Config.

    RtecEventChannelAdmin::SupplierQOS * rt_event_qos ()
      ACE_THROW_SPEC ((CORBA::SystemException));

    virtual void destroy ()
      ACE_THROW_SPEC ((CORBA::SystemException));

  private:
    ACE_CString supplier_id_;

    EventServiceType service_type_;

    ACE_SupplierQOS_Factory qos_;

    PortableServer::POA_var poa_;
  };
}

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