| 1 | #ifndef IN_OUT_BASE_H
|
|---|
| 2 | #define IN_OUT_BASE_H
|
|---|
| 3 |
|
|---|
| 4 | #include <Pacpus/kernel/ConnectionBase.h>
|
|---|
| 5 | #include <Pacpus/kernel/Log.h>
|
|---|
| 6 | #include <Pacpus/kernel/PacpusEvent.h>
|
|---|
| 7 | #include <Pacpus/kernel/PacpusLibConfig.h>
|
|---|
| 8 |
|
|---|
| 9 | #include <QList>
|
|---|
| 10 | #include <QString>
|
|---|
| 11 | #include <QStringList>
|
|---|
| 12 | #include <typeinfo>
|
|---|
| 13 |
|
|---|
| 14 | class QByteArray;
|
|---|
| 15 |
|
|---|
| 16 | namespace pacpus {
|
|---|
| 17 |
|
|---|
| 18 | class ComponentBase;
|
|---|
| 19 |
|
|---|
| 20 | class PACPUSLIB_API AbstractInterface
|
|---|
| 21 | : public QObject
|
|---|
| 22 | {
|
|---|
| 23 | Q_OBJECT
|
|---|
| 24 |
|
|---|
| 25 | protected:
|
|---|
| 26 | AbstractInterface(QString name, ComponentBase * component, QObject * parent = 0);
|
|---|
| 27 | virtual ~AbstractInterface();
|
|---|
| 28 |
|
|---|
| 29 | public:
|
|---|
| 30 | QString getSignature() const;
|
|---|
| 31 | QString getName() const;
|
|---|
| 32 | virtual std::size_t getDataSize() const = 0;
|
|---|
| 33 | virtual const std::type_info & getDataType() const = 0;
|
|---|
| 34 |
|
|---|
| 35 | void addConnection(ConnectionBase connection);
|
|---|
| 36 | bool removeConnection(ConnectionBase connection);
|
|---|
| 37 | bool hasConnection();
|
|---|
| 38 |
|
|---|
| 39 | protected:
|
|---|
| 40 | QList<ConnectionBase> & connections();
|
|---|
| 41 | const QList<ConnectionBase> & getConnections() const;
|
|---|
| 42 |
|
|---|
| 43 | ComponentBase * component();
|
|---|
| 44 | const ComponentBase * getComponent() const;
|
|---|
| 45 |
|
|---|
| 46 | private:
|
|---|
| 47 | QString m_name;
|
|---|
| 48 | ComponentBase * m_component;
|
|---|
| 49 | QList<ConnectionBase> m_connections;
|
|---|
| 50 | };
|
|---|
| 51 |
|
|---|
| 52 | class PACPUSLIB_API InputInterfaceBase
|
|---|
| 53 | : public AbstractInterface
|
|---|
| 54 | {
|
|---|
| 55 | Q_OBJECT
|
|---|
| 56 |
|
|---|
| 57 | protected:
|
|---|
| 58 | // TODO: add ctor with function pointer
|
|---|
| 59 | InputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0);
|
|---|
| 60 |
|
|---|
| 61 | public:
|
|---|
| 62 | enum ReadingMode {
|
|---|
| 63 | NeverSkip,
|
|---|
| 64 | TimeBounded,
|
|---|
| 65 | GetLast
|
|---|
| 66 | };
|
|---|
| 67 |
|
|---|
| 68 | virtual ~InputInterfaceBase();
|
|---|
| 69 |
|
|---|
| 70 | virtual void customEvent(QEvent * e);
|
|---|
| 71 |
|
|---|
| 72 | ReadingMode & readingMode();
|
|---|
| 73 | const ReadingMode & getReadingMode() const;
|
|---|
| 74 | void setReadingMode(ReadingMode mode);
|
|---|
| 75 |
|
|---|
| 76 | // FIXME: what's the purpose of this function?
|
|---|
| 77 | virtual PacpusEvent * getEventTemplate();
|
|---|
| 78 |
|
|---|
| 79 | private:
|
|---|
| 80 | ReadingMode m_readingMode;
|
|---|
| 81 |
|
|---|
| 82 | // metode(QByteArray)
|
|---|
| 83 | //QQueue jobQueue_;
|
|---|
| 84 | };
|
|---|
| 85 |
|
|---|
| 86 | class PACPUSLIB_API OutputInterfaceBase
|
|---|
| 87 | : public AbstractInterface
|
|---|
| 88 | {
|
|---|
| 89 | Q_OBJECT
|
|---|
| 90 |
|
|---|
| 91 | public:
|
|---|
| 92 | OutputInterfaceBase(QString name, ComponentBase * component, QObject * parent = 0)
|
|---|
| 93 | : AbstractInterface(name, component, parent)
|
|---|
| 94 | {}
|
|---|
| 95 |
|
|---|
| 96 | virtual ~OutputInterfaceBase()
|
|---|
| 97 | {}
|
|---|
| 98 |
|
|---|
| 99 | QStringList getInputConnectedList();
|
|---|
| 100 |
|
|---|
| 101 | void send(/*const*/ QByteArray & data);
|
|---|
| 102 | };
|
|---|
| 103 |
|
|---|
| 104 | } // namespace pacpus
|
|---|
| 105 |
|
|---|
| 106 | #endif // IN_OUT_BASE_H
|
|---|