All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pySpec.h File Reference
#include "pxr/pxr.h"
#include "pxr/usd/sdf/api.h"
#include <hboost/python/def_visitor.hpp>
#include <hboost/python/dict.hpp>
#include <hboost/python/errors.hpp>
#include <hboost/python/raw_function.hpp>
#include <hboost/python/pointee.hpp>
#include <hboost/python/to_python_converter.hpp>
#include <hboost/python/tuple.hpp>
#include "pxr/base/tf/pyError.h"
#include "pxr/base/tf/pyUtils.h"
#include "pxr/usd/sdf/declareHandles.h"
#include "pxr/base/tf/tf.h"
#include "pxr/base/tf/diagnostic.h"
#include "pxr/base/tf/stringUtils.h"
#include "pxr/base/arch/demangle.h"
#include <string>
#include <type_traits>
+ Include dependency graph for pySpec.h:

Go to the source code of this file.


struct  hboost::python::pointee< PXR_NS::SdfHandle< T > >
struct  Sdf_PySpecDetail::NewVisitor< CTOR >
struct  Sdf_PySpecDetail::CtorBase< SIG >
struct  Sdf_PySpecDetail::NewCtor< SIG >
struct  Sdf_PySpecDetail::_ConstHandleToPython< _SpecType >
struct  Sdf_PySpecDetail::_HandleToPython< _SpecType, _Held, _Holder >
struct  Sdf_PySpecDetail::_HandleFromPython< _SpecType >
struct  Sdf_PySpecDetail::SpecVisitor< Abstract >
struct  Sdf_PySpecDetail::SpecVisitor< Abstract >::_Helper< CLS >
struct  Sdf_PySpecDetail::NewCtor< R(Args...)>




typedef PyObject *(* Sdf_PySpecDetail::_HolderCreator )(const SdfSpec &)


SDF_API bp::object Sdf_PySpecDetail::_DummyInit (bp::tuple const &, bp::dict const &)
template<typename T >
< typename
Sdf_PySpecDetail::NewCtor< T > > 
SdfMakePySpecConstructor (T *func, const std::string &doc=std::string())
SDF_API std::string Sdf_PySpecDetail::_SpecRepr (const bp::object &, const SdfSpec *)
SDF_API void Sdf_PySpecDetail::_RegisterHolderCreator (const std::type_info &, _HolderCreator)
SDF_API PyObject * Sdf_PySpecDetail::_CreateHolder (const std::type_info &, const SdfSpec &)
< false > 
SdfPySpec ()
< true > 
SdfPyAbstractSpec ()
< false > 
SdfPySpecNoRepr ()
< true > 
SdfPyAbstractSpecNoRepr ()

Detailed Description

SdfSpec Python wrapping utilities.

An SdfSpec subclass is not the representation of scene data. An SdfSpec simply provides an interface to data stored in some internal representation. SdfSpec subclasses are value types and their lifetimes don't reflect the lifetime of the scene data. However, clients still create scene data using the New methods on SdfSpec subclasses.

When wrapping to Python we need to wrap the New methods as the constructors. This used to look like this:

class_<MyClass, MyClassHandle>("MyClass", no_init)

But we can't use TfMakePyConstructor() because an SdfSpec handle is not a weak pointer. Furthermore, we don't have the problem of needing to store a ref pointer in the Python object. But we do still need conversion of spec types to yield the most-derived type in python.

This file introduces a few hboost::python::class_ def visitors to make wrapping specs easy. Spec wrapping should now look like:

class_<MyClass, SdfHandle<MyClass>, bases<SdfSpec>, hboost::noncopyable>
("MyClass", no_init)
.def(SdfPySpec()) // or SdfPyAbstractSpec()

If you need a custom repr you can use SdfPySpecNoRepr() or SdfPyAbstractSpecNoRepr() and def("__repr__", ...).

Definition in file pySpec.h.

Function Documentation

template<typename T >
Sdf_PySpecDetail::NewVisitor<typename Sdf_PySpecDetail::NewCtor<T> > SdfMakePySpecConstructor ( T *  func,
const std::string doc = std::string() 

Definition at line 200 of file pySpec.h.

Sdf_PySpecDetail::SpecVisitor<true> SdfPyAbstractSpec ( )

Definition at line 452 of file pySpec.h.

Sdf_PySpecDetail::SpecVisitor<true> SdfPyAbstractSpecNoRepr ( )

Definition at line 466 of file pySpec.h.

Sdf_PySpecDetail::SpecVisitor<false> SdfPySpec ( )

Definition at line 445 of file pySpec.h.

Sdf_PySpecDetail::SpecVisitor<false> SdfPySpecNoRepr ( )

Definition at line 459 of file pySpec.h.