Changeset 11575 for trunk/FACT++/src/mcp.cc
- Timestamp:
- 07/24/11 21:00:00 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/mcp.cc
r11574 r11575 422 422 #include "Main.h" 423 423 424 /*425 void RunThread(StateMachineImp *io_service)426 {427 // This is necessary so that the StateMachien Thread can signal the428 // Readline to exit429 io_service->Run();430 Readline::Stop();431 }432 */433 /*434 template<class S, class T>435 int RunDim(Configuration &conf)436 {437 WindowLog wout;438 439 ReadlineColor::PrintBootMsg(wout, conf.GetName(), false);440 441 442 if (conf.Has("log"))443 if (!wout.OpenLogFile(conf.Get<string>("log")))444 wout << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;445 446 // Start io_service.Run to use the StateMachineImp::Run() loop447 // Start io_service.run to only use the commandHandler command detaching448 StateMachineMCP<S, T> io_service(wout);449 if (!io_service.EvalConfiguration(conf))450 return -1;451 452 io_service.Run();453 454 return 0;455 }456 */457 458 424 template<class T> 459 425 int RunShell(Configuration &conf) 460 426 { 461 return Main<T, StateMachineMCP>(conf); 462 /* 463 static T shell(conf.GetName().c_str(), conf.Get<int>("console")!=1); 464 465 WindowLog &win = shell.GetStreamIn(); 466 WindowLog &wout = shell.GetStreamOut(); 467 468 if (conf.Has("log")) 469 if (!wout.OpenLogFile(conf.Get<string>("log"))) 470 win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl; 471 472 StateMachineMCP<S, R> io_service(wout); 473 if (!io_service.EvalConfiguration(conf)) 474 return -1; 475 476 shell.SetReceiver(io_service); 477 478 boost::thread t(bind(RunThread, &io_service)); 479 // boost::thread t(bind(&StateMachineMCP<S>::Run, &io_service)); 480 481 if (conf.Has("cmd")) 482 { 483 const vector<string> v = conf.Get<vector<string>>("cmd"); 484 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 485 shell.ProcessLine(*it); 486 } 487 488 if (conf.Has("exec")) 489 { 490 const vector<string> v = conf.Get<vector<string>>("exec"); 491 for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++) 492 shell.Execute(*it); 493 } 494 495 if (conf.Get<bool>("quit")) 496 shell.Stop(); 497 498 shell.Run(); // Run the shell 499 io_service.Stop(); // Signal Loop-thread to stop 500 // io_service.Close(); // Obsolete, done by the destructor 501 502 // Wait until the StateMachine has finished its thread 503 // before returning and destroying the dim objects which might 504 // still be in use. 505 t.join(); 506 507 return 0; 508 */ 509 } 510 511 void SetupConfiguration(Configuration &conf) 512 { 513 const string n = conf.GetName()+".log"; 514 515 po::options_description config("Program options"); 516 config.add_options() 517 ("dns", var<string>("localhost"), "Dim nameserver (overwites DIM_DNS_NODE environment variable)") 518 ("host", var<string>(""), "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)") 519 ("log,l", var<string>(n), "Write log-file") 520 // ("no-dim,d", po_bool(), "Disable dim services") 521 ("console,c", var<int>(), "Use console (0=shell, 1=simple buffered, X=simple unbuffered)") 522 ("cmd", vars<string>(), "Execute one or more commands at startup") 523 ("exec,e", vars<string>(), "Execute one or more scrips at startup") 524 ("quit,q", po_switch(), "Quit after startup"); 525 ; 526 /* 527 po::options_description control("FTM control options"); 528 control.add_options() 529 ("addr,a", var<string>("localhost:5000"), "Network address of FTM") 530 ("quiet,q", po_bool(), "Disable printing contents of all received messages (except dynamic data) in clear text.") 531 ; 532 */ 533 conf.AddEnv("dns", "DIM_DNS_NODE"); 534 conf.AddEnv("host", "DIM_HOST_NODE"); 535 536 conf.AddOptions(config); 537 // conf.AddOptions(control); 427 return Main::execute<T, StateMachineMCP>(conf); 538 428 } 539 429 … … 586 476 Configuration conf(argv[0]); 587 477 conf.SetPrintUsage(PrintUsage); 588 SetupConfiguration(conf);478 Main::SetupConfiguration(conf); 589 479 590 480 po::variables_map vm;
Note:
See TracChangeset
for help on using the changeset viewer.