forked from qt-creator/qt-creator
Move parts of QmlEvent and QmlEventType to timeline
Timeline will become a generic trace handling library. It needs some abstract concept of events and event types. Move operator== and operator!= for QmlEvent into the test as we don't use them anywhere else. Move the operators for QmlEventType to QmlProfilerTraceClient. We want to get rid of the hash there as soon as we can assume that no application we want to profile doesn't support server type IDs. Change-Id: Icde4e3e7634e387171dc1d8bef7bbe8e71684a1a Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -26,6 +26,8 @@
|
||||
|
||||
#include "qmlprofilereventtypes.h"
|
||||
|
||||
#include <timeline/traceevent.h>
|
||||
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
#include <QVarLengthArray>
|
||||
@@ -36,32 +38,31 @@
|
||||
|
||||
namespace QmlProfiler {
|
||||
|
||||
struct QmlEvent {
|
||||
QmlEvent() : m_timestamp(-1), m_typeIndex(-1), m_dataType(Inline8Bit), m_dataLength(0) {}
|
||||
struct QmlEvent : public Timeline::TraceEvent {
|
||||
QmlEvent() : m_dataType(Inline8Bit), m_dataLength(0) {}
|
||||
|
||||
template<typename Number>
|
||||
QmlEvent(qint64 timestamp, int typeIndex, std::initializer_list<Number> list)
|
||||
: m_timestamp(timestamp), m_typeIndex(typeIndex)
|
||||
: TraceEvent(timestamp, typeIndex)
|
||||
{
|
||||
assignNumbers<std::initializer_list<Number>, Number>(list);
|
||||
}
|
||||
|
||||
QmlEvent(qint64 timestamp, int typeIndex, const QString &data)
|
||||
: m_timestamp(timestamp), m_typeIndex(typeIndex)
|
||||
: TraceEvent(timestamp, typeIndex)
|
||||
{
|
||||
assignNumbers<QByteArray, qint8>(data.toUtf8());
|
||||
}
|
||||
|
||||
template<typename Number>
|
||||
QmlEvent(qint64 timestamp, int typeIndex, const QVector<Number> &data)
|
||||
: m_timestamp(timestamp), m_typeIndex(typeIndex)
|
||||
: TraceEvent(timestamp, typeIndex)
|
||||
{
|
||||
assignNumbers<QVector<Number>, Number>(data);
|
||||
}
|
||||
|
||||
QmlEvent(const QmlEvent &other)
|
||||
: m_timestamp(other.m_timestamp), m_typeIndex(other.m_typeIndex),
|
||||
m_dataType(other.m_dataType), m_dataLength(other.m_dataLength)
|
||||
: TraceEvent(other), m_dataType(other.m_dataType), m_dataLength(other.m_dataLength)
|
||||
{
|
||||
assignData(other);
|
||||
}
|
||||
@@ -76,8 +77,7 @@ struct QmlEvent {
|
||||
{
|
||||
if (this != &other) {
|
||||
clearPointer();
|
||||
m_timestamp = other.m_timestamp;
|
||||
m_typeIndex = other.m_typeIndex;
|
||||
TraceEvent::operator=(other);
|
||||
m_dataType = other.m_dataType;
|
||||
m_dataLength = other.m_dataLength;
|
||||
assignData(other);
|
||||
@@ -99,12 +99,6 @@ struct QmlEvent {
|
||||
clearPointer();
|
||||
}
|
||||
|
||||
qint64 timestamp() const { return m_timestamp; }
|
||||
void setTimestamp(qint64 timestamp) { m_timestamp = timestamp; }
|
||||
|
||||
int typeIndex() const { return m_typeIndex; }
|
||||
void setTypeIndex(int typeIndex) { m_typeIndex = typeIndex; }
|
||||
|
||||
template<typename Number>
|
||||
Number number(int i) const
|
||||
{
|
||||
@@ -203,11 +197,6 @@ struct QmlEvent {
|
||||
m_data.internal8bit[0] = stage;
|
||||
}
|
||||
|
||||
bool isValid() const
|
||||
{
|
||||
return m_timestamp != -1;
|
||||
}
|
||||
|
||||
private:
|
||||
enum Type: quint16 {
|
||||
External = 1,
|
||||
@@ -221,7 +210,8 @@ private:
|
||||
External64Bit = Inline64Bit | External
|
||||
};
|
||||
|
||||
qint64 m_timestamp;
|
||||
Type m_dataType;
|
||||
quint16 m_dataLength;
|
||||
|
||||
static const int s_internalDataLength = 8;
|
||||
union {
|
||||
@@ -233,10 +223,6 @@ private:
|
||||
qint64 internal64bit[s_internalDataLength / 8];
|
||||
} m_data;
|
||||
|
||||
qint32 m_typeIndex;
|
||||
Type m_dataType;
|
||||
quint16 m_dataLength;
|
||||
|
||||
void assignData(const QmlEvent &other)
|
||||
{
|
||||
if (m_dataType & External) {
|
||||
@@ -309,9 +295,6 @@ private:
|
||||
friend QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);
|
||||
};
|
||||
|
||||
bool operator==(const QmlEvent &event1, const QmlEvent &event2);
|
||||
bool operator!=(const QmlEvent &event1, const QmlEvent &event2);
|
||||
|
||||
QDataStream &operator>>(QDataStream &stream, QmlEvent &event);
|
||||
QDataStream &operator<<(QDataStream &stream, const QmlEvent &event);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user