Ignore:
Timestamp:
07/24/11 21:00:00 (13 years ago)
Author:
tbretz
Message:
Moved common option setup to Main.h; created Main namespace
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/fadctrl.cc

    r11574 r11575  
    19741974#include "Main.h"
    19751975
    1976 /*
    1977 void RunThread(StateMachineImp *io_service)
    1978 {
    1979     // This is necessary so that the StateMachien Thread can signal the
    1980     // Readline to exit
    1981     io_service->Run();
    1982     Readline::Stop();
    1983 }
    1984 */
    1985 /*
    1986 template<class S>
    1987 int RunDim(Configuration &conf)
    1988 {
    1989     WindowLog wout;
    1990 
    1991     ReadlineColor::PrintBootMsg(wout, conf.GetName(), false);
    1992 
    1993     if (conf.Has("log"))
    1994         if (!wout.OpenLogFile(conf.Get<string>("log")))
    1995             wout << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;
    1996 
    1997     // Start io_service.Run to use the StateMachineImp::Run() loop
    1998     // Start io_service.run to only use the commandHandler command detaching
    1999     StateMachineFAD<S> io_service(wout);
    2000     if (!io_service.EvalConfiguration(conf))
    2001         return -1;
    2002 
    2003     io_service.Run();
    2004 
    2005     return 0;
    2006 }
    2007 */
    2008 
    20091976template<class T, class S>
    20101977int RunShell(Configuration &conf)
    20111978{
    2012     return Main<T, StateMachineFAD<S>>(conf);
    2013 /*
    2014     static T shell(conf.GetName().c_str(), conf.Get<int>("console")!=1);
    2015 
    2016     WindowLog &win  = shell.GetStreamIn();
    2017     WindowLog &wout = shell.GetStreamOut();
    2018 
    2019     if (conf.Has("log"))
    2020         if (!wout.OpenLogFile(conf.Get<string>("log")))
    2021             win << kRed << "ERROR - Couldn't open log-file " << conf.Get<string>("log") << ": " << strerror(errno) << endl;
    2022 
    2023     StateMachineFAD<S> io_service(wout);
    2024     if (!io_service.EvalConfiguration(conf))
    2025         return -1;
    2026 
    2027     shell.SetReceiver(io_service);
    2028 
    2029     boost::thread t(bind(RunThread, &io_service));
    2030     //boost::thread t(bind(&StateMachineFAD<S>::Run, &io_service));
    2031 
    2032     if (conf.Has("cmd"))
    2033     {
    2034         const vector<string> v = conf.Get<vector<string>>("cmd");
    2035         for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++)
    2036             shell.ProcessLine(*it);
    2037     }
    2038 
    2039     if (conf.Has("exec"))
    2040     {
    2041         const vector<string> v = conf.Get<vector<string>>("exec");
    2042         for (vector<string>::const_iterator it=v.begin(); it!=v.end(); it++)
    2043             shell.Execute(*it);
    2044     }
    2045 
    2046     if (conf.Get<bool>("quit"))
    2047         shell.Stop();
    2048 
    2049     shell.Run();                 // Run the shell
    2050     io_service.Stop();           // Signal Loop-thread to stop
    2051 
    2052     // Wait until the StateMachine has finished its thread
    2053     // before returning and destroying the dim objects which might
    2054     // still be in use.
    2055     t.join();
    2056 
    2057     return 0;
    2058     */
     1979    return Main::execute<T, StateMachineFAD<S>>(conf);
    20591980}
    20601981
    20611982void SetupConfiguration(Configuration &conf)
    20621983{
    2063     const string n = conf.GetName()+".log";
    2064 
    2065     po::options_description config("Program options");
    2066     config.add_options()
    2067         ("dns",       var<string>("localhost"),       "Dim nameserver (overwites DIM_DNS_NODE environment variable)")
    2068         ("host",      var<string>(""),                "Address with which the Dim nameserver can connect to this host (overwites DIM_HOST_NODE environment variable)")
    2069         ("log,l",     var<string>(n), "Write log-file")
    2070 //        ("no-dim,d",  po_switch(),    "Disable dim services")
    2071         ("console,c", var<int>(),     "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")
    2072         ("cmd",       vars<string>(), "Execute one or more commands at startup")
    2073         ("exec,e",    vars<string>(), "Execute one or more scrips at startup")
    2074         ("quit",      po_switch(),    "Quit after startup");
    2075         ;
    2076 
    20771984    po::options_description control("FAD control options");
    20781985    control.add_options()
     
    21282035    conf.AddEnv("host", "DIM_HOST_NODE");
    21292036
    2130     conf.AddOptions(config);
    21312037    conf.AddOptions(control);
    21322038    conf.AddOptions(connect);
     
    21602066    Configuration conf(argv[0]);
    21612067    conf.SetPrintUsage(PrintUsage);
     2068    Main::SetupConfiguration(conf);
    21622069    SetupConfiguration(conf);
    21632070
Note: See TracChangeset for help on using the changeset viewer.