1 | /*********************************************************************
|
---|
2 | // created: 2007/11/13 - 10:48
|
---|
3 | // filename: ShMemInput.h
|
---|
4 | //
|
---|
5 | // author: Gerald Dherbomez & Sergio Rodriguez
|
---|
6 | // Copyright Heudiasyc UMR UTC/CNRS 6599
|
---|
7 | //
|
---|
8 | // version: $Id: $
|
---|
9 | //
|
---|
10 | // purpose: Definition of the ShMemInput class
|
---|
11 | *********************************************************************/
|
---|
12 |
|
---|
13 | #ifndef SHMEM_INTERFACE_H
|
---|
14 | #define SHMEM_INTERFACE_H
|
---|
15 |
|
---|
16 | #include "kernel/ComponentBase.h"
|
---|
17 | #include <QThread>
|
---|
18 |
|
---|
19 |
|
---|
20 | namespace pacpus {
|
---|
21 |
|
---|
22 | class ShMem;
|
---|
23 |
|
---|
24 |
|
---|
25 | //class PacpusGenericEvent : QEvent
|
---|
26 | //{
|
---|
27 | //public:
|
---|
28 | // PacpusGenericEvent(QEvent::Type type, char* data, size_t size):QEvent(type) {
|
---|
29 | // _data = (char*)malloc(size);
|
---|
30 | // memcpy(_data,data,size);
|
---|
31 | // _size = size;}
|
---|
32 | // virtual ~PacpusGenericEvent() { free(_data);}
|
---|
33 | // char* _data;
|
---|
34 | // size_t _size;
|
---|
35 |
|
---|
36 | //};
|
---|
37 |
|
---|
38 | class ShMemInput
|
---|
39 | : public QObject
|
---|
40 | , public ComponentBase
|
---|
41 | {
|
---|
42 | Q_OBJECT
|
---|
43 |
|
---|
44 | public:
|
---|
45 | ShMemInput(QString name);
|
---|
46 | ~ShMemInput();
|
---|
47 |
|
---|
48 | virtual void stopActivity();
|
---|
49 | virtual void startActivity();
|
---|
50 | virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
51 |
|
---|
52 | void send(char* data, size_t size);
|
---|
53 | void send(const QByteArray& data);
|
---|
54 |
|
---|
55 | void setDataSize(size_t size) { shMemSize_ = size;}
|
---|
56 |
|
---|
57 | protected:
|
---|
58 |
|
---|
59 | void addInputOutput();
|
---|
60 |
|
---|
61 | ShMem * shmem_,*shmemSize_;
|
---|
62 | QString shMemName_, shMemSizeName_;
|
---|
63 | size_t shMemSize_;
|
---|
64 |
|
---|
65 | };
|
---|
66 |
|
---|
67 | class ShMemOutput
|
---|
68 | : public QThread
|
---|
69 | , public ComponentBase
|
---|
70 | {
|
---|
71 | Q_OBJECT
|
---|
72 |
|
---|
73 | public:
|
---|
74 | ShMemOutput(QString name);
|
---|
75 | ~ShMemOutput();
|
---|
76 |
|
---|
77 | virtual void stopActivity(); /*!< to stop the processing thread */
|
---|
78 | virtual void startActivity(); /*!< to start the processing thread */
|
---|
79 | virtual ComponentBase::COMPONENT_CONFIGURATION configureComponent(XmlComponentConfig config);
|
---|
80 |
|
---|
81 |
|
---|
82 | protected:
|
---|
83 |
|
---|
84 | void addInputOutput();
|
---|
85 |
|
---|
86 | void run();
|
---|
87 |
|
---|
88 | ShMem * shmem_,*shmemSize_;
|
---|
89 | QString shMemName_, shMemSizeName_;
|
---|
90 | size_t shMemSize_;
|
---|
91 | int timeout_;
|
---|
92 |
|
---|
93 | };
|
---|
94 |
|
---|
95 | } // namespace pacpus
|
---|
96 |
|
---|
97 | #endif // SHMEM_INTERFACE_H
|
---|