diff options
author | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-07 02:15:07 +0000 |
---|---|---|
committer | pradeep <pradeep@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1998-11-07 02:15:07 +0000 |
commit | 2770d353d7db5babaf0e91a6ae22ede422a90a73 (patch) | |
tree | 9c18f5ecbfdd6cb04f7d0d5981f94d8a9563c93a | |
parent | cc65dd746abdc21e8ef1e877e813127dae1bea03 (diff) | |
download | ATCD-2770d353d7db5babaf0e91a6ae22ede422a90a73.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/examples/Event_Comm/Consumer_Handler.cpp | 20 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Consumer_Handler.h | 4 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Consumer_Input_Handler.cpp | 38 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Consumer_Input_Handler.h | 16 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Event_Comm_i.cpp | 14 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Supplier_Input_Handler.cpp | 61 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/Supplier_Input_Handler.h | 20 | ||||
-rw-r--r-- | TAO/examples/Event_Comm/consumer.cpp | 3 |
8 files changed, 61 insertions, 115 deletions
diff --git a/TAO/examples/Event_Comm/Consumer_Handler.cpp b/TAO/examples/Event_Comm/Consumer_Handler.cpp index 4e9d7f17a15..70ddac094b4 100644 --- a/TAO/examples/Event_Comm/Consumer_Handler.cpp +++ b/TAO/examples/Event_Comm/Consumer_Handler.cpp @@ -11,30 +11,12 @@ Consumer_Handler::Consumer_Handler (void) // No-Op. } -// Destroy a Receiver target object. - Consumer_Handler::~Consumer_Handler (void) { // No-Op. } int -Consumer_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - if (this->receiver_ != 0) - { - ACE_DEBUG ((LM_DEBUG, - "closing down Consumer_Handler\n")); - - CORBA::release (this->receiver_.in ()); - this->receiver_ = 0; - CORBA::release (this->notifier_.in ()); - this->notifier_ = 0; - } - return 0; -} - -int Consumer_Handler::init (int argc, char *argv[]) { char *filtering_criteria = ""; @@ -122,7 +104,7 @@ Consumer_Handler::get_notifier (void) } void -Consumer_Handler:: close (void) +Consumer_Handler::close (void) { this->orb_->shutdown (); } diff --git a/TAO/examples/Event_Comm/Consumer_Handler.h b/TAO/examples/Event_Comm/Consumer_Handler.h index 3cc1209ff70..0bed428eb27 100644 --- a/TAO/examples/Event_Comm/Consumer_Handler.h +++ b/TAO/examples/Event_Comm/Consumer_Handler.h @@ -59,10 +59,6 @@ public: ACE_Reactor *reactor (void); - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::NULL_MASK); - // Close down the handler. - private: int get_notifier (void); // gets the notifier reference from the naming service. diff --git a/TAO/examples/Event_Comm/Consumer_Input_Handler.cpp b/TAO/examples/Event_Comm/Consumer_Input_Handler.cpp index 6890c591587..ff24597e80a 100644 --- a/TAO/examples/Event_Comm/Consumer_Input_Handler.cpp +++ b/TAO/examples/Event_Comm/Consumer_Input_Handler.cpp @@ -6,7 +6,7 @@ ACE_RCSID(Consumer, Consumer_Input_Handler, "$Id$") Consumer_Input_Handler::Consumer_Input_Handler (void) - : handle_ (0), + : //handle_ (0), receiver_handler_ (0), consumer_initiated_shutdown_ (0) { @@ -30,14 +30,8 @@ Consumer_Input_Handler::consumer_initiated_shutdown (int c) this->consumer_initiated_shutdown_ = c; } -ACE_HANDLE -Consumer_Input_Handler::get_handle (void) const -{ - return this->handle_; -} - int -Consumer_Input_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +Consumer_Input_Handler::handle_close (void) { ACE_DEBUG ((LM_DEBUG, "closing down Consumer::Input_Handler\n")); @@ -69,28 +63,28 @@ Consumer_Input_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) TAO_ENDTRY; } - if (this->receiver_handler_->reactor ()->remove_handler - (this, - // Don't execute a callback here otherwise we'll recurse - // indefinitely! - ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL) == -1) - ACE_ERROR ((LM_ERROR, - "%p\n", - "remove_handler")); + // Make sure to cleanup the STDIN handler. + if (ACE_Event_Handler::remove_stdin_handler + (TAO_ORB_Core_instance ()->reactor (), + TAO_ORB_Core_instance ()->thr_mgr ()) == -1) + ACE_ERROR ((LM_ERROR, + "%p\n", + "remove_stdin_handler")); + return 0; } -int Consumer_Input_Handler::initialize (Consumer_Handler *ch, - ACE_HANDLE handle) +int Consumer_Input_Handler::initialize (Consumer_Handler *ch) { receiver_handler_ = ch; - handle_ = handle; - if (this->receiver_handler_->reactor()->register_handler + if (ACE_Event_Handler::register_stdin_handler (this, - ACE_Event_Handler::READ_MASK) == -1) + TAO_ORB_Core_instance ()->reactor (), + TAO_ORB_Core_instance ()->thr_mgr ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, - "Consumer_Input_Handler::Input_Handler\n"), + "%p\n", + "register_stdin_handler"), -1); return 0; } diff --git a/TAO/examples/Event_Comm/Consumer_Input_Handler.h b/TAO/examples/Event_Comm/Consumer_Input_Handler.h index 7e66ee38c0e..a16a34813d5 100644 --- a/TAO/examples/Event_Comm/Consumer_Input_Handler.h +++ b/TAO/examples/Event_Comm/Consumer_Input_Handler.h @@ -26,7 +26,7 @@ // Forward declaration. class Consumer_Handler; -class Consumer_Input_Handler : public ACE_Service_Object +class Consumer_Input_Handler : public ACE_Event_Handler { // = TITLE // Handles input events generated from a keyboard. @@ -43,16 +43,14 @@ public: ~Consumer_Input_Handler (void); // Destructor. - int initialize (Consumer_Handler *, - ACE_HANDLE h = 0); + int initialize (Consumer_Handler *); // registers the input event handler. // returns 0 on success, -1 on error. virtual int handle_input (ACE_HANDLE); // Dispatch the callback when events occur. - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::NULL_MASK); + virtual int handle_close (void); // Close down the handler. int consumer_initiated_shutdown (void); @@ -62,13 +60,7 @@ public: // Indicate that the Consumer initiated the shutdown. private: - virtual ACE_HANDLE get_handle (void) const; - // Obtain the input HANDLE. - - ACE_HANDLE handle_; - // ACE_HANDLE where the input comes from. - - Consumer_Handler *receiver_handler_; + Consumer_Handler *receiver_handler_; // Pointer to the <Consumer_Handler> that receives notifications // from the <Event_Comm::Notifier>. diff --git a/TAO/examples/Event_Comm/Event_Comm_i.cpp b/TAO/examples/Event_Comm/Event_Comm_i.cpp index e42148c3ebc..bab49f56b0a 100644 --- a/TAO/examples/Event_Comm/Event_Comm_i.cpp +++ b/TAO/examples/Event_Comm/Event_Comm_i.cpp @@ -101,9 +101,17 @@ Consumer_Entry::Consumer_Entry (Event_Comm::Consumer *consumer, ACE_ALLOCATOR (compile_buffer, ACE_OS::strdup ("")); else + { + #if defined (ACE_HAS_REGEX) // Compile the regular expression (the 0's cause ACE_OS::compile // to allocate space). compile_buffer = ACE_OS::compile (filtering_criteria, 0, 0); + #else + // Win32 does not support regular expression functions such as compile. + ACE_ALLOCATOR (compile_buffer, + ACE_OS::strdup ("")); + #endif // #if defined (ACE_HAS_REGEX) + } // Should throw an exception here! ACE_ASSERT (compile_buffer != 0); @@ -331,9 +339,13 @@ Notifier_i::push (const Event_Comm::Event &event, const char *criteria = me->int_id_->criteria (); ACE_ASSERT (criteria); - // Do a regular expression comparison to determine matching. + #if defined (ACE_HAS_REGEX) + // Do a regular expression comparison to determine matching. if (ACE_OS::strcmp ("", criteria) == 0 // Everything matches the wildcard. || ACE_OS::step (event.tag_, regexp) != 0) + #endif // #if defined (ACE_HAS_REGEX) + // if ACE_HAS_REGEX has not been defined, + // let everything through. { ACE_DEBUG ((LM_DEBUG, "string %s matched regexp \"%s\" for client %x\n", diff --git a/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp b/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp index 8f00d6d124a..ad8793474e3 100644 --- a/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp +++ b/TAO/examples/Event_Comm/Supplier_Input_Handler.cpp @@ -7,7 +7,7 @@ ACE_RCSID(Supplier, Supplier_Input_Handler, "$Id$") Supplier_Input_Handler::Supplier_Input_Handler () - : handle_ (0), + : //handle_ (0), notifier_ (0) { // No-Op. @@ -20,59 +20,40 @@ Supplier_Input_Handler::~Supplier_Input_Handler (void) } int -Supplier_Input_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +Supplier_Input_Handler::handle_close (void) { ACE_DEBUG ((LM_DEBUG, "closing down Supplier::Supplier_Input_Handler\n")); - Event_Comm::Notifier *notifier = this->notifier_->notifier (); - ACE_ASSERT (notifier != 0); - - ACE_OS::fclose (this->fp_); - - if (ACE_Reactor::instance ()->remove_handler - (this, - // Don't execute a callback here otherwise we'll recurse - // indefinitely! - ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL) == -1) + // Make sure to cleanup the STDIN handler. + if (ACE_Event_Handler::remove_stdin_handler + (TAO_ORB_Core_instance ()->reactor (), + TAO_ORB_Core_instance ()->thr_mgr ()) == -1) ACE_ERROR ((LM_ERROR, - "%p\n", - "remove_handler")); - return 0; + "%p\n", + "remove_stdin_handler")); + + return 0; } int -Supplier_Input_Handler::initialize (Notifier_Handler *notifier, - ACE_HANDLE handle) // Use stdin by default. +Supplier_Input_Handler::initialize (Notifier_Handler *notifier) { notifier_ = notifier; - handle_ = handle; + // Register our <Input_Handler> to handle STDIN events, which will + // trigger the <handle_input> method to process these events. - // Register ourselves with the ACE_Reactor so that input events - // cause our handle_input() method to be dispatched automatically. - - if (ACE_Reactor::instance ()->register_handler + if (ACE_Event_Handler::register_stdin_handler (this, - ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p\n", - "register_handler"), - -1); - - this->fp_ = ACE_OS::fdopen (handle, "r"); - - if (this->fp_ == 0) + TAO_ORB_Core_instance ()->reactor (), + TAO_ORB_Core_instance ()->thr_mgr ()) == -1) ACE_ERROR_RETURN ((LM_ERROR, "%p\n", - "fdopen"), - -1); - return 0; -} + "register_stdin_handler"), + -1); -ACE_HANDLE -Supplier_Input_Handler::get_handle (void) const -{ - return this->handle_; + + return 0; } // Frame input events and notify <Consumers>. @@ -86,7 +67,7 @@ Supplier_Input_Handler::handle_input (ACE_HANDLE h) if (ACE_OS::fgets (buf, sizeof buf - 1, - this->fp_) == 0) + stdin) == 0) { ACE_OS::strcpy (buf, "quit"); diff --git a/TAO/examples/Event_Comm/Supplier_Input_Handler.h b/TAO/examples/Event_Comm/Supplier_Input_Handler.h index f5811d12458..e509f5e162b 100644 --- a/TAO/examples/Event_Comm/Supplier_Input_Handler.h +++ b/TAO/examples/Event_Comm/Supplier_Input_Handler.h @@ -30,7 +30,7 @@ // Forward declaration. class Notifier_Handler; -class Supplier_Input_Handler : public ACE_Service_Object +class Supplier_Input_Handler : public ACE_Event_Handler { // = TITLE // Handles input events generated from a keyboard. @@ -47,29 +47,19 @@ public: ~Supplier_Input_Handler (void); // Destructor. - int initialize (Notifier_Handler *, ACE_HANDLE = ACE_STDIN); - // Initialization, uses stdin by default. + int initialize (Notifier_Handler *); + // Initialization. virtual int handle_input (ACE_HANDLE); // Frame input events and notify <Consumers>. - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::NULL_MASK); + virtual int handle_close (void); // Close down the handler. protected: - virtual ACE_HANDLE get_handle (void) const; - // Return the input handle. - - ACE_HANDLE handle_; - // ACE_HANDLE where the input comes from. - - Notifier_Handler *notifier_; + Notifier_Handler *notifier_; // Pointer to a <Notifier_Handler> that's used to inform Consumers // that events of interest have occurred. - - FILE *fp_; - // Pointer to an input FILE. }; #endif /* SUPPLIER_INPUT_HANDLER_H */ diff --git a/TAO/examples/Event_Comm/consumer.cpp b/TAO/examples/Event_Comm/consumer.cpp index 49d12a7bdd3..f94e7199450 100644 --- a/TAO/examples/Event_Comm/consumer.cpp +++ b/TAO/examples/Event_Comm/consumer.cpp @@ -46,8 +46,7 @@ Consumer::Consumer (void) Consumer::~Consumer (void) { // Allow the handlers to clean up. - this->ih_.handle_close (); - this->ch_.handle_close (); + this->ih_.handle_close (); } int |