HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SdfListOp< T > Class Template Reference

#include <listOp.h>

Public Types

typedef T ItemType
 
typedef std::vector< ItemTypeItemVector
 
typedef ItemType value_type
 
typedef ItemVector value_vector_type
 
typedef std::function
< hboost::optional< ItemType >
SdfListOpType, const ItemType &) > 
ApplyCallback
 Callback type for ApplyOperations. More...
 
typedef std::function
< hboost::optional< ItemType >
const ItemType &) > 
ModifyCallback
 Callback type for ModifyOperations. More...
 

Public Member Functions

SDF_API SdfListOp ()
 Create an empty ListOp in non-explicit mode. More...
 
SDF_API void Swap (SdfListOp< T > &rhs)
 
bool HasKeys () const
 
SDF_API bool HasItem (const T &item) const
 Returns true if the given item is in any of the item lists. More...
 
bool IsExplicit () const
 Returns true if the list is explicit. More...
 
const ItemVectorGetExplicitItems () const
 Returns the explicit items. More...
 
const ItemVectorGetAddedItems () const
 Returns the explicit items. More...
 
const ItemVectorGetPrependedItems () const
 Returns the explicit items. More...
 
const ItemVectorGetAppendedItems () const
 Returns the explicit items. More...
 
const ItemVectorGetDeletedItems () const
 Returns the deleted items. More...
 
const ItemVectorGetOrderedItems () const
 Returns the ordered items. More...
 
SDF_API const ItemVectorGetItems (SdfListOpType type) const
 Return the item vector identified by type. More...
 
SDF_API ItemVector GetAppliedItems () const
 
SDF_API void SetExplicitItems (const ItemVector &items)
 
SDF_API void SetAddedItems (const ItemVector &items)
 
SDF_API void SetPrependedItems (const ItemVector &items)
 
SDF_API void SetAppendedItems (const ItemVector &items)
 
SDF_API void SetDeletedItems (const ItemVector &items)
 
SDF_API void SetOrderedItems (const ItemVector &items)
 
SDF_API void SetItems (const ItemVector &items, SdfListOpType type)
 Sets the item vector for the given operation type. More...
 
SDF_API void Clear ()
 Removes all items and changes the list to be non-explicit. More...
 
SDF_API void ClearAndMakeExplicit ()
 Removes all items and changes the list to be explicit. More...
 
SDF_API void ApplyOperations (ItemVector *vec, const ApplyCallback &cb=ApplyCallback()) const
 
SDF_API hboost::optional
< SdfListOp< T > > 
ApplyOperations (const SdfListOp< T > &inner) const
 
SDF_API bool ModifyOperations (const ModifyCallback &callback, bool removeDuplicates=false)
 
SDF_API bool ReplaceOperations (const SdfListOpType op, size_t index, size_t n, const ItemVector &newItems)
 
SDF_API void ComposeOperations (const SdfListOp< T > &stronger, SdfListOpType op)
 
bool operator== (const SdfListOp< T > &rhs) const
 
bool operator!= (const SdfListOp< T > &rhs) const
 

Static Public Member Functions

static SDF_API SdfListOp CreateExplicit (const ItemVector &explicitItems=ItemVector())
 Create a ListOp in explicit mode with the given explicitItems. More...
 
static SDF_API SdfListOp Create (const ItemVector &prependedItems=ItemVector(), const ItemVector &appendedItems=ItemVector(), const ItemVector &deletedItems=ItemVector())
 

Friends

size_t hash_value (const SdfListOp &op)
 

Detailed Description

template<typename T>
class SdfListOp< T >

Value type representing a list-edit operation.

SdfListOp is a value type representing an operation that edits a list. It may add or remove items, reorder them, or replace the list entirely.

Definition at line 75 of file listOp.h.

Member Typedef Documentation

template<typename T>
typedef std::function< hboost::optional<ItemType>SdfListOpType, const ItemType&) > SdfListOp< T >::ApplyCallback

Callback type for ApplyOperations.

Definition at line 192 of file listOp.h.

template<typename T>
typedef T SdfListOp< T >::ItemType

Definition at line 77 of file listOp.h.

template<typename T>
typedef std::vector<ItemType> SdfListOp< T >::ItemVector

Definition at line 78 of file listOp.h.

template<typename T>
typedef std::function< hboost::optional<ItemType>const ItemType&) > SdfListOp< T >::ModifyCallback

Callback type for ModifyOperations.

Definition at line 220 of file listOp.h.

template<typename T>
typedef ItemType SdfListOp< T >::value_type

Definition at line 79 of file listOp.h.

template<typename T>
typedef ItemVector SdfListOp< T >::value_vector_type

Definition at line 80 of file listOp.h.

Constructor & Destructor Documentation

template<typename T>
SDF_API SdfListOp< T >::SdfListOp ( )

Create an empty ListOp in non-explicit mode.

Member Function Documentation

template<typename T>
SDF_API void SdfListOp< T >::ApplyOperations ( ItemVector vec,
const ApplyCallback cb = ApplyCallback() 
) const

Applies edit operations to the given ItemVector. If supplied, cb will be called on each item in the operation vectors before they are applied to vec. Consumers can use this to transform the items stored in the operation vectors to match what's stored in vec.

template<typename T>
SDF_API hboost::optional<SdfListOp<T> > SdfListOp< T >::ApplyOperations ( const SdfListOp< T > &  inner) const

