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