All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
eventNode.h
1//
2// Copyright 2018 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7
8#ifndef PXR_BASE_TRACE_EVENT_NODE_H
9#define PXR_BASE_TRACE_EVENT_NODE_H
10
11#include "pxr/pxr.h"
12
13#include "pxr/base/trace/api.h"
14#include "pxr/base/trace/event.h"
15#include "pxr/base/trace/eventData.h"
16
17#include "pxr/base/tf/refBase.h"
18#include "pxr/base/tf/refPtr.h"
19#include "pxr/base/tf/token.h"
21
22#include <vector>
23
24PXR_NAMESPACE_OPEN_SCOPE
25
27
35
36class TraceEventNode : public TfRefBase {
37public:
38
39 using TimeStamp = TraceEvent::TimeStamp;
41 using AttributeMap = std::multimap<TfToken, AttributeData>;
42
45 static TraceEventNodeRefPtr New() {
47 TfToken("root"), TraceCategory::Default, 0.0, 0.0, {}, false);
48 }
49
52 static TraceEventNodeRefPtr New(const TfToken &key,
53 const TraceCategoryId category,
54 const TimeStamp beginTime,
55 const TimeStamp endTime,
56 TraceEventNodeRefPtrVector&& children,
57 const bool separateEvents) {
58 return TfCreateRefPtr(
60 key,
61 category,
62 beginTime,
63 endTime,
64 std::move(children),
65 separateEvents));
66 }
67
70 TraceEventNodeRefPtr Append(const TfToken &key,
71 TraceCategoryId category,
72 TimeStamp beginTime,
73 TimeStamp endTime,
74 bool separateEvents);
75
77 void Append(TraceEventNodeRefPtr node);
78
80 TfToken GetKey() { return _key;}
81
83 TraceCategoryId GetCategory() const { return _category; }
84
88
91
93 TimeStamp GetBeginTime() { return _beginTime; }
94
96 TimeStamp GetEndTime() { return _endTime; }
97
99
102
104 const TraceEventNodeRefPtrVector &GetChildrenRef() {
105 return _children;
106 }
107
109
111 const AttributeMap& GetAttributes() const { return _attributes; }
112
114 void AddAttribute(const TfToken& key, const AttributeData& attr);
115
118 bool IsFromSeparateEvents() const {
119 return _fromSeparateEvents;
120 }
121
122private:
123
125 const TfToken &key,
126 TraceCategoryId category,
127 TimeStamp beginTime,
128 TimeStamp endTime,
129 TraceEventNodeRefPtrVector&& children,
130 bool separateEvents)
131
132 : _key(key)
133 , _category(category)
134 , _beginTime(beginTime)
135 , _endTime(endTime)
136 , _children(std::move(children))
137 , _fromSeparateEvents(separateEvents)
138 {}
139
140
141 TfToken _key;
142 TraceCategoryId _category;
143 TimeStamp _beginTime;
144 TimeStamp _endTime;
145 TraceEventNodeRefPtrVector _children;
146 bool _fromSeparateEvents;
147
148 AttributeMap _attributes;
149};
150
151PXR_NAMESPACE_CLOSE_SCOPE
152
153#endif // PXR_BASE_TRACE_EVENT_NODE_H
uint32_t TraceCategoryId
Categories that a TraceReporter can use to filter events.
Definition: category.h:27
Enable a concrete base class for use with TfRefPtr.
Definition: refBase.h:56
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:71
This class holds data that can be stored in TraceEvents.
Definition: eventData.h:28
uint64_t TimeStamp
Time in "ticks".
Definition: event.h:33
TraceEventNode is used to represents call tree of a trace.
Definition: eventNode.h:36
bool IsFromSeparateEvents() const
Returns whether this node was created from a Begin-End pair or a single Timespan event.
Definition: eventNode.h:118
void Append(TraceEventNodeRefPtr node)
Appends node as a child node.
TimeStamp GetBeginTime()
Returns the time that this scope started.
Definition: eventNode.h:93
TfToken GetKey()
Returns the name of this node.
Definition: eventNode.h:80
TimeStamp GetEndTime()
Returns the time that this scope ended.
Definition: eventNode.h:96
void SetBeginAndEndTimesFromChildren()
Sets this node's begin and end time to the time extents of its direct children.
static TraceEventNodeRefPtr New()
Creates a new root node.
Definition: eventNode.h:45
const AttributeMap & GetAttributes() const
Return the data associated with this node.
Definition: eventNode.h:111
void AddAttribute(const TfToken &key, const AttributeData &attr)
Add data to this node.
TraceCategoryId GetCategory() const
Returns the category of this node.
Definition: eventNode.h:83
const TraceEventNodeRefPtrVector & GetChildrenRef()
Returns references to the children of this node.
Definition: eventNode.h:104
TraceEventNodeRefPtr Append(const TfToken &key, TraceCategoryId category, TimeStamp beginTime, TimeStamp endTime, bool separateEvents)
Appends a new child node with key, category, beginTime and endTime.
static TraceEventNodeRefPtr New(const TfToken &key, const TraceCategoryId category, const TimeStamp beginTime, const TimeStamp endTime, TraceEventNodeRefPtrVector &&children, const bool separateEvents)
Creates a new node with key, category, beginTime and endTime.
Definition: eventNode.h:52
Standard pointer typedefs.
#define TF_DECLARE_REF_PTRS(type)
Define standard ref pointer types.
Definition: declarePtrs.h:58
STL namespace.
Reference counting.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...