From 1d448fc6a433766734beb25e61308f672d1b6cd4 Mon Sep 17 00:00:00 2001 From: nanbor Date: Thu, 9 Nov 2006 18:48:15 +0000 Subject: Added files from old workspace --- .../Priority_Test/Controllers/Controller.cidl | 12 ++ .../RTCCM/Priority_Test/Controllers/Controller.idl | 29 +++ .../RTCCM/Priority_Test/Controllers/Controller.mpc | 92 +++++++++ .../Priority_Test/Controllers/ControllerEI.idl | 32 +++ .../Priority_Test/Controllers/Controller_exec.cpp | 160 +++++++++++++++ .../Priority_Test/Controllers/Controller_exec.h | 114 +++++++++++ .../Controllers/Controller_exec_export.h | 54 +++++ .../Controllers/Controller_stub_export.h | 54 +++++ .../Controllers/Controller_svnt_export.h | 54 +++++ .../RTCCM/Priority_Test/Controllers/Pulser.cpp | 113 +++++++++++ .../tests/RTCCM/Priority_Test/Controllers/Pulser.h | 75 +++++++ .../Priority_Test/Controllers/Rate_Controller.cpp | 221 +++++++++++++++++++++ .../Priority_Test/Controllers/Rate_Controller.h | 163 +++++++++++++++ .../RTCCM/Priority_Test/Controllers/client.cpp | 131 ++++++++++++ CIAO/tests/RTCCM/Priority_Test/Priority_Test.idl | 46 +++++ CIAO/tests/RTCCM/Priority_Test/Priority_Test.mpc | 30 +++ .../Priority_Test/Priority_Test_stub_export.h | 54 +++++ .../Priority_Test/Priority_Test_svnt_export.h | 54 +++++ .../RTCCM/Priority_Test/Workers/CB_Worker_exec.cpp | 127 ++++++++++++ .../RTCCM/Priority_Test/Workers/CB_Worker_exec.h | 117 +++++++++++ .../Priority_Test/Workers/IOB_Worker_exec.cpp | 115 +++++++++++ .../RTCCM/Priority_Test/Workers/IOB_Worker_exec.h | 117 +++++++++++ CIAO/tests/RTCCM/Priority_Test/Workers/README | 21 ++ CIAO/tests/RTCCM/Priority_Test/Workers/Worker.cidl | 12 ++ CIAO/tests/RTCCM/Priority_Test/Workers/Worker.idl | 29 +++ CIAO/tests/RTCCM/Priority_Test/Workers/Worker.mpc | 78 ++++++++ .../tests/RTCCM/Priority_Test/Workers/WorkerEI.idl | 33 +++ .../Priority_Test/Workers/Worker_exec_export.h | 54 +++++ .../Priority_Test/Workers/Worker_stub_export.h | 54 +++++ .../Priority_Test/Workers/Worker_svnt_export.h | 54 +++++ 30 files changed, 2299 insertions(+) create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.cidl create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.idl create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.mpc create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/ControllerEI.idl create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.cpp create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec_export.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_stub_export.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_svnt_export.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.cpp create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp create mode 100644 CIAO/tests/RTCCM/Priority_Test/Priority_Test.idl create mode 100644 CIAO/tests/RTCCM/Priority_Test/Priority_Test.mpc create mode 100644 CIAO/tests/RTCCM/Priority_Test/Priority_Test_stub_export.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Priority_Test_svnt_export.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.cpp create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.cpp create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/README create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/Worker.cidl create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/Worker.idl create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/Worker.mpc create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/WorkerEI.idl create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/Worker_exec_export.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/Worker_stub_export.h create mode 100644 CIAO/tests/RTCCM/Priority_Test/Workers/Worker_svnt_export.h diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.cidl b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.cidl new file mode 100644 index 00000000000..60237271100 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.cidl @@ -0,0 +1,12 @@ +// $Id$ -*- IDL -*- + +#include "Controller.idl" + +composition session Controller_Impl +{ + home executor ControllerHome_exec + { + implements Priority_Test::ControllerHome; + manages Controller_exec; + }; +}; diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.idl b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.idl new file mode 100644 index 00000000000..94e705e3c2d --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.idl @@ -0,0 +1,29 @@ +// $Id$ + +/** + * @file Controller.idl + * + * Definition of an Controller component that triggers a worker + * connecting to it to do some work. + * + * @author Nanbor Wang + */ + +#ifndef CONTROLLER_IDL +#define CONTROLLER_IDL + +#include "../Priority_Test.idl" + +module Priority_Test +{ + component Controller supports Op_Mode + { + uses Common_Ops worker; + }; + + home ControllerHome manages Controller + { + }; +}; + +#endif /* CONTROLLER_IDL */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.mpc b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.mpc new file mode 100644 index 00000000000..1eb9ffc6f89 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller.mpc @@ -0,0 +1,92 @@ +// $Id$ +// This file is generated with "generate_component_mpc.pl -l .. -p Priority_Test -i Controller" + +project(Priority_Test_Controller_stub): ciao_client { + after += Priority_Test_stub + sharedname = Controller_stub + idlflags += -Wb,stub_export_macro=CONTROLLER_STUB_Export -Wb,stub_export_include=Controller_stub_export.h -Wb,skel_export_macro=CONTROLLER_SVNT_Export -Wb,skel_export_include=Controller_svnt_export.h + dynamicflags = CONTROLLER_STUB_BUILD_DLL + + IDL_Files { + Controller.idl + } + + Source_Files { + ControllerC.cpp + } +} + +project(Priority_Test_Controller_svnt) : ciao_servant { + after += Priority_Test_svnt Priority_Test_Controller_stub + sharedname = Controller_svnt + libs += Controller_stub Priority_Test_stub Priority_Test_svnt + libpaths += .. + idlflags += -Wb,export_macro=CONTROLLER_SVNT_Export -Wb,export_include=Controller_svnt_export.h + dynamicflags = CONTROLLER_SVNT_BUILD_DLL + + CIDL_Files { + Controller.cidl + } + + IDL_Files { + ControllerE.idl + } + + Source_Files { + ControllerEC.cpp + ControllerS.cpp + Controller_svnt.cpp + } +} + + +project(Priority_Test_Controller_exec) : ciao_component { + after += Priority_Test_Controller_svnt + sharedname = Controller_exec + libs += Controller_stub Controller_svnt Priority_Test_stub Priority_Test_svnt + libpaths += .. + idlflags += -Wb,export_macro=CONTROLLER_EXEC_Export -Wb,export_include=Controller_exec_export.h + dynamicflags = CONTROLLER_EXEC_BUILD_DLL + + IDL_Files { + ControllerEI.idl + } + + Source_Files { + ControllerEIC.cpp + Controller_exec.cpp + } +} + +project(Priority_Test_Rate_Controller_exec) : ciao_component { + after += Priority_Test_Controller_svnt + sharedname = Rate_Controller_exec + libs += Controller_stub Controller_svnt Priority_Test_stub Priority_Test_svnt + libpaths += .. + idlflags += -Wb,export_macro=CONTROLLER_EXEC_Export -Wb,export_include=Controller_exec_export.h + dynamicflags = CONTROLLER_EXEC_BUILD_DLL + + IDL_Files { + ControllerEI.idl + } + + Source_Files { + ControllerEIC.cpp + Rate_Controller.cpp + Pulser.cpp + } +} + +project (*client) : ciao_client { + exename = client + after += Priority_Test_Controller_stub + libs += Controller_stub Priority_Test_stub + libpaths += .. + + IDL_Files { + } + + Source_Files { + client.cpp + } +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/ControllerEI.idl b/CIAO/tests/RTCCM/Priority_Test/Controllers/ControllerEI.idl new file mode 100644 index 00000000000..7cfb0d8ceed --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/ControllerEI.idl @@ -0,0 +1,32 @@ +// $Id$ + +/** + * @file ControllerEI.idl + * + * Definition of the Controller component implementation. + * + * @author Nanbor Wang + */ + +#ifndef CONTROLLEREI_IDL +#define CONTROLLEREI_IDL + +#include "ControllerE.idl" + +module Priority_Test +{ + /** + * @interface Controller_Exec + * + * The actually Controller executor inherits from + * CCM_Controller as a monolithic implementation. + */ + local interface Controller_Exec : + CCM_Controller, + Components::SessionComponent + { + }; + +}; + +#endif /* CONTROLLEREI_IDL */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.cpp b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.cpp new file mode 100644 index 00000000000..b633aa30290 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.cpp @@ -0,0 +1,160 @@ +// $Id$ + +#include "Controller_exec.h" +#include "CIAO_common.h" +#include "ace/High_Res_Timer.h" +#include "ace/Stats.h" +#include "ace/Sample_History.h" +#include "ace/Env_Value_T.h" + +/// Default constructor. +MyImpl::Controller_exec_i::Controller_exec_i () +{ +} + +/// Default destructor. +MyImpl::Controller_exec_i::~Controller_exec_i () +{ +} + +// Operations from Priority_Test::Controller +void +MyImpl::Controller_exec_i::start (CORBA::Long arg + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // This simply performs some measurements and print out the result. + + ACE_DEBUG ((LM_DEBUG, "PERFORM TEST\n")); + + ACE_UNUSED_ARG (arg); + + Priority_Test::Common_Ops_var device = + this->context_->get_connection_worker (ACE_ENV_SINGLE_ARG_PARAMETER); + + const int niterations = 1000; + const CORBA::Long work = arg; + ACE_Sample_History history (niterations); + + ACE_hrtime_t test_start = ACE_OS::gethrtime (); + for (int i = 0; i < niterations; ++i) + { + ACE_hrtime_t start = ACE_OS::gethrtime (); + + (void) device->do_work (work, 0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_hrtime_t now = ACE_OS::gethrtime (); + history.sample (now - start); + } + ACE_hrtime_t test_end = ACE_OS::gethrtime (); + + ACE_DEBUG ((LM_DEBUG, "test finished\n")); + + const int len = 1024; + char title [len]; + + ACE_OS::snprintf (title, len, "Total (work=%4d)", work); + + ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); + ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); + ACE_DEBUG ((LM_DEBUG, "done\n")); + + ACE_Env_Value envar ("CIAO_DUMP_SAMPLE_HISTORY", 0); + if (envar != 0) + { + history.dump_samples ("HISTORY", gsf); + } + + ACE_Basic_Stats stats; + history.collect_basic_stats (stats); + stats.dump_results (title, gsf); + + ACE_Throughput_Stats::dump_throughput (title, gsf, + test_end - test_start, + stats.samples_count ()); +} + +void +MyImpl::Controller_exec_i::stop (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +// Operations from Components::SessionComponent +void +MyImpl::Controller_exec_i::set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Controller_exec_i::set_session_context\n")); + + this->context_ = + Priority_Test::CCM_Controller_Context::_narrow (ctx + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->context_.in ())) + ACE_THROW (CORBA::INTERNAL ()); + // Urm, we actually discard exceptions thown from this operation. +} + +void +MyImpl::Controller_exec_i::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Controller_exec_i::ccm_activate\n")); +} + +void +MyImpl::Controller_exec_i::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Controller_exec_i::ccm_passivate\n")); +} + +void +MyImpl::Controller_exec_i::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Controller_exec_i::ccm_remove\n")); +} + +/// Default ctor. +MyImpl::Controller_Home_exec_i::Controller_Home_exec_i () +{ +} + +/// Default dtor. +MyImpl::Controller_Home_exec_i::~Controller_Home_exec_i () +{ +} + +// Explicit home operations. + +// Implicit home operations. + +::Components::EnterpriseComponent_ptr +MyImpl::Controller_Home_exec_i::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + return new MyImpl::Controller_exec_i; +} + + +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome_Impl (void) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl\n")); + return new MyImpl::Controller_Home_exec_i; +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.h b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.h new file mode 100644 index 00000000000..cb650ac6b57 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec.h @@ -0,0 +1,114 @@ +// $Id$ + +/** + * @file Controller_exec.h + * + * Header file for the actual Controller and ControllerHome component + * implementations. These classes are the implementations of local + * interfaces defined in ControllerEI.idl. + * + * @author Nanbor Wang + */ + +#ifndef CONTROLLER_EXEC_H +#define CONTROLLER_EXEC_H + +#include "ControllerEIC.h" +#include "tao/LocalObject.h" + +// The namespace name for the actual implementation classes doesn't +// really matter. Since there may be several different +// implementations for a component, they can very well be in different +// namespaces. +namespace MyImpl +{ + /** + * @class Controller_exec_i + * + * A generic controller implementation. + */ + class CONTROLLER_EXEC_Export Controller_exec_i : + public virtual Priority_Test::Controller_Exec, + // CIAO container implementation depends on correct reference + // counting of local interfaces, so we take a short cut to + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default constructor. + Controller_exec_i (); + + /// Default destructor. + ~Controller_exec_i (); + + // Operations from Priority_Test::Controller + + virtual void + start (CORBA::Long arg + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + stop (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Components::SessionComponent + + virtual void + set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + protected: + /// Copmponent specific context + Priority_Test::CCM_Controller_Context_var context_; + }; + + /** + * @class Controller_exec_i + * + * CB_Worker home executor implementation class. + */ + class CONTROLLER_EXEC_Export Controller_Home_exec_i : + public virtual Priority_Test::CCM_ControllerHome, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default ctor. + Controller_Home_exec_i (); + + /// Default dtor. + ~Controller_Home_exec_i (); + + // Explicit home operations. + + // Implicit home operations. + + virtual ::Components::EnterpriseComponent_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + }; + +} + +// Executor DLL entry point. CIAO's deployment and assembly framework +// invokes this function on the resulting DLL to get the home executor. +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome_Impl (void); + +#endif /* CONTROLLER_EXEC_H */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec_export.h b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec_export.h new file mode 100644 index 00000000000..080ecb25a44 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_exec_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CONTROLLER_EXEC +// ------------------------------ +#ifndef CONTROLLER_EXEC_EXPORT_H +#define CONTROLLER_EXEC_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (CONTROLLER_EXEC_HAS_DLL) +# define CONTROLLER_EXEC_HAS_DLL 1 +#endif /* ! CONTROLLER_EXEC_HAS_DLL */ + +#if defined (CONTROLLER_EXEC_HAS_DLL) && (CONTROLLER_EXEC_HAS_DLL == 1) +# if defined (CONTROLLER_EXEC_BUILD_DLL) +# define CONTROLLER_EXEC_Export ACE_Proper_Export_Flag +# define CONTROLLER_EXEC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CONTROLLER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CONTROLLER_EXEC_BUILD_DLL */ +# define CONTROLLER_EXEC_Export ACE_Proper_Import_Flag +# define CONTROLLER_EXEC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CONTROLLER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CONTROLLER_EXEC_BUILD_DLL */ +#else /* CONTROLLER_EXEC_HAS_DLL == 1 */ +# define CONTROLLER_EXEC_Export +# define CONTROLLER_EXEC_SINGLETON_DECLARATION(T) +# define CONTROLLER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CONTROLLER_EXEC_HAS_DLL == 1 */ + +// Set CONTROLLER_EXEC_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CONTROLLER_EXEC_NTRACE) +# if (ACE_NTRACE == 1) +# define CONTROLLER_EXEC_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CONTROLLER_EXEC_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CONTROLLER_EXEC_NTRACE */ + +#if (CONTROLLER_EXEC_NTRACE == 1) +# define CONTROLLER_EXEC_TRACE(X) +#else /* (CONTROLLER_EXEC_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CONTROLLER_EXEC_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CONTROLLER_EXEC_NTRACE == 1) */ + +#endif /* CONTROLLER_EXEC_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_stub_export.h b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_stub_export.h new file mode 100644 index 00000000000..65a430401a8 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_stub_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CONTROLLER_STUB +// ------------------------------ +#ifndef CONTROLLER_STUB_EXPORT_H +#define CONTROLLER_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (CONTROLLER_STUB_HAS_DLL) +# define CONTROLLER_STUB_HAS_DLL 1 +#endif /* ! CONTROLLER_STUB_HAS_DLL */ + +#if defined (CONTROLLER_STUB_HAS_DLL) && (CONTROLLER_STUB_HAS_DLL == 1) +# if defined (CONTROLLER_STUB_BUILD_DLL) +# define CONTROLLER_STUB_Export ACE_Proper_Export_Flag +# define CONTROLLER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CONTROLLER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CONTROLLER_STUB_BUILD_DLL */ +# define CONTROLLER_STUB_Export ACE_Proper_Import_Flag +# define CONTROLLER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CONTROLLER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CONTROLLER_STUB_BUILD_DLL */ +#else /* CONTROLLER_STUB_HAS_DLL == 1 */ +# define CONTROLLER_STUB_Export +# define CONTROLLER_STUB_SINGLETON_DECLARATION(T) +# define CONTROLLER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CONTROLLER_STUB_HAS_DLL == 1 */ + +// Set CONTROLLER_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CONTROLLER_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define CONTROLLER_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CONTROLLER_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CONTROLLER_STUB_NTRACE */ + +#if (CONTROLLER_STUB_NTRACE == 1) +# define CONTROLLER_STUB_TRACE(X) +#else /* (CONTROLLER_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CONTROLLER_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CONTROLLER_STUB_NTRACE == 1) */ + +#endif /* CONTROLLER_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_svnt_export.h b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_svnt_export.h new file mode 100644 index 00000000000..d5e7c6aa42d --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Controller_svnt_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl CONTROLLER_SVNT +// ------------------------------ +#ifndef CONTROLLER_SVNT_EXPORT_H +#define CONTROLLER_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (CONTROLLER_SVNT_HAS_DLL) +# define CONTROLLER_SVNT_HAS_DLL 1 +#endif /* ! CONTROLLER_SVNT_HAS_DLL */ + +#if defined (CONTROLLER_SVNT_HAS_DLL) && (CONTROLLER_SVNT_HAS_DLL == 1) +# if defined (CONTROLLER_SVNT_BUILD_DLL) +# define CONTROLLER_SVNT_Export ACE_Proper_Export_Flag +# define CONTROLLER_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define CONTROLLER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* CONTROLLER_SVNT_BUILD_DLL */ +# define CONTROLLER_SVNT_Export ACE_Proper_Import_Flag +# define CONTROLLER_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define CONTROLLER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* CONTROLLER_SVNT_BUILD_DLL */ +#else /* CONTROLLER_SVNT_HAS_DLL == 1 */ +# define CONTROLLER_SVNT_Export +# define CONTROLLER_SVNT_SINGLETON_DECLARATION(T) +# define CONTROLLER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* CONTROLLER_SVNT_HAS_DLL == 1 */ + +// Set CONTROLLER_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (CONTROLLER_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define CONTROLLER_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define CONTROLLER_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !CONTROLLER_SVNT_NTRACE */ + +#if (CONTROLLER_SVNT_NTRACE == 1) +# define CONTROLLER_SVNT_TRACE(X) +#else /* (CONTROLLER_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define CONTROLLER_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (CONTROLLER_SVNT_NTRACE == 1) */ + +#endif /* CONTROLLER_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.cpp b/CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.cpp new file mode 100644 index 00000000000..6f4be265b19 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.cpp @@ -0,0 +1,113 @@ +// $Id$ + +#include "Pulser.h" +#include "CIAO_common.h" +#include "ace/Timer_Queue.h" +#include "ace/Reactor.h" + +//================================================================= + +PTImpl::Pulser::Pulser (PTImpl::Pulse_Handler *cb) + : active_ (0), + done_ (0), + tid_ (0), + pulser_callback_ (cb) +{ + // Nothing + this->reactor (new ACE_Reactor); +} + +PTImpl::Pulser::~Pulser () +{ + delete this->reactor (); + this->reactor (0); +} + +int +PTImpl::Pulser::open () +{ + return this->activate (); +} + +int +PTImpl::Pulser::close () +{ + this->done_ = 1; + this->reactor ()->notify (); + + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "Waiting\n")); + return this->wait (); +} + +int +PTImpl::Pulser::start (CORBA::Long hertz) +{ + if (hertz == 0 || this->active_ != 0) // Not valid + return -1; + + this->active_ = 1; + long usec = 1000000 / hertz; + + this->tid_ = this->reactor ()->schedule_timer (this, + 0, + ACE_Time_Value (0, usec), + ACE_Time_Value (0, usec)); + + return 0; +} + +int +PTImpl::Pulser::stop (void) +{ + if (this->active_ == 0) // Not valid. + return -1; + else + this->active_ = 0; + return 0; +} + +int +PTImpl::Pulser::active (void) +{ + return this->active_; +} + +int +PTImpl::Pulser::handle_close (ACE_HANDLE handle, + ACE_Reactor_Mask close_mask) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("[%x] handle = %d, close_mask = %d\n"), + this, + handle, + close_mask)); + + return 0; +} + +int +PTImpl::Pulser::handle_timeout (const ACE_Time_Value &, + const void *) +{ + if (this->active_ == 0) + this->reactor ()->cancel_timer (this); + else + this->pulser_callback_->pulse (); + + return 0; +} + +int +PTImpl::Pulser::svc (void) +{ + this->reactor ()->owner (ACE_OS::thr_self ()); + + while (!this->done_) + this->reactor ()->handle_events (); + + return 0; +} + +//================================================================= diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.h b/CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.h new file mode 100644 index 00000000000..9b0d8b6b4cc --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Pulser.h @@ -0,0 +1,75 @@ +// $Id$ + +/** + * @file Pulser.h + * + * Header file for the Pulser class. + * + * @author Nanbor Wang + */ + +#ifndef PULSER_H +#define PULSER_H + +#include "corba.h" +#include "ace/Thread_Manager.h" +#include "ace/Task.h" + +namespace PTImpl +{ + // Forward decl. + class Pulse_Handler + { + public: + /// Helper function to be called back by Pulse_Handler + virtual void pulse (void) = 0; + }; + + /** + * @brief Active pulse generater + */ + class Pulser : public ACE_Task_Base + { + public: + // Default constructor + Pulser (Pulse_Handler *cb); + ~Pulser (); + + int open (void); + + int close (void); + + int start (CORBA::Long hertz); + + int stop (void); + + int active (void); + + // Handle the timeout. + virtual int handle_timeout (const ACE_Time_Value &tv, + const void *arg); + + // Called when is removed. + virtual int handle_close (ACE_HANDLE handle, + ACE_Reactor_Mask close_mask); + + virtual int svc (void); + + private: + /// Tracking whether we are actively generating pulse or not. + long active_; + + /// Flag to indicate completion of this active object. + int done_; + + /// The timer id we are waiting. + int tid_; + + Pulse_Handler *pulser_callback_; + + ACE_Thread_Manager thr_mgr_; + }; + +} + +#endif /* PULSER_H */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp b/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp new file mode 100644 index 00000000000..94419f545aa --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.cpp @@ -0,0 +1,221 @@ +// $Id$ + +#include "Rate_Controller.h" +#include "CIAO_common.h" + +/// Allocate sample history to take up to 5 minutes of samples. +const int MyImpl::Rate_Controller_i::sample_time_ = 5; + +/// Default constructor. +MyImpl::Rate_Controller_i::Rate_Controller_i (CORBA::Long hertz) + : rate_ (hertz), + pulser_ (this), + sampler_ (0) +{ +} + +/// Default destructor. +MyImpl::Rate_Controller_i::~Rate_Controller_i () +{ + delete this->sampler_; +} + +// Operations from Priority_Test::Controller +void +MyImpl::Rate_Controller_i::start (CORBA::Long arg + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // This simply performs some measurements and print out the result. + ACE_DEBUG ((LM_DEBUG, "PERFORM TEST (%dhz)\n", this->rate_)); + + if (this->pulser_.active()) + ACE_THROW (CORBA::BAD_INV_ORDER ()); + + this->work_ = arg; + this->start_time_ = ACE_OS::gethrtime (); + delete this->sampler_; +#if defined (COLLECT_AND_DUMP_SAMPLE_HISTORY) + size_t niterations = this->rate_ * 60 * MyImpl::Rate_Controller_i::sample_time_; + this->sampler_ = new SAMPLER (niterations); +#else + this->sampler_ = new SAMPLER; +#endif /* COLLECT_AND_DUMP_SAMPLE_HISTORY */ + + // @@ Start the rate generator + this->pulser_.start (this->rate_); +} + +void +MyImpl::Rate_Controller_i::stop (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + if (! this->pulser_.active ()) + ACE_THROW (CORBA::BAD_INV_ORDER ()); + + // @@ stop the rate generator + this->pulser_.stop (); + ACE_hrtime_t stop_test = ACE_OS::gethrtime (); + + ACE_DEBUG ((LM_DEBUG, "test finished (%dhz)\n", this->rate_)); + + const int len = 1024; + char title [len]; + + ACE_OS::snprintf (title, len, "Total (work=%4d @ %2dhz)", + this->work_, + this->rate_); + ACE_UINT32 gsf = ACE_High_Res_Timer::global_scale_factor (); + + size_t count = 0; + +#if defined (COLLECT_AND_DUMP_SAMPLE_HISTORY) + this->sampler_->dump_samples (title, gsf); + + ACE_Basic_Stats stats; + this->sampler_->collect_basic_stats (stats); + stats.dump_results (title, gsf); + count = stats.samples_count (); +#else + this->sampler_->dump_results (title, gsf); + count = this->sampler_->samples_count (); +#endif /* COLLECT_BASIC_STATS */ + + ACE_Throughput_Stats::dump_throughput (title, gsf, + stop_test - this->start_time_, + count); +} + +// Operations from Components::SessionComponent +void +MyImpl::Rate_Controller_i::set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Rate_Controller_i::set_session_context (%dhz)\n", + this->rate_)); + + this->context_ = + Priority_Test::CCM_Controller_Context::_narrow (ctx + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->context_.in ())) + ACE_THROW (CORBA::INTERNAL ()); + // Urm, we actually discard exceptions thown from this operation. +} + +void +MyImpl::Rate_Controller_i::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Rate_Controller_i::ccm_activate (%dhz)\n", + this->rate_)); + + this->pulser_.open (); +} + +void +MyImpl::Rate_Controller_i::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Rate_Controller_i::ccm_passivate(%dhz)\n", + this->rate_)); + + this->pulser_.close (); +} + +void +MyImpl::Rate_Controller_i::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::Rate_Controller_i::ccm_remove (%dhz)\n", + this->rate_)); +} + +void +MyImpl::Rate_Controller_i::pulse (void) +{ + ACE_TRY_NEW_ENV + { + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, + "Pulse (%dhz)!\n", + this->rate_)); + + ACE_hrtime_t start = ACE_OS::gethrtime (); + + Priority_Test::Common_Ops_var device = + this->context_->get_connection_worker (ACE_ENV_SINGLE_ARG_PARAMETER); + + (void) device->do_work (this->work_, 0 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_hrtime_t now = ACE_OS::gethrtime (); + this->sampler_->sample (now - start); + } + ACE_CATCHANY + { + // >= 0 meaning always print out the exception. + if (CIAO::debug_level () >= 0) + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Rate_Controller pulse exception\n"); + } + ACE_ENDTRY; +} + +/// Default ctor. +MyImpl::Rate_Controller_Home_i::Rate_Controller_Home_i (CORBA::Long hertz) + : hertz_ (hertz) +{ +} + +/// Default dtor. +MyImpl::Rate_Controller_Home_i::~Rate_Controller_Home_i () +{ +} + +// Explicit home operations. + +// Implicit home operations. + +::Components::EnterpriseComponent_ptr +MyImpl::Rate_Controller_Home_i::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + return new MyImpl::Rate_Controller_i (this->hertz_); +} + + +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome25_Impl (void) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl (25hz)\n")); + return new MyImpl::Rate_Controller_Home_i (25); +} + +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome50_Impl (void) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl (50hz)\n")); + return new MyImpl::Rate_Controller_Home_i (50); +} + +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome75_Impl (void) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "extern \"C\" ::createControllerHome_Impl (75hz)\n")); + return new MyImpl::Rate_Controller_Home_i (75); +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.h b/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.h new file mode 100644 index 00000000000..8da42be49a3 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/Rate_Controller.h @@ -0,0 +1,163 @@ +// $Id$ + +/** + * @file Rate_Controller.h + * + * Header file for the Rate Controller and Rate ControllerHome + * component implementations. These controller trigger a remote + * worker at some rate to do some amount of work. + * + * We should make "hertz" a configurable parameter using a property + * file, but, unfortunately, CIAO doesn't support this feature when + * this executor at this time. Therefore, we use different entry + * points for the DLL to control the rate of the Rate_Controller. + * + * define macro: COLLECT_AND_DUMP_SAMPLE_HISTORY to collect and dump + * sample history. + * + * @author Nanbor Wang + */ + +#ifndef RATE_CONTROLLER_H +#define RATE_CONTROLLER_H + +#include "ControllerEIC.h" +#include "tao/LocalObject.h" +#include "Pulser.h" +#include "ace/High_Res_Timer.h" +#include "ace/Stats.h" +#include "ace/Sample_History.h" + +// The namespace name for the actual implementation classes doesn't +// really matter. Since there may be several different +// implementations for a component, they can very well be in different +// namespaces. +namespace MyImpl +{ + /** + * @class Rate_Controller_i + * + * A generic controller implementation. + */ + class CONTROLLER_EXEC_Export Rate_Controller_i : + public virtual PTImpl::Pulse_Handler, + public virtual Priority_Test::Controller_Exec, + // CIAO container implementation depends on correct reference + // counting of local interfaces, so we take a short cut to + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default constructor. + Rate_Controller_i (CORBA::Long hertz); + + /// Default destructor. + ~Rate_Controller_i (); + + // Operations from Priority_Test::Controller + + virtual void + start (CORBA::Long arg + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void + stop (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Components::SessionComponent + + virtual void + set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + /// Callback + virtual void + pulse (void); + + protected: + const CORBA::Long rate_; + + CORBA::Long work_; + + /// Copmponent specific context + Priority_Test::CCM_Controller_Context_var context_; + + /// Pulser generate periodical events + PTImpl::Pulser pulser_; + + // ------ Statistic related variables -------- + + /// Amount of memory to allocate for performance samples. + static const int sample_time_; // in minute + + /// Mark the time when the "start method" is called. + ACE_hrtime_t start_time_; + +#if defined (COLLECT_AND_DUMP_SAMPLE_HISTORY) + typedef ACE_Sample_History SAMPLER; +#else + typedef ACE_Basic_Stats SAMPLER; +#endif /* COLLECT_AND_DUMP_SAMPLE_HISTORY */ + SAMPLER *sampler_; + }; + + /** + * @class Controller_exec_i + * + * CB_Worker home executor implementation class. + */ + class CONTROLLER_EXEC_Export Rate_Controller_Home_i : + public virtual Priority_Test::CCM_ControllerHome, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default ctor. + Rate_Controller_Home_i (CORBA::Long hertz); + + /// Default dtor. + ~Rate_Controller_Home_i (); + + // Explicit home operations. + + // Implicit home operations. + + virtual ::Components::EnterpriseComponent_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + private: + CORBA::Long hertz_; + }; + +} + +// Executor DLL entry point. CIAO's deployment and assembly framework +// invokes this function on the resulting DLL to get the home executor. +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome25_Impl (void); + +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome50_Impl (void); + +extern "C" CONTROLLER_EXEC_Export ::Components::HomeExecutorBase_ptr +createControllerHome75_Impl (void); + +#endif /* RATE_CONTROLLER_H */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp b/CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp new file mode 100644 index 00000000000..b76d818e005 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Controllers/client.cpp @@ -0,0 +1,131 @@ +// $Id$ +/** + * @file client.cpp + * + * This program interact with a Controller component + */ + +#include "ControllerC.h" +#include "ace/Get_Opt.h" +#include "ace/streams.h" + +int ctrl_off = 0; +long work = 80; +typedef ACE_Unbounded_Stack STRING_STACK; +typedef ACE_Unbounded_Stack CTRL_STACK; + +int +parse_args (int argc, char *argv[], STRING_STACK &iors) +{ + ACE_Get_Opt get_opts (argc, argv, "k:fw:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + + case 'k': + iors.push (get_opts.opt_arg ()); + break; + + case 'f': // Turn off controller + ctrl_off = 1; + break; + + case 'w': + work = ACE_OS::atoi (get_opts.opt_arg ()); + break; + + case '?': // display help for use of the server. + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s\n" + "-k \n" + "-w \n" + "-f: Turn off Controller\n" + "\n", + argv [0]), + -1); + } + + if (iors.is_empty () && ctrl_off == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Please provide controller IOR\n"), + -1); + + return 0; +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + // Initialize orb + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv ACE_ENV_ARG_PARAMETER); + + STRING_STACK IORs; + + if (parse_args (argc, argv, IORs) != 0) + return -1; + + + CTRL_STACK controllers; + + while (!IORs.is_empty ()) + { + ACE_CString ior; + IORs.top (ior); + CORBA::Object_var obj + = orb->string_to_object (ior.c_str () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Priority_Test::Controller_var ctrlr + = Priority_Test::Controller::_narrow (obj.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (ctrlr.in ())) + { + ACE_DEBUG ((LM_ERROR, + "Unable to acquire 'Controller' objref\n", + ior.c_str ())); + } + else + { + controllers.push (ctrlr); + } + IORs.pop (ior); + + } + + while (! controllers.is_empty ()) + { + Priority_Test::Controller_var ctrlr; + controllers.top (ctrlr); + + if (ctrl_off != 0) + ctrlr->stop (ACE_ENV_SINGLE_ARG_PARAMETER); + else + ctrlr->start (work + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + controllers.pop (ctrlr); + } + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Who is the culprit \n"); + cerr << "Uncaught CORBA exception" << endl; + return 1; + } + ACE_ENDTRY; + + return 0; +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Priority_Test.idl b/CIAO/tests/RTCCM/Priority_Test/Priority_Test.idl new file mode 100644 index 00000000000..f0268ad3a42 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Priority_Test.idl @@ -0,0 +1,46 @@ +// $Id$ + +/** + * @file Priority_Test.idl + * + * Definition of events, and common interfaces used in Priority_Test module. + * + * @author Nanbor Wang + */ + +#ifndef CIAO_PRIORITY_TEST_IDL +#define CIAO_PRIORITY_TEST_IDL + +#include + +module Priority_Test +{ + /** + * @brief interface Op_Mode defines the "operation mode" interface. + */ + interface Op_Mode + { + /// Start with arg. + void start (in long arg); + + void stop (); + }; + + /** + * @brief interface Common_Ops defines some "common" operations. It + * is intended to be used as the interface type of a facet or a + * receptacle. All operations in the interface are rather generic + * and the actualy component implmenetion should decide what they + * actually do. + * + * @param work the amount of work to be done + * @param aux auxiliary parameter + */ + interface Common_Ops + { + long do_work (in long work, + in long aux); + }; +}; + +#endif /* CIAO_PRIORITY_TEST_IDL */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Priority_Test.mpc b/CIAO/tests/RTCCM/Priority_Test/Priority_Test.mpc new file mode 100644 index 00000000000..888d0005c99 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Priority_Test.mpc @@ -0,0 +1,30 @@ +// $Id$ +// This file is generated with "generate_component_mpc.pl -n Priority_Test" + +project(Priority_Test_stub): ciao_client { + + sharedname = Priority_Test_stub + idlflags += -Wb,stub_export_macro=PRIORITY_TEST_STUB_Export -Wb,stub_export_include=Priority_Test_stub_export.h -Wb,skel_export_macro=PRIORITY_TEST_SVNT_Export -Wb,skel_export_include=Priority_Test_svnt_export.h + dynamicflags = PRIORITY_TEST_STUB_BUILD_DLL + + IDL_Files { + Priority_Test.idl + } + + Source_Files { + Priority_TestC.cpp + } +} + +project(Priority_Test_svnt) : ciao_servant { + after += Priority_Test_stub + sharedname = Priority_Test_svnt + libs += Priority_Test_stub + + idlflags += -Wb,export_macro=PRIORITY_TEST_SVNT_Export -Wb,export_include=Priority_Test_svnt_export.h + dynamicflags = PRIORITY_TEST_SVNT_BUILD_DLL + + Source_Files { + Priority_TestS.cpp + } +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Priority_Test_stub_export.h b/CIAO/tests/RTCCM/Priority_Test/Priority_Test_stub_export.h new file mode 100644 index 00000000000..7c94cc23525 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Priority_Test_stub_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl PRIORITY_TEST_STUB +// ------------------------------ +#ifndef PRIORITY_TEST_STUB_EXPORT_H +#define PRIORITY_TEST_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (PRIORITY_TEST_STUB_HAS_DLL) +# define PRIORITY_TEST_STUB_HAS_DLL 1 +#endif /* ! PRIORITY_TEST_STUB_HAS_DLL */ + +#if defined (PRIORITY_TEST_STUB_HAS_DLL) && (PRIORITY_TEST_STUB_HAS_DLL == 1) +# if defined (PRIORITY_TEST_STUB_BUILD_DLL) +# define PRIORITY_TEST_STUB_Export ACE_Proper_Export_Flag +# define PRIORITY_TEST_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define PRIORITY_TEST_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* PRIORITY_TEST_STUB_BUILD_DLL */ +# define PRIORITY_TEST_STUB_Export ACE_Proper_Import_Flag +# define PRIORITY_TEST_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define PRIORITY_TEST_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* PRIORITY_TEST_STUB_BUILD_DLL */ +#else /* PRIORITY_TEST_STUB_HAS_DLL == 1 */ +# define PRIORITY_TEST_STUB_Export +# define PRIORITY_TEST_STUB_SINGLETON_DECLARATION(T) +# define PRIORITY_TEST_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* PRIORITY_TEST_STUB_HAS_DLL == 1 */ + +// Set PRIORITY_TEST_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (PRIORITY_TEST_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define PRIORITY_TEST_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define PRIORITY_TEST_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !PRIORITY_TEST_STUB_NTRACE */ + +#if (PRIORITY_TEST_STUB_NTRACE == 1) +# define PRIORITY_TEST_STUB_TRACE(X) +#else /* (PRIORITY_TEST_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define PRIORITY_TEST_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (PRIORITY_TEST_STUB_NTRACE == 1) */ + +#endif /* PRIORITY_TEST_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/RTCCM/Priority_Test/Priority_Test_svnt_export.h b/CIAO/tests/RTCCM/Priority_Test/Priority_Test_svnt_export.h new file mode 100644 index 00000000000..ea8969a9a6d --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Priority_Test_svnt_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl PRIORITY_TEST_SVNT +// ------------------------------ +#ifndef PRIORITY_TEST_SVNT_EXPORT_H +#define PRIORITY_TEST_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (PRIORITY_TEST_SVNT_HAS_DLL) +# define PRIORITY_TEST_SVNT_HAS_DLL 1 +#endif /* ! PRIORITY_TEST_SVNT_HAS_DLL */ + +#if defined (PRIORITY_TEST_SVNT_HAS_DLL) && (PRIORITY_TEST_SVNT_HAS_DLL == 1) +# if defined (PRIORITY_TEST_SVNT_BUILD_DLL) +# define PRIORITY_TEST_SVNT_Export ACE_Proper_Export_Flag +# define PRIORITY_TEST_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define PRIORITY_TEST_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* PRIORITY_TEST_SVNT_BUILD_DLL */ +# define PRIORITY_TEST_SVNT_Export ACE_Proper_Import_Flag +# define PRIORITY_TEST_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define PRIORITY_TEST_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* PRIORITY_TEST_SVNT_BUILD_DLL */ +#else /* PRIORITY_TEST_SVNT_HAS_DLL == 1 */ +# define PRIORITY_TEST_SVNT_Export +# define PRIORITY_TEST_SVNT_SINGLETON_DECLARATION(T) +# define PRIORITY_TEST_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* PRIORITY_TEST_SVNT_HAS_DLL == 1 */ + +// Set PRIORITY_TEST_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (PRIORITY_TEST_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define PRIORITY_TEST_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define PRIORITY_TEST_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !PRIORITY_TEST_SVNT_NTRACE */ + +#if (PRIORITY_TEST_SVNT_NTRACE == 1) +# define PRIORITY_TEST_SVNT_TRACE(X) +#else /* (PRIORITY_TEST_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define PRIORITY_TEST_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (PRIORITY_TEST_SVNT_NTRACE == 1) */ + +#endif /* PRIORITY_TEST_SVNT_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.cpp b/CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.cpp new file mode 100644 index 00000000000..ac9c71bbe29 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.cpp @@ -0,0 +1,127 @@ +// $Id$ + +#include "CB_Worker_exec.h" +#include "CIAO_common.h" + +// This should really be a configurable value. CIAO doesn't suppor +// this yet but the new D&C shall support this RSN. +static long local_primer_ = 9619; + +/// Default constructor. +MyImpl::CB_Worker_exec::CB_Worker_exec () +{ +} + +/// Default destructor. +MyImpl::CB_Worker_exec::~CB_Worker_exec () +{ +} + +// Operations from Priority_Test::Worker + +Priority_Test::CCM_Common_Ops_ptr +MyImpl::CB_Worker_exec::get_some_device (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return Priority_Test::CCM_Common_Ops::_duplicate (this); +} + +// Operations from Priority_Test::Common_Ops + +CORBA::Long +MyImpl::CB_Worker_exec::do_work (CORBA::Long work, + CORBA::Long aux + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + // aux is not use for now, so do something with it. + CORBA::ULong retv = work + aux; + + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, + "CB_Worker::do_work: %hd units of work\n", + work)); + + for (; work != 0; --work) + ACE::is_prime (local_primer_, + 2, + local_primer_ / 2); + + return retv; +} + +// Operations from Components::SessionComponent +void +MyImpl::CB_Worker_exec::set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::CB_Worker_exec::set_session_context\n")); + + this->context_ = + Priority_Test::CCM_Worker_Context::_narrow (ctx + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->context_.in ())) + ACE_THROW (CORBA::INTERNAL ()); + // Urm, we actually discard exceptions thown from this operation. +} + +void +MyImpl::CB_Worker_exec::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::CB_Worker_exec::ccm_activate\n")); +} + +void +MyImpl::CB_Worker_exec::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::CB_Worker_exec::ccm_passivate\n")); +} + +void +MyImpl::CB_Worker_exec::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::CB_Worker_exec::ccm_remove\n")); +} + +/// Default ctor. +MyImpl::CB_Worker_Home_exec::CB_Worker_Home_exec () +{ +} + +/// Default dtor. +MyImpl::CB_Worker_Home_exec::~CB_Worker_Home_exec () +{ +} + +// Explicit home operations. + +// Implicit home operations. + +::Components::EnterpriseComponent_ptr +MyImpl::CB_Worker_Home_exec::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + return new MyImpl::CB_Worker_exec; +} + + +extern "C" WORKER_EXEC_Export ::Components::HomeExecutorBase_ptr +createWorkerHome_Impl (void) +{ + return new MyImpl::CB_Worker_Home_exec; +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.h b/CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.h new file mode 100644 index 00000000000..ea708780acd --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/CB_Worker_exec.h @@ -0,0 +1,117 @@ +// $Id$ + +/** + * @file CB_Worker_exec.h + * + * Header file for the actual CB_Worker and CB_WorkerHome component + * implementations. These classes are the implementations of local + * interfaces defined in WorkerEI.idl. + * + * @author Nanbor Wang + */ + +#ifndef CB_WORKER_EXEC_H +#define CB_WORKER_EXEC_H + +#include "WorkerEIC.h" +#include "tao/LocalObject.h" + +// The namespace name for the actual implementation classes doesn't +// really matter. Since there may be several different +// implementations for a component, they can very well be in different +// namespaces. +namespace MyImpl +{ + /** + * @class CB_Worker_exec + * + * A compute-bound worker executor implementation class. + */ + class WORKER_EXEC_Export CB_Worker_exec : + public virtual Priority_Test::Worker_Exec, + // CIAO container implementation depends on correct reference + // counting of local interfaces, so we take a short cut to + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default constructor. + CB_Worker_exec (); + + /// Default destructor. + ~CB_Worker_exec (); + + // Operations from Priority_Test::Worker + + virtual Priority_Test::CCM_Common_Ops_ptr + get_some_device (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Priority_Test::Common_Ops + + virtual CORBA::Long + do_work (CORBA::Long work, + CORBA::Long aux + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Components::SessionComponent + + virtual void + set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + protected: + /// Copmponent specific context + Priority_Test::CCM_Worker_Context_var context_; + }; + + /** + * @class CB_Worker_exec + * + * CB_Worker home executor implementation class. + */ + class WORKER_EXEC_Export CB_Worker_Home_exec : + public virtual Priority_Test::CCM_WorkerHome, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default ctor. + CB_Worker_Home_exec (); + + /// Default dtor. + ~CB_Worker_Home_exec (); + + // Explicit home operations. + + // Implicit home operations. + + virtual ::Components::EnterpriseComponent_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + }; + +} + +// Executor DLL entry point. CIAO's deployment and assembly framework +// invokes this function on the resulting DLL to get the home executor. +extern "C" WORKER_EXEC_Export ::Components::HomeExecutorBase_ptr +createWorkerHome_Impl (void); + +#endif /* CB_WORKER_EXEC_H */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.cpp b/CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.cpp new file mode 100644 index 00000000000..b51b34e567c --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.cpp @@ -0,0 +1,115 @@ +// $Id$ + +#include "IOB_Worker_exec.h" +#include "CIAO_common.h" + +/// Default constructor. +MyImpl::IOB_Worker_exec::IOB_Worker_exec () +{ +} + +/// Default destructor. +MyImpl::IOB_Worker_exec::~IOB_Worker_exec () +{ +} + +// Operations from Priority_Test::Worker + +Priority_Test::CCM_Common_Ops_ptr +MyImpl::IOB_Worker_exec::get_some_device (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return Priority_Test::CCM_Common_Ops::_duplicate (this); +} + +// Operations from Priority_Test::Common_Ops + +CORBA::Long +MyImpl::IOB_Worker_exec::do_work (CORBA::Long work, + CORBA::Long aux + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + CORBA::ULong retv = work - aux; + + ACE_DEBUG ((LM_DEBUG, + "MyImpl::IOB_Worker_exec::do_work (%d, %d) = %d\n", + work, aux, retv)); + return retv; +} + +// Operations from Components::SessionComponent +void +MyImpl::IOB_Worker_exec::set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::IOB_Worker_exec::set_session_context\n")); + + this->context_ = + Priority_Test::CCM_Worker_Context::_narrow (ctx + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (this->context_.in ())) + ACE_THROW (CORBA::INTERNAL ()); + // Urm, we actually discard exceptions thown from this operation. +} + +void +MyImpl::IOB_Worker_exec::ccm_activate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::IOB_Worker_exec::ccm_activate\n")); +} + +void +MyImpl::IOB_Worker_exec::ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::IOB_Worker_exec::ccm_passivate\n")); +} + +void +MyImpl::IOB_Worker_exec::ccm_remove (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + if (CIAO::debug_level () > 0) + ACE_DEBUG ((LM_DEBUG, "MyImpl::IOB_Worker_exec::ccm_remove\n")); +} + +/// Default ctor. +MyImpl::IOB_Worker_Home_exec::IOB_Worker_Home_exec () +{ +} + +/// Default dtor. +MyImpl::IOB_Worker_Home_exec::~IOB_Worker_Home_exec () +{ +} + +// Explicit home operations. + +// Implicit home operations. + +::Components::EnterpriseComponent_ptr +MyImpl::IOB_Worker_Home_exec::create (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)) +{ + return new MyImpl::IOB_Worker_exec; +} + + +extern "C" WORKER_EXEC_Export ::Components::HomeExecutorBase_ptr +createWorkerHome_Impl (void) +{ + return new MyImpl::IOB_Worker_Home_exec; +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.h b/CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.h new file mode 100644 index 00000000000..1567915d5cc --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/IOB_Worker_exec.h @@ -0,0 +1,117 @@ +// $Id$ + +/** + * @file IOB_Worker_exec.h + * + * Header file for the actual IOB_Worker and IOB_WorkerHome component + * implementations. These classes are the implementations of local + * interfaces defined in WorkerEI.idl. + * + * @author Nanbor Wang + */ + +#ifndef IOB_WORKER_EXEC_H +#define IOB_WORKER_EXEC_H + +#include "WorkerEIC.h" +#include "tao/LocalObject.h" + +// The namespace name for the actual implementation classes doesn't +// really matter. Since there may be several different +// implementations for a component, they can very well be in different +// namespaces. +namespace MyImpl +{ + /** + * @class IOB_Worker_exec + * + * A compute-bound worker executor implementation class. + */ + class WORKER_EXEC_Export IOB_Worker_exec : + public virtual Priority_Test::Worker_Exec, + // CIAO container implementation depends on correct reference + // counting of local interfaces, so we take a short cut to + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default constructor. + IOB_Worker_exec (); + + /// Default destructor. + ~IOB_Worker_exec (); + + // Operations from Priority_Test::Worker + + virtual Priority_Test::CCM_Common_Ops_ptr + get_some_device (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Priority_Test::Common_Ops + + virtual CORBA::Long + do_work (CORBA::Long work, + CORBA::Long aux + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + // Operations from Components::SessionComponent + + virtual void + set_session_context (Components::SessionContext_ptr ctx + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_activate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_passivate (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + + virtual void + ccm_remove (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + protected: + /// Copmponent specific context + Priority_Test::CCM_Worker_Context_var context_; + }; + + /** + * @class IOB_Worker_exec + * + * IOB_Worker home executor implementation class. + */ + class WORKER_EXEC_Export IOB_Worker_Home_exec : + public virtual Priority_Test::CCM_WorkerHome, + public virtual TAO_Local_RefCounted_Object + { + public: + /// Default ctor. + IOB_Worker_Home_exec (); + + /// Default dtor. + ~IOB_Worker_Home_exec (); + + // Explicit home operations. + + // Implicit home operations. + + virtual ::Components::EnterpriseComponent_ptr + create (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException, + Components::CCMException)); + }; + +} + +// Executor DLL entry point. CIAO's deployment and assembly framework +// invokes this function on the resulting DLL to get the home executor. +extern "C" WORKER_EXEC_Export ::Components::HomeExecutorBase_ptr +createWorkerHome_Impl (void); + +#endif /* IOB_WORKER_EXEC_H */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/README b/CIAO/tests/RTCCM/Priority_Test/Workers/README new file mode 100644 index 00000000000..b701702bc84 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/README @@ -0,0 +1,21 @@ +$Id$ + +This directory contains the implementations for worker components. +They have the same component definition and share the same +stub/skeleton/servant lib implementations. That is, they appear to be +the same to their client but they behave differently. + +Workers provide the Common_Ops interface which allows their client to +request them to "do some work." Two differnt kinds of worker +components are available here: + +1. Compute_Bound worker (CB_Worker) + + Upon receiving a request to perform some work, it will perform some + heavy computation and eat up a lot of CPU cycles before returning. + +2. IO_Bound worker (IOB_Worker) + + Upon receiving a request to perform some work, it will perform some + I/O operations before returning. + diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.cidl b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.cidl new file mode 100644 index 00000000000..b30f3994117 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.cidl @@ -0,0 +1,12 @@ +// $Id$ -*- IDL -*- + +#include "Worker.idl" + +composition session Worker_Impl +{ + home executor WorkerHome_exec + { + implements Priority_Test::WorkerHome; + manages Worker_exec; + }; +}; diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.idl b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.idl new file mode 100644 index 00000000000..4f1a5b4a5bf --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.idl @@ -0,0 +1,29 @@ +// $Id$ + +/** + * @file Worker.idl + * + * Definition of a Worker component that does some work. This work + * can be either compute-bound or I/O-bound. + * + * @author Nanbor Wang + */ + +#ifndef WORKER_IDL +#define WORKER_IDL + +#include "../Priority_Test.idl" + +module Priority_Test +{ + component Worker + { + provides Common_Ops some_device; + }; + + home WorkerHome manages Worker + { + }; +}; + +#endif /* WORKER_IDL */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.mpc b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.mpc new file mode 100644 index 00000000000..0b8c74f81b0 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker.mpc @@ -0,0 +1,78 @@ +// $Id$ +// This file is generated with "generate_component_mpc.pl -l .. -p Priority_Test -i Worker" + +project(Priority_Test_Worker_stub): ciao_client { + after += Priority_Test_stub + sharedname = Worker_stub + idlflags += -Wb,stub_export_macro=WORKER_STUB_Export -Wb,stub_export_include=Worker_stub_export.h -Wb,skel_export_macro=WORKER_SVNT_Export -Wb,skel_export_include=Worker_svnt_export.h + dynamicflags = WORKER_STUB_BUILD_DLL + + IDL_Files { + Worker.idl + } + + Source_Files { + WorkerC.cpp + } +} + +project(Priority_Test_Worker_svnt) : ciao_servant { + after += Priority_Test_svnt Priority_Test_Worker_stub + sharedname = Worker_svnt + libs += Worker_stub Priority_Test_stub Priority_Test_svnt + libpaths += .. + idlflags += -Wb,export_macro=WORKER_SVNT_Export -Wb,export_include=Worker_svnt_export.h + dynamicflags = WORKER_SVNT_BUILD_DLL + + CIDL_Files { + Worker.cidl + } + + IDL_Files { + WorkerE.idl + } + + Source_Files { + WorkerEC.cpp + WorkerS.cpp + Worker_svnt.cpp + } +} + +// Compute-bound worker component +project(Priority_Test_CB_Worker_exec) : ciao_component { + after += Priority_Test_Worker_svnt + sharedname = CB_Worker_exec + libs += Worker_stub Worker_svnt Priority_Test_stub Priority_Test_svnt + libpaths += .. + idlflags += -Wb,export_macro=WORKER_EXEC_Export -Wb,export_include=Worker_exec_export.h + dynamicflags = WORKER_EXEC_BUILD_DLL + + IDL_Files { + WorkerEI.idl + } + + Source_Files { + WorkerEIC.cpp + CB_Worker_exec.cpp + } +} + +// IO-bound worker component +project(Priority_Test_IOB_Worker_exec) : ciao_component { + after += Priority_Test_Worker_svnt + sharedname = IOB_Worker_exec + libs += Worker_stub Worker_svnt Priority_Test_stub Priority_Test_svnt + libpaths += .. + idlflags += -Wb,export_macro=WORKER_EXEC_Export -Wb,export_include=Worker_exec_export.h + dynamicflags = WORKER_EXEC_BUILD_DLL + + IDL_Files { + WorkerEI.idl + } + + Source_Files { + WorkerEIC.cpp + IOB_Worker_exec.cpp + } +} diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/WorkerEI.idl b/CIAO/tests/RTCCM/Priority_Test/Workers/WorkerEI.idl new file mode 100644 index 00000000000..d219d91fbb4 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/WorkerEI.idl @@ -0,0 +1,33 @@ +// $Id$ + +/** + * @file WorkerEI.idl + * + * Definition of the Worker component implementation. + * + * @author Nanbor Wang + */ + +#ifndef WORKEREI_IDL +#define WORKEREI_IDL + +#include "WorkerE.idl" + +module Priority_Test +{ + /** + * @interface Worker_Exec + * + * The actually Worker executor inherits from both CCM_Worker and + * CCM_position interfaces as a monolithic implementation. + */ + local interface Worker_Exec : + CCM_Worker, + CCM_Common_Ops, + Components::SessionComponent + { + }; + +}; + +#endif /* WORKEREI_IDL */ diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_exec_export.h b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_exec_export.h new file mode 100644 index 00000000000..760ae5b4b43 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_exec_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl WORKER_EXEC +// ------------------------------ +#ifndef WORKER_EXEC_EXPORT_H +#define WORKER_EXEC_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (WORKER_EXEC_HAS_DLL) +# define WORKER_EXEC_HAS_DLL 1 +#endif /* ! WORKER_EXEC_HAS_DLL */ + +#if defined (WORKER_EXEC_HAS_DLL) && (WORKER_EXEC_HAS_DLL == 1) +# if defined (WORKER_EXEC_BUILD_DLL) +# define WORKER_EXEC_Export ACE_Proper_Export_Flag +# define WORKER_EXEC_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define WORKER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* WORKER_EXEC_BUILD_DLL */ +# define WORKER_EXEC_Export ACE_Proper_Import_Flag +# define WORKER_EXEC_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define WORKER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* WORKER_EXEC_BUILD_DLL */ +#else /* WORKER_EXEC_HAS_DLL == 1 */ +# define WORKER_EXEC_Export +# define WORKER_EXEC_SINGLETON_DECLARATION(T) +# define WORKER_EXEC_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* WORKER_EXEC_HAS_DLL == 1 */ + +// Set WORKER_EXEC_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (WORKER_EXEC_NTRACE) +# if (ACE_NTRACE == 1) +# define WORKER_EXEC_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define WORKER_EXEC_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !WORKER_EXEC_NTRACE */ + +#if (WORKER_EXEC_NTRACE == 1) +# define WORKER_EXEC_TRACE(X) +#else /* (WORKER_EXEC_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define WORKER_EXEC_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (WORKER_EXEC_NTRACE == 1) */ + +#endif /* WORKER_EXEC_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_stub_export.h b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_stub_export.h new file mode 100644 index 00000000000..554243fc699 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_stub_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl WORKER_STUB +// ------------------------------ +#ifndef WORKER_STUB_EXPORT_H +#define WORKER_STUB_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (WORKER_STUB_HAS_DLL) +# define WORKER_STUB_HAS_DLL 1 +#endif /* ! WORKER_STUB_HAS_DLL */ + +#if defined (WORKER_STUB_HAS_DLL) && (WORKER_STUB_HAS_DLL == 1) +# if defined (WORKER_STUB_BUILD_DLL) +# define WORKER_STUB_Export ACE_Proper_Export_Flag +# define WORKER_STUB_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define WORKER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* WORKER_STUB_BUILD_DLL */ +# define WORKER_STUB_Export ACE_Proper_Import_Flag +# define WORKER_STUB_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define WORKER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* WORKER_STUB_BUILD_DLL */ +#else /* WORKER_STUB_HAS_DLL == 1 */ +# define WORKER_STUB_Export +# define WORKER_STUB_SINGLETON_DECLARATION(T) +# define WORKER_STUB_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* WORKER_STUB_HAS_DLL == 1 */ + +// Set WORKER_STUB_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (WORKER_STUB_NTRACE) +# if (ACE_NTRACE == 1) +# define WORKER_STUB_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define WORKER_STUB_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !WORKER_STUB_NTRACE */ + +#if (WORKER_STUB_NTRACE == 1) +# define WORKER_STUB_TRACE(X) +#else /* (WORKER_STUB_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define WORKER_STUB_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (WORKER_STUB_NTRACE == 1) */ + +#endif /* WORKER_STUB_EXPORT_H */ + +// End of auto generated file. diff --git a/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_svnt_export.h b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_svnt_export.h new file mode 100644 index 00000000000..47efffe1596 --- /dev/null +++ b/CIAO/tests/RTCCM/Priority_Test/Workers/Worker_svnt_export.h @@ -0,0 +1,54 @@ + +// -*- C++ -*- +// $Id$ +// Definition for Win32 Export directives. +// This file is generated automatically by generate_export_file.pl WORKER_SVNT +// ------------------------------ +#ifndef WORKER_SVNT_EXPORT_H +#define WORKER_SVNT_EXPORT_H + +#include "ace/config-all.h" + +#if !defined (WORKER_SVNT_HAS_DLL) +# define WORKER_SVNT_HAS_DLL 1 +#endif /* ! WORKER_SVNT_HAS_DLL */ + +#if defined (WORKER_SVNT_HAS_DLL) && (WORKER_SVNT_HAS_DLL == 1) +# if defined (WORKER_SVNT_BUILD_DLL) +# define WORKER_SVNT_Export ACE_Proper_Export_Flag +# define WORKER_SVNT_SINGLETON_DECLARATION(T) ACE_EXPORT_SINGLETON_DECLARATION (T) +# define WORKER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_EXPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# else /* WORKER_SVNT_BUILD_DLL */ +# define WORKER_SVNT_Export ACE_Proper_Import_Flag +# define WORKER_SVNT_SINGLETON_DECLARATION(T) ACE_IMPORT_SINGLETON_DECLARATION (T) +# define WORKER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) ACE_IMPORT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +# endif /* WORKER_SVNT_BUILD_DLL */ +#else /* WORKER_SVNT_HAS_DLL == 1 */ +# define WORKER_SVNT_Export +# define WORKER_SVNT_SINGLETON_DECLARATION(T) +# define WORKER_SVNT_SINGLETON_DECLARE(SINGLETON_TYPE, CLASS, LOCK) +#endif /* WORKER_SVNT_HAS_DLL == 1 */ + +// Set WORKER_SVNT_NTRACE = 0 to turn on library specific tracing even if +// tracing is turned off for ACE. +#if !defined (WORKER_SVNT_NTRACE) +# if (ACE_NTRACE == 1) +# define WORKER_SVNT_NTRACE 1 +# else /* (ACE_NTRACE == 1) */ +# define WORKER_SVNT_NTRACE 0 +# endif /* (ACE_NTRACE == 1) */ +#endif /* !WORKER_SVNT_NTRACE */ + +#if (WORKER_SVNT_NTRACE == 1) +# define WORKER_SVNT_TRACE(X) +#else /* (WORKER_SVNT_NTRACE == 1) */ +# if !defined (ACE_HAS_TRACE) +# define ACE_HAS_TRACE +# endif /* ACE_HAS_TRACE */ +# define WORKER_SVNT_TRACE(X) ACE_TRACE_IMPL(X) +# include "ace/Trace.h" +#endif /* (WORKER_SVNT_NTRACE == 1) */ + +#endif /* WORKER_SVNT_EXPORT_H */ + +// End of auto generated file. -- cgit v1.2.1