diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-01-01 08:00:34 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1997-01-01 08:00:34 +0000 |
commit | 437eea6fa08e931864f89be91d14a816f69075c7 (patch) | |
tree | b8c1fd723fdcd61c3855d3a3a21a9cd45a268219 /apps/Orbix-Examples/Event_Comm/Supplier | |
parent | ea0d28240863caf437a18071bfd03e7b146c5ade (diff) | |
download | ATCD-unlabeled-4.2.2.tar.gz |
This commit was manufactured by cvs2svn to create branchunlabeled-4.2.2
'unlabeled-4.2.2'.
Diffstat (limited to 'apps/Orbix-Examples/Event_Comm/Supplier')
6 files changed, 0 insertions, 592 deletions
diff --git a/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.cpp b/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.cpp deleted file mode 100644 index 0769ecfcd69..00000000000 --- a/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.cpp +++ /dev/null @@ -1,120 +0,0 @@ -#include "Event_Comm.hh" -// $Id$ - -#include "Notifier_Handler.h" -#include "Input_Handler.h" - -#if defined (ACE_HAS_ORBIX) - -int -Input_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - ACE_DEBUG ((LM_DEBUG, "closing down Supplier::Input_Handler\n")); - - Event_Comm::Notifier *notifier = this->notifier_->notifier (); - ACE_ASSERT (notifier != 0); - - ACE_OS::fclose (this->fp_); - - TRY { - // Disconnect all the consumers gracefully. - notifier->send_disconnect ("quit", IT_X); - } CATCHANY { - cerr << IT_X << endl; - } ENDTRY; - - // Don't execute a callback here otherwise we'll recurse indefinitely! - if (ACE_Service_Config::reactor ()->remove_handler (this, ACE_Event_Handler::READ_MASK - | ACE_Event_Handler::DONT_CALL) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "remove_handler")); - - // *Must* be allocated dyanmically! - delete (void *) this; - return 0; -} - -Input_Handler::Input_Handler (Notifier_Handler *notifier, - ACE_HANDLE handle) // Use stdin by default. - : notifier_ (notifier), - handle_ (handle) -{ - // Register ourselves with the ACE_Reactor so that input events - // cause our handle_input() method to be dispatched automatically. - - if (ACE_Service_Config::reactor ()->register_handler (this, - ACE_Event_Handler::READ_MASK) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); - - this->fp_ = ACE_OS::fdopen (handle, "r"); - - if (this->fp_ == 0) - ACE_ERROR ((LM_ERROR, "%p\n", "fdopen")); -} - -Input_Handler::~Input_Handler (void) -{ - ACE_DEBUG ((LM_DEBUG, "closing down Input_Handler::~Input_Handler\n")); - this->handle_close (); -} - -ACE_HANDLE -Input_Handler::get_handle (void) const -{ - return this->handle_; -} - -// Frame input events and notify <Consumers>. - -int -Input_Handler::handle_input (ACE_HANDLE h) -{ - char buf[BUFSIZ]; - - // Read up to BUFSIZ worth of data from ACE_HANDLE h. - - if (ACE_OS::fgets (buf, sizeof buf - 1, this->fp_) == 0) - { - ACE_OS::strcpy (buf, "quit"); - ACE_DEBUG ((LM_DEBUG, "shutting down Input_Handler\n")); - } - else - { - size_t n = ACE_OS::strlen (buf); - - // Null terminate the buffer, replacing the '\n' with '\0'. - if (buf[n - 1] == '\n' || buf[n - 1] == EOF) - buf[n - 1] = '\0'; - else - buf[n] = '\0'; - ACE_DEBUG ((LM_DEBUG, "notifying for event %s\n", buf)); - } - - Event_Comm::Notifier *notifier = this->notifier_->notifier (); - ACE_ASSERT (notifier != 0); - - if (ACE_OS::strcmp (buf, "quit") == 0) - // Tell the main event loop to shutdown. - ACE_Service_Config::end_reactor_event_loop (); - else - { - // Use the notifier to notify Consumers. - TRY { - Event_Comm::Notification notification; - - // Pass the buf over in the tag field. - notification.tag_ = ACE_OS::strdup (buf); - - // This is where the "any" value goes or the object reference... - // notification.value_ = ... - - // Forward <Notification> to all <Notification_Receivers>. - notifier->send_notification (notification, IT_X); - } - CATCHANY { - cerr << "unexpected exception " << IT_X << endl; - } ENDTRY; - } - return 0; -} - -#endif /* ACE_HAS_ORBIX */ diff --git a/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.h b/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.h deleted file mode 100644 index c888b1e75cd..00000000000 --- a/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - - -// ============================================================================ -// -// = LIBRARY -// EventComm -// -// = FILENAME -// Input_Handler.h -// -// = DESCRIPTION -// Handle input from the keyboard. -// -// = AUTHOR -// Douglas C. Schmidt (schmidt@cs.wustl.edu) -// -// ============================================================================ - -#if !defined (_INPUT_HANDLER_H) -#define _INPUT_HANDLER_H - -#include "ace/Service_Config.h" - -#if defined (ACE_HAS_ORBIX) - -// Forward declaration. -class Notifier_Handler; - -class Input_Handler : public ACE_Service_Object - // = TITLE - // Handles input events generated from a keyboard. - // - // = DESCRIPTION - // The events are currently framed and forwarded to - // all Consumers. In the future, we will need to - // be more selective and only send to those Consumers - // whose filtering criteria matches! -{ -public: - Input_Handler (Notifier_Handler *, ACE_HANDLE = 0); // Use stdin by default. - - 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); - // Close down the handler. - -protected: - virtual ACE_HANDLE get_handle (void) const; - - ACE_HANDLE handle_; - // ACE_HANDLE where the input comes from. - - 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 ACE_FILE. - -private: - ~Input_Handler (void); - // Ensure dynamic allocation. -}; - -#endif /* ACE_HAS_ORBIX */ -#endif /* _INPUT_HANDLER_H */ diff --git a/apps/Orbix-Examples/Event_Comm/Supplier/Makefile b/apps/Orbix-Examples/Event_Comm/Supplier/Makefile deleted file mode 100644 index 4ded1a20e24..00000000000 --- a/apps/Orbix-Examples/Event_Comm/Supplier/Makefile +++ /dev/null @@ -1,164 +0,0 @@ -#---------------------------------------------------------------------------- -# @(#)Makefile 1.1 10/18/96 -# -# Makefile for the Notifier. -#---------------------------------------------------------------------------- - -#---------------------------------------------------------------------------- -# Local macros -#---------------------------------------------------------------------------- - -BIN = supplier - -FILES = Input_Handler \ - Notifier_Handler - -LSRC = $(addsuffix .cpp,$(FILES)) supplier.cpp -LOBJ = $(addsuffix .o,$(FILES)) -SHOBJ = $(addsuffix .so,$(FILES)) - -SRX = ../src/.obj - -LDLIBS = $(addprefix .shobj/,$(LOBJ)) ../src/libEvent_Comm.a - -VLDLIBS = $(LDLIBS:%=%$(VAR)) - -BUILD = $(VBIN) - -#---------------------------------------------------------------------------- -# Include macros and targets -#---------------------------------------------------------------------------- - -include $(WRAPPER_ROOT)/include/makeinclude/wrapper_macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/macros.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.common.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.nonested.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.lib.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.bin.GNU -include $(WRAPPER_ROOT)/include/makeinclude/rules.local.GNU - -#---------------------------------------------------------------------------- -# Local targets -#---------------------------------------------------------------------------- - -CPPFLAGS += -I../include -VLDLIBS += -lgen - -#---------------------------------------------------------------------------- -# Dependencies -#---------------------------------------------------------------------------- - -# DO NOT DELETE THIS LINE -- g++dep uses it. -# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. - -Input_Handler.o: Input_Handler.cpp ../include/Event_Comm.hh Notifier_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/CORBA_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Config.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Reactor.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Handle_Set.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/sysincludes.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/config.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Handle_Set.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Timer_Queue.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Event_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Time_Value.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch_T.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Timer_Queue.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Signal.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Set.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Token.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Reactor.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Msg.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Record.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Priority.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Record.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Msg.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Object.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Shared_Object.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Record.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Manager.h \ - ../include/Event_Comm_i.h ../include/Notification_Receiver_i.h \ - ../include/Notifier_i.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Map_Manager.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/SString.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/SString.i \ - Input_Handler.h -Notifier_Handler.o: Notifier_Handler.cpp Notifier_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/CORBA_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Config.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Reactor.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Handle_Set.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/sysincludes.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/config.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Handle_Set.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Timer_Queue.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Event_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Time_Value.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch_T.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Timer_Queue.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Signal.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Set.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Token.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Reactor.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Msg.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Record.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Priority.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Record.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Msg.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Object.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Shared_Object.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Record.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Manager.h \ - ../include/Event_Comm_i.h ../include/Notification_Receiver_i.h \ - ../include/Notifier_i.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Map_Manager.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/SString.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/SString.i \ - ../include/Event_Comm.hh -supplier.o: supplier.cpp \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Config.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Reactor.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Handle_Set.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/sysincludes.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/config.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Handle_Set.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Timer_Queue.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Event_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Time_Value.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch_T.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Timer_Queue.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Signal.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Set.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Token.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Reactor.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Msg.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Record.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Priority.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Record.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Log_Msg.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.i \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Object.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Shared_Object.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Service_Record.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Manager.h \ - Notifier_Handler.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/CORBA_Handler.h \ - ../include/Event_Comm_i.h ../include/Notification_Receiver_i.h \ - ../include/Notifier_i.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Map_Manager.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/SString.h \ - /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/SString.i \ - ../include/Event_Comm.hh Input_Handler.h - -# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.cpp b/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.cpp deleted file mode 100644 index 41f68c77b86..00000000000 --- a/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.cpp +++ /dev/null @@ -1,66 +0,0 @@ -#include "Notifier_Handler.h" -// $Id$ - - -#if defined (ACE_HAS_ORBIX) - -#if defined (ACE_HAS_MT_ORBIX) -typedef ACE_MT_CORBA_Handler CORBA_HANDLER; -#else -typedef ACE_ST_CORBA_Handler CORBA_HANDLER; -#endif /* ACE_HAS_MT_ORBIX */ - -int -Notifier_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - if (this->notifier_ != 0) - { - ACE_DEBUG ((LM_DEBUG, "closing down Notifier_Handler\n")); - CORBA_HANDLER::instance ()->deactivate_service (Event_Comm_Notifier_IMPL, - this->notifier_->_marker ()); - CORBA::release (this->notifier_); - this->notifier_ = 0; - // *Must* be allocated dyanmically! - delete this; - } - return 0; -} - -Event_Comm::Notifier * -Notifier_Handler::notifier (void) -{ - return this->notifier_; -} - -void -Notifier_Handler::notifier (Event_Comm::Notifier *notifier) -{ - if (this->notifier_ != notifier) - { - CORBA::release (this->notifier_); - this->notifier_ = notifier; - } -} - -// Create and initialize a Notifier target object. - -Notifier_Handler::Notifier_Handler (const char *service_location, - const char *marker, - int putit) -{ - CORBA_HANDLER::instance ()->activate_service (Event_Comm_Notifier_IMPL, - putit ? marker : 0, service_location); - - // Create a notifier object using the implementation class Notifier_i. - this->notifier_ = - new TIE_Event_Comm_Notifier (Notifier_i) (new Notifier_i, marker); -} - -// Destroy a Notifier target object. - -Notifier_Handler::~Notifier_Handler (void) -{ - this->handle_close (); -} - -#endif /* ACE_HAS_ORBIX */ diff --git a/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.h b/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.h deleted file mode 100644 index 43730693c93..00000000000 --- a/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// EventComm -// -// = FILENAME -// Notifier_Handler.h -// -// = DESCRIPTION -// Integrate CORBA with the ACE ACE_Reactor. -// -// = AUTHOR -// Douglas C. Schmidt (schmidt@cs.wustl.edu) -// -// ============================================================================ - -#if !defined (_NOTIFIER_HANDLER_H) -#define _NOTIFIER_HANDLER_H - -#include "ace/CORBA_Handler.h" -#include "Event_Comm_i.h" - -#if defined (ACE_HAS_ORBIX) - -class Notifier_Handler - // = TITLE - // Integrate CORBA with the ACE ACE_Reactor. - // - // = DESCRIPTION - // -{ -public: - Notifier_Handler (const char *service_location, - const char *marker = "notifier", - int putit = 1); // Default marker name. - - Event_Comm::Notifier *notifier (void); - void notifier (Event_Comm::Notifier *); - - virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, - ACE_Reactor_Mask = ACE_Event_Handler::NULL_MASK); - // Close down the handler. - -private: - ~Notifier_Handler (void); - // Ensure dynamic allocation. - - Event_Comm::Notifier *notifier_; - // Pointer to an a <Event_Comm::Notifier> object. -}; - -#endif /* ACE_HAS_ORBIX */ -#endif /* _NOTIFIER_HANDLER_H */ diff --git a/apps/Orbix-Examples/Event_Comm/Supplier/supplier.cpp b/apps/Orbix-Examples/Event_Comm/Supplier/supplier.cpp deleted file mode 100644 index 0b818020e2c..00000000000 --- a/apps/Orbix-Examples/Event_Comm/Supplier/supplier.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/* -*- C++ -*- */ -// $Id$ - -// Supplier driver for the Orbix Publish/Subscribe example. - -// The executable file generated from this code should be registered -// (under the name 'logger') using the 'putit' command. - -#include "ace/Service_Config.h" - -#include "Notifier_Handler.h" -#include "Input_Handler.h" - -#if defined (ACE_HAS_ORBIX) - -class Supplier : public ACE_Event_Handler -{ -public: - Supplier (int argc, char *argv[]); - ~Supplier (void); - - void run (void); - // Execute the supplier. - -private: - virtual int handle_signal (int signum, siginfo_t *, ucontext_t *); - - virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); - - Input_Handler *ih_; - // Handler for keyboard input. - - Notifier_Handler *nh_; - // Handler for CORBA Notifier. - - ACE_Service_Config daemon_; - // ACE server event-loop mechanism. -}; - -int -Supplier::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - ACE_DEBUG ((LM_DEBUG, "closing down Supplier\n")); - return 0; -} - -int -Supplier::handle_signal (int signum, siginfo_t *, ucontext_t *) -{ - ACE_DEBUG ((LM_DEBUG, "%S\n", signum)); - ACE_Service_Config::end_reactor_event_loop (); - return 0; -} - -void -Supplier::run (void) -{ - if (ACE_Service_Config::run_reactor_event_loop () == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "run_reactor_event_loop")); -} - -Supplier::Supplier (int argc, char *argv[]) - : ih_ (0), - nh_ (0) -{ - // Initialize the server. - if (this->daemon_.open (argc, argv) == -1) - { - if (errno == ENOENT) // There's no svc.conf file, so use static linking... - { - ACE_DEBUG ((LM_DEBUG, "no config file, using static binding\n")); - // The constructor registers the handlers... - int putit = argc > 1 ? 1 : 0; - - // Pass in program exec name to use a service_location! - this->nh_ = new Notifier_Handler (argv[0], "notifier", putit); - ACE_ASSERT (this->nh_ != 0); - this->ih_ = new Input_Handler (this->nh_); - ACE_ASSERT (this->ih_ != 0); - } - else - ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1)); - } - - ACE_DEBUG ((LM_DEBUG, "starting up server %s\n", - CORBA::Orbix.myImplementationName ())); - - if (ACE_Service_Config::reactor ()->register_handler (SIGINT, this) == -1) - ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); -} - -Supplier::~Supplier (void) -{ - // Free up the handlers if they were statically bound. - this->ih_->handle_close (); - this->nh_->handle_close (); -} - -int -main (int argc, char *argv[]) -{ - // Initialize server daemon. - Supplier supplier (argc, argv); - - // Loop forever handling events. - supplier.run (); - - return 0; -} -#else /* !defined ACE_HAS_ORBIX */ -int -main (int argc, char *argv[]) -{ - ACE_ERROR_RETURN ((LM_ERROR, "you must have Orbix to run application %s\n", argv[0]), 1); -} -#endif /* ACE_HAS_ORBIX */ |