Applies edit operations to the given ListOp.

The result is a ListOp that, when applied to a list, has the same effect as applying inner and then this in sequence.

The result will be empty if the result is not well defined. The result is well-defined when inner and this do not use the 'ordered' or 'added' item lists. In other words, only the explicit, prepended, appended, and deleted portions of SdfListOp are closed under composition with ApplyOperations().

template<typename T>
SDF_API void SdfListOp< T >::Clear ( )

Removes all items and changes the list to be non-explicit.

template<typename T>
SDF_API void SdfListOp< T >::ClearAndMakeExplicit ( )

Removes all items and changes the list to be explicit.

template<typename T>
SDF_API void SdfListOp< T >::ComposeOperations ( const SdfListOp< T > &  stronger,
SdfListOpType  op 
)

Composes a stronger SdfListOp's opinions for a given operation list over this one.

template<typename T>
static SDF_API SdfListOp SdfListOp< T >::Create ( const ItemVector prependedItems = ItemVector(),
const ItemVector appendedItems = ItemVector(),
const ItemVector deletedItems = ItemVector() 
)
static

Create a ListOp in non-explicit mode with the given prependedItems, appendedItems, and deletedItems

template<typename T>
static SDF_API SdfListOp SdfListOp< T >::CreateExplicit ( const ItemVector explicitItems = ItemVector())
static

Create a ListOp in explicit mode with the given explicitItems.

template<typename T>
const ItemVector& SdfListOp< T >::GetAddedItems ( ) const
inline

Returns the explicit items.

Definition at line 133 of file listOp.h.

template<typename T>
const ItemVector& SdfListOp< T >::GetAppendedItems ( ) const
inline

Returns the explicit items.

Definition at line 145 of file listOp.h.

template<typename T>
SDF_API ItemVector SdfListOp< T >::GetAppliedItems ( ) const

Returns the effective list of items represented by the operations in this list op. This function should be used to determine the final list of items added instead of looking at the individual explicit, prepended, and appended item lists.

This is equivalent to calling ApplyOperations on an empty item vector.

template<typename T>
const ItemVector& SdfListOp< T >::GetDeletedItems ( ) const
inline

Returns the deleted items.

Definition at line 151 of file listOp.h.

template<typename T>
const ItemVector& SdfListOp< T >::GetExplicitItems ( ) const
inline

Returns the explicit items.

Definition at line 127 of file listOp.h.

template<typename T>
SDF_API const ItemVector& SdfListOp< T >::GetItems ( SdfListOpType  type) const

Return the item vector identified by type.

template<typename T>
const ItemVector& SdfListOp< T >::GetOrderedItems ( ) const
inline

Returns the ordered items.

Definition at line 157 of file listOp.h.

template<typename T>
const ItemVector& SdfListOp< T >::GetPrependedItems ( ) const
inline

Returns the explicit items.

Definition at line 139 of file listOp.h.

template<typename T>
SDF_API bool SdfListOp< T >::HasItem ( const T item) const

Returns true if the given item is in any of the item lists.

template<typename T>
bool SdfListOp< T >::HasKeys ( ) const
inline

Returns true if the editor has an explicit list (even if it's empty) or it has any added, prepended, appended, deleted, or ordered keys.

Definition at line 103 of file listOp.h.

template<typename T>
bool SdfListOp< T >::IsExplicit ( ) const
inline

Returns true if the list is explicit.

Definition at line 121 of file listOp.h.

template<typename T>
SDF_API bool SdfListOp< T >::ModifyOperations ( const ModifyCallback callback,
bool  removeDuplicates = false 
)

Modifies operations specified in this object. callback is called for every item in all operation vectors. If the returned key is empty then the key is removed, otherwise it's replaced with the returned key.

If removeDuplicates is true and callback returns a key that was previously returned for the current operation vector being processed, the returned key will be removed.

Returns true if a change was made, false otherwise.

template<typename T>
bool SdfListOp< T >::operator!= ( const SdfListOp< T > &  rhs) const
inline

Definition at line 270 of file listOp.h.

template<typename T>
bool SdfListOp< T >::operator== ( const SdfListOp< T > &  rhs) const
inline

Definition at line 260 of file listOp.h.

template<typename T>
SDF_API bool SdfListOp< T >::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 newItems. If newItems is empty the items in the range will simply be removed.

template<typename T>
SDF_API void SdfListOp< T >::SetAddedItems ( const ItemVector items)
template<typename T>
SDF_API void SdfListOp< T >::SetAppendedItems ( const ItemVector items)
template<typename T>
SDF_API void SdfListOp< T >::SetDeletedItems ( const ItemVector items)
template<typename T>
SDF_API void SdfListOp< T >::SetExplicitItems ( const ItemVector items)
template<typename T>
SDF_API void SdfListOp< T >::SetItems ( const ItemVector items,
SdfListOpType  type 
)

Sets the item vector for the given operation type.

template<typename T>
SDF_API void SdfListOp< T >::SetOrderedItems ( const ItemVector items)
template<typename T>
SDF_API void SdfListOp< T >::SetPrependedItems ( const ItemVector items)
template<typename T>
SDF_API void SdfListOp< T >::Swap ( SdfListOp< T > &  rhs)

Friends And Related Function Documentation

template<typename T>
size_t hash_value ( const SdfListOp< T > &  op)
friend

Definition at line 248 of file listOp.h.


The documentation for this class was generated from the following file: