Changeset 199 in pacpusframework for trunk/include/Pacpus/kernel/InputOutputInterface.h


Ignore:
Timestamp:
10/28/13 14:28:14 (11 years ago)
Author:
Marek Kurdej
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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};
Note: See TracChangeset for help on using the changeset viewer.