All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
wrapTypeHelpers.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_WRAP_TYPE_HELPERS_H
8#define PXR_BASE_TF_WRAP_TYPE_HELPERS_H
9
10#include "pxr/pxr.h"
11
12#include "pxr/base/tf/api.h"
13#include "pxr/base/tf/pyObjWrapper.h"
14#include "pxr/base/tf/type.h"
15#include "pxr/external/boost/python/class.hpp"
16#include "pxr/external/boost/python/def_visitor.hpp"
17
18PXR_NAMESPACE_OPEN_SCOPE
19
20// Private implementation namespace; public types are exposed below.
21namespace TfType_WrapHelpers {
22
23 using namespace pxr_boost::python;
24
25 struct _PythonClass : def_visitor<_PythonClass>
26 {
27 friend class def_visitor_access;
28
29 private:
30 template <class CLS, class T>
31 void _Visit(CLS &c, T *) const {
32 if (TfType t = TfType::Find<T>())
33 t.DefinePythonClass(c);
34 }
35
36 public:
37 template <class CLS>
38 void visit(CLS &c) const {
39 // Use function template resolution to wrap the type
40 // appropriately depending on whether it is a polymorphic
41 // wrapper<> type.
42 typedef typename CLS::wrapped_type Type;
43 _Visit(c, detail::unwrap_wrapper((Type*)0));
44 }
45 };
46
47} // namespace TfType_WrapHelpers
48
49
60struct TfTypePythonClass : public TfType_WrapHelpers::_PythonClass {};
61
65TF_API TfType TfType_DefinePythonTypeAndBases( const pxr_boost::python::object & classObj );
66
67PXR_NAMESPACE_CLOSE_SCOPE
68
69#endif // PXR_BASE_TF_WRAP_TYPE_HELPERS_H
TfType represents a dynamic runtime type.
Definition: type.h:48
A boost.python visitor that associates the Python class object created by the wrapping with the TfTyp...