-
Notifications
You must be signed in to change notification settings - Fork 0
/
AllocationPath.h
83 lines (42 loc) · 1.94 KB
/
AllocationPath.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
// AllocationPath.h
// Declares the AllocationPath class representing a path in the Allocation tree
#ifndef ALLOCATIONPATH_H
#define ALLOCATIONPATH_H
#include <vector>
// fwd:
class CodeLocation;
/** Represents a path in the allocation tree of any of the project's snapshots.
CodeLocation pointers are used to identify the path segments.
Note that not every snapshot needs to contain all the possible paths. */
class AllocationPath
{
public:
/** Creates a new path instance corresponding to the root allocation. */
AllocationPath();
/** Creates a new path instance corresponding to a child of the root allocation. */
AllocationPath(CodeLocation * a_CodeLocation);
/** Move-constructor. */
AllocationPath(AllocationPath && a_Src);
/** Copy-constructor. */
AllocationPath(const AllocationPath & a_Src);
/** Comparison to other instances. */
bool operator ==(const AllocationPath & a_Other);
/** Assignment operator.
gcc complains if this isn't defined. */
AllocationPath & operator =(const AllocationPath & a_Src);
/** Create a new path representing a child of this instance with the specified code location. */
AllocationPath makeChild(CodeLocation * a_ChildCodeLocation) const;
/** Creates a new path representing the parent of this instance (or root, for root allocation). */
AllocationPath makeParent() const;
/** Returns the individual segments of the path. */
const std::vector<CodeLocation *> getSegments() const { return m_Segments; }
/** Returns the last (leaf) segment of the path, or nullptr if path is empty. */
CodeLocation * getLeafSegment() const;
/** Returns true iff this path is a child of the specified parent path. */
bool isChildPathOf(const AllocationPath & a_Parent);
protected:
/** The path to the allocation, using CodeLocation pointers from the root allocation.
[0] is the code location of the root allocation's child, etc. */
std::vector<CodeLocation *> m_Segments;
};
#endif // ALLOCATIONPATH_H