-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProject.h
155 lines (92 loc) · 4.75 KB
/
Project.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// Project.h
// Declares the project class representing a project - collection of snapshots.
#ifndef PROJECT_H
#define PROJECT_H
#include <memory>
#include <list>
#include <QObject>
#include "AllocationStats.h"
// fwd:
class QIODevice;
class Snapshot;
typedef std::shared_ptr<Snapshot> SnapshotPtr;
typedef std::list<SnapshotPtr> SnapshotPtrs;
class CodeLocationFactory;
typedef std::shared_ptr<CodeLocationFactory> CodeLocationFactoryPtr;
class CodeLocationStats;
typedef std::shared_ptr<CodeLocationStats> CodeLocationStatsPtr;
class AllocationPath;
class Project:
public QObject
{
Q_OBJECT
public:
Project();
/** Adds the specified snapshot to the project. */
void addSnapshot(SnapshotPtr a_Snapshot);
/** Returns the number of snapshots contained in the project. */
size_t getNumSnapshots(void) const;
/** Returns the snapshot with the specified timestamp, or nullptr if no such timestamp found. */
SnapshotPtr getSnapshotAtTimestamp(quint64 a_Timestamp);
/** Returns true if the project already contains a snapshot with the specified timestamp. */
bool hasSnapshotForTimestamp(quint64 a_Timestamp) const;
/** Checks the command used to create the Massif files for this project.
If there is no snapshot, sets the command and returns true.
If there are snapshots already, compares the stored command with the parameter and returns true if they are the same. */
bool checkAndSetCommand(const char * a_Command);
/** Checks the time unit used to create the Massif files for this project.
If there is no snapshot, sets the command and returns true.
If there are snapshots already, compares the stored command with the parameter and returns true if they are the same. */
bool checkAndSetTimeUnit(const char * a_TimeUnit);
std::string getCommand(void) const { return m_Command; }
std::string getTimeUnit(void) const { return m_TimeUnit; }
void setCommand(const std::string & a_Command);
void setTimeUnit(const std::string & a_TimeUnit);
const SnapshotPtrs & getSnapshots() const { return m_Snapshots; }
CodeLocationFactoryPtr getCodeLocationFactory() { return m_CodeLocationFactory; }
const CodeLocationFactoryPtr getCodeLocationFactory() const { return m_CodeLocationFactory; }
/** Returns the code location stats calculator.
The instance keeps track of min, max and avg allocation sizes of each code location. */
CodeLocationStatsPtr getCodeLocationStats() { return m_CodeLocationStats; }
/** Returns the project-wide stats for the specified allocation path. */
AllocationStats getStatsForAllocationPath(const AllocationPath & a_AllocationPath);
/** Returns all paths across all snapshots that are immediate children to the specified path. */
std::vector<AllocationPath> getAllAllocationPathsImmediateChildren(const AllocationPath & a_Path);
/** Marks the project as saved into the specified file name.
Sets the m_FileName and resets the m_HasChangedSinceSave. */
void setSaved(const QString & a_FileName);
/** Returns the filename used for the last save or load operation.
Empty if not saved or loaded yet. */
const QString & getFileName() const { return m_FileName; }
/** Returns true if the project has changed since it was last saved.
Upon creation, the project hasn't been saved yet but the flag is still set to true
so that a newly created project doesn't prompt for saving. */
bool hasChangedSinceSave() const { return m_HasChangedSinceSave; }
signals:
/** Emitted just before a snapshot is added to the project. */
void addingSnapshot(SnapshotPtr a_Snapshot);
/** Emitted just after a snapshot is added to the project. */
void addedSnapshot(SnapshotPtr a_Snapshot);
protected:
/** The snapshots contained within the project. */
SnapshotPtrs m_Snapshots;
/** The factory that manages all CodeLocation instances used by the project's snapshots. */
CodeLocationFactoryPtr m_CodeLocationFactory;
/** The command used to create the Massif files for this project.
Used to check when adding new files that they come from the same Massif settings. */
std::string m_Command;
/** The time unit used when creating the Massif files for this project.
Used to check when adding new files that they come from the same Massif settings. */
std::string m_TimeUnit;
/** The code location stats calculator.
Keeps track of min, max and avg allocation sizes of each code location. */
CodeLocationStatsPtr m_CodeLocationStats;
/** The filename used to load / save the project last. */
QString m_FileName;
/** True iff the project has changed since it was last saved. */
bool m_HasChangedSinceSave;
};
/** The magic bytes at the start of a project file used to determine if it is a project file.
Shared between the ProjectSaver and ProjectLoader classes. */
static const char g_ProjectFileMagic[] = "VisualMassifDiff project file\n";
#endif // PROJECT_H