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"
33#include <boost/python.hpp>
35PXR_NAMESPACE_OPEN_SCOPE
46 typedef typename T::ItemType ItemType;
47 typedef typename T::ItemVector ItemVector;
53 TfPyWrapOnce<T>([name]() { SdfPyWrapListOp::_Wrap(name); });
57 static ItemVector _ApplyOperations1(
const T& listOp, ItemVector input) {
58 ItemVector result = input;
59 listOp.ApplyOperations(&result);
62 static boost::python::object
63 _ApplyOperations2(
const T& outer,
const T& inner) {
64 if (std::optional<T> r = outer.ApplyOperations(inner)) {
65 return boost::python::object(*r);
67 return boost::python::object();
71 static size_t _Hash(
const T &self){
75 static void _Wrap(
const std::string& name)
77 using namespace boost::python;
79 using ItemVector =
typename T::ItemVector;
81 class_<T>(name.c_str())
82 .def(
"__str__", &This::_GetStr)
83 .def(
"__hash__", &This::_Hash)
85 .def(
"Create", &T::Create,
86 (arg(
"prependedItems") = ItemVector(),
87 arg(
"appendedItems") = ItemVector(),
88 arg(
"deletedItems") = ItemVector()))
89 .staticmethod(
"Create")
91 .def(
"CreateExplicit", &T::CreateExplicit,
92 (arg(
"explicitItems") = ItemVector()))
93 .staticmethod(
"CreateExplicit")
98 .def(
"HasItem", &T::HasItem)
100 .def(
"Clear", &T::Clear)
101 .def(
"ClearAndMakeExplicit", &T::ClearAndMakeExplicit)
102 .def(
"ApplyOperations", &This::_ApplyOperations1)
103 .def(
"ApplyOperations", &This::_ApplyOperations2)
105 .add_property(
"explicitItems",
106 make_function(&T::GetExplicitItems,
107 return_value_policy<return_by_value>()),
108 &T::SetExplicitItems)
109 .add_property(
"addedItems",
110 make_function(&T::GetAddedItems,
111 return_value_policy<return_by_value>()),
113 .add_property(
"prependedItems",
114 make_function(&T::GetPrependedItems,
115 return_value_policy<return_by_value>()),
116 &T::SetPrependedItems)
117 .add_property(
"appendedItems",
118 make_function(&T::GetAppendedItems,
119 return_value_policy<return_by_value>()),
120 &T::SetAppendedItems)
121 .add_property(
"deletedItems",
122 make_function(&T::GetDeletedItems,
123 return_value_policy<return_by_value>()),
125 .add_property(
"orderedItems",
126 make_function(&T::GetOrderedItems,
127 return_value_policy<return_by_value>()),
129 .def(
"GetAddedOrExplicitItems",
131 .def(
"GetAppliedItems",
134 .add_property(
"isExplicit", &T::IsExplicit)
140 static std::string _GetStr(
const T& listOp)
147PXR_NAMESPACE_CLOSE_SCOPE
Miscellaneous Utilities for dealing with script.
Helper class for wrapping SdfListOp objects for Python.
A user-extensible hashing mechanism for use with runtime hash tables.
Demangle C++ typenames generated by the typeid() facility.
std::string TfStringify(const T &v)
Convert an arbitrary type into a string.
Definitions of basic string utilities in tf.