-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
iio-widgets: Add empty data strategy
Signed-off-by: Andrei-Fabian-Pop <[email protected]>
- Loading branch information
1 parent
900419b
commit 244bbe4
Showing
14 changed files
with
209 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
iio-widgets/include/iio-widgets/datastrategy/emptydatastrategy.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef EMPTYDATASTRATEGY_H | ||
#define EMPTYDATASTRATEGY_H | ||
|
||
#include <QObject> | ||
#include "datastrategy/datastrategyinterface.h" | ||
#include "scopy-iio-widgets_export.h" | ||
|
||
namespace scopy { | ||
class SCOPY_IIO_WIDGETS_EXPORT EmptyDataStrategy : public QObject, public DataStrategyInterface | ||
{ | ||
Q_OBJECT | ||
Q_INTERFACES(scopy::DataStrategyInterface) | ||
public: | ||
explicit EmptyDataStrategy(QObject *parent = nullptr); | ||
|
||
QString data() override; | ||
QString optionalData() override; | ||
|
||
public Q_SLOTS: | ||
int write(QString data) override; | ||
QPair<QString, QString> read() override; | ||
void writeAsync(QString data) override; | ||
void readAsync() override; | ||
|
||
Q_SIGNALS: | ||
void sendData(QString data, QString dataOptions) override; | ||
void aboutToWrite(QString oldData, QString newData) override; | ||
void emitStatus(QDateTime timestamp, QString oldData, QString newData, int returnCode, bool isReadOp) override; | ||
|
||
private: | ||
QString m_data; | ||
QString m_previousData; | ||
}; | ||
} // namespace scopy | ||
|
||
#endif // EMPTYDATASTRATEGY_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include "emptydatastrategy.h" | ||
|
||
using namespace scopy; | ||
|
||
EmptyDataStrategy::EmptyDataStrategy(QObject *parent) | ||
: QObject{parent} | ||
, m_data("") | ||
, m_previousData("") | ||
{} | ||
|
||
QString EmptyDataStrategy::data() { return m_data; } | ||
|
||
QString EmptyDataStrategy::optionalData() { return ""; } | ||
|
||
int EmptyDataStrategy::write(QString data) | ||
{ | ||
m_previousData = data; | ||
m_data = data; | ||
return 0; | ||
} | ||
|
||
QPair<QString, QString> EmptyDataStrategy::read() { return {m_data, ""}; } | ||
|
||
void EmptyDataStrategy::writeAsync(QString data) | ||
{ | ||
int res = write(data); | ||
Q_EMIT emitStatus(QDateTime::currentDateTime(), m_data, data, (int)(res), false); | ||
readAsync(); | ||
} | ||
|
||
void EmptyDataStrategy::readAsync() | ||
{ | ||
QPair<QString, QString> res = read(); | ||
Q_EMIT emitStatus(QDateTime::currentDateTime(), m_previousData, m_data, 0, true); | ||
Q_EMIT sendData(res.first, res.second); | ||
} | ||
|
||
#include "moc_emptydatastrategy.cpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.