diff options
author | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-29 21:15:18 +0000 |
---|---|---|
committer | jai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-29 21:15:18 +0000 |
commit | b71531b42b3325fd6079a7039aae8641262c8adf (patch) | |
tree | a5b9aa16924c541fcb424ee9460b1ac7f5a89352 /modules/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp | |
parent | a0f67cc97c0050d907145e312135b60c0125e56e (diff) | |
download | ATCD-b71531b42b3325fd6079a7039aae8641262c8adf.tar.gz |
branching/taggingDS-main
Diffstat (limited to 'modules/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp')
-rw-r--r-- | modules/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/modules/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp b/modules/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp new file mode 100644 index 00000000000..5de92094ee8 --- /dev/null +++ b/modules/CIAO/DAnCE/NodeApplication/Configurator_Factory.cpp @@ -0,0 +1,138 @@ +// $Id$ + +#include "Configurator_Factory.h" +#include "NoOp_Configurator.h" +#include "ace/Null_Mutex.h" +#include "ciao/CIAO_common.h" +#include "ace/Arg_Shifter.h" + +int +CIAO::NodeApplication_Options::parse_args (int &argc, char *argv[]) +{ + ACE_Arg_Shifter shifter (argc, argv); + + while (shifter.is_anything_left ()) + { + const char *parm = 0; + + if (shifter.cur_arg_strncasecmp ("-n") == 0) // Use callback. + { + this->use_callback_ = false; + shifter.consume_arg (); + } + else if (shifter.cur_arg_strncasecmp ("-r") == 0) + { + this->rt_support_ = true; + shifter.consume_arg (); + } + else if (ACE_OS::strncmp (shifter.get_current (), + "-ORB", + ACE_OS::strlen ("-ORB")) == 0) + { + // Ignore ORB parameter + shifter.ignore_arg (); + } + else if (shifter.cur_arg_strncasecmp ("-o") == 0) + { + // This double checking is necessary to avoid the Arg_Shifter from + // mistaking any -ORBxxx flag as -o flag. + if ((parm = shifter.get_the_parameter ("-o")) !=0) + { + this->ior_output_filename_ = parm; + } + shifter.consume_arg (); + } + else if ((parm = shifter.get_the_parameter ("-k")) !=0) + { + this->callback_ior_ = parm; + shifter.consume_arg (); + } + else if (shifter.cur_arg_strncasecmp ("-h") == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s\n" + "-n Do not use Callback (for testing)\n" + "-o <ior_output_file>\n" + "-k <NodeApplicationManager_callback_ior>\n" + "-r Request RT support\n" + "-h Usage help" + "\n", + argv [0]), + -1); + shifter.consume_arg (); + } + else + { + shifter.ignore_arg (); + } + } + + if (this->use_callback_ && 0 == this->callback_ior_.length ()) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Callback IOR to NodeApplicationManager " + "is required.\n"), + -1); + } + + return 0; +} + +CIAO::NodeApp_Configurator * +CIAO::NodeApplication_Options::create_nodeapp_configurator (void) +{ + typedef CIAO::NodeApp_Configurator * (*intelligent_designer)(void); + CIAO::NodeApp_Configurator* ptr = 0; + + if (this->rt_support_) + { + int const retval = + this->config_dll_.open ( + ACE_DLL_PREFIX ACE_TEXT ("CIAO_RTNA_Configurator"), + ACE_DEFAULT_SHLIB_MODE, + 0); + + if (0 != retval) + { + ACE_ERROR_RETURN ((LM_ERROR, + "%p\n", + "dll.open"), + 0); + } + + // Cast the void* to non-pointer type first - it's not legal to + // cast a pointer-to-object directly to a pointer-to-function. + void *void_ptr = + this->config_dll_.symbol (ACE_TEXT ("create_nodeapp_configurator")); + ptrdiff_t tmp = reinterpret_cast<ptrdiff_t> (void_ptr); + + // "id" is for intelligent-designer. + intelligent_designer config_id = + reinterpret_cast<intelligent_designer> (tmp); + + if (0 == config_id) + { + ACE_ERROR_RETURN ((LM_ERROR, + "%p", + "dll.symbol"), + 0); + } + + ptr = config_id (); + + if (0 == ptr) + { + ACE_ERROR_RETURN ((LM_ERROR, + "Error creating RTNodeApp_Configurator\n"), + 0); + } + } + else + { + ACE_NEW_RETURN (ptr, + CIAO::NoOp_Configurator (), + 0); + } + + return ptr; +} |