#ifndef TRACELOADER_H #define TRACELOADER_H #include "apitrace.h" #include "trace_file.hpp" #include "trace_parser.hpp" #include #include #include #include class TraceLoader : public QObject { Q_OBJECT public: TraceLoader(QObject *parent=0); ~TraceLoader(); ApiTraceCallSignature *signature(unsigned id); void addSignature(unsigned id, ApiTraceCallSignature *signature); ApiTraceEnumSignature *enumSignature(unsigned id); void addEnumSignature(unsigned id, ApiTraceEnumSignature *signature); private: class FrameContents { public: FrameContents(int numOfCalls=0); bool load(TraceLoader *loader, ApiTraceFrame* frame, QHash helpHash, trace::Parser &parser); void reset(); int topLevelCount() const; int allCallsCount() const; QVector topLevelCalls() const; QVector allCalls() const; quint64 binaryDataSize() const; bool isEmpty(); private: QStack m_groups; QVector m_topLevelItems; QVector m_allCalls; quint64 m_binaryDataSize; int m_parsedCalls; }; public slots: void loadTrace(const QString &filename); void loadFrame(ApiTraceFrame *frame); void findFrameStart(ApiTraceFrame *frame); void findFrameEnd(ApiTraceFrame *frame); void findCallIndex(int index); void search(const ApiTrace::SearchRequest &request); signals: void startedParsing(); void parsed(int percent); void guessedApi(int api); void finishedParsing(); void framesLoaded(const QList &frames); void frameContentsLoaded(ApiTraceFrame *frame, const QVector &topLevelItems, const QVector &calls, quint64 binaryDataSize); void searchResult(const ApiTrace::SearchRequest &request, ApiTrace::SearchResult result, ApiTraceCall *call); void foundFrameStart(ApiTraceFrame *frame); void foundFrameEnd(ApiTraceFrame *frame); void foundCallIndex(ApiTraceCall *call); private: struct FrameBookmark { FrameBookmark() : numberOfCalls(0) {} FrameBookmark(const trace::ParseBookmark &s) : start(s), numberOfCalls(0) {} trace::ParseBookmark start; int numberOfCalls; }; int numberOfFrames() const; int numberOfCallsInFrame(int frameIdx) const; void loadHelpFile(); void guessApi(const trace::Call *call); void scanTrace(); void parseTrace(); void searchNext(const ApiTrace::SearchRequest &request); void searchPrev(const ApiTrace::SearchRequest &request); int callInFrame(int callIdx) const; bool callContains(trace::Call *call, const QString &str, Qt::CaseSensitivity sensitivity); QVector fetchFrameContents(ApiTraceFrame *frame); bool searchCallsBackwards(const QList &calls, int frameIdx, const ApiTrace::SearchRequest &request); private: trace::Parser m_parser; typedef QMap FrameBookmarks; FrameBookmarks m_frameBookmarks; QList m_createdFrames; QHash m_helpHash; QVector m_signatures; QVector m_enumSignatures; }; #endif