Changeset 176 in pacpusframework for trunk/include/Pacpus


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.

Location:
trunk/include/Pacpus/kernel
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/Pacpus/kernel/ComponentBase.h

    r161 r176  
    3131#include <QMap>
    3232
     33#include <boost/program_options/options_description.hpp>
     34#include <boost/program_options/value_semantic.hpp>
     35#include <string>
     36
    3337class QWidget;
     38
     39namespace boost {
     40namespace program_options {
     41    class options_description_easy_init;
     42}
     43}
    3444
    3545namespace pacpus {
     
    94104     * @return Name of the component.
    95105     */
    96     QString name() const;
    97106    QString getName() const;
    98107
     
    127136    virtual void addOutputs() {}
    128137
     138    boost::program_options::options_description_easy_init addParameters();
     139
    129140protected:
    130141    typedef QMap<QString, InputInterfaceBase *> InputsMap;
     
    177188
    178189    const XmlComponentConfig xmlParameters() const;
     190
     191protected:
     192    std::string mName;
     193    std::string mTypeName;
     194    bool mHasGui;
     195    bool mVerbose;
     196    int mVerbosityLevel;
    179197   
    180198private:
     199    /// Called by ComponentManager to handle parameters
     200    /// @throws
     201    void parseParameters(const XmlComponentConfig & cfg);
     202
    181203    /// called by the ComponentManager to start the component
    182204    int startComponent();
     
    186208
    187209private:
     210    boost::program_options::options_description mOptionsDescription;
     211
    188212    /// The XML node that is got in the configureComponent method
    189213    XmlComponentConfig param;
  • trunk/include/Pacpus/kernel/Log.h

    r143 r176  
    3535
    3636#if defined(PACPUS_USE_LOG)
     37#   include <boost/log/attributes/named_scope.hpp>
     38#   include <boost/log/trivial.hpp>
     39#   include <iosfwd>
    3740
    38 #include <boost/log/trivial.hpp>
    39 #include <iosfwd>
    4041class QString;
    41 
    4242template< typename CharT, typename TraitsT >
    4343PACPUSLIB_API std::basic_ostream< CharT, TraitsT >& operator<< (std::basic_ostream< CharT, TraitsT >& strm, QString const& s);
    4444
    45 #define DECLARE_STATIC_LOGGER(name)
    46 
    47 #define LOG(level, message)         BOOST_LOG_TRIVIAL(level) << message
    48 #define LOG_TRACE(message)          LOG(trace, message)
    49 #define LOG_DEBUG(message)          LOG(debug, message)
    50 #define LOG_INFO(message)           LOG(info, message)
    51 #define LOG_WARN(message)           LOG(warning, message)
    52 #define LOG_ERROR(message)          LOG(error, message)
    53 #define LOG_FATAL(message)          LOG(fatal, message)
    54 
     45#   define DECLARE_STATIC_LOGGER(name)        //BOOST_LOG_NAMED_SCOPE(name)
     46#   define PACPUS_LOG_FUNCTION()              BOOST_LOG_FUNCTION()
     47#   define PACPUS_LOG_NAMED_SCOPE(name)       BOOST_LOG_NAMED_SCOPE(name)
     48#   define PACPUS_LOG(level, message)         BOOST_LOG_TRIVIAL(level) << message
    5549#else
    56 
    5750/// @param name Name of the logger, displayed when logging a message.
    58 #define DECLARE_STATIC_LOGGER(name)
    59 /// Logs a message at TRACE level using default logger
    60 #define LOG_TRACE(message)
    61 /// Logs a message at DEBUG level using default logger
    62 #define LOG_DEBUG(message)
    63 /// Logs a message at INFO level using default logger
    64 #define LOG_INFO(message)
    65 /// Logs a message at WARN level using default logger
    66 #define LOG_WARN(message)
    67 /// Logs a message at ERROR level using default logger
    68 #define LOG_ERROR(message)
    69 /// Logs a message at FATAL level using default logger
    70 #define LOG_FATAL(message)
    71 
     51#   define DECLARE_STATIC_LOGGER(name)
     52#   define PACPUS_LOG_FUNCTION()              ((void) 0)
     53#   define PACPUS_LOG_NAMED_SCOPE(name)       ((void) 0)
     54#   define PACPUS_LOG(level, message)         ((void) 0)
    7255#endif // PACPUS_USE_LOG
    7356
     57/// Logs a message at TRACE level using default logger
     58#define LOG_TRACE(message)          PACPUS_LOG(trace, message)
     59/// Logs a message at DEBUG level using default logger
     60#define LOG_DEBUG(message)          PACPUS_LOG(debug, message)
     61/// Logs a message at INFO level using default logger
     62#define LOG_INFO(message)           PACPUS_LOG(info, message)
     63/// Logs a message at WARN level using default logger
     64#define LOG_WARN(message)           PACPUS_LOG(warning, message)
     65/// Logs a message at ERROR level using default logger
     66#define LOG_ERROR(message)          PACPUS_LOG(error, message)
     67/// Logs a message at FATAL level using default logger
     68#define LOG_FATAL(message)          PACPUS_LOG(fatal, message)
     69
    7470#endif // DEF_PACPUS_LOG_H
  • trunk/include/Pacpus/kernel/XmlComponentConfig.h

    r89 r176  
    2222namespace pacpus {
    2323   
     24//class QDomNamedNodeMap;
    2425class XmlConfigFile;
    2526
     
    3839    /** Dtor of XmlComponentConfig. */
    3940    ~XmlComponentConfig();
     41
     42    QDomNamedNodeMap getProperties() const;
    4043
    4144    /** Add the property @em name to the XML and set its value to @em 0 if it does not exist.
     
    9497
    9598    // Copy internally the node in the internal QDomElement.
    96     void localCopy(const QDomElement& elementToCopy);
     99    void localCopy(const QDomElement & elementToCopy);
    97100
    98101    QString const getComponentName() const;
    99102    QString const getComponentType() const;
    100 
    101103
    102104    QString const getConnectionType() const;
Note: See TracChangeset for help on using the changeset viewer.