HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyWrapContext.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_PY_WRAP_CONTEXT_H
8 #define PXR_BASE_TF_PY_WRAP_CONTEXT_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/base/tf/singleton.h"
13 
14 #include <string>
15 #include <vector>
16 
18 
19 // This is used internally by the Tf python wrapping infrastructure.
20 
24  operator=(const Tf_PyWrapContextManager&) = delete;
25 
26  public:
27 
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 
49 
50  friend class TfSingleton<This>;
51 
52  std::vector<std::string> _contextStack;
53 };
54 
56 
57 #endif // PXR_BASE_TF_PY_WRAP_CONTEXT_H
static T & GetInstance()
Definition: singleton.h:120
static This & GetInstance()
Definition: pyWrapContext.h:30
Tf_PyWrapContextManager This
Definition: pyWrapContext.h:28
void PushContext(std::string const &ctx)
Definition: pyWrapContext.h:38
std::string GetCurrentContext() const
Definition: pyWrapContext.h:34
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74