All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
pyWrapContext.h
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_PY_WRAP_CONTEXT_H
8#define PXR_BASE_TF_PY_WRAP_CONTEXT_H
9
10#include "pxr/pxr.h"
11
13
14#include <string>
15#include <vector>
16
17PXR_NAMESPACE_OPEN_SCOPE
18
19// This is used internally by the Tf python wrapping infrastructure.
20
21class Tf_PyWrapContextManager {
22 Tf_PyWrapContextManager(const Tf_PyWrapContextManager&) = delete;
23 Tf_PyWrapContextManager&
24 operator=(const Tf_PyWrapContextManager&) = delete;
25
26 public:
27
28 typedef Tf_PyWrapContextManager This;
29
30 static This &GetInstance() {
32 }
33
34 std::string GetCurrentContext() const {
35 return _contextStack.empty() ? std::string() : _contextStack.back();
36 }
37
38 void PushContext(std::string const &ctx) {
39 _contextStack.push_back(ctx);
40 }
41
42 void PopContext() {
43 _contextStack.pop_back();
44 }
45
46 private:
47
48 Tf_PyWrapContextManager();
49
50 friend class TfSingleton<This>;
51
52 std::vector<std::string> _contextStack;
53};
54
55PXR_NAMESPACE_CLOSE_SCOPE
56
57#endif // PXR_BASE_TF_PY_WRAP_CONTEXT_H
Manage a single instance of an object (see.
Definition: singleton.h:105
static T & GetInstance()
Return a reference to an object of type T, creating it if necessary.
Definition: singleton.h:120
Manage a single instance of an object.