Changeset 199 in pacpusframework for trunk


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

Update: fixed getDataSize(), getDataType() in connections.

Location:
trunk
Files:
4 edited

Legend:

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

    r196 r199  
    5757class OutputInterface;
    5858
     59using ::boost::program_options::value;
     60
    5961/** ComponentBase
    6062 * @brief Base class of a Pacpus component.
     
    139141    virtual void addOutputs() {}
    140142
    141     boost::program_options::options_description_easy_init addParameters();
    142 
     143    ::boost::program_options::options_description_easy_init addParameters();
     144   
    143145protected:
    144146    typedef QMap<QString, InputInterfaceBase *> InputsMap;
  • trunk/include/Pacpus/kernel/InputOutputBase.h

    r197 r199  
    99#include <QApplication>
    1010#include <QList>
    11 #include <QString>
    1211#include <QStringList>
    1312#include <typeinfo>
     
    2928    QString getSignature() const;
    3029    QString getName() const;
    31     virtual QString getDataType() = 0;
     30    virtual std::size_t getDataSize() const = 0;
     31    virtual const std::type_info & getDataType() const = 0;
    3232   
    3333    void addConnection(ConnectionBase connection);
     
    7272    void setReadingMode(ReadingMode mode);
    7373
     74    // FIXME: what's the purpose of this function?
    7475    virtual PacpusEvent * getEventTemplate();
    7576   
  • trunk/include/Pacpus/kernel/InputOutputInterface.h

    r185 r199  
    22#define IN_OUT_INTERFACE_H
    33
     4#include <Pacpus/kernel/InputOutputBase.h>
    45#include <Pacpus/kernel/Log.h>
    5 #include <Pacpus/kernel/InputOutputBase.h>
    6 #include <QApplication>
     6
    77#include <QByteArray>
    8 #include <QThread>
     8//#include <QThread>
    99#include <typeinfo>
    1010
     
    1616{
    1717public:
    18     InputInterface(QString name, C * component, void (C::*m)(const T&))
     18    typedef T data_type;
     19    typedef C component_type;
     20    typedef void (C::*process_data_function_type)(const T &);
     21
     22    InputInterface(QString name, C * component, process_data_function_type processMethod)
    1923        : InputInterfaceBase(name, component, component)
    20         , method(m)
     24        , method(processMethod)
    2125    {}
    2226
     
    2428    {}
    2529
    26     size_t getDataSize()
     30    std::size_t getDataSize() const
    2731    {
    2832        return sizeof(T);
    2933    }
    3034
    31     QString getDataType()
     35    const std::type_info & getDataType() const
    3236    {
    33         return QString(typeid(T).name());
     37        return typeid(T);
    3438    }
    3539
    36     PacpusEvent* getEventTemplate()
     40    // FIXME: what's the purpose of this function?
     41    PacpusEvent * getEventTemplate()
    3742    {
    3843        return new PacpusTypedEvent<T>(TYPED_EVENT);
    3944    }
    4045
     46    // FIXME: what's the purpose of this function?
    4147    void customEvent(QEvent * event)
    4248    {
     
    4652        case TYPED_EVENT:
    4753            {
    48 
    4954            PacpusTypedEvent<T> * typedEvent = dynamic_cast<PacpusTypedEvent<T> *> (event);
    5055
    5156            LOG_DEBUG("Receiver " << getSignature() << " thread " << QThread::currentThread());
    52 
    53 
    5457
    5558            if (typedEvent->timerange() < 500 && readingMode() == TimeBounded) {
     
    104107
    105108protected:
    106     void (C::*method)(const T&);
     109    process_data_function_type method;
    107110};
    108111
     
    112115{
    113116public:
     117    typedef T data_type;
     118    typedef C component_type;
     119
    114120    OutputInterface(QString name, C * component)
    115121        : OutputInterfaceBase(name, component, component)
    116122    {}
    117     ~OutputInterface() {}
     123
     124    ~OutputInterface()
     125    {}
    118126
    119127    // Used by Components to send data througth typed output
    120128    void send(const T & data, road_time_t t = road_time(), road_timerange_t tr = 0);
    121129   
    122     size_t getDataSize()
     130    std::size_t getDataSize() const
    123131    {
    124132        return sizeof(T);
    125133    }
    126134
    127     QString getDataType()
     135    const std::type_info & getDataType() const
    128136    {
    129         return QString(typeid(T).name());
     137        return typeid(T);
    130138    }
    131139};
  • trunk/src/PacpusLib/ComponentManager.cpp

    r185 r199  
    66/// @version    $Id: ComponentManager.cpp 76 2013-01-10 17:05:10Z kurdejma $
    77
     8#include <Pacpus/kernel/ComponentManager.h>
     9
    810#include <Pacpus/kernel/ComponentFactoryBase.h>
    9 #include <Pacpus/kernel/ComponentManager.h>
    1011#include <Pacpus/kernel/ComponentBase.h>
    1112#include <Pacpus/kernel/ConnectionBase.h>
    1213#include <Pacpus/kernel/InputOutputBase.h>
    1314#include <Pacpus/kernel/Log.h>
     15
    1416#include <QDomNodeList>
    1517#include <QObject>
     
    2729bool connectInterface(OutputInterfaceBase * out, InputInterfaceBase * in, int priority, InputInterfaceBase::ReadingMode mode)
    2830{
    29     if (out->getDataType() == in->getDataType() || out->getDataType() == QString(typeid(QByteArray).name()) || in->getDataType() == QString(typeid(QByteArray).name())) {
     31    if ((out->getDataType() == in->getDataType())
     32            || (out->getDataType() == typeid(QByteArray))
     33            || (in->getDataType() == typeid(QByteArray))) {
    3034        // Add connection
    3135        out->addConnection(ConnectionBase(in, priority));  // TODO make connect function
Note: See TracChangeset for help on using the changeset viewer.