24 #ifndef PXR_USD_SDF_LIST_EDITOR_PROXY_H
25 #define PXR_USD_SDF_LIST_EDITOR_PROXY_H
36 #include <hboost/optional.hpp>
56 template <
class _TypePolicy>
66 typedef std::function<hboost::optional<value_type>
70 typedef std::function<hboost::optional<value_type>
82 : _listEditor(listEditor)
93 return _listEditor->IsExpired();
100 return _Validate() ? _listEditor->IsExplicit() :
true;
107 return _Validate() ? _listEditor->IsOrderedOnly() :
false;
115 return _Validate() ? _listEditor->HasKeys() :
true;
148 return _Validate() && other._Validate() ?
149 _listEditor->CopyEdits(*other._listEditor) :
false;
159 return _Validate() ? _listEditor->ClearEdits() :
false;
169 return _Validate() ? _listEditor->ClearEditsAndMakeExplicit() :
false;
187 bool onlyAddOrExplicit =
false)
const
193 if (i !=
size_t(-1)) {
198 if (i !=
size_t(-1)) {
203 if (i !=
size_t(-1)) {
208 if (i !=
size_t(-1)) {
212 if (!onlyAddOrExplicit) {
214 if (i !=
size_t(-1)) {
219 if (i !=
size_t(-1)) {
314 _listEditor->ApplyEditsToList(&result);
322 if (!_listEditor->IsOrderedOnly()) {
323 if (_listEditor->IsExplicit()) {
337 if (!_listEditor->IsOrderedOnly()) {
338 if (_listEditor->IsExplicit()) {
352 if (!_listEditor->IsOrderedOnly()) {
353 if (_listEditor->IsExplicit()) {
367 if (_listEditor->IsExplicit()) {
370 else if (!_listEditor->IsOrderedOnly()) {
382 if (!_listEditor->IsOrderedOnly()) {
383 if (_listEditor->IsExplicit()) {
398 explicit operator bool()
const
400 return _listEditor && _listEditor->IsValid();
417 bool _Validate()
const
433 size_t index = proxy.Find(value);
434 if (index ==
size_t(-1)) {
435 proxy.push_back(value);
442 size_t index = proxy.Find(value);
443 if (index ==
size_t(-1)) {
444 proxy.push_back(value);
446 else if (value != static_cast<value_type>(proxy[index])) {
454 size_t index = proxy.Find(value);
456 if (index !=
size_t(-1)) {
459 proxy.insert(proxy.begin(),
value);
466 size_t index = proxy.Find(value);
467 if (proxy.empty() || (index != proxy.size()-1)) {
468 if (index !=
size_t(-1)) {
471 proxy.push_back(value);
476 std::shared_ptr<Sdf_ListEditor<TypePolicy> > _listEditor;
490 #endif // PXR_USD_SDF_LIST_EDITOR_PROXY_H
bool IsOrderedOnly() const
std::vector< value_type > value_vector_type
ListProxy GetPrependedItems() const
Returns the items prepended by this list editor.
ListProxy GetAppendedItems() const
Returns the items appended by this list editor.
GLsizei const GLfloat * value
ListProxy GetExplicitItems() const
Returns the explicitly set items.
void ApplyEditsToList(value_vector_type *vec, CB callback) const
void ModifyItemEdits(CB callback)
bool ContainsItemEdit(const value_type &item, bool onlyAddOrExplicit=false) const
void Prepend(const value_type &value)
void Add(const value_type &value)
**But if you need a result
bool ClearEditsAndMakeExplicit()
void Erase(const value_type &value)
ListProxy GetOrderedItems() const
Returns the items reordered by this list editor.
SdfListEditorProxy(const std::shared_ptr< Sdf_ListEditor< TypePolicy > > &listEditor)
Creates a new proxy object backed by the supplied list editor.
void RemoveItemEdits(const value_type &item)
friend class Sdf_ListEditorProxyAccess
ListProxy GetDeletedItems() const
Returns the items deleted by this list editor.
void ApplyEditsToList(value_vector_type *vec) const
Apply the edits to vec.
void Replace(const value_type &oldValue, const value_type &newValue)
std::function< hboost::optional< value_type >SdfListOpType, const value_type &)> ApplyCallback
value_vector_type GetAppliedItems() const
SdfListProxy< TypePolicy > ListProxy
std::function< hboost::optional< value_type >const value_type &)> ModifyCallback
bool IsExpired() const
Returns true if the list editor is expired.
TypePolicy::value_type value_type
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
void Append(const value_type &value)
ListProxy GetAddedItems() const
Returns the items added by this list editor.
#define PXR_NAMESPACE_CLOSE_SCOPE
void Remove(const value_type &value)
value_vector_type GetAddedOrExplicitItems() const
Deprecated. Please use GetAppliedItems.
bool CopyItems(const This &other)
static Vt_DefaultValueHolder Invoke()
void ReplaceItemEdits(const value_type &oldItem, const value_type &newItem)
SdfListEditorProxy< TypePolicy > This
void Remove(const value_type &value)
size_t Find(const value_type &value) const