Ignore:
Timestamp:
Oct 11, 2013, 2:10:06 PM (11 years ago)
Author:
Marek Kurdej
Message:

Added: addParameters() method in ComponentBase using Boost.Program_Options.
Each component can declare its parameters and they will be read automatically before configureComponent() method.
See example ProducerConsumerExample constructors.

File:
1 edited

Legend:

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

    r165 r176  
    2222{
    2323    LOG_TRACE("constructor(" << name << ")");
     24
     25    namespace po = boost::program_options;
     26   
     27    addParameters()
     28        ("output-path", po::value<std::string>(&mOutputFileName)->default_value("producer.txt"), "set output file path")
     29    ;
    2430}
    2531
     
    3238ProducerExample::configureComponent(XmlComponentConfig /*config*/)
    3339{
    34     LOG_TRACE(Q_FUNC_INFO);
     40    PACPUS_LOG_FUNCTION();
    3541
    36     LOG_INFO("component '" << name() << "' configured");
     42    LOG_INFO("component '" << getName() << "' configured");
    3743    return ComponentBase::CONFIGURED_OK;
    3844}
     
    5763    setActive(true);
    5864    setState(MONITOR_OK);
    59     LOG_INFO("started component '" << name() << "'");
     65    LOG_INFO("started component '" << getName() << "'");
    6066}
    6167
     
    6672    setActive(false);
    6773    setState(STOPPED);
    68     LOG_INFO("stopped component '" << name() << "'");
     74    LOG_INFO("stopped component '" << getName() << "'");
    6975}
    7076
Note: See TracChangeset for help on using the changeset viewer.