24 #ifndef PXR_USD_SDF_LIST_OP_H 25 #define PXR_USD_SDF_LIST_OP_H 28 #include "pxr/usd/sdf/api.h" 31 #include <boost/functional/hash.hpp> 32 #include <boost/optional/optional_fwd.hpp> 41 PXR_NAMESPACE_OPEN_SCOPE
48 SdfListOpTypeExplicit,
52 SdfListOpTypePrepended,
62 struct Sdf_ListOpTraits
64 typedef std::less<T> ItemComparator;
78 typedef std::vector<ItemType> ItemVector;
79 typedef ItemType value_type;
80 typedef ItemVector value_vector_type;
85 const ItemVector& explicitItems = ItemVector());
91 const ItemVector& prependedItems = ItemVector(),
92 const ItemVector& appendedItems = ItemVector(),
93 const ItemVector& deletedItems = ItemVector());
108 if (_addedItems.size() != 0 ||
109 _prependedItems.size() != 0 ||
110 _appendedItems.size() != 0 ||
111 _deletedItems.size() != 0) {
114 return _orderedItems.size() != 0;
118 SDF_API
bool HasItem(
const T& item)
const;
129 return _explicitItems;
141 return _prependedItems;
147 return _appendedItems;
153 return _deletedItems;
159 return _orderedItems;
163 SDF_API
const ItemVector&
GetItems(SdfListOpType type)
const;
165 SDF_API
void SetExplicitItems(
const ItemVector &items);
166 SDF_API
void SetAddedItems(
const ItemVector &items);
167 SDF_API
void SetPrependedItems(
const ItemVector &items);
168 SDF_API
void SetAppendedItems(
const ItemVector &items);
169 SDF_API
void SetDeletedItems(
const ItemVector &items);
170 SDF_API
void SetOrderedItems(
const ItemVector &items);
173 SDF_API
void SetItems(
const ItemVector &items, SdfListOpType type);
176 SDF_API
void Clear();
182 typedef std::function<
183 boost::optional<ItemType>(SdfListOpType,
const ItemType&)
206 boost::optional<SdfListOp<T>>
210 typedef std::function<
211 boost::optional<ItemType>(
const ItemType&)
227 const ItemVector& newItems);
234 friend inline size_t hash_value(
const SdfListOp &op) {
236 boost::hash_combine(h, op._isExplicit);
237 boost::hash_combine(h, op._explicitItems);
238 boost::hash_combine(h, op._addedItems);
239 boost::hash_combine(h, op._prependedItems);
240 boost::hash_combine(h, op._appendedItems);
241 boost::hash_combine(h, op._deletedItems);
242 boost::hash_combine(h, op._orderedItems);
247 return _isExplicit == rhs._isExplicit &&
248 _explicitItems == rhs._explicitItems &&
249 _addedItems == rhs._addedItems &&
250 _prependedItems == rhs._prependedItems &&
251 _appendedItems == rhs._appendedItems &&
252 _deletedItems == rhs._deletedItems &&
253 _orderedItems == rhs._orderedItems;
257 return !(*
this == rhs);
261 void _SetExplicit(
bool isExplicit);
263 typedef typename Sdf_ListOpTraits<T>::ItemComparator _ItemComparator;
264 typedef std::list<ItemType> _ApplyList;
265 typedef std::map<ItemType, typename _ApplyList::iterator, _ItemComparator>
269 _ApplyList* result, _ApplyMap* search)
const;
271 _ApplyList* result, _ApplyMap* search)
const;
273 _ApplyList* result, _ApplyMap* search)
const;
275 _ApplyList* result, _ApplyMap* search)
const;
277 _ApplyList* result, _ApplyMap* search)
const;
281 ItemVector _explicitItems;
282 ItemVector _addedItems;
283 ItemVector _prependedItems;
284 ItemVector _appendedItems;
285 ItemVector _deletedItems;
286 ItemVector _orderedItems;
298 template <
class ItemType>
300 void SdfApplyListOrdering(std::vector<ItemType>* v,
301 const std::vector<ItemType>& order);
305 template <
typename T>
310 typedef class SdfListOp<int> SdfIntListOp;
311 typedef class SdfListOp<unsigned int> SdfUIntListOp;
312 typedef class SdfListOp<int64_t> SdfInt64ListOp;
313 typedef class SdfListOp<uint64_t> SdfUInt64ListOp;
315 typedef class SdfListOp<std::string> SdfStringListOp;
316 typedef class
SdfListOp<class SdfPath> SdfPathListOp;
317 typedef class
SdfListOp<class SdfReference> SdfReferenceListOp;
318 typedef class
SdfListOp<class SdfPayload> SdfPayloadListOp;
319 typedef class
SdfListOp<class SdfUnregisteredValue> SdfUnregisteredValueListOp;
321 PXR_NAMESPACE_CLOSE_SCOPE
323 #endif // PXR_USD_SDF_LIST_OP_H void swap(ArAssetInfo &lhs, ArAssetInfo &rhs)
const ItemVector & GetPrependedItems() const
Returns the explicit items.
std::function< boost::optional< ItemType >SdfListOpType, const ItemType &) > ApplyCallback
Callback type for ApplyOperations.
SDF_API const ItemVector & GetItems(SdfListOpType type) const
Return the item vector identified by type.
SDF_API SdfListOp()
Create an empty ListOp in non-explicit mode.
SDF_API void SetItems(const ItemVector &items, SdfListOpType type)
Sets the item vector for the given operation type.
bool HasKeys() const
Returns true if the editor has an explicit list (even if it's empty) or it has any added,...
const ItemVector & GetOrderedItems() const
Returns the ordered items.
SDF_API void ClearAndMakeExplicit()
Removes all items and changes the list to be explicit.
SDF_API void Clear()
Removes all items and changes the list to be non-explicit.
const ItemVector & GetAppendedItems() const
Returns the explicit items.
SDF_API bool ModifyOperations(const ModifyCallback &callback)
Modifies operations specified in this object.
std::function< boost::optional< ItemType >const ItemType &) > ModifyCallback
Callback type for ModifyOperations.
Token for efficient comparison, assignment, and hashing of known strings.
SDF_API bool HasItem(const T &item) const
Returns true if the given item is in any of the item lists.
Value type representing a list-edit operation.
GF_API std::ostream & operator<<(std::ostream &, const GfBBox3d &)
Output a GfBBox3d using the format [(range) matrix zeroArea].
static SDF_API SdfListOp CreateExplicit(const ItemVector &explicitItems=ItemVector())
Create a ListOp in explicit mode with the given explicitItems.
SDF_API bool ReplaceOperations(const SdfListOpType op, size_t index, size_t n, const ItemVector &newItems)
Replaces the items in the specified operation vector in the range (index, index + n] with the given n...
const ItemVector & GetDeletedItems() const
Returns the deleted items.
static SDF_API SdfListOp Create(const ItemVector &prependedItems=ItemVector(), const ItemVector &appendedItems=ItemVector(), const ItemVector &deletedItems=ItemVector())
Create a ListOp in non-explicit mode with the given prependedItems, appendedItems,...
SDF_API void ComposeOperations(const SdfListOp< T > &stronger, SdfListOpType op)
Composes a stronger SdfListOp's opinions for a given operation list over this one.
const ItemVector & GetExplicitItems() const
Returns the explicit items.
const ItemVector & GetAddedItems() const
Returns the explicit items.
bool IsExplicit() const
Returns true if the list is explicit.
SDF_API void ApplyOperations(ItemVector *vec, const ApplyCallback &cb=ApplyCallback()) const
Applies edit operations to the given ItemVector.
TfToken class for efficient string referencing and hashing, plus conversions to and from stl string c...