Changeset 10709 for trunk/FACT++/src


Ignore:
Timestamp:
05/13/11 16:48:46 (14 years ago)
Author:
tbretz
Message:
Removed the use of the Configuration class internal 'database' option, replaces by schedule-database as in triggerschedule and made it the first positional argument.
File:
1 edited

Legend:

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

    r10701 r10709  
    3838using namespace boost::gregorian;
    3939using namespace boost::posix_time;
    40 
    41 
    42 // string containing database information
    43 string database;
    4440
    4541// things to be done/checked/changed
     
    171167
    172168    int fSessionId;
     169    string fDatabase;
    173170    string fDBName;
    174171
     
    196193
    197194        boost::smatch what;
    198         if (!boost::regex_match(database, what, expr, boost::match_extra))
    199         {
    200             cout << "Couldn't parse '" << database << "'." << endl;
     195        if (!boost::regex_match(fDatabase, what, expr, boost::match_extra))
     196        {
     197            cout << "Couldn't parse '" << fDatabase << "'." << endl;
    201198            throw;
    202199        }
     
    204201        if (what.size()!=10)
    205202        {
    206             cout << "Error parsing '" << database << "'." << endl;
     203            cout << "Error parsing '" << fDatabase << "'." << endl;
    207204            throw;
    208205        }
     
    676673        return T::GetCurrentState();
    677674    }
     675
     676    bool SetConfiguration(const Configuration &conf)
     677    {
     678        fDatabase = conf.Get<string>("schedule-database");
     679
     680        return true;
     681    }
     682
    678683};
    679684
     
    694699    // Start io_service.run to only use the commandHandler command detaching
    695700    AutoScheduler<S> io_service(wout);
     701    if (!io_service.SetConfiguration(conf))
     702        return -1;
     703
    696704    io_service.Run();
    697705
     
    712720
    713721    AutoScheduler<S> io_service(wout);
     722    if (!io_service.SetConfiguration(conf))
     723        return -1;
     724
    714725    shell.SetReceiver(io_service);
    715726
     
    738749    po::options_description config("Configuration");
    739750    config.add_options()
    740         ("dns",       var<string>("localhost"),  "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
    741         ("log,l",     var<string>(n), "Write log-file")
    742         ("no-dim,d",  po_switch(),    "Disable dim services")
    743         ("console,c", var<int>(),     "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")
    744         ("mintime",   var<int>(),     "minimum observation time")
     751        ("dns",               var<string>("localhost"),  "Dim nameserver host name (Overwites DIM_DNS_NODE environment variable)")
     752        ("log,l",             var<string>(n), "Write log-file")
     753        ("no-dim,d",          po_switch(),    "Disable dim services")
     754        ("console,c",         var<int>(),     "Use console (0=shell, 1=simple buffered, X=simple unbuffered)")
     755        ("schedule-database", var<string>()->required(),
     756                                              "Database link as in\n\t[user:[password]@][server][:port][/database]\nOverwrites options from the default configuration file.")
     757        ("mintime",           var<int>(),     "minimum observation time")
    745758        ;
    746759
     760    po::positional_options_description p;
     761    p.add("schedule-database", 1); // The first positional options
     762
    747763    conf.AddEnv("dns", "DIM_DNS_NODE");
    748 
    749764    conf.AddOptions(config);
    750     conf.AddOptionsDatabase(config);
     765    conf.SetArgumentPositions(p);
    751766}
    752767
     
    761776        "help message about the usuage can be brought to the screen.\n"
    762777        "\n"
    763         "Usage: scheduler [-c type] [OPTIONS]\n"
    764         "  or:  scheduler [OPTIONS]\n";
     778        "Usage: scheduler [-c type] [OPTIONS] <schedule-database>\n"
     779        "  or:  scheduler [OPTIONS] <schedule-database>\n";
    765780    cout << endl;
    766781}
     
    812827    }
    813828
    814     if (!conf.Has("database"))
    815     {
    816         cout << "Please provide which database you want to use for scheduling." << endl;
    817         return -1;
    818     }
    819 
    820     database = conf.Get<string>("database").c_str();
    821 
    822829    Dim::Setup(conf.Get<string>("dns"));
    823830
Note: See TracChangeset for help on using the changeset viewer.