24 #ifndef PXR_BASE_TF_PY_SINGLETON_H
25 #define PXR_BASE_TF_PY_SINGLETON_H
36 #include <hboost/python/class.hpp>
37 #include <hboost/python/default_call_policies.hpp>
38 #include <hboost/python/def_visitor.hpp>
39 #include <hboost/python/raw_function.hpp>
46 namespace Tf_PySingleton {
48 namespace bp = hboost::python;
70 template <
typename PtrType>
79 struct Visitor : bp::def_visitor<Visitor> {
81 _reprPrefix(reprPrefix) {}
84 template <
typename CLS>
86 typedef typename CLS::metadata::held_type PtrType;
92 c.def(
"__new__", _GetSingletonWeakPtr<PtrType>).staticmethod(
"__new__");
94 c.def(
"__init__", bp::raw_function(_DummyInit));
97 if (!_reprPrefix.empty())
99 make_function(std::bind(
100 _Repr, std::placeholders::_1, _reprPrefix),
101 bp::default_call_policies(),
118 #endif // PXR_BASE_TF_PY_SINGLETON_H
TfRefPtr< typename T::DataType > TfConst_cast(const TfRefPtr< const typename T::DataType > &ptr)
GLsizei const GLchar *const * string
friend class bp::def_visitor_access
TF_API std::string _Repr(bp::object const &self, std::string const &prefix)
TF_API Tf_PySingleton::Visitor TfPySingleton()
Visitor(std::string const &reprPrefix=std::string())
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
TF_API bp::object _DummyInit(bp::tuple const &, bp::dict const &)
PtrType _GetSingletonWeakPtr(bp::object const &)
TfWeakPtr< U > TfCreateWeakPtr(U *p)
TfWeakPtr< T > GetWeakPtr(T &t)