8#ifndef PXR_BASE_TRACE_COLLECTION_H
9#define PXR_BASE_TRACE_COLLECTION_H
13#include "pxr/base/trace/api.h"
14#include "pxr/base/trace/event.h"
15#include "pxr/base/trace/eventList.h"
16#include "pxr/base/trace/threads.h"
21#include <unordered_map>
23PXR_NAMESPACE_OPEN_SCOPE
39 using EventListPtr = std::unique_ptr<EventList>;
106 using KeyTokenCache =
107 std::unordered_map<TraceKey, TfToken, TraceKey::HashFunctor>;
111 void _Iterate(
Visitor& visitor,
bool doReverse)
const;
116 void _IterateEvents(
Visitor&, KeyTokenCache&,
119 using EventTable = std::map<TraceThreadId, EventListPtr>;
121 EventTable _eventsPerThread;
124PXR_NAMESPACE_CLOSE_SCOPE
uint32_t TraceCategoryId
Categories that a TraceReporter can use to filter events.
Token for efficient comparison, assignment, and hashing of known strings.
This interface provides a way to access data a TraceCollection.
virtual bool AcceptsCategory(TraceCategoryId categoryId)=0
Called before an event with categoryId is visited.
virtual void OnBeginCollection()=0
Called at the beginning of an iteration.
virtual void OnBeginThread(const TraceThreadId &threadId)=0
Called before the first event of from the thread with threadId is encountered.
virtual void OnEndThread(const TraceThreadId &threadId)=0
Called after the last event of from the thread with threadId is encountered.
virtual void OnEndCollection()=0
Called at the end of an iteration.
virtual TRACE_API ~Visitor()
Destructor.
virtual void OnEvent(const TraceThreadId &threadId, const TfToken &key, const TraceEvent &event)=0
Called for every event event with key on thread threadId if AcceptsCategory returns true.
This class owns lists of TraceEvent instances per thread, and allows read access to them.
TRACE_API void Iterate(Visitor &visitor) const
Forward iterates over the events of the collection and calls the visitor callbacks.
TraceCollection(TraceCollection &&)=default
Move constructor.
TRACE_API void AddToCollection(const TraceThreadId &id, EventListPtr &&events)
Appends events to the collection.
TRACE_API void ReverseIterate(Visitor &visitor) const
Reverse iterates over the events of the collection and calls the visitor callbacks.
TraceCollection()=default
Constructor.
TraceCollection & operator=(TraceCollection &&)=default
Move assignment operator.
This represents an event recorded by a TraceCollector.
This class represents an ordered collection of TraceEvents and the TraceDynamicKeys and data that the...
This class represents an identifier for a thread.
#define TF_MALLOC_TAG_NEW(name1, name2)
Enable lib/tf memory management.