Ignore:
Timestamp:
07/31/13 14:42:05 (11 years ago)
Author:
Marek Kurdej
Message:

Corrections in PacpusEvent, InputOutputBase, InputOutputInterface.
Fixed: DLL import/export in geodesie.h.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0-beta1/include/Pacpus/kernel/InputOutputBase.h

    r137 r148  
    77
    88#include <QApplication>
     9#include <QList>
     10#include <QString>
     11#include <QStringList>
    912#include <typeinfo>
    10 #include <QList>
    11 #include <QStringList>
    1213
    1314namespace pacpus {
     
    1516class ComponentBase;
    1617
    17 class PACPUSLIB_API AbstractInterface : public QObject
     18class PACPUSLIB_API AbstractInterface
     19    : public QObject
    1820{
    1921     Q_OBJECT
     22
    2023protected:
    21     AbstractInterface(QString name, ComponentBase * component, QObject * parent = 0):_name(name),_component(component),QObject(parent) {}
    22     ~AbstractInterface(){}
     24    AbstractInterface(QString name, ComponentBase * component, QObject * parent = 0)
     25        : m_name(name)
     26        , m_component(component)
     27        , QObject(parent)
     28    {}
     29
     30    ~AbstractInterface()
     31    {}
     32
    2333public:
    2434    QString getSignature();
    25     QString getName() {return _name;}
     35    QString getName()
     36    {
     37        return m_name;
     38    }
     39   
    2640    virtual QString getDataType() = 0;
    27     ComponentBase * getComponent() {return _component;}
    28 
    29     void addConnection(ConnectionBase connection) { _connection.append(connection);}
    30     bool removeConnection(ConnectionBase connection) { return _connection.removeOne(connection);}
    31 
    32     bool hasConnection() { return _connection.size() > 0;}
    33 
     41   
     42    ComponentBase * getComponent()
     43    {
     44        return m_component;
     45    }
     46
     47    void addConnection(ConnectionBase connection)
     48    {
     49        m_connections.append(connection);
     50    }
     51
     52    bool removeConnection(ConnectionBase connection)
     53    {
     54        return m_connections.removeOne(connection);
     55    }
     56
     57    bool hasConnection()
     58    {
     59        return m_connections.size() > 0;
     60    }
     61   
    3462protected:
    35     QString _name;
    36     ComponentBase * _component;
    37     QList<ConnectionBase> _connection;
     63    QList<ConnectionBase> & connections()
     64    {
     65        return m_connections;
     66    }
     67
     68    const QList<ConnectionBase> & connections() const
     69    {
     70        return m_connections;
     71    }
     72
     73    QString name()
     74    {
     75        return m_name;
     76    }
     77
     78    ComponentBase * component()
     79    {
     80        return m_component;
     81    }
     82
     83    const ComponentBase * component() const
     84    {
     85        return m_component;
     86    }
     87   
     88private:
     89    QString m_name;
     90    ComponentBase * m_component;
     91    QList<ConnectionBase> m_connections;
    3892};
    3993
    40 class PACPUSLIB_API InputInterfaceBase : public AbstractInterface
     94class PACPUSLIB_API InputInterfaceBase
     95    : public AbstractInterface
    4196{
    4297    Q_OBJECT
    4398protected:
    44     InputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0):AbstractInterface(name,component,parent) {}
     99    InputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0)
     100        : AbstractInterface(name, component, parent)
     101    {}
    45102
    46103public:
    47104    //InputInterfaceBase(QString name, ComponentBase * component,int a, QObject * parent = 0):AbstractInterface(name,component,parent) {} // TODO add ctor with function pointer
    48105
    49             enum ReadingMode {
     106    enum ReadingMode {
    50107        NeverSkip,
    51108        TimeBounded,
     
    53110    };
    54111
    55     virtual ~InputInterfaceBase(){}
    56 
    57     virtual void customEvent(QEvent* e) {
    58 
     112    virtual ~InputInterfaceBase()
     113    {}
     114
     115    virtual void customEvent(QEvent* e)
     116    {
    59117        //if(event->type())
    60             //TODO get event Type anf call callback function
    61 
    62             PacpusEvent * event = dynamic_cast<PacpusEvent *>(e);
    63     QByteArray buf;
    64     QDataStream out(&buf,QIODevice::WriteOnly);
    65     event->streamOut(out);
    66     // Callback QByteArray
    67     }
    68 
    69     void setReadingMode(ReadingMode mode) { readingMode_ = mode;}
    70     virtual PacpusEvent* getEventTemplate() {return new PacpusEvent(GENERIC_EVENT);} // TODO check ??
    71 protected:
    72             ReadingMode readingMode_;
     118        //TODO get event Type anf call callback function
     119
     120        PacpusEvent * event = dynamic_cast<PacpusEvent *>(e);
     121        QByteArray buf;
     122        QDataStream out(&buf, QIODevice::WriteOnly);
     123        event->streamOut(out);
     124        // Callback QByteArray
     125    }
     126
     127    ReadingMode & readingMode()
     128    {
     129        return m_readingMode;
     130    }
     131
     132    const ReadingMode & readingMode() const
     133    {
     134        return m_readingMode;
     135    }
     136
     137    void setReadingMode(ReadingMode mode)
     138    {
     139        m_readingMode = mode;
     140    }
     141
     142    virtual PacpusEvent* getEventTemplate()
     143    {
     144        // TODO: check
     145        return new PacpusEvent(GENERIC_EVENT);
     146    }
     147   
    73148private:
    74         // metode(QByteArray)
    75 
    76         //QQueue jobQueue_;
     149    ReadingMode m_readingMode;
     150
     151    // metode(QByteArray)
     152    //QQueue jobQueue_;
    77153};
    78154
    79 class PACPUSLIB_API OutputInterfaceBase: public AbstractInterface
     155class PACPUSLIB_API OutputInterfaceBase
     156    : public AbstractInterface
    80157{
    81158    Q_OBJECT
    82159
    83160public:
    84     OutputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0):AbstractInterface(name,component,parent) {}
    85 
    86     virtual ~OutputInterfaceBase(){}
    87 
    88     QStringList getInputConnectedList() {
     161    OutputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0)
     162        : AbstractInterface(name, component, parent)
     163    {}
     164
     165    virtual ~OutputInterfaceBase()
     166    {}
     167
     168    QStringList getInputConnectedList()
     169    {
    89170        QStringList list;
    90         for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it)
     171        for(QList<ConnectionBase>::iterator it = connections().begin(); it != connections().end(); ++it) {
    91172            list.append(it->getInterface()->getName());
     173        }
    92174        return list;
    93175    }
    94176
    95     void send(/*const*/ QByteArray & data) {
     177    void send(/*const*/ QByteArray & data)
     178    {
    96179        // TODO check at least one Typed connection
    97180
    98         for(QList<ConnectionBase>::iterator it = _connection.begin(); it!=_connection.end(); ++it){
     181        for(QList<ConnectionBase>::iterator it = connections().begin(); it!=connections().end(); ++it){
    99182                QDataStream in(&data,QIODevice::ReadOnly);
    100                 PacpusEvent* event = dynamic_cast<InputInterfaceBase*>(_connection.at(0).getInterface())->getEventTemplate();
     183                PacpusEvent* event = dynamic_cast<InputInterfaceBase*>(connections().at(0).getInterface())->getEventTemplate();
    101184                event->streamIn(in);
    102185                QApplication::postEvent(it->getInterface(),event,it->getPriority());
    103186        }
    104 
    105 
    106187    }
    107188
     
    111192{
    112193    if(out->getDataType() == in->getDataType() || out->getDataType() == QString(typeid(QByteArray).name()) || in->getDataType() == QString(typeid(QByteArray).name())) {
    113 
    114194        // Add connection
    115195        out->addConnection(ConnectionBase(in,priority));  // TODO make connect function
     
    119199        return true;
    120200    } else {
    121    //LOG_WARN("connecting " << out->getSignature() << ":" << out->getDataType() << " to " << in->getSignature() << ":" << in->getDataType() << " failled : DataType incompatible " <<  QString(typeid(QByteArray).name()));
    122    return false;
     201        //LOG_WARN("connecting " << out->getSignature() << ":" << out->getDataType() << " to " << in->getSignature() << ":" << in->getDataType() << " failled : DataType incompatible " <<  QString(typeid(QByteArray).name()));
     202        return false;
    123203    }
    124204}
Note: See TracChangeset for help on using the changeset viewer.