HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pyObjectFinder.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_OBJECT_FINDER_H
8 #define PXR_BASE_TF_PY_OBJECT_FINDER_H
9 
10 #include "pxr/pxr.h"
11 
12 #include "pxr/base/tf/api.h"
13 #include "pxr/base/tf/pyIdentity.h"
14 
15 #include "pxr/external/boost/python/handle.hpp"
16 #include "pxr/external/boost/python/object.hpp"
17 
18 #include <typeinfo>
19 
21 
24  virtual pxr_boost::python::object Find(void const *objPtr) const = 0;
25 };
26 
27 template <class T, class PtrType>
29  virtual ~Tf_PyObjectFinder() {}
30  virtual pxr_boost::python::object Find(void const *objPtr) const {
31  using namespace pxr_boost::python;
32  TfPyLock lock;
33  void *p = const_cast<void *>(objPtr);
34  PyObject *obj = Tf_PyGetPythonIdentity(PtrType(static_cast<T *>(p)));
35  return obj ? object(handle<>(obj)) : object();
36  }
37 };
38 
39 TF_API
40 void Tf_RegisterPythonObjectFinderInternal(std::type_info const &type,
41  Tf_PyObjectFinderBase const *finder);
42 
43 template <class T, class PtrType>
47 }
48 
50 Tf_FindPythonObject(void const *objPtr, std::type_info const &type);
51 
53 
54 #endif // PXR_BASE_TF_PY_OBJECT_FINDER_H
virtual ~Tf_PyObjectFinder()
#define TF_API
Definition: api.h:23
TF_API void Tf_RegisterPythonObjectFinderInternal(std::type_info const &type, Tf_PyObjectFinderBase const *finder)
virtual TF_API ~Tf_PyObjectFinderBase()
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:108
TF_API pxr_boost::python::object Tf_FindPythonObject(void const *objPtr, std::type_info const &type)
void Tf_RegisterPythonObjectFinder()
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
Definition: path.h:1425
virtual pxr_boost::python::object Find(void const *objPtr) const
#define PXR_NAMESPACE_CLOSE_SCOPE
Definition: pxr.h:74
PyObject * Tf_PyGetPythonIdentity(Ptr const &ptr)
Definition: pyIdentity.h:213
virtual pxr_boost::python::object Find(void const *objPtr) const =0