Changeset 10701


Ignore:
Timestamp:
May 13, 2011, 2:18:49 PM (9 years ago)
Author:
tbretz
Message:
Updated initialization procedure to fit the other executables.
File:
1 edited

Legend:

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

    r10688 r10701  
     1#include <vector>
     2
    13#include <boost/bind.hpp>
    24#if BOOST_VERSION < 104400
     
    810#include <boost/regex.hpp>
    911#include <boost/asio/deadline_timer.hpp>
    10 
     12#include <boost/date_time/posix_time/posix_time.hpp>
     13
     14#include <mysql++/mysql++.h>
     15
     16#include "FACT.h"
     17#include "Dim.h"
    1118#include "Time.h"
    1219#include "Event.h"
     
    1825#include "Console.h"
    1926#include "Converter.h"
     27#include "LocalControl.h"
    2028
    2129#include "tools.h"
    22 
    23 #include <vector>
    24 
    25 #include "LocalControl.h"
    26 #include <boost/date_time/posix_time/posix_time.hpp>
    27 #include <mysql++/mysql++.h>
    28 
    2930
    3031namespace ba    = boost::asio;
     
    750751}
    751752
     753void PrintUsage()
     754{
     755    cout <<
     756        "The scheduler... TEXT MISSING\n"
     757        "\n"
     758        "The default is that the program is started without user intercation. "
     759        "All actions are supposed to arrive as DimCommands. Using the -c "
     760        "option, a local shell can be initialized. With h or help a short "
     761        "help message about the usuage can be brought to the screen.\n"
     762        "\n"
     763        "Usage: scheduler [-c type] [OPTIONS]\n"
     764        "  or:  scheduler [OPTIONS]\n";
     765    cout << endl;
     766}
     767
     768void PrintHelp()
     769{
     770    /* Additional help text which is printed after the configuration
     771     options goes here */
     772}
     773
    752774int main(int argc, const char* argv[])
    753775{
    754776    Configuration conf(argv[0]);
     777    conf.SetPrintUsage(PrintUsage);
    755778    SetupConfiguration(conf);
    756779
     
    774797    }
    775798
    776     if (conf.Has("database"))
    777     {
    778         database = conf.Get<string>("database").c_str();
    779     }
    780     else
     799    if (conf.HasPrint())
     800        return -1;
     801
     802    if (conf.HasVersion())
     803    {
     804        FACT::PrintVersion(argv[0]);
     805        return -1;
     806    }
     807
     808    if (conf.HasHelp())
     809    {
     810        PrintHelp();
     811        return -1;
     812    }
     813
     814    if (!conf.Has("database"))
    781815    {
    782816        cout << "Please provide which database you want to use for scheduling." << endl;
     
    784818    }
    785819
    786     if (conf.HasHelp() || conf.HasPrint())
    787         return -1;
    788 
    789     // To allow overwriting of DIM_DNS_NODE set 0 to 1
    790     setenv("DIM_DNS_NODE", conf.Get<string>("dns").c_str(), 1);
    791 
    792     try
     820    database = conf.Get<string>("database").c_str();
     821
     822    Dim::Setup(conf.Get<string>("dns"));
     823
     824//    try
    793825    {
    794826        // No console access at all
     
    816848        }
    817849    }
    818     catch (std::exception& e)
     850/*    catch (std::exception& e)
    819851    {
    820852        std::cerr << "Exception: " << e.what() << "\n";
    821     }
     853    }*/
    822854
    823855    return 0;
Note: See TracChangeset for help on using the changeset viewer.