-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeLocationStats.h
93 lines (51 loc) · 1.75 KB
/
CodeLocationStats.h
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// CodeLocationStats.h
// Declares the CodeLocationStats class that calculates project-wide statistics on CodeLocations
#ifndef CODELOCATIONSTATS_H
#define CODELOCATIONSTATS_H
#include <map>
#include <vector>
#include <memory>
#include <QObject>
// fwd:
class CodeLocation;
class Project;
class Snapshot;
typedef std::shared_ptr<Snapshot> SnapshotPtr;
class Allocation;
class CodeLocationStats:
public QObject
{
Q_OBJECT
public:
/** Represents the statistics for a single CodeLocation. */
struct Stats
{
quint64 m_MaxAllocationSize;
quint64 m_MinAllocationSize;
double m_AvgAllocationSize;
CodeLocation * m_CodeLocation;
static decltype(m_MaxAllocationSize) unassignedMax;
static decltype(m_MinAllocationSize) unassignedMin;
Stats();
};
/** Creates a new instance bound to the specified project. */
CodeLocationStats(Project * a_Project);
/** Retrieves the stats for the specified CodeLocation.
Returns nullptr if CodeLocation is not found. */
Stats * findStats(CodeLocation * a_CodeLocation);
/** Returns a copy of all the stats, transformed into a vector. */
std::vector<Stats> getAllStats();
public slots:
/** Emitted by the underlying project just before a new snapshot is added. */
void onProjectAddingSnapshot(SnapshotPtr a_Snapshot);
protected:
/** The project for which the stats are being recorded. */
Project * m_Project;
/** Stats, in a map for fast CodeLocation-based retrieval. */
std::map<CodeLocation *, Stats> m_Stats;
/** Recursively updates the stats when adding a snapshot to the project.
The specified allocation and all its (recursive) children are updated.
The snapshot is not yet added to the project. */
void updateStatsByAllocation(Allocation * a_Allocation);
};
#endif // CODELOCATIONSTATS_H