summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECSupplier.h
blob: 3cf9516f7785b17fdcee47ee9dfdd1d15fc6d050 (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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Real-time Event Channel examples
//
// = FILENAME
//   ECSupplier
//
// = AUTHOR
//   Carlos O'Ryan (coryan@cs.wustl.edu)
//
// ============================================================================

#ifndef SUPPLIER_H
#define SUPPLIER_H

#include "ace/Event_Handler.h"

#include "orbsvcs/RtecEventCommS.h"
#include "orbsvcs/RtecEventChannelAdminC.h"
#include "orbsvcs/RtecSchedulerC.h"
#include "orbsvcs/Event/EC_Event_Channel.h"

#include "Service_Handler.h"

#include <vector>

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

class ECSupplier : public POA_RtecEventComm::PushSupplier
{
  // = TITLE
  //   Simple supplier object
  //
  // = DESCRIPTION
  //   This class is a supplier of events.
  //   The class is just a helper to simplify common tasks in EC
  //   tests, such as subscribing for a range of events, disconnecting
  //   from the EC, informing the driver of shutdown messages, etc.
  //
  //   There are several ways to connect and disconnect this class,
  //   and it is up to the driver program to use the right one.
  //
public:
  typedef RtecEventChannelAdmin::ProxyPushConsumer_var ConsumerProxy;
  typedef RtecEventComm::EventSourceID SourceID;
  typedef RtecEventComm::EventType EventType;
  typedef std::vector<EventType> EventTypeVector;
  typedef RtecScheduler::handle_t InfoHandle;

  ECSupplier (SourceID id, const EventTypeVector &pub_types,
            Service_Handler * handler = 0);
  // Constructor

  virtual ~ECSupplier(void);

  // = The RtecEventComm::PushSupplier methods

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

  virtual void timeout_occured (ACE_ENV_SINGLE_ARG_DECL);

  void set_consumer_proxy(ConsumerProxy consumer_proxies);

  void rt_info(InfoHandle supplier_rt_info);
  InfoHandle rt_info(void);

  SourceID get_id(void) const;

  Service_Handler * handler(void) const;

  const EventTypeVector &getPublishedTypes (void) const;

protected:
  SourceID id_;
  EventTypeVector pub_types_;

  ConsumerProxy consumer_proxy_;

  InfoHandle rt_info_;

  Service_Handler *handler_;
}; //class ECSupplier
/*
class ECTimeout_Consumer : public POA_RtecEventComm::PushConsumer
{
  // = TITLE
  //   Timer consumer object
  //
  // = DESCRIPTION
  //   This class is a consumer of timeout events from EC.
  //   It registers for timeout event with EC and calls
  //   the
  //
public:
  ECTimeout_Consumer (ECSupplier * supplier_impl);
  // Constructor

  // = 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.

private:
  ECSupplier *supplier_impl_;
}; //class ECTimeout_Consumer
*/
class ECSupplier_Timeout_Handler : public ACE_Event_Handler
{
  // = TITLE
  //   Timer consumer object
  //
  // = DESCRIPTION
  //   This class is a consumer of timeout events from EC.
  //   It registers for timeout event with EC and calls
  //   the
  //
public:
  ECSupplier_Timeout_Handler (ECSupplier * supplier_impl);
  // Constructor

  virtual int handle_timeout (const ACE_Time_Value &current_time,
                              const void *act = 0);

private:
  ECSupplier *supplier_impl_;
}; //class ECSupplier_Timeout_Handler

#endif /* SUPPLIER_H */