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