summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/EC_Config/Consumer.h
blob: 800bc309f3b06a579b6c6b3713e63d871b705e68 (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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Real-time Event Channel examples
//
// = FILENAME
//   Consumer
//
// = AUTHOR
//   Bryan A. Thrall (thrall@cse.wustl.edu)
//
// ============================================================================

#ifndef CONSUMER_H
#define CONSUMER_H

#include "orbsvcs/RtecEventChannelAdminC.h"
#include "orbsvcs/RtecEventCommC.h"
#include "orbsvcs/RtecSchedulerC.h"
#include "orbsvcs/Channel_Clients_T.h"

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

class Consumer
{
  // = TITLE
  //   Simple consumer object
  //
  // = DESCRIPTION
  //   This class is a consumer of the events pushed by a TimeoutConsumer
  //   every timeout.
  //
  //   It simply registers for the event type specified in its connect()
  //   function.
  //
public:
  Consumer (void);
  // Default Constructor.

  virtual ~Consumer (void);

  void connect (RtecScheduler::Scheduler_ptr scheduler,
                const char *entry_prefix,
                int consumer_id, //unique identifier
                long event_type,
                RtecEventChannelAdmin::EventChannel_ptr ec
                ACE_ENV_ARG_DECL);
  // This method connects the consumer to the EC without setting anything
  //   in the RT_Info (such as period, criticality, etc.). The consumer
  //   subscribes to events with the specified event_type.

  void connect (RtecScheduler::Scheduler_ptr scheduler,
                const char *entry_prefix,
                int consumer_id, //unique identifier
                long event_type,
                TimeBase::TimeT period,
                RtecScheduler::Importance_t importance,
                RtecScheduler::Criticality_t criticality,
                RtecEventChannelAdmin::EventChannel_ptr ec
                ACE_ENV_ARG_DECL);
  // This method connects the consumer to the EC, setting RT_Info values
  //   for period, criticality, and importance. The consumer subscribes
  //   to events with the specified event_type.

  void disconnect (ACE_ENV_SINGLE_ARG_DECL);
  // Disconnect from the EC.

  // = The RtecEventComm::PushConsumer methods

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

  virtual void disconnect_push_consumer (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
    ACE_THROW_SPEC ((CORBA::SystemException));
  // The skeleton methods.

protected:
  void connect_impl (bool set_rtinfo, //true if should set RT_Info
                     RtecScheduler::Scheduler_ptr scheduler,
                     const char *entry_prefix,
                     int consumer_id, //unique identifier
                     long event_type,
                     TimeBase::TimeT period,
                     RtecScheduler::Importance_t importance,
                     RtecScheduler::Criticality_t criticality,
                     RtecEventChannelAdmin::EventChannel_ptr ec
                     ACE_ENV_ARG_DECL);
  // This method implements the Consumer::connect() methods; if the first
  //   parameter is false, then the RT_Info values are ignored. Otherwise,
  //   they are set.

private:
  RtecEventChannelAdmin::ProxyPushSupplier_var _supplier_proxy;
  // We talk to the EC (as a consumer) using this proxy.

  ACE_PushConsumer_Adapter<Consumer> _consumer;
  // We connect to the EC as a consumer so we can receive the
  // timeout events.

  int _consumer_id;
};

#endif /* CONSUMER_H */