Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / TAO / examples / Event_Comm / Consumer_Input_Handler.h
blobb8a91aea145dd8b54da8127bccdf73fa3f227aa4
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Consumer_Input_Handler.h
7 * @author Douglas C. Schmidt (d.schmidt@vanderbilt.edu)
8 */
9 //=============================================================================
12 #ifndef CONSUMER_INPUT_HANDLER_H
13 #define CONSUMER_INPUT_HANDLER_H
15 #include "ace/Service_Config.h"
16 #include "ace/Event_Handler.h"
19 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 # pragma once
21 #endif /* ACE_LACKS_PRAGMA_ONCE */
23 // Forward declaration.
24 class Consumer_Handler;
26 /**
27 * @class Consumer_Input_Handler
29 * @brief Handles input events generated from a keyboard.
31 * This class holds a <Consumer_Handler> object. It accepts input
32 * from the user and passes events to the <Notifier>. It also
33 * initiates shutdown.
35 class Consumer_Input_Handler : public ACE_Event_Handler
37 public:
38 // Initialization and termination methods.
39 /// Constructor.
40 Consumer_Input_Handler();
42 /// Destructor.
43 ~Consumer_Input_Handler () = default;
45 /// registers the input event handler.
46 /// returns 0 on success, -1 on error.
47 int initialize (Consumer_Handler *);
49 /// Dispatch the callback when events occur.
50 virtual int handle_input (ACE_HANDLE);
52 /// Close down the handler.
53 int close ();
55 /// Report whether the Consumer initiated the shutdown.
56 int consumer_initiated_shutdown ();
58 /// Indicate that the Consumer initiated the shutdown.
59 void consumer_initiated_shutdown (int);
61 private:
62 /// Pointer to the <Consumer_Handler> that receives notifications
63 /// from the <Event_Comm::Notifier>.
64 Consumer_Handler *receiver_handler_;
66 /// Keep track of whether the Consumer initiated the shutdown.
67 int consumer_initiated_shutdown_;
70 #endif /* CONSUMER_INPUT_HANDLER_H */