本文整理汇总了C++中ACE_ARGV类的典型用法代码示例。如果您正苦于以下问题:C++ ACE_ARGV类的具体用法?C++ ACE_ARGV怎么用?C++ ACE_ARGV使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ACE_ARGV类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ACE_TMAIN
int
ACE_TMAIN (int, ACE_TCHAR *argv[])
{
ACE_Service_Config daemon;
ACE_ARGV new_args;
// Load the existing <argv> into our new one.
new_args.add (argv);
// Enable loading of static services.
new_args.add (ACE_TEXT ("-y"));
// Enable debugging within dynamically linked services.
new_args.add (ACE_TEXT ("-d"));
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("argc = %d\n"),
new_args.argc ()));
// Print the contents of the combined <ACE_ARGV>.
for (int i = 0; i < new_args.argc (); i++)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("(%d) %s\n"),
i,
new_args.argv ()[i]));
if (daemon.open (new_args.argc (),
new_args.argv ()) == -1)
{
if (errno != ENOENT)
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("open")),
1);
else // Use static binding.
{
ACE_ARGV args;
args.add (argv[0]);
args.add (ACE_TEXT ("-p10011")); // Port number.
ACE_Service_Object *so =
ACE_SVC_INVOKE (ACE_Naming_Context);
if (so->init (args.argc (),
args.argv ()) == -1)
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("%p\n"),
ACE_TEXT ("ACE_Naming_Context")),
1);
}
}
Client_Test test_body;
if (test_body.open () == -1)
return 1;
// Run forever, performing the configured services until we are shut
// down by a SIGINT/SIGQUIT signal.
ACE_Reactor::instance ()->run_reactor_event_loop ();
test_body.close ();
return 0;
}
示例2: ACE_TMAIN
int
ACE_TMAIN(int argc, ACE_TCHAR *argv[])
{
ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("s:c:"));
int c = -1;
const ACE_TCHAR *client_cmd = 0;
while ((c = get_opts ()) != -1)
switch (c)
{
case 'c':
client_cmd = get_opts.opt_arg ();
ACE_DEBUG ((LM_DEBUG, "Client argument: %s\n", client_cmd));
break;
case 's':
server_cmd = get_opts.opt_arg ();
ACE_DEBUG ((LM_DEBUG, "Server argument: %s\n", server_cmd));
break;
default:
ACE_ERROR_RETURN ((LM_ERROR,
"Usage: collocation_test -s \"server opts\" -c \"client opts\""),
-1);
}
ACE_TCHAR cmd_line[1024];
ACE_OS::strcpy (cmd_line, ACE_TEXT("client "));
if (client_cmd != 0)
ACE_OS::strcat (cmd_line, client_cmd);
ACE_OS::strcat (cmd_line, ACE_TEXT(" -f ") THE_IOR);
ACE_ARGV args (cmd_line);
Barriers thread_barrier (2);
int retv = 1;
ACE_DEBUG ((LM_DEBUG,
"\n \t IDL_Cubit: Collocation test \n\n"));
ACE_Thread_Manager tm;
tm.spawn (reinterpret_cast<ACE_THR_FUNC> (&svr_worker),
&thread_barrier);
thread_barrier.server_init_.wait ();
ACE_OS::sleep (1);
Cubit_Client cubit_client (1);
// Make sure the server shuts itself down afterward.
if (cubit_client.init (args.argc (), args.argv ()) == -1)
return 1;
else
retv = cubit_client.run ();
thread_barrier.client_fini_.wait ();
tm.wait ();
ACE_OS::unlink (THE_IOR);
return retv;
}
示例3: test_simple_argv
static int
test_simple_argv (ACE_TCHAR *argv[])
{
// From command line.
ACE_ARGV cl (argv);
// My own stuff.
ACE_ARGV my;
// Add to my stuff.
my.add (ACE_TEXT ("-ORBEndpoint iiop://localhost:12345"));
// Combine the two (see the ace/ARGV.h constructors documentation).
ACE_ARGV a (cl.argv (),
my.argv ());
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("argc = %d\n"),
a.argc ()));
// Print the contents of the combined <ACE_ARGV>.
for (int i = 0; i < a.argc (); i++)
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT (" (%d) %s\n"),
i,
a.argv ()[i]));
return 0;
}
示例4: GetLogLevel
//初始化日志策略
int Frame_Logging_Strategy::InitLogStrategy(Logging_Config_Param &ConfigParam)
{
//Set Arg List
char cmdline[1024] = {0};
string strTemp = ConfigParam.m_strLogLevel;
string strLogLevel = GetLogLevel(strTemp);
if(ConfigParam.m_bSendTerminal)
{
ACE_OS::sprintf(cmdline,"-s %s -f STDERR -p %s -i %d -m %d -N %d",
ConfigParam.m_strLogFile,
strLogLevel.c_str(),
ConfigParam.m_iChkInterval,
ConfigParam.m_iLogFileMaxSize,
ConfigParam.m_iLogFileMaxCnt);
}
else
{
ACE_OS::sprintf(cmdline,"-s %s -f OSTREAM -p %s -i %d -m %d -N %d",
ConfigParam.m_strLogFile,
strLogLevel.c_str(),
ConfigParam.m_iChkInterval,
ConfigParam.m_iLogFileMaxSize,
ConfigParam.m_iLogFileMaxCnt);
}
ACE_Reactor_Impl * pImpl = 0;
ACE_NEW_RETURN (pImpl, ACE_TP_Reactor, -1);
ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor(pImpl ,1), -1);
//ACE_NEW_RETURN(pLogStraReactor, ACE_Reactor, -1);
ACE_NEW_RETURN(pLogStrategy, My_ACE_Logging_Strategy, -1);
//Set Reactor
pLogStrategy->reactor(pLogStraReactor);
ACE_ARGV args;
//args.add(__argv[0]);
args.add(ACE_TEXT(cmdline));
pLogStrategy->init(args.argc(),args.argv());
if (ACE_Thread_Manager::instance ()->spawn(ACE_THR_FUNC (run_reactor), (void *)pLogStraReactor) == -1)
{
ACE_ERROR_RETURN ((LM_ERROR,"Spawning Reactor.\n"),-1);
}
ACE_DEBUG((LM_INFO, ACE_TEXT("(%P|%t) %M Init Log Strategy Success [%N,%l]\n")));
return 0;
}
示例5: av
int
ImR_Locator_i::init (Options& opts)
{
this->opts_ = &opts;
ACE_CString cmdline = opts.cmdline ();
cmdline += " -orbuseimr 0";
ACE_ARGV av (ACE_TEXT_CHAR_TO_TCHAR (cmdline.c_str ()));
int argc = av.argc ();
ACE_TCHAR** argv = av.argv ();
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "TAO_ImR_Locator");
int err = this->init_with_orb (orb.in ());
return err;
}
示例6: ACE_NEW_RETURN
ACE_ARGV*
Lorica::Config::get_ifr_options_copy(void)
{
ACE_ARGV *args;
ACE_NEW_RETURN(args,
ACE_ARGV(),
0);
ssize_t len = this->ifr_args_.size();
for (ssize_t count = 0; count < len; count++)
args->add (this->ifr_args_[count].c_str());
return args;
}
示例7: Enable3dControls
BOOL CNamingViewerApp::InitInstance()
{
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
/*
From MFC 5.0, Enable3dControls and Enable3dControlsStatic are obsolete
because their functionality is incorporated into Microsoft's 32-bit
operating systems. Basically no need to call with VC5.0 and above.
#if !defined (_WIN32_WCE)
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
#endif
*/
// Parse command line arguments so we can initialize ORB with them
ACE_ARGV Argv (m_lpCmdLine);
ACE::init();
{
int argc = Argv.argc ();
CORBA::ORB_var ORB = CORBA::ORB_init(argc, Argv.argv());
CNamingViewerDlg dlg(ORB);
m_pMainWnd = &dlg;
int const nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}
ACE::fini();
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
示例8: av
int
ImR_Activator_i::init (Activator_Options& opts)
{
ACE_CString cmdline = opts.cmdline();
// Must use IOR style objrefs, because URLs sometimes get mangled when passed
// to ACE_Process::spawn().
cmdline += "-ORBUseImR 0 -ORBObjRefStyle IOR ";
ACE_ARGV av (cmdline.c_str ());
int argc = av.argc ();
CORBA::ORB_var orb =
CORBA::ORB_init (argc, av.argv (), "TAO_ImR_Activator");
int ret = this->init_with_orb(orb.in (), opts);
return ret;
}
示例9: ACE_TRACE
/// Dynamically link the shared object file and retrieve a pointer to
/// the designated shared object in this file.
int
ACE_Service_Gestalt::initialize_i (const ACE_Service_Type *sr,
const ACE_TCHAR *parameters)
{
ACE_TRACE ("ACE_Service_Gestalt::initialize_i");
ACE_ARGV args (parameters);
if (sr->type ()->init (args.argc (),
args.argv ()) == -1)
{
// We just get ps to avoid having remove() delete it.
ACE_Service_Type *ps = 0;
this->repo_->remove (sr->name (), &ps);
#ifndef ACE_NLOGGING
// Not using LM_ERROR here to avoid confusing the test harness
if (ACE::debug ())
ACELIB_ERROR_RETURN ((LM_WARNING,
ACE_TEXT ("ACE (%P|%t) SG::initialize_i -")
ACE_TEXT (" repo=%@, name=%s - remove failed: %m\n"),
this->repo_,
sr->name ()),
-1);
#endif
return -1;
}
if (this->repo_->insert (sr) == -1)
{
#ifndef ACE_NLOGGING
// Not using LM_ERROR here to avoid confusing the test harness
if (ACE::debug ())
ACELIB_ERROR_RETURN ((LM_WARNING,
ACE_TEXT ("ACE (%P|%t) SG::initialize_i -")
ACE_TEXT (" repo=%@, name=%s - insert failed: %m\n"),
this->repo_,
sr->name ()),
-1);
#endif
return -1;
}
return 0;
}
示例10: arguments
int
Handle_Events::serve (char *buf)
{
ACE_ARGV arguments (buf);
if (ACE_OS::strcmp (arguments[0], TESTER) == 0)
{
ACE_Process_Options po;
ACE_Process p;
po.set_handles (ACE_INVALID_HANDLE, OUTPUT_FILE, OUTPUT_FILE);
po.command_line (arguments.argv ());
p.spawn (po);
return 0;
}
else
return -1;
}
示例11: svr_worker
void *
svr_worker (void *arg)
{
Cubit_Server cubit_server;
Barriers *thread_barrier = (Barriers *) arg;
ACE_TCHAR cmd_line[BUFSIZ];
ACE_OS::strcpy (cmd_line, ACE_TEXT("server "));
if (server_cmd != 0)
ACE_OS::strcat (cmd_line, server_cmd);
ACE_OS::strcat (cmd_line, ACE_TEXT(" -f ") THE_IOR);
ACE_ARGV args (cmd_line);
try
{
int result = cubit_server.init (args.argc (),
args.argv ());
if (result == -1)
return (void *) 1;
thread_barrier->server_init_.wait ();
cubit_server.run ();
thread_barrier->client_fini_.wait ();
}
catch (const CORBA::SystemException& sysex)
{
sysex._tao_print_exception ("System Exception");
return (void *) 1;
}
catch (const CORBA::UserException& userex)
{
userex._tao_print_exception ("User Exception");
return (void *) 1;
}
return 0;
}
示例12: run_main
int
run_main (int, ACE_TCHAR *[])
{
ACE_START_TEST (ACE_TEXT ("Bug_3319_Regression_Test"));
ACE_Log_Msg *log_msg = ACE_LOG_MSG;
ACE_ARGV args;
args.add (ACE_TEXT("MyProgram"), true);
int ret = ACE_Service_Config::open(args.argc(), args.argv(),
ACE_DEFAULT_LOGGER_KEY,
1, 1, 1);
if (ACE_OS::strcmp (log_msg->program_name (), ACE_TEXT("MyProgram")) != 0)
{
ACE_ERROR_RETURN ((LM_ERROR,
ACE_TEXT ("Program name is not <MyProgram> but <%s>\n"),
ACE_Log_Msg::program_name ()),
1);
}
ACE_END_TEST;
return ret;
}
示例13: ACE_TMAIN
int
ACE_TMAIN(int, ACE_TCHAR **)
{
int result = 0;
#if 0
ACE_Service_Config serviceConfig;
char signum[64];
ACE_OS::sprintf(signum, "%d", SIGUSR1);
ACE_ARGV args;
args.add(argv[0]);
args.add("-s");
args.add(signum);
result = serviceConfig.open (
args.argc(),
args.argv(),
ACE_DEFAULT_LOGGER_KEY,
1, // ignore_static_svcs = 1,
1, // ignore_default_svc_conf_file = 0,
0 // ignore_debug_flag = 0
);
if(0 != result)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error: serviceConfig.open failed\n")));
return result;
}
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) serviceConfig.open done\n")));
#endif
for(int cnt = 0; cnt < 1000; ++cnt)
{
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) Loading ORB cnt = %d\n"), cnt));
result = ACE_Service_Config::process_directive(scpc_loadOrb);
if(0 != result)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error loading ORB failed (%d)\n"), result));
return result;
}
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) Loading ORB done\n")));
result = ACE_Service_Config::process_directive(scpc_unloadOrb);
if(0 != result)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) Error unloading ORB failed (%d)\n"), result));
return result;
}
ACE_DEBUG ((LM_INFO, ACE_TEXT ("(%P|%t) Unloading ORB done\n")));
}
return result;
}
示例14: run_main
int
run_main (int, ACE_TCHAR *argv[])
{
ACE_START_TEST (ACE_TEXT ("Bug_2975_Regression_Test"));
int ret = 0;
ACE_ARGV args;
args.add (argv[0], true);
args.add (ACE_TEXT("-S"));
#if (ACE_USES_CLASSIC_SVC_CONF == 1)
args.add (
ACE_TEXT ("\"dynamic ACE_Logger Service_Object * ")
ACE_TEXT ("ACE:_make_ACE_Logging_Strategy() ")
ACE_TEXT ("'-p ~TRACE|DEBUG|INFO|WARNING|NOTICE|ERROR|CRITICAL|ALERT'")
ACE_TEXT ("\""));
#else // not (ACE_USES_CLASSIC_SVC_CONF == 1)
args.add (
ACE_TEXT ("'<ACE_Svc_Conf>")
ACE_TEXT ("<dynamic id=\"ACE_Logger\"")
ACE_TEXT (" type=\"Service_Object\">")
ACE_TEXT ("<initializer path=\"ACE\"")
ACE_TEXT (" init=\"_make_ACE_Logging_Strategy\"")
ACE_TEXT (" params=\"-p ~TRACE|DEBUG|INFO|WARNING|NOTICE|ERROR|CRITICAL|ALERT\"/>")
ACE_TEXT ("</dynamic>")
ACE_TEXT ("</ACE_Svc_Conf>'"));
#endif // not (ACE_USES_CLASSIC_SVC_CONF == 1)
ret = ACE_Service_Config::open(args.argc(), args.argv(),
ACE_DEFAULT_LOGGER_KEY,
1, 1);
if (0 != ret)
{
ACE_ERROR ((LM_ERROR, ACE_TEXT ("ACE_Service_Config::open() failed\n")));
}
ACE_END_TEST;
return 0;
}
示例15: ACE_MT
// ****************************************************************
/// Note that the argument vector will be corrupted upon return
int
TAO::ORB::open_global_services (int argc, ACE_TCHAR **argv)
{
{
// Count of the number of (times we did this for all) ORBs.
static int orb_init_count = 0;
// Using ACE_Static_Object_Lock::instance() precludes ORB_init()
// from being called within a static object CTOR.
ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
guard,
*ACE_Static_Object_Lock::instance (),
-1));
// Make sure TAO's singleton manager is initialized.
// We need to initialize before TAO_default_environment() is called
// since that call instantiates a TAO_TSS_Singleton.
if (TAO_Singleton_Manager::instance ()->init () == -1)
return -1;
// Prevent multiple initializations.
if (++orb_init_count > 1)
return 0;
}
// Prevent any other thread from going through ORB initialization before the
// uber-gestalt is initialized.
ACE_MT (ACE_GUARD_RETURN (TAO_SYNCH_RECURSIVE_MUTEX,
guard,
TAO_Ubergestalt_Ready_Condition::instance ()->mutex (),
-1));
if (TAO_debug_level > 2)
{
TAOLIB_DEBUG ((LM_DEBUG,
ACE_TEXT ("TAO (%P|%t) Initializing the ")
ACE_TEXT ("process-wide service context\n")));
}
ACE_Service_Gestalt* theone = ACE_Service_Config::global ();
ACE_Service_Config_Guard auto_config_guard (theone);
// Construct an argument vector specific to the process-wide
// (global) Service Configurator instance.
// Be certain to copy the program name so that service configurator
// has something to skip!
ACE_ARGV global_svc_config_argv (true); // only this ctor allows
// subsequent use of add()!
global_svc_config_argv.add ((argc <= 0 || argv == 0) ?
ACE_TEXT ("") : argv[0], true);
// Will expand the environment variables, if any were used.
// Is this a good thing? I guess it provides greater flexibility
// for deployment,so let's leave it. Will also quote arguments.
ACE_ARGV copyargv (argc, argv, true, true);
// Adjust to proper type
int tmpargc = copyargv.argc (); // use copied count, not original
ACE_Argv_Type_Converter cvtargv (tmpargc, copyargv.argv());
tmpargc = cvtargv.get_argc ();
ACE_TCHAR **tmpargv = cvtargv.get_TCHAR_argv ();
// Collect global SC parameters. True means "immediately
// apply global setting" like debug flag, etc.
if (parse_global_args_i (tmpargc,
tmpargv,
global_svc_config_argv,
true) == -1)
return -1;
bool skip_service_config_open = false; // by default we shouldn't
if (using_global_gestalt_i (tmpargc,
tmpargv,
skip_service_config_open))
{
if (parse_svcconf_args_i (tmpargc,
tmpargv,
global_svc_config_argv) == -1)
return -1;
}
bool ignore_default_svc_conf_file = false;
if (parse_private_args_i (tmpargc,
tmpargv,
global_svc_config_argv,
skip_service_config_open,
ignore_default_svc_conf_file) == -1)
return -1;
// register_global_services_i depends on the parsing of at least the
// -ORBNegotiateCodesets option, and must be invoked after all the
// parsing methods, but still must preceed the opening of other services.
register_global_services_i (theone);
//.........这里部分代码省略.........