24 #ifndef PXR_USD_SDF_PY_LIST_OP_H
25 #define PXR_USD_SDF_PY_LIST_OP_H
28 #include "pxr/usd/sdf/listOp.h"
32 #include <boost/python.hpp>
34 PXR_NAMESPACE_OPEN_SCOPE
45 typedef typename T::ItemType ItemType;
46 typedef typename T::ItemVector ItemVector;
52 TfPyWrapOnce<T>([name]() { SdfPyWrapListOp::_Wrap(name); });
56 static ItemVector _ApplyOperations1(
const T& listOp, ItemVector input) {
57 ItemVector result = input;
58 listOp.ApplyOperations(&result);
61 static boost::python::object
62 _ApplyOperations2(
const T& outer,
const T& inner) {
63 if (boost::optional<T> r = outer.ApplyOperations(inner)) {
64 return boost::python::object(*r);
66 return boost::python::object();
70 static void _Wrap(
const std::string& name)
72 using namespace boost::python;
74 using ItemVector =
typename T::ItemVector;
76 class_<T>(name.c_str())
77 .def(
"__str__", &This::_GetStr)
79 .def(
"Create", &T::Create,
80 (arg(
"prependedItems") = ItemVector(),
81 arg(
"appendedItems") = ItemVector(),
82 arg(
"deletedItems") = ItemVector()))
83 .staticmethod(
"Create")
85 .def(
"CreateExplicit", &T::CreateExplicit,
86 (arg(
"explicitItems") = ItemVector()))
87 .staticmethod(
"CreateExplicit")
92 .def(
"HasItem", &T::HasItem)
94 .def(
"Clear", &T::Clear)
95 .def(
"ClearAndMakeExplicit", &T::ClearAndMakeExplicit)
96 .def(
"ApplyOperations", &This::_ApplyOperations1)
97 .def(
"ApplyOperations", &This::_ApplyOperations2)
99 .add_property(
"explicitItems",
100 make_function(&T::GetExplicitItems,
101 return_value_policy<return_by_value>()),
102 &T::SetExplicitItems)
103 .add_property(
"addedItems",
104 make_function(&T::GetAddedItems,
105 return_value_policy<return_by_value>()),
107 .add_property(
"prependedItems",
108 make_function(&T::GetPrependedItems,
109 return_value_policy<return_by_value>()),
110 &T::SetPrependedItems)
111 .add_property(
"appendedItems",
112 make_function(&T::GetAppendedItems,
113 return_value_policy<return_by_value>()),
114 &T::SetAppendedItems)
115 .add_property(
"deletedItems",
116 make_function(&T::GetDeletedItems,
117 return_value_policy<return_by_value>()),
119 .add_property(
"orderedItems",
120 make_function(&T::GetOrderedItems,
121 return_value_policy<return_by_value>()),
123 .def(
"GetAddedOrExplicitItems",
124 &This::_GetAddedOrExplicitItems)
126 .add_property(
"isExplicit", &T::IsExplicit)
132 static std::string _GetStr(
const T& listOp)
138 ItemVector _GetAddedOrExplicitItems(
const T& listOp)
141 listOp.ApplyOperations(&result);
147 PXR_NAMESPACE_CLOSE_SCOPE
149 #endif // PXR_USD_SDF_PY_LIST_OP_H
Definitions of basic string utilities in tf.
Miscellaneous Utilities for dealing with script.
Demangle C++ typenames generated by the typeid() facility.
Helper class for wrapping SdfListOp objects for Python.
std::enable_if<!std::is_enum< T >::value, std::string >::type TfStringify(const T &v)
Convert an arbitrary type into a string.