Changeset 179 in pacpusframework


Ignore:
Timestamp:
Oct 11, 2013, 5:40:46 PM (11 years ago)
Author:
Marek Kurdej
Message:

Update: DbtPlyEngine uses addParameters().

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/examples/ProducerConsumerExample/ConsumerExample.cpp

    r176 r179  
    2222
    2323    namespace po = boost::program_options;
    24    
    2524    addParameters()
    2625        ("output-path", po::value<std::string>(&mOutputFileName)->default_value("consumer.txt"), "set output file path")
  • trunk/include/Pacpus/DbitePlayer/DbtPlyEngine.h

    r152 r179  
    2525#include <QSemaphore>
    2626#include <QThread>
     27#include <string>
    2728
    2829namespace pacpus {
     
    133134
    134135    /// where the data are stored
    135     QString dataDir_;
     136    std::string mDataDir;
    136137
    137138    /// mode
    138139    PlayMode replayMode_;
     140
     141    std::string mLoggerConfigFile;
    139142
    140143Q_SIGNALS:
  • trunk/src/DBITEPlayerLib/DbtPlyEngine.cpp

    r176 r179  
    2222
    2323DECLARE_STATIC_LOGGER("pacpus.core.DbtPlyEngine");
    24 
    25 static const char * kPropertyDataDirectory = "datadir";
    26 
    27 static const char *  kPropertyLoggerConfiguration = "log-config-file";
    28 
    29 static const char *  kPropertyReplayMode = "replay_mode";
    30 static const char *  kPropertyReplayModeLastData = "1";
    31 static const char *  kPropertyReplayModeAllData = "2";
    3224
    3325typedef float SpeedType;
     
    5345    tDbtMin_ = numeric_limits<road_time_t>::max();
    5446    tDbtMax_ = 0;
    55     dataDir_ = QString::null;
     47
     48    namespace po = boost::program_options;
     49    addParameters()
     50        ("datadir", po::value<string>(&mDataDir)->required(), "set root data directory")
     51        ("replay_mode", po::value<int>(&reinterpret_cast<int&>(replayMode_))->default_value(PlayModeLastData), "set data replay mode")
     52        ("log-config-file", po::value<string>(&mLoggerConfigFile), "set logger configuration file path")
     53    ;
    5654}
    5755
     
    7876QString DbtPlyEngine::getDataDir()
    7977{
    80     return dataDir_;
     78    return mDataDir.c_str();
    8179}
    8280
     
    157155ComponentBase::COMPONENT_CONFIGURATION DbtPlyEngine::configureComponent(XmlComponentConfig config)
    158156{
    159     // datadir
    160     dataDir_ = config.getProperty(kPropertyDataDirectory);
    161     LOG_INFO("property " << kPropertyDataDirectory << "=\""
    162              << dataDir_ << "\"");
    163     if (dataDir_.isNull()) {
    164         LOG_FATAL("The data directory '" << getName() << "' is invalid or unavailable!");
    165     }
    166 
    167     dataDir_ = QDir::toNativeSeparators(dataDir_);
    168     if (!dataDir_.endsWith(QDir::separator())) {
    169         dataDir_ += QDir::separator();
     157    {
     158        // data directory: add path separator at end if needed
     159        QString dataDir = mDataDir.c_str();
     160        dataDir = QDir::toNativeSeparators(dataDir);
     161        if (!dataDir.endsWith(QDir::separator())) {
     162            dataDir += QDir::separator();
     163            mDataDir = dataDir.toStdString();
     164        }
    170165    }
    171166
    172167    ////////////////////////////////////////////////////////////////////////////////
    173168    // logger configuration
    174     QString loggerConfig = config.getProperty(kPropertyLoggerConfiguration);
    175     LOG_INFO("property " << kPropertyLoggerConfiguration << "=\""
    176              << loggerConfig << "\"");
    177     if (!loggerConfig.isNull()) {
    178         LOG_INFO("configuring logger with file '" << loggerConfig << "'");
    179         LogConfigurator::configureLoggerWithFile(loggerConfig.toStdString().c_str());
    180     }
    181 
    182     ////////////////////////////////////////////////////////////////////////////////
    183     // Replay Mode
    184     QString replayModeValue = config.getProperty(kPropertyReplayMode);
    185     LOG_INFO("property " << kPropertyReplayMode << "=\""
    186              << replayModeValue << "\"");
    187     if (replayModeValue.isNull()) {
    188         LOG_INFO("property " << kPropertyReplayMode << " unset."
    189                  << " Set to default = 1.");
    190         replayMode_ = PlayModeLastData;
    191     } else {
    192         if (kPropertyReplayModeLastData == replayModeValue.toStdString()) {
    193             replayMode_ = PlayModeLastData;
    194         } else if (kPropertyReplayModeAllData == replayModeValue.toStdString()) {
    195             replayMode_ = PlayModeAllData;
    196         } else {
    197             LOG_WARN("unknown " << kPropertyReplayMode << " '" << replayModeValue << "'."
    198                      << " Set to default = 1.");
    199             replayMode_ = PlayModeLastData;
    200         }
     169    if (!mLoggerConfigFile.empty()) {
     170        LOG_INFO("configuring logger with file '" << mLoggerConfigFile << "'");
     171        LogConfigurator::configureLoggerWithFile(mLoggerConfigFile.c_str());
    201172    }
    202173
  • trunk/src/PacpusLib/ComponentBase.cpp

    r178 r179  
    197197            po::command_line_parser(xargs)
    198198                .options(mOptionsDescription)
    199                 //.allow_unregistered()
     199                //.allow_unregistered()   // FIXME: temporary only, at term all the components specify all parameters
    200200                .run()
    201201        , vm);
Note: See TracChangeset for help on using the changeset viewer.