Changeset 202 in pacpusframework for trunk/src


Ignore:
Timestamp:
Oct 29, 2013, 3:40:48 PM (11 years ago)
Author:
Marek Kurdej
Message:

Added: OutputInterface::checkedSend.
Added: ComponentManager: prints InputsMap, OutputsMap.

Location:
trunk/src/PacpusLib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/PacpusLib/ComponentBase.cpp

    r201 r202  
    1313#include <boost/program_options/parsers.hpp>
    1414#include <boost/program_options/variables_map.hpp>
     15#include <ostream>
    1516#include <string>
    1617#include <vector>
    17 
    18 const bool kPropertyVerboseDefaultValue = false;
    1918
    2019namespace po = boost::program_options;
     
    2322
    2423vector<string> convertAttributesToArgumentVector(const QDomNamedNodeMap & attributes);
    25 void logVariablesMap(po::variables_map vm);
     24
     25namespace std {
     26
     27template <typename _Elem, typename _Traits>
     28std::basic_ostream<_Elem, _Traits> & operator<<(std::basic_ostream<_Elem, _Traits> & os, const boost::program_options::variables_map & vm)
     29{
     30    for (po::variables_map::const_iterator i = vm.cbegin(); i != vm.cend(); ++i) {
     31        const po::variable_value & v = i->second;
     32        if (v.empty()) {
     33            continue;
     34        }
     35        const type_info & type = v.value().type();
     36        if (type == typeid(string)) {
     37            const string & val = v.as<string>();
     38            os << i->first << "=" << val;
     39        } else if (type == typeid(long)) {
     40            int val = v.as<long>();
     41            os << i->first << "=" << val;
     42        } else if (type == typeid(int)) {
     43            int val = v.as<int>();
     44            os << i->first << "=" << val;
     45        } else if (type == typeid(unsigned long)) {
     46            int val = v.as<unsigned long>();
     47            os << i->first << "=" << val;
     48        } else if (type == typeid(unsigned int)) {
     49            int val = v.as<unsigned int>();
     50            os << i->first << "=" << val;
     51        } else if (type == typeid(double)) {
     52            int val = v.as<double>();
     53            os << i->first << "=" << val;
     54        } else if (type == typeid(float)) {
     55            int val = v.as<float>();
     56            os << i->first << "=" << val;
     57        } else if (type == typeid(bool)) {
     58            int val = v.as<bool>();
     59            os << i->first << "=" << val;
     60        }
     61    }
     62    return os;
     63}
     64
     65} // namespace std
    2666
    2767DECLARE_STATIC_LOGGER("pacpus.core.ComponentBase");
     
    225265    }
    226266
    227     logVariablesMap(vm);
    228 }
    229 
    230 void logVariablesMap(boost::program_options::variables_map vm)
    231 {
    232     for (po::variables_map::iterator i = vm.begin(); i != vm.end(); ++i) {
    233         const po::variable_value& v = i->second;
    234         if (v.empty()) {
    235             continue;
    236         }
    237         const type_info & type = v.value().type();
    238         if (type == typeid(string)) {
    239             const string & val = v.as<string>();
    240             LOG_INFO(i->first << "=" << val);
    241         } else if (type == typeid(int)) {
    242             int val = v.as<int>();
    243             LOG_INFO(i->first << "=" << val);
    244         } else if (type == typeid(bool)) {
    245             int val = v.as<bool>();
    246             LOG_INFO(i->first << "=" << val);
    247         }
    248     }
     267    LOG_INFO(vm);
    249268}
    250269
  • trunk/src/PacpusLib/ComponentManager.cpp

    r201 r202  
    1717#include <QDomNodeList>
    1818#include <QObject>
     19#include <QList>
     20#include <ostream>
    1921
    2022using namespace pacpus;
     23
     24template <typename _Elem, typename _Traits, typename _ListElem>
     25std::basic_ostream<_Elem, _Traits> & operator<<(std::basic_ostream<_Elem, _Traits> & os, const QList<_ListElem> & list)
     26{
     27    typedef QList<_ListElem> ListType;
     28    for (ListType::const_iterator it = list.cbegin(), itend = list.cend(); it != itend; ++it) {
     29        os << *it << "\n";
     30    }
     31    return os;
     32}
    2133
    2234DECLARE_STATIC_LOGGER("pacpus.core.ComponentManager");
     
    316328        }
    317329         
    318         // Pacpus 2.0 : add inputs and outputs
     330        // add inputs and outputs
    319331        component->addInputs();
    320332        component->addOutputs();
     333        // print inputs and outputs
     334        LOG_INFO("Inputs: " << component->inputs().keys());
     335        LOG_INFO("Outputs: " << component->outputs().keys());
    321336
    322337        if (ComponentBase::CONFIGURATION_DELAYED == component->configurationState()) {
Note: See TracChangeset for help on using the changeset viewer.