All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
key.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_KEY_H
9#define PXR_BASE_TRACE_KEY_H
10
11#include "pxr/pxr.h"
12#include "pxr/base/trace/staticKeyData.h"
13
14
15PXR_NAMESPACE_OPEN_SCOPE
16
23class TraceKey {
24public:
26 constexpr TraceKey(const TraceStaticKeyData& data) : _ptr(&data) {}
27
29 bool operator == (const TraceKey& other) const {
30 if (_ptr == other._ptr) {
31 return true;
32 } else {
33 return *_ptr == *other._ptr;
34 }
35 }
36
38 size_t Hash() const {
39 return reinterpret_cast<size_t>(_ptr)/sizeof(TraceStaticKeyData);
40 }
41
43 struct HashFunctor {
44 size_t operator()(const TraceKey& key) const {
45 return key.Hash();
46 }
47 };
48
49private:
50 const TraceStaticKeyData* _ptr;
51
52 // TraceCollection converts TraceKeys to TfTokens for visitors.
53 friend class TraceCollection;
54};
55
56PXR_NAMESPACE_CLOSE_SCOPE
57
58#endif // PXR_BASE_TRACE_KEY_H
This class owns lists of TraceEvent instances per thread, and allows read access to them.
Definition: collection.h:32
A wrapper around a TraceStaticKeyData pointer that is stored in TraceEvent instances.
Definition: key.h:23
constexpr TraceKey(const TraceStaticKeyData &data)
Constructor.
Definition: key.h:26
bool operator==(const TraceKey &other) const
Equality comparison.
Definition: key.h:29
size_t Hash() const
Hash function.
Definition: key.h:38
This class holds data necessary to create keys for TraceEvent instances.
Definition: staticKeyData.h:26
A Hash functor which may be used to store keys in a TfHashMap.
Definition: key.h:43