mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-26 17:58:43 -05:00
FileSource: make Settings an independant struct
This commit is contained in:
parent
996f964435
commit
351651c3e5
@ -7,6 +7,7 @@ set(filesource_SOURCES
|
|||||||
filesourceinput.cpp
|
filesourceinput.cpp
|
||||||
filesourceplugin.cpp
|
filesourceplugin.cpp
|
||||||
filesourcethread.cpp
|
filesourcethread.cpp
|
||||||
|
filesourcesettings.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
set(filesource_HEADERS
|
set(filesource_HEADERS
|
||||||
@ -14,6 +15,7 @@ set(filesource_HEADERS
|
|||||||
filesourceinput.h
|
filesourceinput.h
|
||||||
filesourceplugin.h
|
filesourceplugin.h
|
||||||
filesourcethread.h
|
filesourcethread.h
|
||||||
|
filesourcesettings.h
|
||||||
)
|
)
|
||||||
|
|
||||||
set(filesource_FORMS
|
set(filesource_FORMS
|
||||||
|
@ -28,12 +28,14 @@ CONFIG(Debug):build_subdir = debug
|
|||||||
SOURCES += filesourcegui.cpp\
|
SOURCES += filesourcegui.cpp\
|
||||||
filesourceinput.cpp\
|
filesourceinput.cpp\
|
||||||
filesourceplugin.cpp\
|
filesourceplugin.cpp\
|
||||||
filesourcethread.cpp
|
filesourcethread.cpp\
|
||||||
|
filesourcesettings.cpp
|
||||||
|
|
||||||
HEADERS += filesourcegui.h\
|
HEADERS += filesourcegui.h\
|
||||||
filesourceinput.h\
|
filesourceinput.h\
|
||||||
filesourceplugin.h\
|
filesourceplugin.h\
|
||||||
filesourcethread.h
|
filesourcethread.h\
|
||||||
|
filesourcesettings.h
|
||||||
|
|
||||||
FORMS += filesourcegui.ui
|
FORMS += filesourcegui.ui
|
||||||
|
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "util/messagequeue.h"
|
#include "util/messagequeue.h"
|
||||||
|
|
||||||
|
#include "filesourcesettings.h"
|
||||||
#include "filesourceinput.h"
|
#include "filesourceinput.h"
|
||||||
|
|
||||||
class DeviceUISet;
|
class DeviceUISet;
|
||||||
@ -54,7 +55,7 @@ private:
|
|||||||
Ui::FileSourceGui* ui;
|
Ui::FileSourceGui* ui;
|
||||||
|
|
||||||
DeviceUISet* m_deviceUISet;
|
DeviceUISet* m_deviceUISet;
|
||||||
FileSourceInput::Settings m_settings;
|
FileSourceSettings m_settings;
|
||||||
bool m_doApplySettings;
|
bool m_doApplySettings;
|
||||||
QTimer m_statusTimer;
|
QTimer m_statusTimer;
|
||||||
std::vector<int> m_gains;
|
std::vector<int> m_gains;
|
||||||
|
@ -42,41 +42,6 @@ MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceAcquisition, Messag
|
|||||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message)
|
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamData, Message)
|
||||||
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message)
|
MESSAGE_CLASS_DEFINITION(FileSourceInput::MsgReportFileSourceStreamTiming, Message)
|
||||||
|
|
||||||
FileSourceInput::Settings::Settings() :
|
|
||||||
m_fileName("./test.sdriq")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void FileSourceInput::Settings::resetToDefaults()
|
|
||||||
{
|
|
||||||
m_fileName = "./test.sdriq";
|
|
||||||
}
|
|
||||||
|
|
||||||
QByteArray FileSourceInput::Settings::serialize() const
|
|
||||||
{
|
|
||||||
SimpleSerializer s(1);
|
|
||||||
s.writeString(1, m_fileName);
|
|
||||||
return s.final();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool FileSourceInput::Settings::deserialize(const QByteArray& data)
|
|
||||||
{
|
|
||||||
SimpleDeserializer d(data);
|
|
||||||
|
|
||||||
if(!d.isValid()) {
|
|
||||||
resetToDefaults();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(d.getVersion() == 1) {
|
|
||||||
d.readString(1, &m_fileName, "./test.sdriq");
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
resetToDefaults();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
FileSourceInput::FileSourceInput(DeviceSourceAPI *deviceAPI) :
|
FileSourceInput::FileSourceInput(DeviceSourceAPI *deviceAPI) :
|
||||||
m_deviceAPI(deviceAPI),
|
m_deviceAPI(deviceAPI),
|
||||||
m_settings(),
|
m_settings(),
|
||||||
|
@ -24,35 +24,28 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "filesourcesettings.h"
|
||||||
|
|
||||||
class FileSourceThread;
|
class FileSourceThread;
|
||||||
class DeviceSourceAPI;
|
class DeviceSourceAPI;
|
||||||
|
|
||||||
class FileSourceInput : public DeviceSampleSource {
|
class FileSourceInput : public DeviceSampleSource {
|
||||||
public:
|
public:
|
||||||
struct Settings {
|
|
||||||
QString m_fileName;
|
|
||||||
|
|
||||||
Settings();
|
|
||||||
void resetToDefaults();
|
|
||||||
QByteArray serialize() const;
|
|
||||||
bool deserialize(const QByteArray& data);
|
|
||||||
};
|
|
||||||
|
|
||||||
class MsgConfigureFileSource : public Message {
|
class MsgConfigureFileSource : public Message {
|
||||||
MESSAGE_CLASS_DECLARATION
|
MESSAGE_CLASS_DECLARATION
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const Settings& getSettings() const { return m_settings; }
|
const FileSourceSettings& getSettings() const { return m_settings; }
|
||||||
|
|
||||||
static MsgConfigureFileSource* create(const Settings& settings)
|
static MsgConfigureFileSource* create(const FileSourceSettings& settings)
|
||||||
{
|
{
|
||||||
return new MsgConfigureFileSource(settings);
|
return new MsgConfigureFileSource(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Settings m_settings;
|
FileSourceSettings m_settings;
|
||||||
|
|
||||||
MsgConfigureFileSource(const Settings& settings) :
|
MsgConfigureFileSource(const FileSourceSettings& settings) :
|
||||||
Message(),
|
Message(),
|
||||||
m_settings(settings)
|
m_settings(settings)
|
||||||
{ }
|
{ }
|
||||||
@ -259,7 +252,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
DeviceSourceAPI *m_deviceAPI;
|
DeviceSourceAPI *m_deviceAPI;
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
Settings m_settings;
|
FileSourceSettings m_settings;
|
||||||
std::ifstream m_ifstream;
|
std::ifstream m_ifstream;
|
||||||
FileSourceThread* m_fileSourceThread;
|
FileSourceThread* m_fileSourceThread;
|
||||||
QString m_deviceDescription;
|
QString m_deviceDescription;
|
||||||
|
58
plugins/samplesource/filesource/filesourcesettings.cpp
Normal file
58
plugins/samplesource/filesource/filesourcesettings.cpp
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "util/simpleserializer.h"
|
||||||
|
|
||||||
|
#include "filesourcesettings.h"
|
||||||
|
|
||||||
|
FileSourceSettings::FileSourceSettings()
|
||||||
|
{
|
||||||
|
resetToDefaults();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSourceSettings::resetToDefaults()
|
||||||
|
{
|
||||||
|
m_fileName = "./test.sdriq";
|
||||||
|
}
|
||||||
|
|
||||||
|
QByteArray FileSourceSettings::serialize() const
|
||||||
|
{
|
||||||
|
SimpleSerializer s(1);
|
||||||
|
s.writeString(1, m_fileName);
|
||||||
|
return s.final();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FileSourceSettings::deserialize(const QByteArray& data)
|
||||||
|
{
|
||||||
|
SimpleDeserializer d(data);
|
||||||
|
|
||||||
|
if(!d.isValid()) {
|
||||||
|
resetToDefaults();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(d.getVersion() == 1) {
|
||||||
|
d.readString(1, &m_fileName, "./test.sdriq");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
resetToDefaults();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
34
plugins/samplesource/filesource/filesourcesettings.h
Normal file
34
plugins/samplesource/filesource/filesourcesettings.h
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Copyright (C) 2017 Edouard Griffiths, F4EXB //
|
||||||
|
// //
|
||||||
|
// This program is free software; you can redistribute it and/or modify //
|
||||||
|
// it under the terms of the GNU General Public License as published by //
|
||||||
|
// the Free Software Foundation as version 3 of the License, or //
|
||||||
|
// //
|
||||||
|
// This program is distributed in the hope that it will be useful, //
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||||
|
// GNU General Public License V3 for more details. //
|
||||||
|
// //
|
||||||
|
// You should have received a copy of the GNU General Public License //
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef PLUGINS_SAMPLESOURCE_FILESOURCE_FILESOURCESETTINGS_H_
|
||||||
|
#define PLUGINS_SAMPLESOURCE_FILESOURCE_FILESOURCESETTINGS_H_
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include <QByteArray>
|
||||||
|
|
||||||
|
struct FileSourceSettings {
|
||||||
|
QString m_fileName;
|
||||||
|
|
||||||
|
FileSourceSettings();
|
||||||
|
~FileSourceSettings() {}
|
||||||
|
|
||||||
|
void resetToDefaults();
|
||||||
|
QByteArray serialize() const;
|
||||||
|
bool deserialize(const QByteArray& data);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* PLUGINS_SAMPLESOURCE_FILESOURCE_FILESOURCESETTINGS_H_ */
|
Loading…
Reference in New Issue
Block a user