diff options
Diffstat (limited to 'ACE/examples/ASX/CCM_App')
-rw-r--r-- | ACE/examples/ASX/CCM_App/ASX_CCM_App.mpc | 26 | ||||
-rw-r--r-- | ACE/examples/ASX/CCM_App/CCM_App.cpp | 122 | ||||
-rw-r--r-- | ACE/examples/ASX/CCM_App/Makefile.am | 59 | ||||
-rw-r--r-- | ACE/examples/ASX/CCM_App/SC_Client.cpp | 13 | ||||
-rw-r--r-- | ACE/examples/ASX/CCM_App/SC_Server.cpp | 86 | ||||
-rw-r--r-- | ACE/examples/ASX/CCM_App/svc.conf | 21 | ||||
-rw-r--r-- | ACE/examples/ASX/CCM_App/svc.conf.xml | 33 |
7 files changed, 360 insertions, 0 deletions
diff --git a/ACE/examples/ASX/CCM_App/ASX_CCM_App.mpc b/ACE/examples/ASX/CCM_App/ASX_CCM_App.mpc new file mode 100644 index 00000000000..b5c40beb84c --- /dev/null +++ b/ACE/examples/ASX/CCM_App/ASX_CCM_App.mpc @@ -0,0 +1,26 @@ +// -*- MPC -*- +// $Id$ + +project(*Lib) : acelib { + sharedname = ccm_app + Source_Files { + CCM_App.cpp + } +} + +project(*Server) : aceexe { + exename = server + after += ASX_CCM_App_Lib + Source_Files { + SC_Server.cpp + } +} + +project(*Client) : aceexe { + exename = client + after += ASX_CCM_App_Server + Source_Files { + SC_Client.cpp + } +} + diff --git a/ACE/examples/ASX/CCM_App/CCM_App.cpp b/ACE/examples/ASX/CCM_App/CCM_App.cpp new file mode 100644 index 00000000000..540dd545d90 --- /dev/null +++ b/ACE/examples/ASX/CCM_App/CCM_App.cpp @@ -0,0 +1,122 @@ +// $Id$ + +#define ACE_BUILD_SVC_DLL + +#include "ace/Stream.h" +#include "ace/Task.h" +#include "ace/Module.h" +#include "ace/svc_export.h" + +ACE_RCSID(CCM_App, CCM_App, "$Id$") + +typedef ACE_Task<ACE_SYNCH> MT_Task; +typedef ACE_Stream<ACE_SYNCH> MT_Stream; +typedef ACE_Module<ACE_SYNCH> MT_Module; + +class ACE_Svc_Export Test_Task : public MT_Task +{ +public: + //FUZZ: disable check_for_lack_ACE_OS + virtual int open (void *); + virtual int close (u_long); + //FUZZ: enable check_for_lack_ACE_OS + + virtual int init (int, ACE_TCHAR *[]); + virtual int fini (void); + virtual int suspend (void); + virtual int resume (void); +}; + +int +Test_Task::open (void *) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("opening %s\n"), + this->name () ? this->name () : ACE_TEXT ("task"))); + return 0; +} + +int +Test_Task::close (u_long) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("closing %s\n"), + this->name () ? this->name () : ACE_TEXT ("task"))); + return 0; +} + +int +Test_Task::suspend (void) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("suspending in %s\n"), + this->name () ? this->name () : ACE_TEXT ("task"))); + return 0; +} + +int +Test_Task::resume (void) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("resuming in %s\n"), + this->name () ? this->name () : ACE_TEXT ("task"))); + return 0; +} + +int +Test_Task::init (int, ACE_TCHAR *[]) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("initializing %s\n"), + this->name () ? this->name () : ACE_TEXT ("task"))); + + return 0; +} + +int +Test_Task::fini (void) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("finalizing %s\n"), + this->name () ? this->name () : ACE_TEXT ("task"))); + return 0; +} + +// Factories used to control configuration. + +ACE_SVC_FACTORY_DECLARE (Test_Task) +ACE_SVC_FACTORY_DEFINE (Test_Task) + +// Dynamically linked functions used to control configuration. + +extern "C" ACE_Svc_Export MT_Stream *make_stream (void); +extern "C" ACE_Svc_Export MT_Module *make_da (void); +extern "C" ACE_Svc_Export MT_Module *make_ea (void); +extern "C" ACE_Svc_Export MT_Module *make_mr (void); + +MT_Stream * +make_stream (void) +{ + return new MT_Stream; +} + +MT_Module * +make_da (void) +{ + return new MT_Module (ACE_TEXT ("Device_Adapter"), + new Test_Task, new Test_Task); +} + +MT_Module * +make_ea (void) +{ + return new MT_Module (ACE_TEXT ("Event_Analyzer"), + new Test_Task, new Test_Task); +} + +MT_Module * +make_mr (void) +{ + return new MT_Module (ACE_TEXT ("Multicast_Router"), + new Test_Task, new Test_Task); +} diff --git a/ACE/examples/ASX/CCM_App/Makefile.am b/ACE/examples/ASX/CCM_App/Makefile.am new file mode 100644 index 00000000000..78ded02a046 --- /dev/null +++ b/ACE/examples/ASX/CCM_App/Makefile.am @@ -0,0 +1,59 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ./bin/mwc.pl -type automake -noreldefs ACE.mwc + +ACE_BUILDDIR = $(top_builddir) +ACE_ROOT = $(top_srcdir) + +## Makefile.ASX_CCM_App_Lib.am + +noinst_LTLIBRARIES = libccm_app.la + +libccm_app_la_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) + +libccm_app_la_SOURCES = \ + CCM_App.cpp + +## Makefile.ASX_CCM_App_Server.am + +noinst_PROGRAMS = server + +server_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) + +server_SOURCES = \ + SC_Server.cpp + +server_LDADD = \ + $(ACE_BUILDDIR)/ace/libACE.la + +## Makefile.ASX_CCM_App_Client.am + +noinst_PROGRAMS += client + +client_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) + +client_SOURCES = \ + SC_Client.cpp + +client_LDADD = \ + $(ACE_BUILDDIR)/ace/libACE.la + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/ACE/examples/ASX/CCM_App/SC_Client.cpp b/ACE/examples/ASX/CCM_App/SC_Client.cpp new file mode 100644 index 00000000000..fbd4439784a --- /dev/null +++ b/ACE/examples/ASX/CCM_App/SC_Client.cpp @@ -0,0 +1,13 @@ +// $Id$ + +#include "ace/ACE.h" + +ACE_RCSID(CCM_App, SC_Client, "$Id$") + +// Pretty simple, eh? ;-) + +int +ACE_TMAIN (int, ACE_TCHAR *[]) +{ + return 0; +} diff --git a/ACE/examples/ASX/CCM_App/SC_Server.cpp b/ACE/examples/ASX/CCM_App/SC_Server.cpp new file mode 100644 index 00000000000..b93e49005bf --- /dev/null +++ b/ACE/examples/ASX/CCM_App/SC_Server.cpp @@ -0,0 +1,86 @@ +// $Id$ + +// Simple driver program for the server. This driver dynamically +// links in all the services in the <svc.conf> file. + +#include "ace/OS_NS_unistd.h" +#include "ace/OS_main.h" +#include "ace/Service_Config.h" +#include "ace/Thread_Manager.h" +#include "ace/Reactor.h" +#include "ace/Sig_Adapter.h" + +ACE_RCSID(CCM_App, SC_Server, "$Id$") + +class Event_Handler : public ACE_Event_Handler +{ +public: + virtual int handle_input (ACE_HANDLE handle); + virtual int handle_close (ACE_HANDLE, + ACE_Reactor_Mask); +}; + +int +Event_Handler::handle_input (ACE_HANDLE handle) +{ + char buf[BUFSIZ]; + ssize_t n = ACE_OS::read (handle, buf, sizeof buf); + + if (n == -1) + return -1; + else if (n == 0) + ACE_ERROR_RETURN ((LM_DEBUG, + ACE_TEXT ("shutting down on EOF\n")), + -1); + else if (ACE_OS::write (ACE_STDOUT, buf, n) != n) + ACE_ERROR_RETURN ((LM_DEBUG, + ACE_TEXT ("%p\n"), ACE_TEXT ("write failed")), + -1); + else + return 0; +} + +int +Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("closing Event_Handler\n"))); + ACE_Reactor::instance ()->end_reactor_event_loop (); + return 0; +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + ACE_Service_Config loggerd; + Event_Handler handler; + ACE_Sig_Adapter shutdown_handler ((ACE_Sig_Handler_Ex) ACE_Reactor::end_event_loop); + + if (ACE_Event_Handler::register_stdin_handler (&handler, + ACE_Reactor::instance (), + ACE_Thread_Manager::instance ()) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n"), + ACE_TEXT ("register_stdin_handler"))); + + if (loggerd.open (argc, + argv, + ACE_DEFAULT_LOGGER_KEY, + // Don't ignore static services! + 0) == -1 && errno != ENOENT) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n%a"), + ACE_TEXT ("open"), + 1)); + else if (ACE_Reactor::instance ()->register_handler + (SIGINT, &shutdown_handler) == -1) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("%p\n%a"), + ACE_TEXT ("register_handler"), + 1)); + + // Perform logging service until we receive SIGINT. + + ACE_Reactor::instance ()->run_reactor_event_loop (); + return 0; +} diff --git a/ACE/examples/ASX/CCM_App/svc.conf b/ACE/examples/ASX/CCM_App/svc.conf new file mode 100644 index 00000000000..b894e6e69e5 --- /dev/null +++ b/ACE/examples/ASX/CCM_App/svc.conf @@ -0,0 +1,21 @@ +static ACE_Service_Manager "-d -p 4911" + +dynamic Test_Task Service_Object *CCM_App:_make_Test_Task() "-p 3000" + +stream dynamic CCM_App STREAM *CCM_App:make_stream() active +{ + dynamic Device_Adapter Module *CCM_App:make_da() + dynamic Event_Analyzer Module *CCM_App:make_ea() + dynamic Multicast_Router Module *CCM_App:make_mr() "-p 3001" +} + +stream CCM_App +{ + remove Device_Adapter +# remove Event_Analyzer +# remove Multicast_Router +} + +# remove CCM_App +remove Test_Task + diff --git a/ACE/examples/ASX/CCM_App/svc.conf.xml b/ACE/examples/ASX/CCM_App/svc.conf.xml new file mode 100644 index 00000000000..e743d4ed986 --- /dev/null +++ b/ACE/examples/ASX/CCM_App/svc.conf.xml @@ -0,0 +1,33 @@ +<?xml version='1.0'?> +<!-- Converted from svc.conf by svcconf-convert.pl --> +<ACE_Svc_Conf> + <static id="ACE_Service_Manager" params="-d -p 4911"/> + <dynamic id="Test_Task" type="Service_Object"> + <initializer path="CCM_App" init="_make_Test_Task" params="-p 3000"/> + </dynamic> + <streamdef> + <dynamic id="CCM_App" type="STREAM"> + <initializer path="CCM_App" init="make_stream"/> + </dynamic> + <module> + <dynamic id="Device_Adapter" type="Module"> + <initializer path="CCM_App" init="make_da"/> + </dynamic> + <dynamic id="Event_Analyzer" type="Module"> + <initializer path="CCM_App" init="make_ea"/> + </dynamic> + <dynamic id="Multicast_Router" type="Module"> + <initializer path="CCM_App" init="make_mr" params="-p 3001"/> + </dynamic> + </module> + </streamdef> + <stream id="CCM_App"> + <module> + <remove id="Device_Adapter"/> + <!-- remove Event_Analyzer --> + <!-- remove Multicast_Router --> + </module> + </stream> + <!-- remove CCM_App --> + <remove id="Test_Task"/> +</ACE_Svc_Conf> |