Changes to attempt to silence bcc64x
[ACE_TAO.git] / TAO / examples / Event_Comm / consumer.cpp
blobd368c5262db3af9c411a1ea8edbb7fca34206d4f
1 #include "Consumer_Handler.h"
2 #include "Consumer_Input_Handler.h"
4 /**
5 * Consumer driver for the Publish/Subscribe example.
7 * The Consumer holds the <Consumer_Input_Handler> and
8 * <Cosumer_Handler> objects.
9 */
10 class Consumer : public ACE_Event_Handler, public ShutdownCallback
12 public:
13 Consumer () = default;
14 // Constructor.
16 ~Consumer () = default;
17 // Destructor.
19 int initialize (int argc, ACE_TCHAR *argv[]);
20 // Initialization method.
22 int run ();
23 // Execute the consumer;
25 //FUZZ: disable check_for_lack_ACE_OS
26 virtual void close ();
27 // Shutdown the consumer.
28 //FUZZ: enable check_for_lack_ACE_OS
30 private:
31 virtual int handle_signal (int signum, siginfo_t *, ucontext_t *);
32 // Signal handler method.
34 Consumer_Input_Handler ih_;
35 // Handler for keyboard input.
37 Consumer_Handler ch_;
38 // Handler for CORBA Consumer.
41 int
42 Consumer::handle_signal (int signum,
43 siginfo_t *,
44 ucontext_t *)
46 ACE_DEBUG ((LM_DEBUG,
47 "%S\n",
48 signum));
50 // Indicate that the consumer initiated the shutdown.
51 this->ih_.consumer_initiated_shutdown (1);
53 this->close ();
55 return 0;
58 void
59 Consumer::close ()
61 // clean up the input handler.
62 ih_.close ();
63 // Shut down the ORB
64 ch_.close ();
67 int
68 Consumer::run ()
70 // Run the <Consumer_Handler>'s ORB.
71 return ch_.run ();
74 int
75 Consumer::initialize (int argc, ACE_TCHAR *argv[])
77 // Initialize the <Consumer_Handler>.
78 if (this->ch_.init (argc, argv, this) == -1)
79 ACE_ERROR_RETURN ((LM_ERROR,
80 "%p\n",
81 "Consumer_Handler failed to initialize\n"),
82 -1);
83 // Initialize the <Consumer_Input_Handler>.
84 else if (this->ih_.initialize (&this->ch_) == -1)
85 ACE_ERROR_RETURN ((LM_ERROR,
86 "%p\n",
87 "Consumer_Input_Handler failed to initialize\n"),
88 -1);
89 else if (this->ch_.reactor ()->register_handler (SIGINT,
90 this) == -1)
91 ACE_ERROR_RETURN ((LM_ERROR,
92 "%p\n",
93 "register_handler"),
94 -1);
95 else
96 return 0;
99 int
100 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
102 // Initialize the supplier and consumer object references.
103 Consumer consumer;
105 if (consumer.initialize (argc, argv) == -1)
106 ACE_ERROR_RETURN ((LM_ERROR,
107 "%p\n",
108 "Consumer init failed\n"),
111 // Loop forever handling events.
112 if (consumer.run () == -1)
113 ACE_ERROR_RETURN ((LM_ERROR,
114 "%p\n",
115 "Consumer run failed\n"),
118 return 0;