24 #ifndef PXR_BASE_TF_PY_NOTICE_WRAPPER_H
25 #define PXR_BASE_TF_PY_NOTICE_WRAPPER_H
36 #include <hboost/mpl/and.hpp>
37 #include <hboost/mpl/if.hpp>
38 #include <hboost/mpl/or.hpp>
39 #include <hboost/python/bases.hpp>
40 #include <hboost/python/class.hpp>
41 #include <hboost/python/extract.hpp>
42 #include <hboost/python/handle.hpp>
44 #include <type_traits>
58 (*_generators)[
typeid(
T).
name()] = This::_Generate<T>;
83 template <
class Notice>
87 using namespace hboost::python;
89 Notice
const *wrapper =
static_cast<Notice
const *
>(objPtr);
90 return wrapper ?
object(wrapper->GetNoticePythonObject()) :
object();
94 template <
typename NoticeType,
typename BaseType>
99 "Notice type must be derived from or equal to TfNotice.");
103 "BaseType type must be derived from or equal to TfNotice.");
108 "BaseType type must be a base of notice, unless both "
109 "BaseType and Notice type are equal to TfNotice.");
117 typedef typename hboost::mpl::if_<
118 hboost::is_same<NoticeType, TfNotice>
119 , hboost::python::bases<>, hboost::python::bases<BaseType> >
::type Bases;
121 typedef hboost::python::class_<NoticeType, This, Bases>
ClassType;
125 if (wrappedName.empty()) {
127 wrappedName = TfType::Find<NoticeType>().GetTypeName();
131 Tf_PyNoticeObjectGenerator::Register<NoticeType>();
135 return ClassType(wrappedName.c_str(), hboost::python::no_init)
142 return hboost::python::handle<>(hboost::python::borrowed(_self));
147 template <
typename... Args>
149 : NoticeType(
args...)
157 #define TF_INSTANTIATE_NOTICE_WRAPPER(T, Base) \
158 TF_REGISTRY_FUNCTION(TfType) \
160 TfType::Define< TfPyNoticeWrapper<T, Base>, \
161 TfType::Bases<Base> >(); \
166 #endif // PXR_BASE_TF_PY_NOTICE_WRAPPER_H
GLuint const GLchar * name
TF_API std::string TfStringGetSuffix(const std::string &name, char delimiter= '.')
TfPyNoticeWrapper(PyObject *self, Args...args)
virtual ~Tf_PyNoticeObjectFinder()
TF_API void Tf_RegisterPythonObjectFinderInternal(std::type_info const &type, Tf_PyObjectFinderBase const *finder)
hboost::python::class_< NoticeType, This, Bases > ClassType
TfPyNoticeWrapper< NoticeType, BaseType > This
virtual hboost::python::object Find(void const *objPtr) const
static ClassType Wrap(std::string const &name=std::string())
Tf_PyNoticeObjectGenerator This
GLuint GLuint GLsizei GLenum type
GLsizei const GLchar *const * string
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
virtual hboost::python::handle GetNoticePythonObject() const
hboost::python::object(* MakeObjectFunc)(TfNotice const &)
#define PXR_NAMESPACE_CLOSE_SCOPE
hboost::mpl::if_< hboost::is_same< NoticeType, TfNotice >, hboost::python::bases<>, hboost::python::bases< BaseType > >::type Bases
virtual TF_API ~TfPyNoticeWrapperBase()
static TF_API hboost::python::object Invoke(TfNotice const &n)
GLsizei const GLfloat * value
virtual hboost::python::handle GetNoticePythonObject() const =0