summaryrefslogtreecommitdiff
path: root/common/trace_loader.hpp
blob: 6873c964ae6d0a140b4f6bdb3cb5bbcf2b245fd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef TRACE_LOADER_HPP
#define TRACE_LOADER_HPP

#include "trace_file.hpp"
#include "trace_parser.hpp"

#include <string>
#include <map>
#include <queue>
#include <vector>

namespace trace  {

class Frame;

class Loader
{
public:
    enum FrameMarker {
        FrameMarker_SwapBuffers,
        FrameMarker_Flush,
        FrameMarker_Finish,
        FrameMarker_Clear
    };
public:
    Loader();
    ~Loader();

    Loader::FrameMarker frameMarker() const;
    void setFrameMarker(Loader::FrameMarker marker);

    unsigned numberOfFrames() const;
    unsigned numberOfCallsInFrame(unsigned frameIdx) const;

    bool open(const char *filename);
    void close();

    std::vector<trace::Call*> frame(unsigned idx);

private:
    struct FrameBookmark {
        FrameBookmark()
            : numberOfCalls(0)
        {}
        FrameBookmark(const ParseBookmark &s)
            : start(s),
              numberOfCalls(0)
        {}

        ParseBookmark start;
        unsigned numberOfCalls;
    };
    bool isCallAFrameMarker(const trace::Call *call) const;

private:
    trace::Parser m_parser;
    FrameMarker m_frameMarker;

    typedef std::map<int, FrameBookmark> FrameBookmarks;
    FrameBookmarks m_frameBookmarks;
};

}

#endif // TRACE_LOADER_HPP