From a5fdebc5f6375078ec1763850a4ca23ec7fe6458 Mon Sep 17 00:00:00 2001 From: levine Date: Mon, 21 Oct 1996 21:41:34 +0000 Subject: Initial revision --- .../Event_Comm/Consumer/Input_Handler.cpp | 130 +++ .../Event_Comm/Consumer/Input_Handler.h | 71 ++ apps/Orbix-Examples/Event_Comm/Consumer/Makefile | 165 ++++ .../Consumer/Notification_Receiver_Handler.cpp | 114 +++ .../Consumer/Notification_Receiver_Handler.h | 62 ++ .../Event_Comm/Consumer/consumer.cpp | 114 +++ apps/Orbix-Examples/Event_Comm/Makefile | 26 + apps/Orbix-Examples/Event_Comm/README | 109 +++ .../Event_Comm/Supplier/Input_Handler.cpp | 120 +++ .../Event_Comm/Supplier/Input_Handler.h | 70 ++ apps/Orbix-Examples/Event_Comm/Supplier/Makefile | 164 ++++ .../Event_Comm/Supplier/Notifier_Handler.cpp | 66 ++ .../Event_Comm/Supplier/Notifier_Handler.h | 57 ++ .../Event_Comm/Supplier/supplier.cpp | 116 +++ .../Event_Comm/include/Event_Comm.hh | 887 +++++++++++++++++++++ .../Event_Comm/include/Event_Comm_i.h | 37 + .../Event_Comm/include/Notification_Receiver_i.h | 48 ++ .../Orbix-Examples/Event_Comm/include/Notifier_i.h | 82 ++ .../Orbix-Examples/Event_Comm/libsrc/Event_Comm.hh | 887 +++++++++++++++++++++ .../Event_Comm/libsrc/Event_Comm.idl | 92 +++ .../Event_Comm/libsrc/Event_CommC.cpp | 351 ++++++++ .../Event_Comm/libsrc/Event_CommS.cpp | 166 ++++ .../Event_Comm/libsrc/Event_Comm_i.h | 38 + apps/Orbix-Examples/Event_Comm/libsrc/Makefile | 113 +++ .../Event_Comm/libsrc/Notification.idl | 42 + .../Event_Comm/libsrc/Notification_Receiver.idl | 42 + .../Event_Comm/libsrc/Notification_Receiver_i.cpp | 39 + .../Event_Comm/libsrc/Notification_Receiver_i.h | 48 ++ apps/Orbix-Examples/Event_Comm/libsrc/Notifier.idl | 49 ++ .../Event_Comm/libsrc/Notifier_i.cpp | 324 ++++++++ apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.h | 82 ++ 31 files changed, 4711 insertions(+) create mode 100644 apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.h create mode 100644 apps/Orbix-Examples/Event_Comm/Consumer/Makefile create mode 100644 apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.h create mode 100644 apps/Orbix-Examples/Event_Comm/Consumer/consumer.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/Makefile create mode 100644 apps/Orbix-Examples/Event_Comm/README create mode 100644 apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.h create mode 100644 apps/Orbix-Examples/Event_Comm/Supplier/Makefile create mode 100644 apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.h create mode 100644 apps/Orbix-Examples/Event_Comm/Supplier/supplier.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/include/Event_Comm.hh create mode 100644 apps/Orbix-Examples/Event_Comm/include/Event_Comm_i.h create mode 100644 apps/Orbix-Examples/Event_Comm/include/Notification_Receiver_i.h create mode 100644 apps/Orbix-Examples/Event_Comm/include/Notifier_i.h create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.hh create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.idl create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Event_CommC.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Event_CommS.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm_i.h create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Makefile create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Notification.idl create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver.idl create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.h create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Notifier.idl create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.cpp create mode 100644 apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.h (limited to 'apps/Orbix-Examples/Event_Comm') diff --git a/apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.cpp b/apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.cpp new file mode 100644 index 00000000000..29d8b1218b2 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.cpp @@ -0,0 +1,130 @@ +#include "Input_Handler.h" +// @(#)Input_Handler.cpp 1.1 10/18/96 + +#include "Notification_Receiver_Handler.h" + +#if defined (ACE_HAS_ORBIX) + +Input_Handler::~Input_Handler (void) +{ + ACE_DEBUG ((LM_DEBUG, "closing down Input_Handler::~Input_Handler\n")); + this->handle_close (); +} + +int +Input_Handler::consumer_initiated_shutdown (void) +{ + return this->consumer_initiated_shutdown_; +} + +void +Input_Handler::consumer_initiated_shutdown (int c) +{ + this->consumer_initiated_shutdown_ = c; +} + +ACE_HANDLE +Input_Handler::get_handle (void) const +{ + return this->handle_; +} + +int +Input_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_DEBUG ((LM_DEBUG, "closing down Consumer::Input_Handler\n")); + + Event_Comm::Notification_Receiver *receiver = this->receiver_handler_->receiver (); + Event_Comm::Notifier *notifier = this->receiver_handler_->notifier (); + + if (this->consumer_initiated_shutdown ()) + { + // Only try to unsubscribe if the Consumer initiated the + // shutdown. Otherwise, the Supplier initiated it and + // it has probably gone away by now! + TRY { + // Gracefully shutdown the Receiver by removing it + // from the Notifier's internal map. + + notifier->unsubscribe (receiver, "", 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 (Notification_Receiver_Handler *ch, + ACE_HANDLE handle) + : receiver_handler_ (ch), + handle_ (handle), + consumer_initiated_shutdown_ (0) +{ + if (ACE_Service_Config::reactor ()->register_handler (this, + ACE_Event_Handler::READ_MASK) == -1) + ACE_ERROR ((LM_ERROR, "Input_Handler::Input_Handler\n")); +} + +int +Input_Handler::handle_input (ACE_HANDLE h) +{ + char buf[BUFSIZ]; + ssize_t n; + + // Read up to BUFSIZ worth of data from ACE_HANDLE h. + + n = ACE_OS::read (h, buf, sizeof buf - 1); + + if (n > 0) + { + // 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)); + + } + else + { + ACE_OS::strcpy (buf, "quit"); + ACE_DEBUG ((LM_DEBUG, "shutting down Input_Handler\n")); + } + + Event_Comm::Notifier *notifier = this->receiver_handler_->notifier (); + + ACE_ASSERT (notifier != 0); + + if (ACE_OS::strcmp (buf, "quit") == 0) + { + // Consumer wants to shutdown. + this->consumer_initiated_shutdown (1); + + // Tell the main event loop to shutdown. + ACE_Service_Config::end_reactor_event_loop (); + } + else + { + TRY { + Event_Comm::Notification notification; + + notification.tag_ = ACE_OS::strdup (buf); + + notifier->send_notification (notification, IT_X); + } + CATCHANY { + cerr << "Unexpected exception " << IT_X << endl; + } ENDTRY; + } + + /* NOTREACHED */ + return 0; +} +#endif /* ACE_HAS_ORBIX */ diff --git a/apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.h b/apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.h new file mode 100644 index 00000000000..d2b87d90f57 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Consumer/Input_Handler.h @@ -0,0 +1,71 @@ +/* -*- C++ -*- */ +// @(#)Input_Handler.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Input_Handler.h +// +// = DESCRIPTION +// Subclass of ACE ACE_Service_Object that receives unsubscribes from +// the Notifier when input is received from the keyboard. +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_INPUT_HANDLER_H) +#define _INPUT_HANDLER_ + +#include "ace/Service_Config.h" + +#if defined (ACE_HAS_ORBIX) +// Forward declaration. +class Notification_Receiver_Handler; + +class Input_Handler : public ACE_Service_Object + // = TITLE + // Handles input events generated from a keyboard. + // + // = DESCRIPTION +{ +public: + Input_Handler (Notification_Receiver_Handler *, ACE_HANDLE h = 0); + + 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); + // Close down the handler. + + int consumer_initiated_shutdown (void); + // Report whether the Consumer initiated the shutdown. + + void consumer_initiated_shutdown (int); + // Indicate that the Consumer initiated the shutdown. + +private: + ~Input_Handler (void); + // Ensure dynamic allocation. + + virtual ACE_HANDLE get_handle (void) const; + + ACE_HANDLE handle_; + // ACE_HANDLE where the input comes from. + + Notification_Receiver_Handler *receiver_handler_; + // Pointer to the that + // receives notifications from the . + + int consumer_initiated_shutdown_; + // Keep track of whether the Consumer initiated the shutdown. +}; + +#endif /* ACE_HAS_ORBIX */ +#endif /* _INPUT_HANDLER_H */ diff --git a/apps/Orbix-Examples/Event_Comm/Consumer/Makefile b/apps/Orbix-Examples/Event_Comm/Consumer/Makefile new file mode 100644 index 00000000000..872b72a1880 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Consumer/Makefile @@ -0,0 +1,165 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Consumer. +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +BIN = consumer + +FILES = Notification_Receiver_Handler \ + Input_Handler + +LSRC = $(addsuffix .cpp,$(FILES)) consumer.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. + +Notification_Receiver_Handler.o: Notification_Receiver_Handler.cpp \ + Notification_Receiver_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 +Input_Handler.o: Input_Handler.cpp Input_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 \ + Notification_Receiver_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 +consumer.o: consumer.cpp \ + /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/sysincludes.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/config.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/Synch.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Time_Value.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch_T.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.i \ + Notification_Receiver_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/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/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/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 Input_Handler.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.cpp b/apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.cpp new file mode 100644 index 00000000000..eccf499f6c0 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.cpp @@ -0,0 +1,114 @@ +#include "Notification_Receiver_Handler.h" +// @(#)Notification_Receiver_Handler.cpp 1.1 10/18/96 + + +#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 +Notification_Receiver_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ +// ACE_ST_CORBA_Handler::remove_service (Event_Comm_Notification_Receiver_IMPL); + + if (this->receiver_ != 0) + { + ACE_DEBUG ((LM_DEBUG, "closing down Notification_Receiver_Handler\n")); + CORBA_HANDLER::instance ()->deactivate_service (Event_Comm_Notification_Receiver_IMPL, + this->receiver_->_marker ()); + CORBA::release (this->receiver_); + this->receiver_ = 0; + CORBA::release (this->notifier_); + this->notifier_ = 0; + // *Must* be allocated dynamically in order to delete this! + delete this; + } + return 0; +} + +Notification_Receiver_Handler::Notification_Receiver_Handler (int argc, char *argv[]) + : notifier_ (0), + receiver_ (0) +{ + const char *server_name = Event_Comm_Notification_Receiver_IMPL; + char buf[BUFSIZ]; + char *receiver_marker = buf; + char *filtering_criteria; + char *host; + char *notifier_marker; + char *service_location = argv[0]; + + // First see if we have any environment variables. + filtering_criteria = ACE_OS::getenv ("FILTERING_CRITERIA"); + host = ACE_OS::getenv ("HOST"); + notifier_marker = ACE_OS::getenv ("NOTIFIER_MARKER"); + + // Then override these variables with command-line arguments. + filtering_criteria = argc > 1 ? argv[1] : ""; + host = argc > 2 ? argv[2] : "tango.cs"; + notifier_marker = argc > 3 ? argv[3] : "notifier:" Event_Comm_Notifier_IR; + + CORBA::Orbix.setDiagnostics (0); + + struct utsname name; + + // Make the marker name be the "/hostname/processid" + ACE_OS::uname (&name); + sprintf (buf, "/%s/%d", name.nodename, ACE_OS::getpid ()); + + CORBA_HANDLER::instance ()->activate_service (Event_Comm_Notification_Receiver_IMPL, + receiver_marker, service_location); + + // Create the receiver object. + this->receiver_ = new TIE_Event_Comm_Notification_Receiver (Notification_Receiver_i) + (new Notification_Receiver_i); + + this->receiver_->_marker (receiver_marker); + + ACE_ASSERT (this->receiver_); + + TRY { + // Get a binding to the notifier. + this->notifier_ = Event_Comm::Notifier::_bind (notifier_marker, host, IT_X); + + if (this->notifier_ != CORBA::OBJECT_NIL) + // Subscribe ourselves with the notifier's broker. + this->notifier_->subscribe (this->receiver_, + filtering_criteria, IT_X); + } CATCHANY { + cerr << "Unexpected exception " << IT_X << endl; + ACE_OS::exit (1); + } ENDTRY; + // Print out context. + + receiver_marker = (char *) this->receiver_->_marker (); + CORBA::BOA::activationMode mode = CORBA::Orbix.myActivationMode (); + ACE_DEBUG ((LM_DEBUG, "starting up a %spersistent server in mode %d with marker name %s\n", + mode == CORBA::BOA::persistentActivationMode ? "" : "non-", + mode, receiver_marker)); +} + +Event_Comm::Notification_Receiver * +Notification_Receiver_Handler::receiver (void) +{ + return this->receiver_; +} + +Event_Comm::Notifier * +Notification_Receiver_Handler::notifier (void) +{ + return this->notifier_; +} + +// Destroy a Receiver target object. + +Notification_Receiver_Handler::~Notification_Receiver_Handler (void) +{ + this->handle_close (-1, ACE_Event_Handler::RWE_MASK); +} + +#endif /* ACE_HAS_ORBIX */ diff --git a/apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.h b/apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.h new file mode 100644 index 00000000000..9ccd472ef1b --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Consumer/Notification_Receiver_Handler.h @@ -0,0 +1,62 @@ +/* -*- C++ -*- */ +// @(#)Notification_Receiver_Handler.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notifier_Receiver_Handler.h +// +// = DESCRIPTION +// Subclass of Corba_Handler that sets up the Notification_Receiver handler +// for use with the ACE ACE_Reactor. +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_NOTIFICATION_RECEIVER_HANDLER_H) +#define _NOTIFICATION_RECEIVER_HANDLER_H + +#include "ace/CORBA_Handler.h" +#include "Event_Comm_i.h" + +#if defined (ACE_HAS_ORBIX) + +class Notification_Receiver_Handler + // = TITLE + // Subclass of Corba_Handler that sets up the Notification Receiver handler + // for use with the ACE ACE_Reactor. + // + // = DESCRIPTION + // Note that this class doesn't inherit from ACE_ST_CORBA_Handler (unlike + // the Supplier's Notifier_Handler class). Instead, it uses an + // alternative interface that can be called directly. +{ +public: + Notification_Receiver_Handler (int argc, char *argv[]); + + Event_Comm::Notification_Receiver *receiver (void); + Event_Comm::Notifier *notifier (void); + + virtual int handle_close (ACE_HANDLE = ACE_INVALID_HANDLE, + ACE_Reactor_Mask = ACE_Event_Handler::NULL_MASK); + // Close down the handler. + +private: + ~Notification_Receiver_Handler (void); + // Ensure dynamic allocation. + + Event_Comm::Notification_Receiver *receiver_; + // Pointer to an IDL proxy object. + + Event_Comm::Notifier *notifier_; + // Pointer to an IDL proxy object. +}; + +#endif /* ACE_HAS_ORBIX */ +#endif /* _NOTIFICATION_RECEIVER_HANDLER_H */ diff --git a/apps/Orbix-Examples/Event_Comm/Consumer/consumer.cpp b/apps/Orbix-Examples/Event_Comm/Consumer/consumer.cpp new file mode 100644 index 00000000000..7133a8c8749 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Consumer/consumer.cpp @@ -0,0 +1,114 @@ +/* -*- C++ -*- */ +// @(#)consumer.cpp 1.1 10/18/96 + +// Consumer driver for the Orbix Notification example. + +#include "ace/Log_Msg.h" +#include "Notification_Receiver_Handler.h" +#include "Input_Handler.h" + +#if defined (ACE_HAS_ORBIX) + +class Consumer : public ACE_Event_Handler +{ +public: + Consumer (int argc, char *argv[]); + ~Consumer (void); + + void run (void); + // Execute the consumer; + +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. + + Notification_Receiver_Handler *nrh_; + // Handler for CORBA Consumer. + + ACE_Service_Config daemon_; + // ACE server event-loop mechanism. +}; + +int +Consumer::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_DEBUG ((LM_DEBUG, "closing down Consumer\n")); + return 0; +} + +int +Consumer::handle_signal (int signum, siginfo_t *, ucontext_t *) +{ + ACE_DEBUG ((LM_DEBUG, "%S\n", signum)); + + // Indicate that the consumer initiated the shutdown. + this->ih_->consumer_initiated_shutdown (1); + + // Shut down the event loop. + ACE_Service_Config::end_reactor_event_loop (); + return 0; +} + +// Run the event loop until someone calls +// calls ACE_Service_Config::end_reactor_event_loop(). + +void +Consumer::run (void) +{ + if (ACE_Service_Config::run_reactor_event_loop () == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "run_reactor_event_loop")); +} + +Consumer::Consumer (int argc, char *argv[]) + : ih_ (0), + nrh_ (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... + this->nrh_ = new Notification_Receiver_Handler (argc, argv); + ACE_ASSERT (this->nrh_ != 0); + this->ih_ = new Input_Handler (this->nrh_); + ACE_ASSERT (this->ih_ != 0); + } + else + ACE_ERROR ((LM_ERROR, "%p\n%a", "open", 1)); + } + + if (ACE_Service_Config::reactor ()->register_handler (SIGINT, this) == -1) + ACE_ERROR ((LM_ERROR, "%p\n", "register_handler")); +} + +Consumer::~Consumer (void) +{ + // Free up the handlers if they were statically bound. + this->ih_->handle_close (); + this->nrh_->handle_close (); +} + +int +main (int argc, char *argv[]) +{ + // Initialize the supplier and consumer object references. + Consumer consumer (argc, argv); + + // Loop forever handling events. + consumer.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 */ diff --git a/apps/Orbix-Examples/Event_Comm/Makefile b/apps/Orbix-Examples/Event_Comm/Makefile new file mode 100644 index 00000000000..3e0c8ae2dd8 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Makefile @@ -0,0 +1,26 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the consumer/supplier notification application +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +INFO = README + +DIRS = libsrc \ + Consumer \ + Supplier + +#---------------------------------------------------------------------------- +# 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.nested.GNU +include $(WRAPPER_ROOT)/include/makeinclude/rules.nolocal.GNU + diff --git a/apps/Orbix-Examples/Event_Comm/README b/apps/Orbix-Examples/Event_Comm/README new file mode 100644 index 00000000000..1bd7b5d8c45 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/README @@ -0,0 +1,109 @@ +OVERVIEW + +This directory contains source code for a prototype CORBA-based +distributed notification mechanism. This mechanism implements a +"publish/subscribe" communication protocol. It allows Suppliers to +pass messages containing object references to a dynamically managed +group of Consumers. This is similar to the OMG COSS Event Service, +though not as sophisticated. + +This example also illustrates how to integrate Orbix with the ACE +libraries. + +DIRECTORY STRUCTURE + +There are 4 directories: + +Supplier + + -- The supplier test driver, which must be started + first. It has an instance of an IDL Notifier + object. This object accepts subscriptions from Consumers + and forwards events sent to it either via Consumers or + via its standard input. + + The Supplier must be registered with the ORB using the + following command: + + % putit Event_Comm_Notifier /supplier + +Consumer + + -- The consumer test driver, which must be started + after the Supplier. It has an instance of an + IDL Notification_Receiver object. This object is + used to receive notifications from the Notifier object + residing in the Supplier. When the Consumer starts up it + gets an object reference to the Supplier's Notifier. + It then subscribes its Notification_Receiver object with + the Supplier's Notifier by passing an object reference. + + In addition to passing an object reference to a + Notification_Receiver, the Consumer also may specify a + filtering criteria, which is a regular expression. If + the filtering criteria is the string "" then the Notifier + will send all Notifications to the Consumer (i.e., "" is + treated as a "wildcard"). Otherwise, the filtering + criteria is considered to be a regular expression, + and only those Notification tags that match the regular + expression will be forwarded to the Consumer. The regular + expressions are those used by ed(1) (see the regexp(5) + manual page for more info). + + The Consumer must be registered with the ORB + using the following command: + + % putit Event_Comm_Notification_Receiver /consumer + +include + + -- This contains links to the appropriate header + files. + +libsrc + + -- This contains the IDL files and IDL implementation + classes that support the distributed notification scheme. + These are shared by the Consumer and Supplier. + +RUNNING THE TESTS + +To run the tests do the following: + +1. Compile everything. + +2. Start up the Orbix daemon (orbixd) if it's not already + running. + +3. Register the Consumer (i.e., Notification_Receiver) and Supplier + (i.e., Notifier) with the Orbix daemon (orbixd), as described + above. + +4. Start the Supplier/supplier executable. + +5. Start up as many copies of the Consumer/consumer as you'd like. + Typically, I run each one in its own window. If you'd like to use + different machines make sure that you start up the Orbix daemon on + each one and register the Consumer. + +6. Once the Consumers have subscribed you can send them info by typing + commands in the Supplier window. These will be sent to all the + Consumers who have subscribed. Likewise, you can send messages + from a Consumer to all other Consumers by typing messages in a + Consumer window. + + Note that if you type "quit", ^D, or ^C in a Consumer window the + Consumer will unsubscribe and shutdown its handlers and exit. + Likewise, if you type "quit", ^D, or ^C in the Supplier window + the Supplier will disconnect all of its Consumers and exit. + When a Consumer is disconnected from its Supplier it automatically + shuts itself down. + +7. When you want to terminate a Consumer or a Supplier, just type ^C + and the process will shut down gracefully. + +Please let me know if there are any questions. + + Doug + +schmidt@cs.wustl.edu diff --git a/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.cpp b/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.cpp new file mode 100644 index 00000000000..96a89f0ac6b --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.cpp @@ -0,0 +1,120 @@ +#include "Event_Comm.hh" +// @(#)Input_Handler.cpp 1.1 10/18/96 + +#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 . + +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 to all . + 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 new file mode 100644 index 00000000000..7bd05bbb5db --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Supplier/Input_Handler.h @@ -0,0 +1,70 @@ +/* -*- C++ -*- */ +// @(#)Input_Handler.h 1.1 10/18/96 + + +// ============================================================================ +// +// = 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 . + + 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 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 new file mode 100644 index 00000000000..4ded1a20e24 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Supplier/Makefile @@ -0,0 +1,164 @@ +#---------------------------------------------------------------------------- +# @(#)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 new file mode 100644 index 00000000000..84e9b3380bf --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.cpp @@ -0,0 +1,66 @@ +#include "Notifier_Handler.h" +// @(#)Notifier_Handler.cpp 1.1 10/18/96 + + +#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 new file mode 100644 index 00000000000..5d0be45924c --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Supplier/Notifier_Handler.h @@ -0,0 +1,57 @@ +/* -*- C++ -*- */ +// @(#)Notifier_Handler.h 1.1 10/18/96 + + +// ============================================================================ +// +// = 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 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 new file mode 100644 index 00000000000..927ab73a022 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/Supplier/supplier.cpp @@ -0,0 +1,116 @@ +/* -*- C++ -*- */ +// @(#)supplier.cpp 1.1 10/18/96 + +// 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 "ace/Log_Msg.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 */ diff --git a/apps/Orbix-Examples/Event_Comm/include/Event_Comm.hh b/apps/Orbix-Examples/Event_Comm/include/Event_Comm.hh new file mode 100644 index 00000000000..85ad256da2a --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/include/Event_Comm.hh @@ -0,0 +1,887 @@ + +#ifndef Event_Comm_hh +#define Event_Comm_hh + +#include + +#include + +class Event_Comm { +public: + +#ifndef Event_Comm_Notification_defined +#define Event_Comm_Notification_defined + + struct Notification { + CORBA::String_mgr tag_; + + void encodeOp (CORBA::Request &IT_r) const; + void decodeOp (CORBA::Request &IT_r); + void decodeInOutOp (CORBA::Request &IT_r); + static void* IT_anySupport (CORBA::Request &IT_r, + void *&, void*, const CORBA::Flags&); + static const void *IT_fn; + }; + + static const CORBA::TypeCode_ptr _tc_Notification; + +#ifndef Event_Comm_NotificationVarH +#define Event_Comm_NotificationVarH + +#ifndef Event_Comm_NotificationvPtr +#define Event_Comm_NotificationvPtr +typedef Notification* Notification_vPtr; +#endif + +class Notification_var : public CORBA::_var +{ + public: + + Notification_var () { + _ptr = NULL; + } + + Notification_var (Notification *IT_p) { + _ptr = IT_p; + } + + Notification_var (const Notification_var &IT_s) { + if (!IT_s._ptr) { + _ptr = IT_s._ptr; + return; + } + _ptr = new Notification (*(IT_s._ptr)); + } + + Notification_var &operator= (Notification *IT_p) { + if (_ptr != IT_p) { + delete _ptr; + } + _ptr = IT_p; + return (*this); + } + + Notification_var &operator= (const Notification_var &IT_s) { + if (_ptr != IT_s._ptr) { + delete _ptr; + } + _ptr = new Notification (*(IT_s._ptr)); + return (*this); + } + + ~Notification_var () { + delete _ptr; + } + + Notification* operator-> () { + return _ptr; + } + + operator const Notification_vPtr () const { return _ptr;} + operator Notification_vPtr& () { return _ptr;} + operator Notification& () const { return * _ptr;} + + protected: + Notification *_ptr; + private: + Notification_var &operator= (const CORBA::_var &IT_s); + Notification_var (const CORBA::_var &IT_s); +}; + +#endif + + +#endif + + +#ifndef _Event_Comm_Notification_Receiver_defined +#define _Event_Comm_Notification_Receiver_defined +class Notification_Receiver_dispatch : public virtual CORBA::PPTR { +public: + + Notification_Receiver_dispatch (void *IT_p, CORBA::Object* IT_o, const char *IT_m, + CORBA::LoaderClass *IT_l, char *IT_i, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_l,IT_i,IT_im) {} + + + Notification_Receiver_dispatch (char *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notification_Receiver_dispatch () {} + + Notification_Receiver_dispatch (ObjectReference *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notification_Receiver_dispatch (void *IT_p, CORBA::Object *IT_o, const char *IT_m, + char *IT_i, CORBA::Object* IT_ob, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_i,IT_ob,IT_im) {} + + + virtual unsigned char dispatch (CORBA::Request &IT_r, + unsigned char IT_isTarget, void* IT_pp=NULL); + + +}; + +class Notification_Receiver; + +#ifndef Event_Comm_Notification_ReceiverPtr +#define Event_Comm_Notification_ReceiverPtr + + typedef Notification_Receiver* Notification_Receiver_ptr; + + typedef Notification_Receiver* Notification_ReceiverRef; + +#endif + + +#ifndef Event_Comm_Notification_ReceiverForwH +#define Event_Comm_Notification_ReceiverForwH +static CORBA::ObjectRef Notification_Receiver_getBase (void *); +static void Notification_Receiver_release (Notification_Receiver *, CORBA::Environment &IT_env); +static void Notification_Receiver_release (Notification_Receiver_ptr); +static Notification_Receiver* Notification_Receiver_duplicate (Notification_Receiver_ptr, CORBA::Environment &IT_env); +static Notification_Receiver* Notification_Receiver_duplicate (Notification_Receiver_ptr ); +static Notification_Receiver_ptr Notification_Receiver_nil (CORBA::Environment &IT_env); +static Notification_Receiver_ptr Notification_Receiver_nil (); +#endif +#define Event_Comm_Notification_Receiver_IMPL "Event_Comm_Notification_Receiver" + + +class Notification_Receiver; + + typedef Notification_Receiver Notification_ReceiverProxy; +#define Event_Comm_Notification_Receiver_IR "Event_Comm_Notification_Receiver" +#define Event_Comm_Notification_Receiver_IMPL "Event_Comm_Notification_Receiver" + +#ifndef Event_Comm_Notification_ReceiverPtr +#define Event_Comm_Notification_ReceiverPtr + + typedef Notification_Receiver* Notification_Receiver_ptr; + + typedef Notification_Receiver* Notification_ReceiverRef; + +#endif + +class Notification_Receiver: public virtual CORBA::Object { +public: + Notification_Receiver (char *IT_OR); + Notification_Receiver (ObjectReference *IT_OR); + Notification_Receiver () : CORBA::Object (1) {} +protected: + Notification_Receiver_ptr __duplicate( + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::Object::__duplicate (IT_env); + return this; + } +public: + static Notification_Receiver_ptr _duplicate( + Notification_Receiver_ptr obj, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + if (CORBA::is_nil(obj, IT_env)) { + IT_raise.maybeRaise (); + return (obj); + } + Notification_Receiver_ptr IT_obj = obj->__duplicate (IT_env); + IT_raise.maybeRaise(); + return IT_obj; + } +public: + static Notification_Receiver* _bind (const char* IT_markerServer, const char* host, + const CORBA::Context &IT_c, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notification_Receiver* _bind (CORBA::Environment &IT_env); + static Notification_Receiver* _bind (const char* IT_markerServer=NULL, const char* host=NULL, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notification_Receiver* _narrow (CORBA::Object* , CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notification_Receiver_ptr _nil (CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + IT_raise.maybeRaise(); + return (Notification_Receiver_ptr) CORBA::OBJECT_NIL;} + virtual void receive_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void disconnect (const char * reason, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); +}; + + static const CORBA::TypeCode_ptr _tc_Notification_Receiver; + + static const CORBA::TypeCode_ptr _tc_Notification_ReceiverRef; + +#ifndef Event_Comm_Notification_ReceiverVarH +#define Event_Comm_Notification_ReceiverVarH + +#ifndef Event_Comm_Notification_ReceivervPtr +#define Event_Comm_Notification_ReceivervPtr +typedef Notification_Receiver* Notification_Receiver_vPtr; +#endif + +class Notification_Receiver_var : public CORBA::_var +{ + public: + + Notification_Receiver_var () { + _ptr = Notification_Receiver_nil (); + } + + Notification_Receiver_var (Notification_Receiver *IT_p) { + _ptr = IT_p; + } + + Notification_Receiver_var (const Notification_Receiver_var &IT_s) { + _ptr = Notification_Receiver_duplicate (IT_s._ptr); + } + + Notification_Receiver_var &operator= (Notification_Receiver *IT_p) { + Notification_Receiver_release (_ptr); + _ptr = IT_p; + return (*this); + } + + Notification_Receiver_var &operator= (const Notification_Receiver_var &IT_s) { + Notification_Receiver_release (_ptr); + _ptr = Notification_Receiver_duplicate (IT_s._ptr); + return (*this); + } + + ~Notification_Receiver_var () { + Notification_Receiver_release (_ptr); + } + + Notification_Receiver* operator-> () { + return _ptr; + } + + operator const Notification_Receiver_vPtr () const { return _ptr;} + operator Notification_Receiver_vPtr& () { return _ptr;} + + protected: + Notification_Receiver *_ptr; + private: + Notification_Receiver_var &operator= (const CORBA::_var &IT_s); + Notification_Receiver_var (const CORBA::_var &IT_s); + Notification_Receiver_var &operator= (const CORBA::_mgr &IT_s); + Notification_Receiver_var &operator= (const CORBA::_SeqElem &IT_s); + Notification_Receiver_var (const CORBA::_mgr &IT_s); + Notification_Receiver_var (const CORBA::_SeqElem &IT_s); +}; + +#endif + + +#ifndef Event_Comm_Notification_ReceiverMgrH +#define Event_Comm_Notification_ReceiverMgrH + +class Notification_Receiver_mgr : public CORBA::_mgr +{ + public: + + Notification_Receiver_mgr () { + _ptr = Notification_Receiver_nil (); + _release = 1; + } + + Notification_Receiver_mgr (const Notification_Receiver_mgr &IT_s) { + _ptr = Notification_Receiver_duplicate (IT_s._ptr); + _release = 1; + } + + Notification_Receiver_mgr &operator= (Notification_Receiver *IT_p) { + if (_ptr && _release) + Notification_Receiver_release (_ptr); + _ptr = IT_p; + _release = 1; + return (*this); + } + + Notification_Receiver_mgr &operator= (const Notification_Receiver_mgr &IT_s) { + if (_ptr && _release) + Notification_Receiver_release (_ptr); + _ptr = Notification_Receiver_duplicate(IT_s._ptr); + _release = 1; + return (*this); + } + + Notification_Receiver_mgr &operator= (const Notification_Receiver_var &IT_s) { + if (_ptr && _release) + Notification_Receiver_release (_ptr); + _ptr = Notification_Receiver_duplicate(IT_s); + _release = 1; + return (*this); + } + + ~Notification_Receiver_mgr () { + if (_release) + Notification_Receiver_release (_ptr); + } + + unsigned char release () { + return _release; + } + + void release (unsigned char rel) { + _release = rel; + } + + operator int () const { + CORBA::Environment env; + CORBA::EnvExcRaiser IT_raise (&env); + return (!(CORBA::is_nil((CORBA::Object*) _ptr, env))); + } + + operator void* () const { + return _ptr; + } + + operator CORBA::Object * () const { + return (CORBA::Object *) _ptr; + } + + operator Notification_Receiver* () const { + return (Notification_Receiver*) _ptr; + } + + Notification_Receiver *_ptr; + + protected: + + unsigned char _release; +}; + +#endif + +#ifndef Event_Comm_Notification_ReceiverSeqElemH +#define Event_Comm_Notification_ReceiverSeqElemH + +class Notification_Receiver_SeqElem : public CORBA::_SeqElem +{ + public: + + Notification_Receiver_SeqElem (Event_Comm::Notification_Receiver_ptr* IT_p, unsigned char rel) { + _ptr = IT_p; + _release = rel; + } + + Notification_Receiver_SeqElem &operator= (Event_Comm::Notification_Receiver_ptr IT_p) { + if (!_ptr) + return (*this); + if (*(_ptr) && _release) + Notification_Receiver_release (*(_ptr)); + *(_ptr) = IT_p; + return (*this); + } + + Notification_Receiver_SeqElem &operator= (const Notification_Receiver_SeqElem &IT_s) { + if (!_ptr|| !IT_s._ptr) + return (*this); + if (*(_ptr) && _release) + Notification_Receiver_release (*(_ptr)); + *(_ptr) = Notification_Receiver_duplicate(*(IT_s._ptr)); + return (*this); + } + + operator Event_Comm::Notification_Receiver_ptr () const +{ + if (!_ptr) + return (Notification_Receiver_nil()); + return (Event_Comm::Notification_Receiver_ptr) (*_ptr); + } + + Notification_Receiver_ptr operator->() const { return *_ptr;} + + protected: + Event_Comm::Notification_Receiver_ptr *_ptr; + unsigned char _release; +}; + +#endif + + +#define TIE_Event_Comm_Notification_Receiver(X) Event_Comm_Notification_Receiver##X + +#define DEF_TIE_Event_Comm_Notification_Receiver(X) \ + class Event_Comm_Notification_Receiver##X : public virtual Event_Comm::Notification_Receiver { \ + X* m_obj; \ + public: \ + \ + Event_Comm_Notification_Receiver##X (X *objp, const char* m="", CORBA::LoaderClass *l=0)\ + : Event_Comm::Notification_Receiver(), CORBA::Object (), m_obj(objp) { \ + m_pptr = new Event_Comm::Notification_Receiver_dispatch \ + (( Event_Comm::Notification_Receiver*)this,(CORBA::Object*)this,m,l,Event_Comm_Notification_Receiver_IR,m_obj); \ + } \ + Event_Comm_Notification_Receiver##X (CORBA::Object *IT_p, const char* IT_m="", void *IT_q=0)\ + : Event_Comm::Notification_Receiver(), CORBA::Object () { \ + m_pptr = new Event_Comm::Notification_Receiver_dispatch \ + (( Event_Comm::Notification_Receiver*)this,(CORBA::Object*)this,IT_m,Event_Comm_Notification_Receiver_IR,IT_p,IT_q); \ + m_obj = (X*)(m_pptr->getImplObj ()); \ + } \ + \ + virtual ~Event_Comm_Notification_Receiver##X () { \ + if (_okToDeleteImpl ()) delete m_obj; } \ + \ + virtual void* _deref () { \ + return m_obj; } \ + \ + virtual void receive_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->receive_notification ( notification,IT_env);\ +}\ + \ + virtual void disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->disconnect ( reason,IT_env);\ +}\ + \ + }; + + +#define QUALS_Event_Comm_Notification_Receiver \ + virtual void receive_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->receive_notification ( notification,IT_env);\ +}\ + \ + virtual void disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->disconnect ( reason,IT_env);\ +}\ + + + + +class Notification_ReceiverProxyFactoryClass : public virtual CORBA::ObjectFactoryClass { +public: + Notification_ReceiverProxyFactoryClass (unsigned char IT_p=0) + : CORBA::ProxyFactory (Event_Comm_Notification_Receiver_IR, IT_p) {} + + virtual void* New (char *IT_OR, CORBA::Environment&); + + virtual void* New (ObjectReference *IT_OR, CORBA::Environment&); + + virtual void* New2 (); + + virtual void* IT_castUp (void *IT_p, char* IT_s); + + virtual CORBA::PPTR* pptr (void *IT_p); + + virtual void baseInterfaces (_IDL_SEQUENCE_string&); + + +}; + +static Notification_ReceiverProxyFactoryClass Notification_ReceiverProxyFactory; + + + +#endif + + +#ifndef _Event_Comm_Notifier_defined +#define _Event_Comm_Notifier_defined +class Notifier_dispatch : public virtual CORBA::PPTR { +public: + + Notifier_dispatch (void *IT_p, CORBA::Object* IT_o, const char *IT_m, + CORBA::LoaderClass *IT_l, char *IT_i, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_l,IT_i,IT_im) {} + + + Notifier_dispatch (char *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notifier_dispatch () {} + + Notifier_dispatch (ObjectReference *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notifier_dispatch (void *IT_p, CORBA::Object *IT_o, const char *IT_m, + char *IT_i, CORBA::Object* IT_ob, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_i,IT_ob,IT_im) {} + + + virtual unsigned char dispatch (CORBA::Request &IT_r, + unsigned char IT_isTarget, void* IT_pp=NULL); + + +}; + +class Notifier; + +#ifndef Event_Comm_NotifierPtr +#define Event_Comm_NotifierPtr + + typedef Notifier* Notifier_ptr; + + typedef Notifier* NotifierRef; + +#endif + + +#ifndef Event_Comm_NotifierForwH +#define Event_Comm_NotifierForwH +static CORBA::ObjectRef Notifier_getBase (void *); +static void Notifier_release (Notifier *, CORBA::Environment &IT_env); +static void Notifier_release (Notifier_ptr); +static Notifier* Notifier_duplicate (Notifier_ptr, CORBA::Environment &IT_env); +static Notifier* Notifier_duplicate (Notifier_ptr ); +static Notifier_ptr Notifier_nil (CORBA::Environment &IT_env); +static Notifier_ptr Notifier_nil (); +#endif +#define Event_Comm_Notifier_IMPL "Event_Comm_Notifier" + + +class Notifier; + + typedef Notifier NotifierProxy; +#define Event_Comm_Notifier_IR "Event_Comm_Notifier" +#define Event_Comm_Notifier_IMPL "Event_Comm_Notifier" + +#ifndef Event_Comm_NotifierPtr +#define Event_Comm_NotifierPtr + + typedef Notifier* Notifier_ptr; + + typedef Notifier* NotifierRef; + +#endif + +class Notifier: public virtual CORBA::Object { +public: + Notifier (char *IT_OR); + Notifier (ObjectReference *IT_OR); + Notifier () : CORBA::Object (1) {} +protected: + Notifier_ptr __duplicate( + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::Object::__duplicate (IT_env); + return this; + } +public: + static Notifier_ptr _duplicate( + Notifier_ptr obj, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + if (CORBA::is_nil(obj, IT_env)) { + IT_raise.maybeRaise (); + return (obj); + } + Notifier_ptr IT_obj = obj->__duplicate (IT_env); + IT_raise.maybeRaise(); + return IT_obj; + } +public: + static Notifier* _bind (const char* IT_markerServer, const char* host, + const CORBA::Context &IT_c, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notifier* _bind (CORBA::Environment &IT_env); + static Notifier* _bind (const char* IT_markerServer=NULL, const char* host=NULL, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notifier* _narrow (CORBA::Object* , CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notifier_ptr _nil (CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + IT_raise.maybeRaise(); + return (Notifier_ptr) CORBA::OBJECT_NIL;} + virtual void send_disconnect (const char * reason, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void send_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void subscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void unsubscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); +}; + + static const CORBA::TypeCode_ptr _tc_Notifier; + + static const CORBA::TypeCode_ptr _tc_NotifierRef; + +#ifndef Event_Comm_NotifierVarH +#define Event_Comm_NotifierVarH + +#ifndef Event_Comm_NotifiervPtr +#define Event_Comm_NotifiervPtr +typedef Notifier* Notifier_vPtr; +#endif + +class Notifier_var : public CORBA::_var +{ + public: + + Notifier_var () { + _ptr = Notifier_nil (); + } + + Notifier_var (Notifier *IT_p) { + _ptr = IT_p; + } + + Notifier_var (const Notifier_var &IT_s) { + _ptr = Notifier_duplicate (IT_s._ptr); + } + + Notifier_var &operator= (Notifier *IT_p) { + Notifier_release (_ptr); + _ptr = IT_p; + return (*this); + } + + Notifier_var &operator= (const Notifier_var &IT_s) { + Notifier_release (_ptr); + _ptr = Notifier_duplicate (IT_s._ptr); + return (*this); + } + + ~Notifier_var () { + Notifier_release (_ptr); + } + + Notifier* operator-> () { + return _ptr; + } + + operator const Notifier_vPtr () const { return _ptr;} + operator Notifier_vPtr& () { return _ptr;} + + protected: + Notifier *_ptr; + private: + Notifier_var &operator= (const CORBA::_var &IT_s); + Notifier_var (const CORBA::_var &IT_s); + Notifier_var &operator= (const CORBA::_mgr &IT_s); + Notifier_var &operator= (const CORBA::_SeqElem &IT_s); + Notifier_var (const CORBA::_mgr &IT_s); + Notifier_var (const CORBA::_SeqElem &IT_s); +}; + +#endif + + +#ifndef Event_Comm_NotifierMgrH +#define Event_Comm_NotifierMgrH + +class Notifier_mgr : public CORBA::_mgr +{ + public: + + Notifier_mgr () { + _ptr = Notifier_nil (); + _release = 1; + } + + Notifier_mgr (const Notifier_mgr &IT_s) { + _ptr = Notifier_duplicate (IT_s._ptr); + _release = 1; + } + + Notifier_mgr &operator= (Notifier *IT_p) { + if (_ptr && _release) + Notifier_release (_ptr); + _ptr = IT_p; + _release = 1; + return (*this); + } + + Notifier_mgr &operator= (const Notifier_mgr &IT_s) { + if (_ptr && _release) + Notifier_release (_ptr); + _ptr = Notifier_duplicate(IT_s._ptr); + _release = 1; + return (*this); + } + + Notifier_mgr &operator= (const Notifier_var &IT_s) { + if (_ptr && _release) + Notifier_release (_ptr); + _ptr = Notifier_duplicate(IT_s); + _release = 1; + return (*this); + } + + ~Notifier_mgr () { + if (_release) + Notifier_release (_ptr); + } + + unsigned char release () { + return _release; + } + + void release (unsigned char rel) { + _release = rel; + } + + operator int () const { + CORBA::Environment env; + CORBA::EnvExcRaiser IT_raise (&env); + return (!(CORBA::is_nil((CORBA::Object*) _ptr, env))); + } + + operator void* () const { + return _ptr; + } + + operator CORBA::Object * () const { + return (CORBA::Object *) _ptr; + } + + operator Notifier* () const { + return (Notifier*) _ptr; + } + + Notifier *_ptr; + + protected: + + unsigned char _release; +}; + +#endif + +#ifndef Event_Comm_NotifierSeqElemH +#define Event_Comm_NotifierSeqElemH + +class Notifier_SeqElem : public CORBA::_SeqElem +{ + public: + + Notifier_SeqElem (Event_Comm::Notifier_ptr* IT_p, unsigned char rel) { + _ptr = IT_p; + _release = rel; + } + + Notifier_SeqElem &operator= (Event_Comm::Notifier_ptr IT_p) { + if (!_ptr) + return (*this); + if (*(_ptr) && _release) + Notifier_release (*(_ptr)); + *(_ptr) = IT_p; + return (*this); + } + + Notifier_SeqElem &operator= (const Notifier_SeqElem &IT_s) { + if (!_ptr|| !IT_s._ptr) + return (*this); + if (*(_ptr) && _release) + Notifier_release (*(_ptr)); + *(_ptr) = Notifier_duplicate(*(IT_s._ptr)); + return (*this); + } + + operator Event_Comm::Notifier_ptr () const +{ + if (!_ptr) + return (Notifier_nil()); + return (Event_Comm::Notifier_ptr) (*_ptr); + } + + Notifier_ptr operator->() const { return *_ptr;} + + protected: + Event_Comm::Notifier_ptr *_ptr; + unsigned char _release; +}; + +#endif + + +#define TIE_Event_Comm_Notifier(X) Event_Comm_Notifier##X + +#define DEF_TIE_Event_Comm_Notifier(X) \ + class Event_Comm_Notifier##X : public virtual Event_Comm::Notifier { \ + X* m_obj; \ + public: \ + \ + Event_Comm_Notifier##X (X *objp, const char* m="", CORBA::LoaderClass *l=0)\ + : Event_Comm::Notifier(), CORBA::Object (), m_obj(objp) { \ + m_pptr = new Event_Comm::Notifier_dispatch \ + (( Event_Comm::Notifier*)this,(CORBA::Object*)this,m,l,Event_Comm_Notifier_IR,m_obj); \ + } \ + Event_Comm_Notifier##X (CORBA::Object *IT_p, const char* IT_m="", void *IT_q=0)\ + : Event_Comm::Notifier(), CORBA::Object () { \ + m_pptr = new Event_Comm::Notifier_dispatch \ + (( Event_Comm::Notifier*)this,(CORBA::Object*)this,IT_m,Event_Comm_Notifier_IR,IT_p,IT_q); \ + m_obj = (X*)(m_pptr->getImplObj ()); \ + } \ + \ + virtual ~Event_Comm_Notifier##X () { \ + if (_okToDeleteImpl ()) delete m_obj; } \ + \ + virtual void* _deref () { \ + return m_obj; } \ + \ + virtual void send_disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_disconnect ( reason,IT_env);\ +}\ + \ + virtual void send_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_notification ( notification,IT_env);\ +}\ + \ + virtual void subscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->subscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + \ + virtual void unsubscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->unsubscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + \ + }; + + +#define QUALS_Event_Comm_Notifier \ + virtual void send_disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_disconnect ( reason,IT_env);\ +}\ + \ + virtual void send_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_notification ( notification,IT_env);\ +}\ + \ + virtual void subscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->subscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + \ + virtual void unsubscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->unsubscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + + + + +class NotifierProxyFactoryClass : public virtual CORBA::ObjectFactoryClass { +public: + NotifierProxyFactoryClass (unsigned char IT_p=0) + : CORBA::ProxyFactory (Event_Comm_Notifier_IR, IT_p) {} + + virtual void* New (char *IT_OR, CORBA::Environment&); + + virtual void* New (ObjectReference *IT_OR, CORBA::Environment&); + + virtual void* New2 (); + + virtual void* IT_castUp (void *IT_p, char* IT_s); + + virtual CORBA::PPTR* pptr (void *IT_p); + + virtual void baseInterfaces (_IDL_SEQUENCE_string&); + + +}; + +static NotifierProxyFactoryClass NotifierProxyFactory; + + + +#endif + +}; + + +void operator<<= (CORBA::any &IT_a, Event_Comm::Notification_Receiver_ptr IT_t); +CORBA::Boolean operator>>= (const CORBA::any &IT_a, Event_Comm::Notification_Receiver_ptr& IT_t); + + +void operator<<= (CORBA::any &IT_a, Event_Comm::Notifier_ptr IT_t); +CORBA::Boolean operator>>= (const CORBA::any &IT_a, Event_Comm::Notifier_ptr& IT_t); + + +void operator<<= (CORBA::any &IT_a, const Event_Comm::Notification& IT_t); +CORBA::Boolean operator>>= (const CORBA::any &IT_a, Event_Comm::Notification*& IT_t); + + +#endif diff --git a/apps/Orbix-Examples/Event_Comm/include/Event_Comm_i.h b/apps/Orbix-Examples/Event_Comm/include/Event_Comm_i.h new file mode 100644 index 00000000000..49673abec84 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/include/Event_Comm_i.h @@ -0,0 +1,37 @@ +/* -*- C++ -*- */ +// @(#)Event_Comm_i.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Event_Comm_i.h +// +// = DESCRIPTION +// Class interface for the implementation of the distributed +// event notification mechanism. +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_EVENT_COMM_I_H) +#define _EVENT_COMM_I_H + +#include "Notification_Receiver_i.h" +#include "Notifier_i.h" + +#if defined (ACE_HAS_ORBIX) + +// Tie the Notification_Receiver and Notifier implementation classes +// together with the IDL interface. + +DEF_TIE_Event_Comm_Notification_Receiver (Notification_Receiver_i) +DEF_TIE_Event_Comm_Notifier (Notifier_i) + +#endif /* ACE_HAS_ORBIX */ +#endif /* _EVENT_COMM_I_H */ diff --git a/apps/Orbix-Examples/Event_Comm/include/Notification_Receiver_i.h b/apps/Orbix-Examples/Event_Comm/include/Notification_Receiver_i.h new file mode 100644 index 00000000000..4f0bcc980e4 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/include/Notification_Receiver_i.h @@ -0,0 +1,48 @@ +/* -*- C++ -*- */ +// @(#)Notification_Receiver_i.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notification_Receiver__i.h +// +// = DESCRIPTION +// Class interface for the implementation of the +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_Notification_Receiver_i_H) +#define _Notification_Receiver_i_H + +#if defined (ACE_HAS_ORBIX) +#include "Event_Comm.hh" + +class Notification_Receiver_i + // = TITLE + // Defines the implementation class for event . + // + // = DESCRIPTION +{ +public: + Notification_Receiver_i (void); + ~Notification_Receiver_i (void); + + virtual void receive_notification (const Event_Comm::Notification ¬ification, + CORBA::Environment &IT_env); + // Pass the to the . + + virtual void disconnect (const char *reason, + CORBA::Environment &IT_env); + // Disconnect the from the , + // giving it the . +}; + +#endif /* ACE_HAS_ORBIX */ +#endif /* _Notification_Receiver_i_H */ diff --git a/apps/Orbix-Examples/Event_Comm/include/Notifier_i.h b/apps/Orbix-Examples/Event_Comm/include/Notifier_i.h new file mode 100644 index 00000000000..379f96b8097 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/include/Notifier_i.h @@ -0,0 +1,82 @@ +/* -*- C++ -*- */ +// @(#)Notifier_i.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notifier_i.h +// +// = DESCRIPTION +// Class interface for the implementation of the +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_Notifier_i_H) +#define _Notifier_i_H + +#include "ace/Map_Manager.h" +#include "ace/Synch.h" +#include "ace/SString.h" +#include "Event_Comm.hh" + +#if defined (ACE_HAS_ORBIX) + +// Forward reference. +class Notification_Receiver_Entry; + +class Notifier_i + // = TITLE + // Defines the implementation class for event . + // + // = DESCRIPTION +{ +public: + enum + { + DEFAULT_SIZE = 1024 // Default max number of Event_Comm::Notification_Receivers. + }; + + Notifier_i (size_t size_hint = Notifier_i::DEFAULT_SIZE); + // Initialize a Notifier_i object with the specified size hint. + + void send_disconnect (const char *reason, + CORBA::Environment &IT_env); + // Disconnect all the receivers, giving them the . + + void send_notification (const Event_Comm::Notification ¬ification, + CORBA::Environment &IT_env); + // Send the to all the consumers who + // have subscribed and who match the filtering criteria. + + void subscribe (Event_Comm::Notification_Receiver *notification_receiver, + const char *filtering_criteria, + CORBA::Environment &IT_env); + // Subscribe the to receive events that + // match applied by the . + + void unsubscribe (Event_Comm::Notification_Receiver *notification_receiver, + const char *filtering_criteria, + CORBA::Environment &IT_env); + // Unsubscribe the . + +private: + // The following implementation should be replaced + // by a standard container class from STL... + + typedef ACE_Map_Manager MAP_MANAGER; + typedef ACE_Map_Iterator MAP_ITERATOR; + typedef ACE_Map_Entry MAP_ENTRY; + + MAP_MANAGER map_; + // Table that maps a to a . +}; + +#endif /* ACE_HAS_ORBIX */ +#endif /* _Notifier_i_H */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.hh b/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.hh new file mode 100644 index 00000000000..85ad256da2a --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.hh @@ -0,0 +1,887 @@ + +#ifndef Event_Comm_hh +#define Event_Comm_hh + +#include + +#include + +class Event_Comm { +public: + +#ifndef Event_Comm_Notification_defined +#define Event_Comm_Notification_defined + + struct Notification { + CORBA::String_mgr tag_; + + void encodeOp (CORBA::Request &IT_r) const; + void decodeOp (CORBA::Request &IT_r); + void decodeInOutOp (CORBA::Request &IT_r); + static void* IT_anySupport (CORBA::Request &IT_r, + void *&, void*, const CORBA::Flags&); + static const void *IT_fn; + }; + + static const CORBA::TypeCode_ptr _tc_Notification; + +#ifndef Event_Comm_NotificationVarH +#define Event_Comm_NotificationVarH + +#ifndef Event_Comm_NotificationvPtr +#define Event_Comm_NotificationvPtr +typedef Notification* Notification_vPtr; +#endif + +class Notification_var : public CORBA::_var +{ + public: + + Notification_var () { + _ptr = NULL; + } + + Notification_var (Notification *IT_p) { + _ptr = IT_p; + } + + Notification_var (const Notification_var &IT_s) { + if (!IT_s._ptr) { + _ptr = IT_s._ptr; + return; + } + _ptr = new Notification (*(IT_s._ptr)); + } + + Notification_var &operator= (Notification *IT_p) { + if (_ptr != IT_p) { + delete _ptr; + } + _ptr = IT_p; + return (*this); + } + + Notification_var &operator= (const Notification_var &IT_s) { + if (_ptr != IT_s._ptr) { + delete _ptr; + } + _ptr = new Notification (*(IT_s._ptr)); + return (*this); + } + + ~Notification_var () { + delete _ptr; + } + + Notification* operator-> () { + return _ptr; + } + + operator const Notification_vPtr () const { return _ptr;} + operator Notification_vPtr& () { return _ptr;} + operator Notification& () const { return * _ptr;} + + protected: + Notification *_ptr; + private: + Notification_var &operator= (const CORBA::_var &IT_s); + Notification_var (const CORBA::_var &IT_s); +}; + +#endif + + +#endif + + +#ifndef _Event_Comm_Notification_Receiver_defined +#define _Event_Comm_Notification_Receiver_defined +class Notification_Receiver_dispatch : public virtual CORBA::PPTR { +public: + + Notification_Receiver_dispatch (void *IT_p, CORBA::Object* IT_o, const char *IT_m, + CORBA::LoaderClass *IT_l, char *IT_i, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_l,IT_i,IT_im) {} + + + Notification_Receiver_dispatch (char *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notification_Receiver_dispatch () {} + + Notification_Receiver_dispatch (ObjectReference *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notification_Receiver_dispatch (void *IT_p, CORBA::Object *IT_o, const char *IT_m, + char *IT_i, CORBA::Object* IT_ob, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_i,IT_ob,IT_im) {} + + + virtual unsigned char dispatch (CORBA::Request &IT_r, + unsigned char IT_isTarget, void* IT_pp=NULL); + + +}; + +class Notification_Receiver; + +#ifndef Event_Comm_Notification_ReceiverPtr +#define Event_Comm_Notification_ReceiverPtr + + typedef Notification_Receiver* Notification_Receiver_ptr; + + typedef Notification_Receiver* Notification_ReceiverRef; + +#endif + + +#ifndef Event_Comm_Notification_ReceiverForwH +#define Event_Comm_Notification_ReceiverForwH +static CORBA::ObjectRef Notification_Receiver_getBase (void *); +static void Notification_Receiver_release (Notification_Receiver *, CORBA::Environment &IT_env); +static void Notification_Receiver_release (Notification_Receiver_ptr); +static Notification_Receiver* Notification_Receiver_duplicate (Notification_Receiver_ptr, CORBA::Environment &IT_env); +static Notification_Receiver* Notification_Receiver_duplicate (Notification_Receiver_ptr ); +static Notification_Receiver_ptr Notification_Receiver_nil (CORBA::Environment &IT_env); +static Notification_Receiver_ptr Notification_Receiver_nil (); +#endif +#define Event_Comm_Notification_Receiver_IMPL "Event_Comm_Notification_Receiver" + + +class Notification_Receiver; + + typedef Notification_Receiver Notification_ReceiverProxy; +#define Event_Comm_Notification_Receiver_IR "Event_Comm_Notification_Receiver" +#define Event_Comm_Notification_Receiver_IMPL "Event_Comm_Notification_Receiver" + +#ifndef Event_Comm_Notification_ReceiverPtr +#define Event_Comm_Notification_ReceiverPtr + + typedef Notification_Receiver* Notification_Receiver_ptr; + + typedef Notification_Receiver* Notification_ReceiverRef; + +#endif + +class Notification_Receiver: public virtual CORBA::Object { +public: + Notification_Receiver (char *IT_OR); + Notification_Receiver (ObjectReference *IT_OR); + Notification_Receiver () : CORBA::Object (1) {} +protected: + Notification_Receiver_ptr __duplicate( + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::Object::__duplicate (IT_env); + return this; + } +public: + static Notification_Receiver_ptr _duplicate( + Notification_Receiver_ptr obj, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + if (CORBA::is_nil(obj, IT_env)) { + IT_raise.maybeRaise (); + return (obj); + } + Notification_Receiver_ptr IT_obj = obj->__duplicate (IT_env); + IT_raise.maybeRaise(); + return IT_obj; + } +public: + static Notification_Receiver* _bind (const char* IT_markerServer, const char* host, + const CORBA::Context &IT_c, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notification_Receiver* _bind (CORBA::Environment &IT_env); + static Notification_Receiver* _bind (const char* IT_markerServer=NULL, const char* host=NULL, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notification_Receiver* _narrow (CORBA::Object* , CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notification_Receiver_ptr _nil (CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + IT_raise.maybeRaise(); + return (Notification_Receiver_ptr) CORBA::OBJECT_NIL;} + virtual void receive_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void disconnect (const char * reason, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); +}; + + static const CORBA::TypeCode_ptr _tc_Notification_Receiver; + + static const CORBA::TypeCode_ptr _tc_Notification_ReceiverRef; + +#ifndef Event_Comm_Notification_ReceiverVarH +#define Event_Comm_Notification_ReceiverVarH + +#ifndef Event_Comm_Notification_ReceivervPtr +#define Event_Comm_Notification_ReceivervPtr +typedef Notification_Receiver* Notification_Receiver_vPtr; +#endif + +class Notification_Receiver_var : public CORBA::_var +{ + public: + + Notification_Receiver_var () { + _ptr = Notification_Receiver_nil (); + } + + Notification_Receiver_var (Notification_Receiver *IT_p) { + _ptr = IT_p; + } + + Notification_Receiver_var (const Notification_Receiver_var &IT_s) { + _ptr = Notification_Receiver_duplicate (IT_s._ptr); + } + + Notification_Receiver_var &operator= (Notification_Receiver *IT_p) { + Notification_Receiver_release (_ptr); + _ptr = IT_p; + return (*this); + } + + Notification_Receiver_var &operator= (const Notification_Receiver_var &IT_s) { + Notification_Receiver_release (_ptr); + _ptr = Notification_Receiver_duplicate (IT_s._ptr); + return (*this); + } + + ~Notification_Receiver_var () { + Notification_Receiver_release (_ptr); + } + + Notification_Receiver* operator-> () { + return _ptr; + } + + operator const Notification_Receiver_vPtr () const { return _ptr;} + operator Notification_Receiver_vPtr& () { return _ptr;} + + protected: + Notification_Receiver *_ptr; + private: + Notification_Receiver_var &operator= (const CORBA::_var &IT_s); + Notification_Receiver_var (const CORBA::_var &IT_s); + Notification_Receiver_var &operator= (const CORBA::_mgr &IT_s); + Notification_Receiver_var &operator= (const CORBA::_SeqElem &IT_s); + Notification_Receiver_var (const CORBA::_mgr &IT_s); + Notification_Receiver_var (const CORBA::_SeqElem &IT_s); +}; + +#endif + + +#ifndef Event_Comm_Notification_ReceiverMgrH +#define Event_Comm_Notification_ReceiverMgrH + +class Notification_Receiver_mgr : public CORBA::_mgr +{ + public: + + Notification_Receiver_mgr () { + _ptr = Notification_Receiver_nil (); + _release = 1; + } + + Notification_Receiver_mgr (const Notification_Receiver_mgr &IT_s) { + _ptr = Notification_Receiver_duplicate (IT_s._ptr); + _release = 1; + } + + Notification_Receiver_mgr &operator= (Notification_Receiver *IT_p) { + if (_ptr && _release) + Notification_Receiver_release (_ptr); + _ptr = IT_p; + _release = 1; + return (*this); + } + + Notification_Receiver_mgr &operator= (const Notification_Receiver_mgr &IT_s) { + if (_ptr && _release) + Notification_Receiver_release (_ptr); + _ptr = Notification_Receiver_duplicate(IT_s._ptr); + _release = 1; + return (*this); + } + + Notification_Receiver_mgr &operator= (const Notification_Receiver_var &IT_s) { + if (_ptr && _release) + Notification_Receiver_release (_ptr); + _ptr = Notification_Receiver_duplicate(IT_s); + _release = 1; + return (*this); + } + + ~Notification_Receiver_mgr () { + if (_release) + Notification_Receiver_release (_ptr); + } + + unsigned char release () { + return _release; + } + + void release (unsigned char rel) { + _release = rel; + } + + operator int () const { + CORBA::Environment env; + CORBA::EnvExcRaiser IT_raise (&env); + return (!(CORBA::is_nil((CORBA::Object*) _ptr, env))); + } + + operator void* () const { + return _ptr; + } + + operator CORBA::Object * () const { + return (CORBA::Object *) _ptr; + } + + operator Notification_Receiver* () const { + return (Notification_Receiver*) _ptr; + } + + Notification_Receiver *_ptr; + + protected: + + unsigned char _release; +}; + +#endif + +#ifndef Event_Comm_Notification_ReceiverSeqElemH +#define Event_Comm_Notification_ReceiverSeqElemH + +class Notification_Receiver_SeqElem : public CORBA::_SeqElem +{ + public: + + Notification_Receiver_SeqElem (Event_Comm::Notification_Receiver_ptr* IT_p, unsigned char rel) { + _ptr = IT_p; + _release = rel; + } + + Notification_Receiver_SeqElem &operator= (Event_Comm::Notification_Receiver_ptr IT_p) { + if (!_ptr) + return (*this); + if (*(_ptr) && _release) + Notification_Receiver_release (*(_ptr)); + *(_ptr) = IT_p; + return (*this); + } + + Notification_Receiver_SeqElem &operator= (const Notification_Receiver_SeqElem &IT_s) { + if (!_ptr|| !IT_s._ptr) + return (*this); + if (*(_ptr) && _release) + Notification_Receiver_release (*(_ptr)); + *(_ptr) = Notification_Receiver_duplicate(*(IT_s._ptr)); + return (*this); + } + + operator Event_Comm::Notification_Receiver_ptr () const +{ + if (!_ptr) + return (Notification_Receiver_nil()); + return (Event_Comm::Notification_Receiver_ptr) (*_ptr); + } + + Notification_Receiver_ptr operator->() const { return *_ptr;} + + protected: + Event_Comm::Notification_Receiver_ptr *_ptr; + unsigned char _release; +}; + +#endif + + +#define TIE_Event_Comm_Notification_Receiver(X) Event_Comm_Notification_Receiver##X + +#define DEF_TIE_Event_Comm_Notification_Receiver(X) \ + class Event_Comm_Notification_Receiver##X : public virtual Event_Comm::Notification_Receiver { \ + X* m_obj; \ + public: \ + \ + Event_Comm_Notification_Receiver##X (X *objp, const char* m="", CORBA::LoaderClass *l=0)\ + : Event_Comm::Notification_Receiver(), CORBA::Object (), m_obj(objp) { \ + m_pptr = new Event_Comm::Notification_Receiver_dispatch \ + (( Event_Comm::Notification_Receiver*)this,(CORBA::Object*)this,m,l,Event_Comm_Notification_Receiver_IR,m_obj); \ + } \ + Event_Comm_Notification_Receiver##X (CORBA::Object *IT_p, const char* IT_m="", void *IT_q=0)\ + : Event_Comm::Notification_Receiver(), CORBA::Object () { \ + m_pptr = new Event_Comm::Notification_Receiver_dispatch \ + (( Event_Comm::Notification_Receiver*)this,(CORBA::Object*)this,IT_m,Event_Comm_Notification_Receiver_IR,IT_p,IT_q); \ + m_obj = (X*)(m_pptr->getImplObj ()); \ + } \ + \ + virtual ~Event_Comm_Notification_Receiver##X () { \ + if (_okToDeleteImpl ()) delete m_obj; } \ + \ + virtual void* _deref () { \ + return m_obj; } \ + \ + virtual void receive_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->receive_notification ( notification,IT_env);\ +}\ + \ + virtual void disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->disconnect ( reason,IT_env);\ +}\ + \ + }; + + +#define QUALS_Event_Comm_Notification_Receiver \ + virtual void receive_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->receive_notification ( notification,IT_env);\ +}\ + \ + virtual void disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->disconnect ( reason,IT_env);\ +}\ + + + + +class Notification_ReceiverProxyFactoryClass : public virtual CORBA::ObjectFactoryClass { +public: + Notification_ReceiverProxyFactoryClass (unsigned char IT_p=0) + : CORBA::ProxyFactory (Event_Comm_Notification_Receiver_IR, IT_p) {} + + virtual void* New (char *IT_OR, CORBA::Environment&); + + virtual void* New (ObjectReference *IT_OR, CORBA::Environment&); + + virtual void* New2 (); + + virtual void* IT_castUp (void *IT_p, char* IT_s); + + virtual CORBA::PPTR* pptr (void *IT_p); + + virtual void baseInterfaces (_IDL_SEQUENCE_string&); + + +}; + +static Notification_ReceiverProxyFactoryClass Notification_ReceiverProxyFactory; + + + +#endif + + +#ifndef _Event_Comm_Notifier_defined +#define _Event_Comm_Notifier_defined +class Notifier_dispatch : public virtual CORBA::PPTR { +public: + + Notifier_dispatch (void *IT_p, CORBA::Object* IT_o, const char *IT_m, + CORBA::LoaderClass *IT_l, char *IT_i, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_l,IT_i,IT_im) {} + + + Notifier_dispatch (char *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notifier_dispatch () {} + + Notifier_dispatch (ObjectReference *IT_OR, void *IT_p, CORBA::Object *IT_o) + : CORBA::PPTR (IT_OR,IT_p,IT_o) {} + + + Notifier_dispatch (void *IT_p, CORBA::Object *IT_o, const char *IT_m, + char *IT_i, CORBA::Object* IT_ob, void* IT_im) + : CORBA::PPTR (IT_p,IT_o,IT_m,IT_i,IT_ob,IT_im) {} + + + virtual unsigned char dispatch (CORBA::Request &IT_r, + unsigned char IT_isTarget, void* IT_pp=NULL); + + +}; + +class Notifier; + +#ifndef Event_Comm_NotifierPtr +#define Event_Comm_NotifierPtr + + typedef Notifier* Notifier_ptr; + + typedef Notifier* NotifierRef; + +#endif + + +#ifndef Event_Comm_NotifierForwH +#define Event_Comm_NotifierForwH +static CORBA::ObjectRef Notifier_getBase (void *); +static void Notifier_release (Notifier *, CORBA::Environment &IT_env); +static void Notifier_release (Notifier_ptr); +static Notifier* Notifier_duplicate (Notifier_ptr, CORBA::Environment &IT_env); +static Notifier* Notifier_duplicate (Notifier_ptr ); +static Notifier_ptr Notifier_nil (CORBA::Environment &IT_env); +static Notifier_ptr Notifier_nil (); +#endif +#define Event_Comm_Notifier_IMPL "Event_Comm_Notifier" + + +class Notifier; + + typedef Notifier NotifierProxy; +#define Event_Comm_Notifier_IR "Event_Comm_Notifier" +#define Event_Comm_Notifier_IMPL "Event_Comm_Notifier" + +#ifndef Event_Comm_NotifierPtr +#define Event_Comm_NotifierPtr + + typedef Notifier* Notifier_ptr; + + typedef Notifier* NotifierRef; + +#endif + +class Notifier: public virtual CORBA::Object { +public: + Notifier (char *IT_OR); + Notifier (ObjectReference *IT_OR); + Notifier () : CORBA::Object (1) {} +protected: + Notifier_ptr __duplicate( + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::Object::__duplicate (IT_env); + return this; + } +public: + static Notifier_ptr _duplicate( + Notifier_ptr obj, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + if (CORBA::is_nil(obj, IT_env)) { + IT_raise.maybeRaise (); + return (obj); + } + Notifier_ptr IT_obj = obj->__duplicate (IT_env); + IT_raise.maybeRaise(); + return IT_obj; + } +public: + static Notifier* _bind (const char* IT_markerServer, const char* host, + const CORBA::Context &IT_c, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notifier* _bind (CORBA::Environment &IT_env); + static Notifier* _bind (const char* IT_markerServer=NULL, const char* host=NULL, + CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notifier* _narrow (CORBA::Object* , CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()); + static Notifier_ptr _nil (CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) { + CORBA::EnvExcRaiser IT_raise (&IT_env); + IT_raise.maybeRaise(); + return (Notifier_ptr) CORBA::OBJECT_NIL;} + virtual void send_disconnect (const char * reason, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void send_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void subscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); + virtual void unsubscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env=CORBA::IT_chooseDefaultEnv ()) throw (CORBA::SystemException); +}; + + static const CORBA::TypeCode_ptr _tc_Notifier; + + static const CORBA::TypeCode_ptr _tc_NotifierRef; + +#ifndef Event_Comm_NotifierVarH +#define Event_Comm_NotifierVarH + +#ifndef Event_Comm_NotifiervPtr +#define Event_Comm_NotifiervPtr +typedef Notifier* Notifier_vPtr; +#endif + +class Notifier_var : public CORBA::_var +{ + public: + + Notifier_var () { + _ptr = Notifier_nil (); + } + + Notifier_var (Notifier *IT_p) { + _ptr = IT_p; + } + + Notifier_var (const Notifier_var &IT_s) { + _ptr = Notifier_duplicate (IT_s._ptr); + } + + Notifier_var &operator= (Notifier *IT_p) { + Notifier_release (_ptr); + _ptr = IT_p; + return (*this); + } + + Notifier_var &operator= (const Notifier_var &IT_s) { + Notifier_release (_ptr); + _ptr = Notifier_duplicate (IT_s._ptr); + return (*this); + } + + ~Notifier_var () { + Notifier_release (_ptr); + } + + Notifier* operator-> () { + return _ptr; + } + + operator const Notifier_vPtr () const { return _ptr;} + operator Notifier_vPtr& () { return _ptr;} + + protected: + Notifier *_ptr; + private: + Notifier_var &operator= (const CORBA::_var &IT_s); + Notifier_var (const CORBA::_var &IT_s); + Notifier_var &operator= (const CORBA::_mgr &IT_s); + Notifier_var &operator= (const CORBA::_SeqElem &IT_s); + Notifier_var (const CORBA::_mgr &IT_s); + Notifier_var (const CORBA::_SeqElem &IT_s); +}; + +#endif + + +#ifndef Event_Comm_NotifierMgrH +#define Event_Comm_NotifierMgrH + +class Notifier_mgr : public CORBA::_mgr +{ + public: + + Notifier_mgr () { + _ptr = Notifier_nil (); + _release = 1; + } + + Notifier_mgr (const Notifier_mgr &IT_s) { + _ptr = Notifier_duplicate (IT_s._ptr); + _release = 1; + } + + Notifier_mgr &operator= (Notifier *IT_p) { + if (_ptr && _release) + Notifier_release (_ptr); + _ptr = IT_p; + _release = 1; + return (*this); + } + + Notifier_mgr &operator= (const Notifier_mgr &IT_s) { + if (_ptr && _release) + Notifier_release (_ptr); + _ptr = Notifier_duplicate(IT_s._ptr); + _release = 1; + return (*this); + } + + Notifier_mgr &operator= (const Notifier_var &IT_s) { + if (_ptr && _release) + Notifier_release (_ptr); + _ptr = Notifier_duplicate(IT_s); + _release = 1; + return (*this); + } + + ~Notifier_mgr () { + if (_release) + Notifier_release (_ptr); + } + + unsigned char release () { + return _release; + } + + void release (unsigned char rel) { + _release = rel; + } + + operator int () const { + CORBA::Environment env; + CORBA::EnvExcRaiser IT_raise (&env); + return (!(CORBA::is_nil((CORBA::Object*) _ptr, env))); + } + + operator void* () const { + return _ptr; + } + + operator CORBA::Object * () const { + return (CORBA::Object *) _ptr; + } + + operator Notifier* () const { + return (Notifier*) _ptr; + } + + Notifier *_ptr; + + protected: + + unsigned char _release; +}; + +#endif + +#ifndef Event_Comm_NotifierSeqElemH +#define Event_Comm_NotifierSeqElemH + +class Notifier_SeqElem : public CORBA::_SeqElem +{ + public: + + Notifier_SeqElem (Event_Comm::Notifier_ptr* IT_p, unsigned char rel) { + _ptr = IT_p; + _release = rel; + } + + Notifier_SeqElem &operator= (Event_Comm::Notifier_ptr IT_p) { + if (!_ptr) + return (*this); + if (*(_ptr) && _release) + Notifier_release (*(_ptr)); + *(_ptr) = IT_p; + return (*this); + } + + Notifier_SeqElem &operator= (const Notifier_SeqElem &IT_s) { + if (!_ptr|| !IT_s._ptr) + return (*this); + if (*(_ptr) && _release) + Notifier_release (*(_ptr)); + *(_ptr) = Notifier_duplicate(*(IT_s._ptr)); + return (*this); + } + + operator Event_Comm::Notifier_ptr () const +{ + if (!_ptr) + return (Notifier_nil()); + return (Event_Comm::Notifier_ptr) (*_ptr); + } + + Notifier_ptr operator->() const { return *_ptr;} + + protected: + Event_Comm::Notifier_ptr *_ptr; + unsigned char _release; +}; + +#endif + + +#define TIE_Event_Comm_Notifier(X) Event_Comm_Notifier##X + +#define DEF_TIE_Event_Comm_Notifier(X) \ + class Event_Comm_Notifier##X : public virtual Event_Comm::Notifier { \ + X* m_obj; \ + public: \ + \ + Event_Comm_Notifier##X (X *objp, const char* m="", CORBA::LoaderClass *l=0)\ + : Event_Comm::Notifier(), CORBA::Object (), m_obj(objp) { \ + m_pptr = new Event_Comm::Notifier_dispatch \ + (( Event_Comm::Notifier*)this,(CORBA::Object*)this,m,l,Event_Comm_Notifier_IR,m_obj); \ + } \ + Event_Comm_Notifier##X (CORBA::Object *IT_p, const char* IT_m="", void *IT_q=0)\ + : Event_Comm::Notifier(), CORBA::Object () { \ + m_pptr = new Event_Comm::Notifier_dispatch \ + (( Event_Comm::Notifier*)this,(CORBA::Object*)this,IT_m,Event_Comm_Notifier_IR,IT_p,IT_q); \ + m_obj = (X*)(m_pptr->getImplObj ()); \ + } \ + \ + virtual ~Event_Comm_Notifier##X () { \ + if (_okToDeleteImpl ()) delete m_obj; } \ + \ + virtual void* _deref () { \ + return m_obj; } \ + \ + virtual void send_disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_disconnect ( reason,IT_env);\ +}\ + \ + virtual void send_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_notification ( notification,IT_env);\ +}\ + \ + virtual void subscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->subscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + \ + virtual void unsubscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->unsubscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + \ + }; + + +#define QUALS_Event_Comm_Notifier \ + virtual void send_disconnect (const char * reason, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_disconnect ( reason,IT_env);\ +}\ + \ + virtual void send_notification (const Event_Comm::Notification& notification, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->send_notification ( notification,IT_env);\ +}\ + \ + virtual void subscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->subscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + \ + virtual void unsubscribe (Event_Comm::Notification_Receiver_ptr notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) throw (CORBA::SystemException){\ + m_obj->unsubscribe ( notification_receiver, filtering_criteria,IT_env);\ +}\ + + + + +class NotifierProxyFactoryClass : public virtual CORBA::ObjectFactoryClass { +public: + NotifierProxyFactoryClass (unsigned char IT_p=0) + : CORBA::ProxyFactory (Event_Comm_Notifier_IR, IT_p) {} + + virtual void* New (char *IT_OR, CORBA::Environment&); + + virtual void* New (ObjectReference *IT_OR, CORBA::Environment&); + + virtual void* New2 (); + + virtual void* IT_castUp (void *IT_p, char* IT_s); + + virtual CORBA::PPTR* pptr (void *IT_p); + + virtual void baseInterfaces (_IDL_SEQUENCE_string&); + + +}; + +static NotifierProxyFactoryClass NotifierProxyFactory; + + + +#endif + +}; + + +void operator<<= (CORBA::any &IT_a, Event_Comm::Notification_Receiver_ptr IT_t); +CORBA::Boolean operator>>= (const CORBA::any &IT_a, Event_Comm::Notification_Receiver_ptr& IT_t); + + +void operator<<= (CORBA::any &IT_a, Event_Comm::Notifier_ptr IT_t); +CORBA::Boolean operator>>= (const CORBA::any &IT_a, Event_Comm::Notifier_ptr& IT_t); + + +void operator<<= (CORBA::any &IT_a, const Event_Comm::Notification& IT_t); +CORBA::Boolean operator>>= (const CORBA::any &IT_a, Event_Comm::Notification*& IT_t); + + +#endif diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.idl b/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.idl new file mode 100644 index 00000000000..26890129d70 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm.idl @@ -0,0 +1,92 @@ +/* -*- C++ -*- */ +// @(#)Event_Comm.idl 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Event_Comm.idl +// +// = DESCRIPTION +// The CORBA IDL module for distributed event notification. +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#ifndef _EVENT_COMM_IDL +#define _EVENT_COMM_IDL + +module Event_Comm + // = TITLE + // The CORBA IDL module for distributed event notification. + // + // = DESCRIPTION +{ + struct Notification + // = TITLE + // Defines the interface for an event . + // + // = This is the type passed by the Notifier to the Notification_Receiver. + // Since it contains an , it can hold any values. Naturally, + // the consumer must understand how to interpret this! + { + string tag_; + // Tag for the notification. + + // any value_; + // A notification can contain anything. + +// Object object_ref_; + // Object reference for callbacks. + }; + + interface Notification_Receiver + // = TITLE + // Defines the interface for a of events. + // Note that all operations are to avoid blocking. + // + // = DESCRIPTION + { + oneway void receive_notification (in Notification notification); + // Inform the that has occurred. + + oneway void disconnect (in string reason); + // Disconnect the from the , + // giving it the . + }; + + interface Notifier + // = TITLE + // Defines the interface for a of events. + // + // = DESCRIPTION + { + oneway void send_disconnect (in string reason); + // Disconnect all the receivers, giving them the . + + oneway void send_notification (in Notification notification); + // Send the to all the consumers who + // have subscribed and who match the filtering criteria. + + oneway void subscribe (in Notification_Receiver notification_receiver, + in string filtering_criteria); + // Subscribe the to receive events that + // match the regular expresssion applied by + // the . If is "" then all events + // are matched. + + oneway void unsubscribe (in Notification_Receiver notification_receiver, + in string filtering_criteria); + // Unsubscribe the that matches the + // filtering criteria. If is "" then + // all with the matching object reference + // are removed. + }; +}; + +#endif /* _EVENT_COMM_IDL */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Event_CommC.cpp b/apps/Orbix-Examples/Event_Comm/libsrc/Event_CommC.cpp new file mode 100644 index 00000000000..eee25b11a72 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Event_CommC.cpp @@ -0,0 +1,351 @@ + +// @(#)Event_CommC.cpp 1.1 10/18/96 + +#include "Event_Comm.hh" + + +#ifndef Event_Comm_Notification_Ops +#define Event_Comm_Notification_Ops + +void Event_Comm::Notification:: encodeOp (CORBA::Request &IT_r) const { + IT_r.encodeStringOp (tag_); +} + +void Event_Comm::Notification:: decodeOp (CORBA::Request &IT_r) { + IT_r.decodeStringOp(tag_); +} + +void Event_Comm::Notification:: decodeInOutOp (CORBA::Request &IT_r) { + IT_r.decodeInOutStrOp(tag_, 0); +} + +void* Event_Comm::Notification:: IT_anySupport (CORBA::Request &IT_r, + void *& IT_v, void *IT_to, const CORBA::Flags& IT_f) { + Event_Comm::Notification* IT_l = (Event_Comm::Notification*)IT_v; + + if (IT_f.isSetAll (CORBA::ARG_INOUT)) { + if (!IT_l) + IT_l = new Event_Comm::Notification(); + IT_l -> decodeInOutOp (IT_r); + IT_v = IT_l; + } + else if (IT_f.isSet (CORBA::ARG_IN)) { + IT_l -> encodeOp (IT_r); + } + else if (IT_f.isSet (CORBA::ARG_OUT)) { + if (!IT_l) + IT_l = new Event_Comm::Notification(); + IT_l -> decodeOp (IT_r); + IT_v = IT_l; + } + else if (IT_f.isSet (CORBA::_ANY_ASSIGN)) { + Event_Comm::Notification*IT_s = IT_to ? (Event_Comm::Notification*)IT_to : new Event_Comm::Notification; + *IT_s = *IT_l; return IT_s; + } + else if (IT_f.isSet (CORBA::_ANY_DELETE)) { + if (IT_to) IT_l->Event_Comm::Notification::~Notification(); + else delete IT_l; + return NULL; + } + else if (IT_f.isSet (CORBA::_ANY_SIZEOF)) { + return (void*) (sizeof (Event_Comm::Notification)); + } + else if (IT_f.isNil ()) { + if (!IT_l) + IT_l = new Event_Comm::Notification(); + IT_l -> decodeOp (IT_r); + IT_v = IT_l; + } + return NULL; +} + +const void *Event_Comm::Notification:: IT_fn = +CORBA::anyTable.record ("Event_Comm::Notification", &Event_Comm::Notification:: IT_anySupport); + +Event_Comm::Notification &Event_Comm::Notification:: operator= (const Event_Comm::IONANC_Notification& IT_p) { + this->operator= (*(Event_Comm::Notification*) &IT_p); + return (*this); +} + +Event_Comm::Notification:: operator Event_Comm::IONANC_Notification () { + Event_Comm::IONANC_Notification tmp; + memset (&tmp, 0, sizeof(tmp)); + ((Event_Comm::Notification *) &tmp)->operator= (*this); + return tmp; +} + +Event_Comm::Notification:: operator const Event_Comm::IONANC_Notification () const { + Event_Comm::IONANC_Notification tmp; + memset (&tmp, 0, sizeof(tmp)); + ((Event_Comm::Notification *) &tmp)->operator= (*this); + return tmp; +} + +Event_Comm::Notification::~Notification () { + if (tag_) delete [] tag_; +} + +Event_Comm::Notification:: Notification (const Event_Comm::Notification &IT_s) + { + if (IT_s.tag_) { + tag_=new char [strlen(IT_s.tag_)+1]; + strcpy (tag_, IT_s.tag_); + } + else { + tag_ = NULL; + } +} + +Event_Comm::Notification:: Notification () { + tag_ = NULL; +} + +Event_Comm::Notification &Event_Comm::Notification:: operator= (const Event_Comm::Notification& IT_s) { + if (this == &IT_s) return *this; + if (tag_) delete [] tag_; + if (IT_s.tag_) { + tag_=new char [strlen(IT_s.tag_)+1]; + strcpy (tag_, IT_s.tag_); + } + else { + tag_ = NULL; + } + return *this; +} + +Event_Comm::IONANC_Notification:: operator Event_Comm::Notification () { + return (*((Event_Comm::Notification *) this)); +} + +Event_Comm::IONANC_Notification:: operator const Event_Comm::Notification () const { + return (*((const Event_Comm::Notification *) this)); +} + + +#endif +Event_Comm::Notification_Receiver::Notification_Receiver (char *IT_OR) { + m_pptr = new Notification_Receiver_dispatch (IT_OR, this,(CORBA::Object*)this); +} + +#ifndef Event_Comm_Notification_ReceiverForwC +#define Event_Comm_Notification_ReceiverForwC +CORBA::ObjectRef Event_Comm::Notification_Receiver_getBase(void *IT_p){ + return (Event_Comm::Notification_Receiver*)IT_p;} + +void Event_Comm::Notification_Receiver_release (void *IT_p, CORBA::Environment &IT_env) { + ((Event_Comm::Notification_Receiver*)IT_p)->_release(IT_env);} + +Event_Comm::Notification_Receiver* Event_Comm::Notification_Receiver_duplicate (void *IT_p, CORBA::Environment &IT_env) { + return ((Event_Comm::Notification_Receiver*)IT_p)->_duplicate(IT_env); } +#endif + + + +Event_Comm::Notification_Receiver* Event_Comm::Notification_Receiver:: _bind (const char* IT_markerServer, const char* host, + const CORBA::Context &IT_c, + CORBA::Environment &IT_env) { + Notification_Receiver*IT_p = + (Notification_Receiver*)CORBA::Factory.New (IT_markerServer, IT_env, IT_c, host, + Event_Comm_Notification_Receiver_IMPL, Event_Comm_Notification_Receiver_IR); + return IT_p ? IT_p->_duplicate () : NULL; } + + + +Event_Comm::Notification_Receiver* Event_Comm::Notification_Receiver:: _bind (CORBA::Environment &IT_env) { + return _bind (NULL,NULL,CORBA::Context(), IT_env); } + + +Event_Comm::Notification_Receiver* Event_Comm::Notification_Receiver:: _bind (const char* IT_markerServer, const char* host, + CORBA::Environment &IT_env) { + return _bind (IT_markerServer, host, CORBA::Context (), IT_env); } +Event_Comm::Notification_Receiver* Event_Comm::Notification_Receiver::_narrow (CORBA::Object* IT_obj, CORBA::Environment &IT_env) { + Event_Comm::Notification_Receiver* IT_p = (Event_Comm::Notification_Receiver*)CORBA::Object::_castDown (IT_obj, Event_Comm_Notification_Receiver_IR, IT_env); + return IT_p ? IT_p->_duplicate(IT_env) : NULL; + } + +void* Event_Comm::Notification_ReceiverProxyFactoryClass::New (char *IT_OR, CORBA::Environment&) { + return new Notification_Receiver(IT_OR);} + +void* Event_Comm::Notification_ReceiverProxyFactoryClass::New2 () { + return new Notification_Receiver();} + +void* Event_Comm::Notification_ReceiverProxyFactoryClass::IT_castUp (void *IT_p, char* IT_s) { + void *IT_l; + if (!CORBA::_interfaceCmp (IT_s,Event_Comm_Notification_Receiver_IR)) + return IT_p; + else if (IT_l=CORBA::ObjectFactoryClass::IT_castUp((CORBA::Object*)((Event_Comm::Notification_Receiver*)IT_p),IT_s)) + return IT_l; + else return NULL; + } + + +CORBA::PPTR* Event_Comm::Notification_ReceiverProxyFactoryClass::pptr (void *IT_p) { + return ((Event_Comm::Notification_Receiver*)IT_p)->_pptr ();} + +void Event_Comm::Notification_ReceiverProxyFactoryClass::baseInterfaces (_IDL_SEQUENCE_string& seq) { + add (seq, Event_Comm_Notification_Receiver_IR); + CORBA::ObjectFactoryClass::baseInterfaces (seq); +} + + void Event_Comm::Notification_Receiver:: receive_notification(const Event_Comm::Notification& notification, CORBA::Environment &IT_env) { + + if (IT_env || m_isNull) return ; + CORBA::Request IT_r (this, "receive_notification",IT_env,1,1); + if (!IT_r.isException (IT_env)) { + notification.encodeOp (IT_r); + } + + IT_r.invoke (CORBA::Flags(CORBA::INV_NO_RESPONSE), IT_env); + } + + void Event_Comm::Notification_Receiver:: disconnect(const char * reason, CORBA::Environment &IT_env) { + + if (IT_env || m_isNull) return ; + CORBA::Request IT_r (this, "disconnect",IT_env,1,1); + if (!IT_r.isException (IT_env)) { + IT_r.encodeStringOp (reason); + } + + IT_r.invoke (CORBA::Flags(CORBA::INV_NO_RESPONSE), IT_env); + } + + +Event_Comm::Notification_ReceiverProxyFactoryClass Event_Comm::Notification_ReceiverProxyFactory(1); + + +#ifndef Event_Comm_Notification_Receiver_dispatch_impl + +unsigned char Event_Comm::Notification_Receiver_dispatch::dispatch (CORBA::Request &IT_r, + unsigned char, void *) { + IT_r.makeRuntimeException1 ("Event_Comm::Notification_Receiver"); + return 0; +} + +#endif + +Event_Comm::Notifier::Notifier (char *IT_OR) { + m_pptr = new Notifier_dispatch (IT_OR, this,(CORBA::Object*)this); +} + +#ifndef Event_Comm_NotifierForwC +#define Event_Comm_NotifierForwC +CORBA::ObjectRef Event_Comm::Notifier_getBase(void *IT_p){ + return (Event_Comm::Notifier*)IT_p;} + +void Event_Comm::Notifier_release (void *IT_p, CORBA::Environment &IT_env) { + ((Event_Comm::Notifier*)IT_p)->_release(IT_env);} + +Event_Comm::Notifier* Event_Comm::Notifier_duplicate (void *IT_p, CORBA::Environment &IT_env) { + return ((Event_Comm::Notifier*)IT_p)->_duplicate(IT_env); } +#endif + + + +Event_Comm::Notifier* Event_Comm::Notifier:: _bind (const char* IT_markerServer, const char* host, + const CORBA::Context &IT_c, + CORBA::Environment &IT_env) { + Notifier*IT_p = + (Notifier*)CORBA::Factory.New (IT_markerServer, IT_env, IT_c, host, + Event_Comm_Notifier_IMPL, Event_Comm_Notifier_IR); + return IT_p ? IT_p->_duplicate () : NULL; } + + + +Event_Comm::Notifier* Event_Comm::Notifier:: _bind (CORBA::Environment &IT_env) { + return _bind (NULL,NULL,CORBA::Context(), IT_env); } + + +Event_Comm::Notifier* Event_Comm::Notifier:: _bind (const char* IT_markerServer, const char* host, + CORBA::Environment &IT_env) { + return _bind (IT_markerServer, host, CORBA::Context (), IT_env); } +Event_Comm::Notifier* Event_Comm::Notifier::_narrow (CORBA::Object* IT_obj, CORBA::Environment &IT_env) { + Event_Comm::Notifier* IT_p = (Event_Comm::Notifier*)CORBA::Object::_castDown (IT_obj, Event_Comm_Notifier_IR, IT_env); + return IT_p ? IT_p->_duplicate(IT_env) : NULL; + } + +void* Event_Comm::NotifierProxyFactoryClass::New (char *IT_OR, CORBA::Environment&) { + return new Notifier(IT_OR);} + +void* Event_Comm::NotifierProxyFactoryClass::New2 () { + return new Notifier();} + +void* Event_Comm::NotifierProxyFactoryClass::IT_castUp (void *IT_p, char* IT_s) { + void *IT_l; + if (!CORBA::_interfaceCmp (IT_s,Event_Comm_Notifier_IR)) + return IT_p; + else if (IT_l=CORBA::ObjectFactoryClass::IT_castUp((CORBA::Object*)((Event_Comm::Notifier*)IT_p),IT_s)) + return IT_l; + else return NULL; + } + + +CORBA::PPTR* Event_Comm::NotifierProxyFactoryClass::pptr (void *IT_p) { + return ((Event_Comm::Notifier*)IT_p)->_pptr ();} + +void Event_Comm::NotifierProxyFactoryClass::baseInterfaces (_IDL_SEQUENCE_string& seq) { + add (seq, Event_Comm_Notifier_IR); + CORBA::ObjectFactoryClass::baseInterfaces (seq); +} + + void Event_Comm::Notifier:: send_disconnect(const char * reason, CORBA::Environment &IT_env) { + + if (IT_env || m_isNull) return ; + CORBA::Request IT_r (this, "send_disconnect",IT_env,1,1); + if (!IT_r.isException (IT_env)) { + IT_r.encodeStringOp (reason); + } + + IT_r.invoke (CORBA::Flags(CORBA::INV_NO_RESPONSE), IT_env); + } + + void Event_Comm::Notifier:: send_notification(const Event_Comm::Notification& notification, CORBA::Environment &IT_env) { + + if (IT_env || m_isNull) return ; + CORBA::Request IT_r (this, "send_notification",IT_env,1,1); + if (!IT_r.isException (IT_env)) { + notification.encodeOp (IT_r); + } + + IT_r.invoke (CORBA::Flags(CORBA::INV_NO_RESPONSE), IT_env); + } + + void Event_Comm::Notifier:: subscribe(Event_Comm::Notification_Receiver* notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) { + + if (IT_env || m_isNull) return ; + CORBA::Request IT_r (this, "subscribe",IT_env,1,1); + if (!IT_r.isException (IT_env)) { + IT_r << (CORBA::Object*)notification_receiver; + + IT_r.encodeStringOp (filtering_criteria); + } + + IT_r.invoke (CORBA::Flags(CORBA::INV_NO_RESPONSE), IT_env); + } + + void Event_Comm::Notifier:: unsubscribe(Event_Comm::Notification_Receiver* notification_receiver, const char * filtering_criteria, CORBA::Environment &IT_env) { + + if (IT_env || m_isNull) return ; + CORBA::Request IT_r (this, "unsubscribe",IT_env,1,1); + if (!IT_r.isException (IT_env)) { + IT_r << (CORBA::Object*)notification_receiver; + + IT_r.encodeStringOp (filtering_criteria); + } + + IT_r.invoke (CORBA::Flags(CORBA::INV_NO_RESPONSE), IT_env); + } + + +Event_Comm::NotifierProxyFactoryClass Event_Comm::NotifierProxyFactory(1); + + +#ifndef Event_Comm_Notifier_dispatch_impl + +unsigned char Event_Comm::Notifier_dispatch::dispatch (CORBA::Request &IT_r, + unsigned char, void *) { + IT_r.makeRuntimeException1 ("Event_Comm::Notifier"); + return 0; +} + +#endif + diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Event_CommS.cpp b/apps/Orbix-Examples/Event_Comm/libsrc/Event_CommS.cpp new file mode 100644 index 00000000000..9adc4cb26d4 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Event_CommS.cpp @@ -0,0 +1,166 @@ + +// @(#)Event_CommS.cpp 1.1 10/18/96 + +#include "Event_Comm.hh" + + +#define Event_Comm_Notification_Receiver_dispatch_impl + +unsigned char Event_Comm::Notification_Receiver_dispatch::dispatch (CORBA::Request &IT_r, + unsigned char IT_isTarget, void *IT_pp) { + if (!IT_pp) + IT_pp = m_obj; + const char *IT_s = IT_r.getOperation (); + if (!strcmp(IT_s,"receive_notification")) { + CORBA::Environment IT_env (IT_r); + CORBA::Filter* IT_f = CORBA::Orbix.getFilter (); + if (!IT_r.tcAssert ("\ +Ro~receive_notification~+notification{R~Event_Comm::Notification~tag_{0}},>{v},O{}\ +")) + return 1; + Event_Comm::Notification notification; + notification.decodeOp (IT_r); + + if (IT_f && !IT_r.isException (IT_env)) + IT_f->inRequestPostM (IT_r, IT_env); + if (!IT_r.isException (IT_env)) + ((Event_Comm::Notification_Receiver*)IT_pp)->receive_notification ( notification, IT_env); + + IT_r.replyNoResults (CORBA::Flags(CORBA::INV_NO_RESPONSE),IT_env); + return 1; + } + + else if (!strcmp(IT_s,"disconnect")) { + CORBA::Environment IT_env (IT_r); + CORBA::Filter* IT_f = CORBA::Orbix.getFilter (); + if (!IT_r.tcAssert ("\ +Ro~disconnect~+reason{0},>{v},O{}\ +")) + return 1; + char * reason; + IT_r.decodeStringOp(reason); + + if (IT_f && !IT_r.isException (IT_env)) + IT_f->inRequestPostM (IT_r, IT_env); + if (!IT_r.isException (IT_env)) + ((Event_Comm::Notification_Receiver*)IT_pp)->disconnect ( reason, IT_env); + + delete [] reason; + IT_r.replyNoResults (CORBA::Flags(CORBA::INV_NO_RESPONSE),IT_env); + return 1; + } + + else if (IT_isTarget) + IT_r.makeRuntimeException2 (); + + return 0; +} + +#define Event_Comm_Notifier_dispatch_impl + +unsigned char Event_Comm::Notifier_dispatch::dispatch (CORBA::Request &IT_r, + unsigned char IT_isTarget, void *IT_pp) { + if (!IT_pp) + IT_pp = m_obj; + const char *IT_s = IT_r.getOperation (); + if (!strcmp(IT_s,"send_disconnect")) { + CORBA::Environment IT_env (IT_r); + CORBA::Filter* IT_f = CORBA::Orbix.getFilter (); + if (!IT_r.tcAssert ("\ +Ro~send_disconnect~+reason{0},>{v},O{}\ +")) + return 1; + char * reason; + IT_r.decodeStringOp(reason); + + if (IT_f && !IT_r.isException (IT_env)) + IT_f->inRequestPostM (IT_r, IT_env); + if (!IT_r.isException (IT_env)) + ((Event_Comm::Notifier*)IT_pp)->send_disconnect ( reason, IT_env); + + delete [] reason; + IT_r.replyNoResults (CORBA::Flags(CORBA::INV_NO_RESPONSE),IT_env); + return 1; + } + + else if (!strcmp(IT_s,"send_notification")) { + CORBA::Environment IT_env (IT_r); + CORBA::Filter* IT_f = CORBA::Orbix.getFilter (); + if (!IT_r.tcAssert ("\ +Ro~send_notification~+notification{R~Event_Comm::Notification~tag_{0}},>{v},O{}\ +")) + return 1; + Event_Comm::Notification notification; + notification.decodeOp (IT_r); + + if (IT_f && !IT_r.isException (IT_env)) + IT_f->inRequestPostM (IT_r, IT_env); + if (!IT_r.isException (IT_env)) + ((Event_Comm::Notifier*)IT_pp)->send_notification ( notification, IT_env); + + IT_r.replyNoResults (CORBA::Flags(CORBA::INV_NO_RESPONSE),IT_env); + return 1; + } + + else if (!strcmp(IT_s,"subscribe")) { + CORBA::Environment IT_env (IT_r); + CORBA::Filter* IT_f = CORBA::Orbix.getFilter (); + if (!IT_r.tcAssert ("\ +Ro~subscribe~+notification_receiver{O~Event_Comm::Notification_Receiver},+filtering_criteria{0},>{v},O{}\ +")) + return 1; + Event_Comm::Notification_Receiver* notification_receiver; + notification_receiver = (Event_Comm::Notification_Receiver*) IT_r.decodeObjRef (Event_Comm_Notification_Receiver_IR); + if (notification_receiver) notification_receiver->_duplicate (); + + char * filtering_criteria; + IT_r.decodeStringOp(filtering_criteria); + + if (IT_f && !IT_r.isException (IT_env)) + IT_f->inRequestPostM (IT_r, IT_env); + if (!IT_r.isException (IT_env)) + ((Event_Comm::Notifier*)IT_pp)->subscribe ( notification_receiver, filtering_criteria, IT_env); + + if (notification_receiver) notification_receiver->_release (); + + delete [] filtering_criteria; + IT_r.replyNoResults (CORBA::Flags(CORBA::INV_NO_RESPONSE),IT_env); + + return 1; + } + + else if (!strcmp(IT_s,"unsubscribe")) { + CORBA::Environment IT_env (IT_r); + CORBA::Filter* IT_f = CORBA::Orbix.getFilter (); + if (!IT_r.tcAssert ("\ +Ro~unsubscribe~+notification_receiver{O~Event_Comm::Notification_Receiver},+filtering_criteria{0},>{v},O{}\ +")) + return 1; + Event_Comm::Notification_Receiver* notification_receiver; + notification_receiver = (Event_Comm::Notification_Receiver*) IT_r.decodeObjRef (Event_Comm_Notification_Receiver_IR); + if (notification_receiver) notification_receiver->_duplicate (); + + char * filtering_criteria; + IT_r.decodeStringOp(filtering_criteria); + + if (IT_f && !IT_r.isException (IT_env)) + IT_f->inRequestPostM (IT_r, IT_env); + if (!IT_r.isException (IT_env)) + ((Event_Comm::Notifier*)IT_pp)->unsubscribe ( notification_receiver, filtering_criteria, IT_env); + + if (notification_receiver) notification_receiver->_release (); + + delete [] filtering_criteria; + IT_r.replyNoResults (CORBA::Flags(CORBA::INV_NO_RESPONSE),IT_env); + + return 1; + } + + else if (IT_isTarget) + IT_r.makeRuntimeException2 (); + + return 0; +} + +#include "Event_CommC.cpp" + diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm_i.h b/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm_i.h new file mode 100644 index 00000000000..2db73e2f616 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Event_Comm_i.h @@ -0,0 +1,38 @@ +/* -*- C++ -*- */ +// @(#)Event_Comm_i.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Event_Comm_i.h +// +// = DESCRIPTION +// Class interface for the implementation of the distributed +// event notification mechanism. +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_EVENT_COMM_I_H) +#define _EVENT_COMM_I_H + +#include "Notification_Receiver_i.h" +#include "Notifier_i.h" + +#if defined (ACE_HAS_ORBIX) +#define nil 0 + +// Tie the Notification_Receiver and Notifier implementation classes +// together with the IDL interface. + +DEF_TIE_Event_Comm_Notification_Receiver (Notification_Receiver_i) +DEF_TIE_Event_Comm_Notifier (Notifier_i) + +#endif /* ACE_HAS_ORBIX */ +#endif /* _EVENT_COMM_I_H */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Makefile b/apps/Orbix-Examples/Event_Comm/libsrc/Makefile new file mode 100644 index 00000000000..add9fd31151 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Makefile @@ -0,0 +1,113 @@ +#---------------------------------------------------------------------------- +# @(#)Makefile 1.1 10/18/96 +# +# Makefile for the Event Communications library +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Local macros +#---------------------------------------------------------------------------- + +LIB = libEvent_Comm.a +SHLIB = libEvent_Comm.so + +FILES = Event_CommS \ + Event_CommC \ + Notifier_i \ + Notification_Receiver_i + +LSRC = $(addsuffix .cpp,$(FILES)) +LOBJ = $(addsuffix .o,$(FILES)) +SHOBJ = $(addsuffix .so,$(FILES)) + +VLDLIBS = $(LDLIBS:%=%$(VAR)) + +BUILD = $(VLIB) + +#---------------------------------------------------------------------------- +# 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.local.GNU + +#---------------------------------------------------------------------------- +# Orbix related macros and target settings. +#---------------------------------------------------------------------------- + +ORBIX_BINDIR = $(ORBIX_ROOT)/bin +ORBIX_LIBDIR = $(ORBIX_ROOT)/lib +ORBIX_INCDIR = $(ORBIX_ROOT)/include + +CPPFLAGS += -DEXCEPTIONS -I$(ORBIX_INCDIR) -DWANT_ORBIX_FDS +LDFLAGS += -L$(ORBIX_LIBDIR) -R $(ORBIX_LIBDIR) + +IDLFLAGS = -A -s S.cpp -c C.cpp + +#---------------------------------------------------------------------------- +# Local targets +#---------------------------------------------------------------------------- + +#---------------------------------------------------------------------------- +# Dependencies +#---------------------------------------------------------------------------- + +# DO NOT DELETE THIS LINE -- g++dep uses it. +# DO NOT PUT ANYTHING AFTER THIS LINE, IT WILL GO AWAY. + +Event_CommS.o: Event_CommS.cpp Event_Comm.hh Event_CommC.cpp +Event_CommC.o: Event_CommC.cpp Event_Comm.hh +Notifier_i.o: Notifier_i.cpp \ + /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/sysincludes.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/config.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/Synch.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Time_Value.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch_T.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.i \ + Notification_Receiver_i.h 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 \ + Event_Comm.hh +Notification_Receiver_i.o: Notification_Receiver_i.cpp \ + /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/sysincludes.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/config.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/Synch.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Time_Value.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Synch_T.h \ + /project/adaptive/ACE_wrappers/build/SunOS5.4/include/ace/Thread_Specific.i \ + /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/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/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/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 \ + Notification_Receiver_i.h + +# IF YOU PUT ANYTHING HERE IT WILL GO AWAY diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Notification.idl b/apps/Orbix-Examples/Event_Comm/libsrc/Notification.idl new file mode 100644 index 00000000000..ecfd5adb8e0 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Notification.idl @@ -0,0 +1,42 @@ +/* -*- C++ -*- */ +// @(#)Notification.idl 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notification.idl +// +// = DESCRIPTION +// This is the CORBA IDL interface for the Event Communication . +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#ifndef _NOTIFICATION_IDL +#define _NOTIFICATION_IDL + +struct Notification + // = TITLE + // Defines the interface for an event . + // + // = This is the type passed by the Notifier to the Notification_Receiver. + // Since it contains an , it can hold any values. Naturally, + // the consumer must understand how to interpret this! +{ + string tag_; + // Tag for the notification. + +// any value_; + // A notification can contain anything. + + Object object_ref_; + // Object reference for callbacks. +}; + +#endif /* _NOTIFICATION_IDL */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver.idl b/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver.idl new file mode 100644 index 00000000000..222f18782f7 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver.idl @@ -0,0 +1,42 @@ +/* -*- C++ -*- */ +// @(#)Notification_Receiver.idl 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notification_Receiver.idl +// +// = DESCRIPTION +// The CORBA IDL interface for the Event Communication +// component. +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#include "Notification.idl" + +#ifndef _Notification_Receiver_iDL +#define _Notification_Receiver_iDL + +interface Notification_Receiver + // = TITLE + // Defines the interface for a of events. + // Note that all operations are to avoid blocking. + // + // = DESCRIPTION +{ + oneway void receive_notification (in Notification notification); + // Inform the that has occurred. + + oneway void disconnect (in string reason); + // Disconnect the from the , + // giving it the . +}; + +#endif /* _Notification_Receiver_iDL */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.cpp b/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.cpp new file mode 100644 index 00000000000..337cf91e31e --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.cpp @@ -0,0 +1,39 @@ +#include "ace/Log_Msg.h" +// @(#)Notification_Receiver_i.cpp 1.1 10/18/96 + +#include "ace/Service_Config.h" +#include "Notification_Receiver_i.h" + +#if defined (ACE_HAS_ORBIX) + +Notification_Receiver_i::Notification_Receiver_i (void) +{ +} + +Notification_Receiver_i::~Notification_Receiver_i (void) +{ +} + +// Inform the that has occurred. + +void +Notification_Receiver_i::receive_notification + (const Event_Comm::Notification ¬ification, + CORBA::Environment &IT_env) +{ + const char *tmpstr = notification.tag_; + + ACE_DEBUG ((LM_DEBUG, "**** got notification = %s\n", tmpstr)); +} + +// Disconnect the from the . + +void +Notification_Receiver_i::disconnect (const char *reason, + CORBA::Environment &IT_env) +{ + ACE_DEBUG ((LM_DEBUG, "**** got disconnected due to %s\n", reason)); + ACE_Service_Config::end_reactor_event_loop (); +} + +#endif /* ACE_HAS_ORBIX */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.h b/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.h new file mode 100644 index 00000000000..4f0bcc980e4 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Notification_Receiver_i.h @@ -0,0 +1,48 @@ +/* -*- C++ -*- */ +// @(#)Notification_Receiver_i.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notification_Receiver__i.h +// +// = DESCRIPTION +// Class interface for the implementation of the +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_Notification_Receiver_i_H) +#define _Notification_Receiver_i_H + +#if defined (ACE_HAS_ORBIX) +#include "Event_Comm.hh" + +class Notification_Receiver_i + // = TITLE + // Defines the implementation class for event . + // + // = DESCRIPTION +{ +public: + Notification_Receiver_i (void); + ~Notification_Receiver_i (void); + + virtual void receive_notification (const Event_Comm::Notification ¬ification, + CORBA::Environment &IT_env); + // Pass the to the . + + virtual void disconnect (const char *reason, + CORBA::Environment &IT_env); + // Disconnect the from the , + // giving it the . +}; + +#endif /* ACE_HAS_ORBIX */ +#endif /* _Notification_Receiver_i_H */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Notifier.idl b/apps/Orbix-Examples/Event_Comm/libsrc/Notifier.idl new file mode 100644 index 00000000000..75e738e0627 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Notifier.idl @@ -0,0 +1,49 @@ +/* -*- C++ -*- */ +// @(#)Notifier.idl 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notifier.idl +// +// = DESCRIPTION +// This is the CORBA IDL interface for the Event Communication . +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#ifndef _Notifier_iDL +#define _Notifier_iDL + +#include "Notification.idl" +#include "Notification_Receiver.idl" + +interface Notifier + // = TITLE + // Defines the interface for a of events. + // + // = DESCRIPTION +{ + oneway void send_disconnect (in string reason); + // Disconnect all the receivers, giving them the . + + oneway void send_notification (in Notification notification); + // Send the to all the consumers who + // have subscribed and who match the filtering criteria. + + oneway void subscribe (in Notification_Receiver notification_receiver, + in string filtering_criteria); + // Subscribe the to receive events that + // match applied by the . + + oneway void unsubscribe (in Notification_Receiver notification_receiver); + // Unsubscribe the . +}; + +#endif /* _Notifier_iDL */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.cpp b/apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.cpp new file mode 100644 index 00000000000..1edefc82a29 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.cpp @@ -0,0 +1,324 @@ +#include "ace/Log_Msg.h" +// @(#)Notifier_i.cpp 1.1 10/18/96 + +#include "Notification_Receiver_i.h" +#include "Notifier_i.h" + +#if defined (ACE_HAS_ORBIX) + +class Notification_Receiver_Entry + // = TITLE + // Keeps track of context information associated with + // a entry. + // + // = DESCRIPTION + // +{ +public: + Notification_Receiver_Entry (Event_Comm::Notification_Receiver *notification_receiver, + const char *filtering_criteria); + ~Notification_Receiver_Entry (void); + + // = Set/get filtering criteria. + void criteria (const char *criteria); + const char *criteria (void); + + // = Set/get Event_Comm::Notification_Receiver object reference. + Event_Comm::Notification_Receiver *receiver (void); + void receiver (Event_Comm::Notification_Receiver *); + + // = Set/get the compiled regular expression buffer. + const char *regexp (void); + void regexp (char *); + +private: + const char *filtering_criteria_; + // String containing the filtering criteria. + + char *compiled_regexp_; + // Compiled representation of the regular expression (see + // regexpr(3g)). + + Event_Comm::Notification_Receiver *receiver_; + // Object reference for the Event_Comm::Notification_Receiver. +}; + +// = Set/get filtering criteria. + +void +Notification_Receiver_Entry::criteria (const char *criteria) +{ + ACE_OS::free (ACE_MALLOC_T (this->filtering_criteria_)); + this->filtering_criteria_ = ACE_OS::strdup (criteria); +} + +const char * +Notification_Receiver_Entry::criteria (void) +{ + return this->filtering_criteria_; +} + +// = Set/get Event_Comm::Notification_Receiver object reference. + +Event_Comm::Notification_Receiver * +Notification_Receiver_Entry::receiver (void) +{ + return this->receiver_; +} + +void +Notification_Receiver_Entry::receiver (Event_Comm::Notification_Receiver *receiver) +{ + this->receiver_ = receiver; +} + +const char * +Notification_Receiver_Entry::regexp (void) +{ + return this->compiled_regexp_; +} + +void +Notification_Receiver_Entry::regexp (char *regexp) +{ + ACE_OS::free (ACE_MALLOC_T (this->compiled_regexp_)); + this->compiled_regexp_ = regexp; +} + +Notification_Receiver_Entry::Notification_Receiver_Entry (Event_Comm::Notification_Receiver *receiver, + const char *filtering_criteria) + : receiver_ (receiver), + filtering_criteria_ (0), + compiled_regexp_ (0) +{ + char *compile_buffer = 0; + + this->criteria (filtering_criteria); + ACE_ASSERT (this->criteria ()); + + // Check for wildcard case first. + if (ACE_OS::strcmp (filtering_criteria, "") == 0) + compile_buffer = ACE_OS::strdup (""); + else // Compile the regular expression (the 0's cause ACE_OS::compile to allocate space). + compile_buffer = ACE_OS::compile (filtering_criteria, 0, 0); + + // Should throw an exception here! + ACE_ASSERT (compile_buffer != 0); + + this->regexp (compile_buffer); + ACE_ASSERT (this->regexp ()); + + // Increment the reference count since we are keeping a copy of + // this... + this->receiver_->_duplicate (this->receiver_); +} + +Notification_Receiver_Entry::~Notification_Receiver_Entry (void) +{ + ACE_OS::free (this->filtering_criteria_); + ACE_OS::free (this->compiled_regexp_); + // Decrement the object reference count. + CORBA::release (this->receiver_); +} + +Notifier_i::Notifier_i (size_t size) + : map_ (size) +{ +} + +// Add a new receiver to the table, being careful to check for +// duplicate entries. A receiver is considered a duplicate under +// the following circumstances: +// 1. It has the same marker name and the same filtering criteria +// 2. It has the same marker name and its filtering criteria is "" (the wild card). + +void +Notifier_i::subscribe (Event_Comm::Notification_Receiver *receiver_ref, + const char *filtering_criteria, + CORBA::Environment &IT_env) +{ + ACE_DEBUG ((LM_DEBUG, + "in Notifier_i::subscribe for %s with filtering criteria \"%s\"\n", + receiver_ref->_marker (), filtering_criteria)); + ACE_SString key (receiver_ref->_marker ()); + MAP_ITERATOR mi (this->map_); + + // Try to locate an entry using its marker name (which should be + // unique across the system). If we don't find the entry, or if the + // filtering criteria is different that is good news since we + // currently don't allow duplicates... In particular, if @@ Should + // duplicates be allowed? + + for (MAP_ENTRY *me = 0; mi.next (me) != 0; mi.advance ()) + { + Notification_Receiver_Entry *nr_entry = me->int_id_; + + // Check for a duplicate entry. + if (key == me->ext_id_ + && (ACE_OS::strcmp (filtering_criteria, "") == 0 + || ACE_OS::strcmp (filtering_criteria, nr_entry->criteria ()) == 0)) + { + // Inform the caller that the + // Event_Comm::Notification_Receiver * is already being + // used. + + errno = EADDRINUSE; + ACE_ERROR ((LM_ERROR, + "duplicate entry for receiver %s with criteria \"%s\"", + receiver_ref->_marker (), filtering_criteria)); + // Raise exception here??? + return; + } + } + + // If we get this far then we didn't find a duplicate, so add the + // new entry! + Notification_Receiver_Entry *nr_entry = + new Notification_Receiver_Entry (receiver_ref, filtering_criteria); + + if (nr_entry == 0) + { + errno = ENOMEM; + ACE_ERROR ((LM_ERROR, "%p\n", "new failed")); + // Raise exception here... + } + // Try to add new to the map. + else if (this->map_.bind (key, nr_entry) == -1) + { + // Prevent memory leaks. + delete nr_entry; + // Raise exception here... + ACE_ERROR ((LM_ERROR, "%p\n", "bind failed")); + } +} + +// Remove a receiver from the table. + +void +Notifier_i::unsubscribe (Event_Comm::Notification_Receiver *receiver_ref, + const char *filtering_criteria, + CORBA::Environment &IT_env) +{ + ACE_DEBUG ((LM_DEBUG, "in Notifier_i::unsubscribe for %s\n", + receiver_ref->_marker ())); + Notification_Receiver_Entry *nr_entry = 0; + ACE_SString key; + MAP_ITERATOR mi (this->map_); + int found = 0; + + // Don't make a copy since we are deleting... + key.rep ((char *) receiver_ref->_marker ()); + + // Locate and free up resources. @@ + // Note, we don't properly handle deallocation of KEYS! + + for (MAP_ENTRY *me = 0; mi.next (me) != 0; mi.advance ()) + { + if (key == me->ext_id_ + && (ACE_OS::strcmp (filtering_criteria, "") == 0 + || ACE_OS::strcmp (filtering_criteria, nr_entry->criteria ()) == 0)) + { + ACE_DEBUG ((LM_DEBUG, "removed entry %s with criteria \"%s\"\n", + receiver_ref->_marker (), filtering_criteria)); + found = 1; + // @@ This is a hack, we need a better approach! + if (this->map_.unbind (key, nr_entry) == -1) + ACE_ERROR ((LM_ERROR, "unbind failed for %s\n", + receiver_ref->_marker ())); + else + delete nr_entry; + } + } + + if (found == 0) + ACE_ERROR ((LM_ERROR, "entry %s with criteria \"%s\" not found\n", + receiver_ref->_marker (), filtering_criteria)); +} + +// Disconnect all the receivers, giving them the . + +void +Notifier_i::send_disconnect (const char *reason, + CORBA::Environment &IT_env) +{ + ACE_DEBUG ((LM_DEBUG, "in Notifier_i::send_disconnect = %s\n", reason)); + + MAP_ITERATOR mi (this->map_); + int count = 0; + + // Notify all the receivers, taking into account the filtering criteria. + + for (MAP_ENTRY *me = 0; mi.next (me) != 0; mi.advance ()) + { + Event_Comm::Notification_Receiver *receiver_ref = me->int_id_->receiver (); + ACE_ASSERT (receiver_ref->_marker () != 0); + ACE_DEBUG ((LM_DEBUG, "disconnecting client %s\n", receiver_ref->_marker ())); + TRY { + receiver_ref->disconnect (reason, IT_X); + } + CATCHANY { + cerr << "Unexpected exception " << IT_X << endl; + } + ENDTRY; + delete me->int_id_; + delete me->ext_id_.rep (); + count++; + } + + this->map_.close (); + if (count == 1) + ACE_DEBUG ((LM_DEBUG, "there was 1 receiver\n")); + else + ACE_DEBUG ((LM_DEBUG, "there were %d receivers\n", count)); +} + +// Notify all receivers whose filtering criteria match the event. + +void +Notifier_i::send_notification (const Event_Comm::Notification ¬ification, + CORBA::Environment &IT_env) +{ + ACE_DEBUG ((LM_DEBUG, "in Notifier_i::send_notification = %s\n", + notification.tag_)); + MAP_ITERATOR mi (this->map_); + int count = 0; + + // Notify all the receivers. + // @@ Later on we need to consider the filtering_criteria! + + for (MAP_ENTRY *me = 0; mi.next (me) != 0; mi.advance ()) + { + Event_Comm::Notification_Receiver *receiver_ref = me->int_id_->receiver (); + ACE_ASSERT (receiver_ref->_marker () != 0); + const char *regexp = me->int_id_->regexp (); + const char *criteria = me->int_id_->criteria (); + ACE_ASSERT (regexp); + ACE_ASSERT (criteria); + + // Do a regular expression comparison to determine matching. + if (ACE_OS::strcmp ("", criteria) == 0 // Everything matches the wildcard. +// || ACE_OS::strcmp (notification.tag_, regexp) == 0) + || ACE_OS::step (notification.tag_, regexp) != 0) + { + ACE_DEBUG ((LM_DEBUG, "string %s matched regexp \"%s\" for client %s\n", + notification.tag_, me->int_id_->criteria (), + receiver_ref->_marker ())); + TRY { + receiver_ref->receive_notification (notification, IT_X); + } + CATCHANY { + cerr << "Unexpected exception " << IT_X << endl; + continue; + } + ENDTRY; + count++; + } + } + + if (count == 1) + ACE_DEBUG ((LM_DEBUG, "there was 1 receiver\n")); + else + ACE_DEBUG ((LM_DEBUG, "there were %d receivers\n", count)); +} + +#endif /* ACE_HAS_ORBIX */ diff --git a/apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.h b/apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.h new file mode 100644 index 00000000000..379f96b8097 --- /dev/null +++ b/apps/Orbix-Examples/Event_Comm/libsrc/Notifier_i.h @@ -0,0 +1,82 @@ +/* -*- C++ -*- */ +// @(#)Notifier_i.h 1.1 10/18/96 + + +// ============================================================================ +// +// = LIBRARY +// EventComm +// +// = FILENAME +// Notifier_i.h +// +// = DESCRIPTION +// Class interface for the implementation of the +// +// = AUTHOR +// Douglas C. Schmidt (schmidt@cs.wustl.edu) +// +// ============================================================================ + +#if !defined (_Notifier_i_H) +#define _Notifier_i_H + +#include "ace/Map_Manager.h" +#include "ace/Synch.h" +#include "ace/SString.h" +#include "Event_Comm.hh" + +#if defined (ACE_HAS_ORBIX) + +// Forward reference. +class Notification_Receiver_Entry; + +class Notifier_i + // = TITLE + // Defines the implementation class for event . + // + // = DESCRIPTION +{ +public: + enum + { + DEFAULT_SIZE = 1024 // Default max number of Event_Comm::Notification_Receivers. + }; + + Notifier_i (size_t size_hint = Notifier_i::DEFAULT_SIZE); + // Initialize a Notifier_i object with the specified size hint. + + void send_disconnect (const char *reason, + CORBA::Environment &IT_env); + // Disconnect all the receivers, giving them the . + + void send_notification (const Event_Comm::Notification ¬ification, + CORBA::Environment &IT_env); + // Send the to all the consumers who + // have subscribed and who match the filtering criteria. + + void subscribe (Event_Comm::Notification_Receiver *notification_receiver, + const char *filtering_criteria, + CORBA::Environment &IT_env); + // Subscribe the to receive events that + // match applied by the . + + void unsubscribe (Event_Comm::Notification_Receiver *notification_receiver, + const char *filtering_criteria, + CORBA::Environment &IT_env); + // Unsubscribe the . + +private: + // The following implementation should be replaced + // by a standard container class from STL... + + typedef ACE_Map_Manager MAP_MANAGER; + typedef ACE_Map_Iterator MAP_ITERATOR; + typedef ACE_Map_Entry MAP_ENTRY; + + MAP_MANAGER map_; + // Table that maps a to a . +}; + +#endif /* ACE_HAS_ORBIX */ +#endif /* _Notifier_i_H */ -- cgit v1.2.1