All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
callContext.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the terms set forth in the LICENSE.txt file available at
5// https://openusd.org/license.
6//
7#ifndef PXR_BASE_TF_CALL_CONTEXT_H
8#define PXR_BASE_TF_CALL_CONTEXT_H
9
20
21#include "pxr/pxr.h"
22#include "pxr/base/tf/api.h"
24
25#include <stddef.h>
26
27PXR_NAMESPACE_OPEN_SCOPE
28
30#define TF_CALL_CONTEXT \
31TfCallContext(__ARCH_FILE__, __ARCH_FUNCTION__, __LINE__, __ARCH_PRETTY_FUNCTION__)
32
33class TfCallContext
34{
35public:
36 constexpr TfCallContext()
37 : _file(nullptr)
38 , _function(nullptr)
39 , _line(0)
40 , _prettyFunction(nullptr)
41 , _hidden(false) {}
42
43 constexpr TfCallContext(char const *file,
44 char const *function,
45 size_t line,
46 char const *prettyFunction) :
47 _file(file),
48 _function(function),
49 _line(line),
50 _prettyFunction(prettyFunction),
51 _hidden(false)
52 {
53 }
54
55 char const *GetFile() const {
56 return _file;
57 }
58
59 char const *GetFunction() const {
60 return _function;
61 }
62
63 size_t GetLine() const {
64 return _line;
65 }
66
67 char const *GetPrettyFunction() const {
68 return _prettyFunction;
69 }
70
71 TfCallContext const& Hide() const {
72 _hidden = true;
73 return *this;
74 }
75
76 bool IsHidden() const {
77 return _hidden;
78 }
79
80 explicit operator bool() const { return _file && _function; }
81
82 private:
83
84 char const *_file;
85 char const *_function;
86 size_t _line;
87 char const *_prettyFunction;
88 mutable bool _hidden;
89};
90
91PXR_NAMESPACE_CLOSE_SCOPE
92
93#endif // PXR_BASE_TF_CALL_CONTEXT_H
Define preprocessor function name macros.