Minor cutting/pasting in device connection manager.

No functional change.
This commit is contained in:
sawinglogz 2020-06-30 11:35:23 -04:00
parent 09a96b893e
commit e47610cf5c
2 changed files with 23 additions and 29 deletions

View File

@ -14,6 +14,8 @@
#include <QDir> #include <QDir>
#include <QBuffer> #include <QBuffer>
#include <QDateTime> #include <QDateTime>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
#include <QDebug> #include <QDebug>
@ -940,12 +942,27 @@ bool SerialPortInfo::operator==(const SerialPortInfo & other) const
} }
// TODO: restrict constructor to OpenConnectionEvent // MARK: -
// MARK: Device connection base class
class OpenConnectionEvent : public XmlReplayBase<OpenConnectionEvent>
{
public:
OpenConnectionEvent() {}
OpenConnectionEvent(const QString & type, const QString & name)
{
set("type", type);
set("name", name);
}
virtual const QString id() const { return m_values["name"]; }
};
REGISTER_XMLREPLAYEVENT("openConnection", OpenConnectionEvent);
class ConnectionEvent : public XmlReplayBase<ConnectionEvent> class ConnectionEvent : public XmlReplayBase<ConnectionEvent>
{ {
public: public:
ConnectionEvent() { Q_ASSERT(false); } // Implement if we ever support string-based substreams ConnectionEvent() { Q_ASSERT(false); } // Implement if we ever support string-based substreams
ConnectionEvent(const XmlReplayEvent & trigger) ConnectionEvent(const OpenConnectionEvent & trigger)
{ {
copy(trigger); copy(trigger);
} }
@ -957,9 +974,6 @@ public:
}; };
REGISTER_XMLREPLAYEVENT("connection", ConnectionEvent); REGISTER_XMLREPLAYEVENT("connection", ConnectionEvent);
// MARK: -
// MARK: Device connection base class
class ConnectionRecorder : public XmlRecorder class ConnectionRecorder : public XmlRecorder
{ {
public: public:
@ -1027,19 +1041,6 @@ public:
}; };
REGISTER_XMLREPLAYEVENT("get", GetValueEvent); REGISTER_XMLREPLAYEVENT("get", GetValueEvent);
class OpenConnectionEvent : public XmlReplayBase<OpenConnectionEvent>
{
public:
OpenConnectionEvent() {}
OpenConnectionEvent(const QString & type, const QString & name)
{
set("type", type);
set("name", name);
}
virtual const QString id() const { return m_values["name"]; }
};
REGISTER_XMLREPLAYEVENT("openConnection", OpenConnectionEvent);
class CloseConnectionEvent : public XmlReplayBase<CloseConnectionEvent> class CloseConnectionEvent : public XmlReplayBase<CloseConnectionEvent>
{ {
public: public:

View File

@ -15,20 +15,13 @@
#include <QtSerialPort/QSerialPort> #include <QtSerialPort/QSerialPort>
#include <QHash> #include <QHash>
#include <QVariant> #include <QVariant>
#include <QDateTime>
#include <QXmlStreamReader>
#include <QXmlStreamWriter>
class XmlRecorder;
class XmlReplay;
class XmlReplayEvent;
class DeviceConnection : public QObject class DeviceConnection : public QObject
{ {
Q_OBJECT Q_OBJECT
protected: protected:
DeviceConnection(const QString & name, XmlRecorder* record, XmlReplay* replay); DeviceConnection(const QString & name, class XmlRecorder* record, class XmlReplay* replay);
const QString & m_name; const QString & m_name;
XmlRecorder* m_record; XmlRecorder* m_record;
@ -99,7 +92,7 @@ class SerialPortConnection : public DeviceConnection
private: private:
QSerialPort m_port; QSerialPort m_port;
void checkResult(bool ok, XmlReplayEvent & event) const; void checkResult(bool ok, class XmlReplayEvent & event) const;
void checkResult(qint64 len, XmlReplayEvent & event) const; void checkResult(qint64 len, XmlReplayEvent & event) const;
void checkError(XmlReplayEvent & event) const; void checkError(XmlReplayEvent & event) const;
void close(); void close();
@ -197,8 +190,8 @@ public:
inline bool isNull() const { return m_info.isEmpty(); } inline bool isNull() const { return m_info.isEmpty(); }
operator QString() const; operator QString() const;
friend QXmlStreamWriter & operator<<(QXmlStreamWriter & xml, const SerialPortInfo & info); friend class QXmlStreamWriter & operator<<(QXmlStreamWriter & xml, const SerialPortInfo & info);
friend QXmlStreamReader & operator>>(QXmlStreamReader & xml, SerialPortInfo & info); friend class QXmlStreamReader & operator>>(QXmlStreamReader & xml, SerialPortInfo & info);
bool operator==(const SerialPortInfo & other) const; bool operator==(const SerialPortInfo & other) const;
protected: protected: