Renamed AbstractFileFormat to StreamFileFormat and FileFormat to OstmFielFormat to be consistent with the new convention introduced with SessionFileFormat/OssnFileFormat
This commit is contained in:
parent
c8a31f3068
commit
ff066ea657
@ -19,8 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "port.h"
|
#include "port.h"
|
||||||
|
|
||||||
#include "abstractfileformat.h"
|
|
||||||
#include "emulation.h"
|
#include "emulation.h"
|
||||||
|
#include "streamfileformat.h"
|
||||||
|
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
@ -553,7 +553,7 @@ bool Port::openStreams(QString fileName, bool append, QString &error)
|
|||||||
QDialog *optDialog;
|
QDialog *optDialog;
|
||||||
QProgressDialog progress("Opening Streams", "Cancel", 0, 0, mainWindow);
|
QProgressDialog progress("Opening Streams", "Cancel", 0, 0, mainWindow);
|
||||||
OstProto::StreamConfigList streams;
|
OstProto::StreamConfigList streams;
|
||||||
AbstractFileFormat *fmt = AbstractFileFormat::fileFormatFromFile(fileName);
|
StreamFileFormat *fmt = StreamFileFormat::fileFormatFromFile(fileName);
|
||||||
|
|
||||||
if (fmt == NULL) {
|
if (fmt == NULL) {
|
||||||
error = tr("Unknown streams file format");
|
error = tr("Unknown streams file format");
|
||||||
@ -642,7 +642,7 @@ bool Port::saveStreams(QString fileName, QString fileType, QString &error)
|
|||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
QProgressDialog progress("Saving Streams", "Cancel", 0, 0, mainWindow);
|
QProgressDialog progress("Saving Streams", "Cancel", 0, 0, mainWindow);
|
||||||
AbstractFileFormat *fmt = AbstractFileFormat::fileFormatFromType(fileType);
|
StreamFileFormat *fmt = StreamFileFormat::fileFormatFromType(fileType);
|
||||||
OstProto::StreamConfigList streams;
|
OstProto::StreamConfigList streams;
|
||||||
|
|
||||||
if (fmt == NULL)
|
if (fmt == NULL)
|
||||||
|
@ -19,11 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
#include "portswindow.h"
|
#include "portswindow.h"
|
||||||
|
|
||||||
#include "abstractfileformat.h"
|
|
||||||
#include "deviceswidget.h"
|
#include "deviceswidget.h"
|
||||||
#include "portconfigdialog.h"
|
#include "portconfigdialog.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
#include "streamconfigdialog.h"
|
#include "streamconfigdialog.h"
|
||||||
|
#include "streamfileformat.h"
|
||||||
#include "streamlistdelegate.h"
|
#include "streamlistdelegate.h"
|
||||||
|
|
||||||
#include "fileformat.pb.h"
|
#include "fileformat.pb.h"
|
||||||
@ -812,8 +812,8 @@ void PortsWindow::on_actionOpen_Streams_triggered()
|
|||||||
{
|
{
|
||||||
qDebug("Open Streams Action");
|
qDebug("Open Streams Action");
|
||||||
|
|
||||||
QStringList fileTypes = AbstractFileFormat::supportedFileTypes(
|
QStringList fileTypes = StreamFileFormat::supportedFileTypes(
|
||||||
AbstractFileFormat::kOpenFile);
|
StreamFileFormat::kOpenFile);
|
||||||
QString fileType;
|
QString fileType;
|
||||||
QModelIndex current = tvPortList->selectionModel()->currentIndex();
|
QModelIndex current = tvPortList->selectionModel()->currentIndex();
|
||||||
static QString dirName;
|
static QString dirName;
|
||||||
@ -885,8 +885,8 @@ void PortsWindow::on_actionSave_Streams_triggered()
|
|||||||
|
|
||||||
QModelIndex current = tvPortList->selectionModel()->currentIndex();
|
QModelIndex current = tvPortList->selectionModel()->currentIndex();
|
||||||
static QString fileName;
|
static QString fileName;
|
||||||
QStringList fileTypes = AbstractFileFormat::supportedFileTypes(
|
QStringList fileTypes = StreamFileFormat::supportedFileTypes(
|
||||||
AbstractFileFormat::kSaveFile);
|
StreamFileFormat::kSaveFile);
|
||||||
QString fileType;
|
QString fileType;
|
||||||
QString errorStr;
|
QString errorStr;
|
||||||
QFileDialog::Options options;
|
QFileDialog::Options options;
|
||||||
|
@ -17,17 +17,17 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "fileformat.h"
|
#include "ostmfileformat.h"
|
||||||
|
|
||||||
FileFormat fileFormat;
|
OstmFileFormat fileFormat;
|
||||||
|
|
||||||
FileFormat::FileFormat()
|
OstmFileFormat::OstmFileFormat()
|
||||||
: AbstractFileFormat(), NativeFileFormat()
|
: StreamFileFormat(), NativeFileFormat()
|
||||||
{
|
{
|
||||||
// Do Nothing!
|
// Do Nothing!
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFormat::openStreams(const QString fileName,
|
bool OstmFileFormat::openStreams(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error)
|
OstProto::StreamConfigList &streams, QString &error)
|
||||||
{
|
{
|
||||||
OstProto::FileMeta meta;
|
OstProto::FileMeta meta;
|
||||||
@ -54,7 +54,7 @@ _fail:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
bool OstmFileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error)
|
const QString fileName, QString &error)
|
||||||
{
|
{
|
||||||
OstProto::FileContent content;
|
OstProto::FileContent content;
|
||||||
@ -79,12 +79,12 @@ _fail:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFormat::isMyFileFormat(const QString fileName)
|
bool OstmFileFormat::isMyFileFormat(const QString fileName)
|
||||||
{
|
{
|
||||||
return isNativeFileFormat(fileName, OstProto::kStreamsFileType);
|
return isNativeFileFormat(fileName, OstProto::kStreamsFileType);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FileFormat::isMyFileType(const QString fileType)
|
bool OstmFileFormat::isMyFileType(const QString fileType)
|
||||||
{
|
{
|
||||||
if (fileType.startsWith("Ostinato"))
|
if (fileType.startsWith("Ostinato"))
|
||||||
return true;
|
return true;
|
@ -16,18 +16,18 @@ GNU General Public License for more details.
|
|||||||
You should have received a copy of the GNU General Public License
|
You should have received a copy of the GNU General Public License
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
#ifndef _FILE_FORMAT_H
|
#ifndef _OSTM_FILE_FORMAT_H
|
||||||
#define _FILE_FORMAT_H
|
#define _OSTM_FILE_FORMAT_H
|
||||||
|
|
||||||
#include "abstractfileformat.h"
|
|
||||||
#include "nativefileformat.h"
|
#include "nativefileformat.h"
|
||||||
|
#include "streamfileformat.h"
|
||||||
|
|
||||||
#include "fileformat.pb.h"
|
#include "fileformat.pb.h"
|
||||||
|
|
||||||
class FileFormat : public AbstractFileFormat, public NativeFileFormat
|
class OstmFileFormat : public StreamFileFormat, public NativeFileFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileFormat();
|
OstmFileFormat();
|
||||||
|
|
||||||
virtual bool openStreams(const QString fileName,
|
virtual bool openStreams(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error);
|
OstProto::StreamConfigList &streams, QString &error);
|
||||||
@ -38,6 +38,6 @@ public:
|
|||||||
bool isMyFileType(const QString fileType);
|
bool isMyFileType(const QString fileType);
|
||||||
};
|
};
|
||||||
|
|
||||||
extern FileFormat fileFormat;
|
extern OstmFileFormat fileFormat;
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -35,12 +35,11 @@ PROTOS = \
|
|||||||
# TODO: Move fileformat related stuff into a different library - why?
|
# TODO: Move fileformat related stuff into a different library - why?
|
||||||
HEADERS = \
|
HEADERS = \
|
||||||
ostprotolib.h \
|
ostprotolib.h \
|
||||||
abstractfileformat.h \
|
|
||||||
fileformat.h \
|
|
||||||
ipv4addressdelegate.h \
|
ipv4addressdelegate.h \
|
||||||
ipv6addressdelegate.h \
|
ipv6addressdelegate.h \
|
||||||
nativefileformat.h \
|
nativefileformat.h \
|
||||||
ossnfileformat.h \
|
ossnfileformat.h \
|
||||||
|
ostmfileformat.h \
|
||||||
pcapfileformat.h \
|
pcapfileformat.h \
|
||||||
pdmlfileformat.h \
|
pdmlfileformat.h \
|
||||||
pythonfileformat.h \
|
pythonfileformat.h \
|
||||||
@ -48,6 +47,7 @@ HEADERS = \
|
|||||||
pdmlprotocols.h \
|
pdmlprotocols.h \
|
||||||
pdmlreader.h \
|
pdmlreader.h \
|
||||||
sessionfileformat.h \
|
sessionfileformat.h \
|
||||||
|
streamfileformat.h \
|
||||||
spinboxdelegate.h
|
spinboxdelegate.h
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
@ -83,10 +83,9 @@ HEADERS += \
|
|||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
ostprotolib.cpp \
|
ostprotolib.cpp \
|
||||||
abstractfileformat.cpp \
|
|
||||||
fileformat.cpp \
|
|
||||||
nativefileformat.cpp \
|
nativefileformat.cpp \
|
||||||
ossnfileformat.cpp \
|
ossnfileformat.cpp \
|
||||||
|
ostmfileformat.cpp \
|
||||||
pcapfileformat.cpp \
|
pcapfileformat.cpp \
|
||||||
pdmlfileformat.cpp \
|
pdmlfileformat.cpp \
|
||||||
pythonfileformat.cpp \
|
pythonfileformat.cpp \
|
||||||
@ -94,6 +93,7 @@ SOURCES += \
|
|||||||
pdmlprotocols.cpp \
|
pdmlprotocols.cpp \
|
||||||
pdmlreader.cpp \
|
pdmlreader.cpp \
|
||||||
sessionfileformat.cpp \
|
sessionfileformat.cpp \
|
||||||
|
streamfileformat.cpp \
|
||||||
spinboxdelegate.cpp
|
spinboxdelegate.cpp
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
@ -19,7 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#ifndef _PCAP_FILE_FORMAT_H
|
#ifndef _PCAP_FILE_FORMAT_H
|
||||||
#define _PCAP_FILE_FORMAT_H
|
#define _PCAP_FILE_FORMAT_H
|
||||||
|
|
||||||
#include "abstractfileformat.h"
|
#include "streamfileformat.h"
|
||||||
#include "ui_pcapfileimport.h"
|
#include "ui_pcapfileimport.h"
|
||||||
|
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
@ -39,7 +39,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
class PdmlReader;
|
class PdmlReader;
|
||||||
class PcapFileFormat : public AbstractFileFormat
|
class PcapFileFormat : public StreamFileFormat
|
||||||
{
|
{
|
||||||
friend class PdmlReader;
|
friend class PdmlReader;
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ bool PdmlFileFormat::saveStreams(const OstProto::StreamConfigList streams,
|
|||||||
{
|
{
|
||||||
bool isOk = false;
|
bool isOk = false;
|
||||||
QTemporaryFile pcapFile;
|
QTemporaryFile pcapFile;
|
||||||
AbstractFileFormat *fmt = AbstractFileFormat::fileFormatFromType("PCAP");
|
StreamFileFormat *fmt = StreamFileFormat::fileFormatFromType("PCAP");
|
||||||
QProcess tshark;
|
QProcess tshark;
|
||||||
|
|
||||||
Q_ASSERT(fmt);
|
Q_ASSERT(fmt);
|
||||||
|
@ -19,9 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#ifndef _PDML_FILE_FORMAT_H
|
#ifndef _PDML_FILE_FORMAT_H
|
||||||
#define _PDML_FILE_FORMAT_H
|
#define _PDML_FILE_FORMAT_H
|
||||||
|
|
||||||
#include "abstractfileformat.h"
|
#include "streamfileformat.h"
|
||||||
|
|
||||||
class PdmlFileFormat : public AbstractFileFormat
|
class PdmlFileFormat : public StreamFileFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PdmlFileFormat();
|
PdmlFileFormat();
|
||||||
|
@ -20,11 +20,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
#ifndef _PYTHON_FILE_FORMAT_H
|
#ifndef _PYTHON_FILE_FORMAT_H
|
||||||
#define _PYTHON_FILE_FORMAT_H
|
#define _PYTHON_FILE_FORMAT_H
|
||||||
|
|
||||||
#include "abstractfileformat.h"
|
#include "streamfileformat.h"
|
||||||
|
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
class PythonFileFormat : public AbstractFileFormat
|
class PythonFileFormat : public StreamFileFormat
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PythonFileFormat();
|
PythonFileFormat();
|
||||||
|
@ -17,35 +17,35 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "abstractfileformat.h"
|
#include "streamfileformat.h"
|
||||||
|
|
||||||
#include "fileformat.h"
|
#include "ostmfileformat.h"
|
||||||
#include "pcapfileformat.h"
|
#include "pcapfileformat.h"
|
||||||
#include "pdmlfileformat.h"
|
#include "pdmlfileformat.h"
|
||||||
#include "pythonfileformat.h"
|
#include "pythonfileformat.h"
|
||||||
|
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|
||||||
AbstractFileFormat::AbstractFileFormat()
|
StreamFileFormat::StreamFileFormat()
|
||||||
{
|
{
|
||||||
stop_ = false;
|
stop_ = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractFileFormat::~AbstractFileFormat()
|
StreamFileFormat::~StreamFileFormat()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog* AbstractFileFormat::openOptionsDialog()
|
QDialog* StreamFileFormat::openOptionsDialog()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDialog* AbstractFileFormat::saveOptionsDialog()
|
QDialog* StreamFileFormat::saveOptionsDialog()
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
QStringList AbstractFileFormat::supportedFileTypes(Operation op)
|
QStringList StreamFileFormat::supportedFileTypes(Operation op)
|
||||||
{
|
{
|
||||||
QStringList fileTypes;
|
QStringList fileTypes;
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ QStringList AbstractFileFormat::supportedFileTypes(Operation op)
|
|||||||
return fileTypes;
|
return fileTypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractFileFormat::openStreamsOffline(const QString fileName,
|
void StreamFileFormat::openStreamsOffline(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error)
|
OstProto::StreamConfigList &streams, QString &error)
|
||||||
{
|
{
|
||||||
fileName_ = fileName;
|
fileName_ = fileName;
|
||||||
@ -74,7 +74,7 @@ void AbstractFileFormat::openStreamsOffline(const QString fileName,
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractFileFormat::saveStreamsOffline(
|
void StreamFileFormat::saveStreamsOffline(
|
||||||
const OstProto::StreamConfigList streams,
|
const OstProto::StreamConfigList streams,
|
||||||
const QString fileName, QString &error)
|
const QString fileName, QString &error)
|
||||||
{
|
{
|
||||||
@ -87,12 +87,12 @@ void AbstractFileFormat::saveStreamsOffline(
|
|||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractFileFormat::result()
|
bool StreamFileFormat::result()
|
||||||
{
|
{
|
||||||
return result_;
|
return result_;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractFileFormat* AbstractFileFormat::fileFormatFromFile(
|
StreamFileFormat* StreamFileFormat::fileFormatFromFile(
|
||||||
const QString fileName)
|
const QString fileName)
|
||||||
{
|
{
|
||||||
if (fileFormat.isMyFileFormat(fileName))
|
if (fileFormat.isMyFileFormat(fileName))
|
||||||
@ -107,7 +107,7 @@ AbstractFileFormat* AbstractFileFormat::fileFormatFromFile(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractFileFormat* AbstractFileFormat::fileFormatFromType(
|
StreamFileFormat* StreamFileFormat::fileFormatFromType(
|
||||||
const QString fileType)
|
const QString fileType)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -126,12 +126,12 @@ AbstractFileFormat* AbstractFileFormat::fileFormatFromType(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractFileFormat::cancel()
|
void StreamFileFormat::cancel()
|
||||||
{
|
{
|
||||||
stop_ = true;
|
stop_ = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AbstractFileFormat::run()
|
void StreamFileFormat::run()
|
||||||
{
|
{
|
||||||
if (op_ == kOpenFile)
|
if (op_ == kOpenFile)
|
||||||
result_ = openStreams(fileName_, *openStreams_, *error_);
|
result_ = openStreams(fileName_, *openStreams_, *error_);
|
@ -17,8 +17,8 @@ You should have received a copy of the GNU General Public License
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>
|
along with this program. If not, see <http://www.gnu.org/licenses/>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ABSTRACT_FILE_FORMAT_H
|
#ifndef _STREAM_FILE_FORMAT_H
|
||||||
#define _ABSTRACT_FILE_FORMAT_H
|
#define _STREAM_FILE_FORMAT_H
|
||||||
|
|
||||||
#include "protocol.pb.h"
|
#include "protocol.pb.h"
|
||||||
|
|
||||||
@ -27,14 +27,14 @@ along with this program. If not, see <http://www.gnu.org/licenses/>
|
|||||||
|
|
||||||
class QDialog;
|
class QDialog;
|
||||||
|
|
||||||
class AbstractFileFormat : public QThread
|
class StreamFileFormat : public QThread
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
enum Operation { kOpenFile, kSaveFile };
|
enum Operation { kOpenFile, kSaveFile };
|
||||||
|
|
||||||
AbstractFileFormat();
|
StreamFileFormat();
|
||||||
virtual ~AbstractFileFormat();
|
virtual ~StreamFileFormat();
|
||||||
|
|
||||||
virtual bool openStreams(const QString fileName,
|
virtual bool openStreams(const QString fileName,
|
||||||
OstProto::StreamConfigList &streams, QString &error) = 0;
|
OstProto::StreamConfigList &streams, QString &error) = 0;
|
||||||
@ -53,8 +53,8 @@ public:
|
|||||||
|
|
||||||
static QStringList supportedFileTypes(Operation op);
|
static QStringList supportedFileTypes(Operation op);
|
||||||
|
|
||||||
static AbstractFileFormat* fileFormatFromFile(const QString fileName);
|
static StreamFileFormat* fileFormatFromFile(const QString fileName);
|
||||||
static AbstractFileFormat* fileFormatFromType(const QString fileType);
|
static StreamFileFormat* fileFormatFromType(const QString fileType);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
bool isMyFileFormat(const QString fileName) = 0;
|
bool isMyFileFormat(const QString fileName) = 0;
|
Loading…
Reference in New Issue
Block a user