const std::string &file_name,
std::shared_ptr<sigrok::InputFormat> format,
const std::map<std::string, Glib::VariantBase> &options) :
+ File(file_name),
context_(context),
input_(format->create_input(options)),
- file_name_(file_name),
interrupt_(false) {
if (!input_)
throw QString("Failed to create input");
#include <libsigrokcxx/libsigrokcxx.hpp>
-#include "device.hpp"
+#include "file.hpp"
namespace pv {
namespace devices {
-class InputFile final : public Device
+class InputFile final : public File
{
private:
static const std::streamsize BufferSize;
private:
const std::shared_ptr<sigrok::Context> context_;
const std::shared_ptr<sigrok::Input> input_;
- const std::string file_name_;
std::atomic<bool> interrupt_;
};
#include "devicemanager.hpp"
#include "devices/hardwaredevice.hpp"
+#include "devices/inputfile.hpp"
#include "devices/sessionfile.hpp"
#include "dialogs/about.hpp"
#include "dialogs/connect.hpp"
using sigrok::Error;
using sigrok::OutputFormat;
+using sigrok::InputFormat;
namespace pv {
QMainWindow::keyReleaseEvent(event);
}
-void MainWindow::load_file(QString file_name)
+void MainWindow::load_file(QString file_name,
+ std::shared_ptr<sigrok::InputFormat> format,
+ const std::map<std::string, Glib::VariantBase> &options)
{
const QString errorMessage(
QString("Failed to load file %1").arg(file_name));
const QString infoMessage;
try {
- session_.set_device(
- shared_ptr<devices::Device>(new devices::SessionFile(
- device_manager_.context(),
- file_name.toStdString())));
+ if (format)
+ session_.set_device(shared_ptr<devices::Device>(
+ new devices::InputFile(
+ device_manager_.context(),
+ file_name.toStdString(),
+ format, options)));
+ else
+ session_.set_device(shared_ptr<devices::Device>(
+ new devices::SessionFile(
+ device_manager_.context(),
+ file_name.toStdString())));
} catch(Error e) {
show_session_error(tr("Failed to load ") + file_name, e.what());
session_.set_default_device();
#define PULSEVIEW_PV_MAINWINDOW_HPP
#include <list>
+#include <map>
#include <memory>
+#include <glibmm/variant.h>
+
#include <QMainWindow>
#include "session.hpp"
class QVBoxLayout;
namespace sigrok {
+class InputFormat;
class OutputFormat;
}
void keyReleaseEvent(QKeyEvent *event);
private Q_SLOTS:
- void load_file(QString file_name);
+ void load_file(QString file_name,
+ std::shared_ptr<sigrok::InputFormat> format = nullptr,
+ const std::map<std::string, Glib::VariantBase> &options =
+ std::map<std::string, Glib::VariantBase>());
void show_session_error(
const QString text, const QString info_text);