summaryrefslogtreecommitdiff
path: root/TAO/examples/Event_Comm/Consumer_Input_Handler.h
blob: 2a5f599d21f87ce3ed752497cec7d11544ca0920 (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
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    Consumer_Input_Handler.h
 *
 *  @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu)
 */
//=============================================================================


#ifndef CONSUMER_INPUT_HANDLER_H
#define CONSUMER_INPUT_HANDLER_H

#include "ace/Service_Config.h"
#include "ace/Event_Handler.h"


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

// Forward declaration.
class Consumer_Handler;

/**
 * @class Consumer_Input_Handler
 *
 * @brief Handles input events generated from a keyboard.
 *
 * This class holds a <Consumer_Handler> object. It accepts input
 * from the user and passes events to the <Notifier>. It also
 * initiates shutdown.
 */
class Consumer_Input_Handler : public ACE_Event_Handler
{
public:
  // Initialization and termination methods.
  /// Constructor.
  Consumer_Input_Handler(void);

  /// Destructor.
  ~Consumer_Input_Handler (void);

  /// registers the input event handler.
  /// returns 0 on success, -1 on error.
  int initialize (Consumer_Handler *);

  /// Dispatch the callback when events occur.
  virtual int handle_input (ACE_HANDLE);

  /// Close down the handler.
  int close (void);

  /// Report whether the Consumer initiated the shutdown.
  int consumer_initiated_shutdown (void);

  /// Indicate that the Consumer initiated the shutdown.
  void consumer_initiated_shutdown (int);

private:
  /// Pointer to the <Consumer_Handler> that receives notifications
  /// from the <Event_Comm::Notifier>.
    Consumer_Handler *receiver_handler_;

  /// Keep track of whether the Consumer initiated the shutdown.
  int consumer_initiated_shutdown_;
};

#endif /* CONSUMER_INPUT_HANDLER_H */