summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/examples/RtEC/ECConfigurator/ECConsumer.h
blob: 612a0d379ca285e6e3da860654139e55ad01e0dc (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
/* -*- C++ -*- */
// $Id$
//
// ============================================================================
//
// = LIBRARY
//   ORBSVCS Real-time Event Channel examples
//
// = FILENAME
//   ECConsumer
//
// = AUTHOR
//   Bryan Thrall
//
// ============================================================================

#ifndef CONSUMER_H
#define CONSUMER_H

#include "orbsvcs/RtecEventCommS.h"
#include "orbsvcs/RtecSchedulerC.h"

#include "ace/Time_Value.h"

#include "ECSupplier.h"
#include "Service_Handler.h"

#include <vector>

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

class ECConsumer : public POA_RtecEventComm::PushConsumer
{
  // = TITLE
  //   Simple consumer object
  //
  // = DESCRIPTION
  //   This class is a consumer 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 RtecEventComm::EventSourceID SourceID;
  typedef RtecEventComm::EventType EventType;
  typedef std::vector<EventType> EventTypeVector;
  typedef RtecScheduler::handle_t InfoHandle;
  typedef std::vector<ECSupplier*> SupplierVector;

  ECConsumer (EventTypeVector &sub_types,
              ACE_Time_Value& worktime, Service_Handler *handler = 0);
  // Constructor

  ECConsumer (EventTypeVector &sub_types, Service_Handler *handler = 0);
  // Constructor

  virtual ~ECConsumer(void);

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

  void setWorkTime(ACE_Time_Value& worktime);

  void rt_info(InfoHandle consumer_rt_info);
  InfoHandle rt_info(void);

  void handler(Service_Handler * handler);

  Service_Handler * handler(void) const;

  void pushDependant (ECSupplier *dep);

protected:
  ACE_Time_Value worktime_;

  SupplierVector dependants_;
  InfoHandle rt_info_;

  Service_Handler * handler_;

  EventTypeVector sub_types_;
};

#endif /* CONSUMER_H */