trikRuntime
trikFifo.h
Go to the documentation of this file.
1 /* Copyright 2015 Yurii Litvinov and CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include <QtCore/QScopedPointer>
18 
19 #include "fifoInterface.h"
20 
21 class QSocketNotifier;
22 
23 namespace trikHal {
24 namespace trik {
25 
27 class TrikFifo : public FifoInterface
28 {
29  Q_OBJECT
30 
31 public:
34  TrikFifo(const QString &fileName);
35 
36  ~TrikFifo() override;
37 
38  bool open() override;
39  bool close() override;
40  QString fileName() override;
41 
42 private slots:
44  void readFile();
45 
46 private:
48  const QString mFileName;
49 
51  int mFileDescriptor;
52 
54  QScopedPointer<QSocketNotifier> mSocketNotifier;
55 
57  QString mBuffer;
58 };
59 
60 }
61 }
bool close() override
Closes FIFO file and stops listening for events.
Definition: trikFifo.cpp:86
bool open() override
Opens FIFO file and starts listening for events.
Definition: trikFifo.cpp:39
TrikFifo(const QString &fileName)
Constructor.
Definition: trikFifo.cpp:28
Real implementation of FIFO.
Definition: trikFifo.h:27
~TrikFifo() override
Definition: trikFifo.cpp:34
Definition: brickFactory.h:21
Abstraction of Linux FIFO used to receive events. To write to FIFO, use OutputDeviceFileInterface.
Definition: fifoInterface.h:23
QString fileName() override
Returns file name of a FIFO file.
Definition: trikFifo.cpp:97