Merge pull request #1551 from DOCGroup/plm_jira_333
[ACE_TAO.git] / TAO / examples / Event_Comm / supplier.cpp
bloba6dd1cb8cac335fd2909da216eda351b6eb87e1d
1 #include "Notifier_Handler.h"
2 #include "Supplier_Input_Handler.h"
3 #include "supplier.h"
5 Supplier::Supplier (void)
7 // No-Op.
10 Supplier::~Supplier (void)
12 // No-Op.
15 int
16 Supplier::handle_signal (int signum, siginfo_t *, ucontext_t *)
18 ACE_DEBUG ((LM_DEBUG,
19 "%S\n",
20 signum));
22 this->close ();
23 return 0;
26 void
27 Supplier::run (void)
29 if (nh_.run () == -1)
30 ACE_ERROR ((LM_ERROR,
31 "%p\n",
32 "Notifier_Handler::run"));
35 void
36 Supplier::close (void)
38 ih_.close ();
39 nh_.close ();
42 int
43 Supplier::init (int argc, ACE_TCHAR *argv[])
45 if (this->nh_.init (argc, argv, this) == -1)
46 ACE_ERROR_RETURN ((LM_ERROR,
47 "%p\n",
48 "Notifier_Handler did not init\n"),
49 -1);
50 else if (this->ih_.initialize (&nh_) == -1)
51 ACE_ERROR_RETURN ((LM_ERROR,
52 "%p\n",
53 "Supplier Input handler did not init\n"),
54 -1);
55 else if (nh_.reactor ()->register_handler (SIGINT, this) == -1)
56 ACE_ERROR_RETURN ((LM_ERROR,
57 "%p\n",
58 "register_handler"),
59 -1);
60 ACE_DEBUG ((LM_DEBUG,
61 "Supplier initialized..\n"));
62 return 0;
65 int
66 ACE_TMAIN(int argc, ACE_TCHAR *argv[])
68 // Initialize server daemon.
69 Supplier supplier;
71 try
74 if (supplier.init (argc, argv) == -1)
75 ACE_ERROR_RETURN ((LM_ERROR,
76 "%p\n",
77 "supplier init failed"),
78 1);
80 // Loop forever handling events.
81 supplier.run ();
83 catch (const ::CORBA::Exception &e)
85 e._tao_print_exception ("Caught unexpected CORBA exception : ");
86 return 1;
89 return 0;