SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Hold resources as an attribute value. More...
#include <ResourceItem.h>
Public Types | |
using | Resource = smtk::resource::Resource |
using | ResourcePtr = smtk::resource::ResourcePtr |
Public Types inherited from smtk::attribute::ReferenceItem | |
using | Key = std::pair< smtk::common::UUID, smtk::common::UUID > |
A Key is a pair of UUIDs. More... | |
Public Types inherited from smtk::attribute::Item | |
enum | Type { AttributeRefType, DoubleType, GroupType, IntType, StringType, VoidType, FileType, DirectoryType, ColorType, ModelEntityType, MeshEntityType, DateTimeType, ReferenceType, ResourceType, ComponentType, NUMBER_OF_TYPES } |
using | Status = smtk::common::Status |
Public Member Functions | |
smtkTypeMacro (smtk::attribute::ResourceItem) | |
smtkSuperclassMacro (ReferenceItem) | |
~ResourceItem () override | |
Destructor. | |
Item::Type | type () const override |
Return the type of storage used by the item. | |
ResourcePtr | value (std::size_t ii=0) const |
Return the ii-th value as a resource. | |
bool | setValue (ResourcePtr value) |
Set the 0-th value, ensuring type-safety. | |
bool | setValue (std::size_t ii, ResourcePtr value) |
Set the ii-th value, ensuring type-safety. | |
bool | appendValue (ResourcePtr value, bool allowDuplicates=true) |
Append a value to the item if possible. More... | |
std::string | valueAsString () const override |
Serialize the i-th value to a string. | |
std::string | valueAsString (std::size_t i) const override |
Return the value of the i-th component as a string. More... | |
Public Member Functions inherited from smtk::attribute::ReferenceItem | |
smtkTypeMacro (ReferenceItem) | |
smtkSuperclassMacro (Item) | |
ReferenceItem (const ReferenceItem &) | |
ReferenceItem & | operator= (const ReferenceItem &) |
std::size_t | numberOfValues () const |
Return the size of the item (number of entities associated with the item). | |
bool | setNumberOfValues (std::size_t newSize) |
Set the number of entities to be associated with this item (returns true if permitted). | |
bool | removeInvalidValues () |
Remove all invalid references. More... | |
virtual std::shared_ptr< const ReferenceItemDefinition > | definition () const |
Return this item's definition. | |
const std::multimap< std::string, std::string > & | acceptableEntries () const |
Return the association constraints for this item. | |
std::size_t | numberOfRequiredValues () const |
Return the number of values required by this item's definition (if it has one). | |
std::size_t | maxNumberOfValues () const |
Return the maximum number of values allowed by this item's definition (or 0). | |
bool | contains (const smtk::resource::PersistentObjectPtr &obj) const |
Return true if the ReferenceItem contains a reference to the given object. | |
bool | contains (const smtk::common::UUID &compId) const |
Return true if the component is contained in this item; false otherwise. | |
void | visit (std::function< bool(const PersistentObjectPtr &)> visitor) const |
Invoke a method on each value of this item. More... | |
template<typename Container > | |
void | as (Container &result, std::function< typename Container::value_type(const PersistentObjectPtr &)> converter=[](const PersistentObjectPtr &obj) { return obj;}) const |
Populate a container of the given type with members of this item. More... | |
template<typename Container > | |
Container | as (std::function< typename Container::value_type(const PersistentObjectPtr &)> converter=[](const PersistentObjectPtr &obj) { return obj;}) const |
Key | objectKey (std::size_t i=0) const |
\ Set/get object key (used for serialization). More... | |
bool | setObjectKey (std::size_t i, const Key &key) |
bool | setObjectKey (std::size_t i, const Key &key, std::size_t conditional) |
PersistentObjectPtr | value (std::size_t i=0) const |
Return the i-th object stored in this item. | |
template<typename T > | |
T::Ptr | valueAs (std::size_t i=0) const |
virtual bool | isValueValid (std::size_t ii, const PersistentObjectPtr &entity) const |
bool | isValueValid (const PersistentObjectPtr &entity) const |
bool | setValue (const PersistentObjectPtr &val) |
Set the component stored with this item. More... | |
bool | setValue (std::size_t i, const PersistentObjectPtr &val) |
Set the i-th value to the given item. More... | |
template<typename I > | |
bool | setValues (I vbegin, I vend, typename std::iterator_traits< I >::difference_type offset=0) |
template<typename I > | |
bool | appendValues (I vbegin, I vend) |
template<typename I , typename T > | |
bool | setValuesVia (I vbegin, I vend, const T &converter, typename std::iterator_traits< I >::difference_type offset=0) |
template<typename I , typename T > | |
bool | appendValuesVia (I vbegin, I vend, const T &converter) |
bool | appendValue (const PersistentObjectPtr &val, bool allowDuplicates=true) |
Add val if it is allowed and val is not already present in the item unless allowDuplicates is true. More... | |
bool | removeValue (std::size_t i) |
Remove the value at the i-th location. More... | |
void | detachOwningResource () override |
Release the item's dependency on its parent attribute's Resource. | |
void | reset () override |
Clear the list of values and fill it with null entries up to the number of required values. | |
virtual bool | isSet (std::size_t i=0) const |
Return whether the i-th value is set. More... | |
virtual void | unset (std::size_t i=0) |
Force the i-th value of the item to be invalid. | |
virtual std::size_t | numberOfSetValues () const |
Return the number of non-null values in the item. | |
Item::Status | assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options, smtk::io::Logger &logger) override |
bool | isExtensible () const |
A convenience method returning whether the item's definition is extensible. | |
const_iterator | begin () const |
Return an iterator to the first value in this item. | |
const_iterator | end () const |
Return an iterator just past the last value in this item. | |
std::ptrdiff_t | find (const smtk::common::UUID &compId) const |
Return the index of the first component with the given compId. | |
std::ptrdiff_t | find (const PersistentObjectPtr &component) const |
Return the index of the given component. | |
smtk::resource::LockType | lockType () const |
void | visitChildren (std::function< void(smtk::attribute::ItemPtr, bool)> visitor, bool activeChildren=true) override |
visitChildren Invoke a function on each (or, if findInActiveChildren is true, each active) child item. More... | |
std::size_t | numberOfChildrenItems () const |
Return the number of all children items associated with the item. | |
const std::map< std::string, smtk::attribute::ItemPtr > & | childrenItems () const |
Return the map of all children items. More... | |
std::size_t | numberOfActiveChildrenItems () const |
Return the number of active children items associated with the item. | |
smtk::attribute::ItemPtr | activeChildItem (std::size_t i) const |
Return the i th active child item associated with the item. | |
std::size_t | currentConditional () const |
Return the index of the current active conditional. More... | |
virtual Status | assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options=CopyAssignmentOptions()) |
Assigns contents to be same as source item. More... | |
virtual Status | assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options, smtk::io::Logger &logger) |
Assigns contents to be same as source item. More... | |
Public Member Functions inherited from smtk::attribute::Item | |
smtkTypeMacroBase (smtk::attribute::Item) | |
std::string | name () const |
std::string | label () const |
virtual bool | isRelevant (bool includeCatagories=true, bool includeReadAccess=false, unsigned int readAccessLevel=0) const |
Returns true if the item is relevant. More... | |
const smtk::attribute::ConstItemDefinitionPtr & | definition () const |
template<typename DefType > | |
std::shared_ptr< const DefType > | definitionAs () const |
smtk::attribute::AttributePtr | attribute () const |
Return the attribute that owns this item. | |
smtk::attribute::ItemPtr | owningItem () const |
int | position () const |
Position is the item's location w/r to the owning item if not null or the owning attribute. More... | |
int | subGroupPosition () const |
bool | isOptional () const |
Returns true if the item is optional. | |
bool | isEnabled () const |
An item is enabled under the following conditions: More... | |
bool | localEnabledState () const |
Return the state of the instance's isEnabled state. | |
void | setIsEnabled (bool isEnabledValue) |
Set the instance's local enabled state. | |
const smtk::attribute::Categories & | categories () const |
return the categories associated with the item (via its Definition) | |
unsigned int | advanceLevel (int mode=0) const |
Get the item 's advance level. More... | |
void | setLocalAdvanceLevel (int mode, unsigned int level) |
unsigned int | localAdvanceLevel (int mode=0) const |
void | unsetLocalAdvanceLevel (int mode=0) |
bool | hasLocalAdvanceLevelInfo (int mode=0) const |
void | setUserData (const std::string &key, smtk::simulation::UserDataPtr value) |
smtk::simulation::UserDataPtr | userData (const std::string &key) const |
void | clearUserData (const std::string &key) |
void | clearAllUserData () |
virtual bool | rotate (std::size_t fromPosition, std::size_t toPosition) |
Rotate internal data. More... | |
void | detachOwningAttribute () |
This should be used only by attributes. | |
void | detachOwningItem () |
This should only be called by the item that owns this one. | |
bool | isValid (bool useActiveCategories=true) const |
tests the validity of an item More... | |
bool | isValid (const std::set< std::string > &categories) const |
tests the validity of an item More... | |
smtk::attribute::ItemPtr | find (const std::string &name, SearchStyle style=RECURSIVE_ACTIVE) |
return a child item that matches name and satisfies the SearchStyle | |
smtk::attribute::ConstItemPtr | find (const std::string &name, SearchStyle style=RECURSIVE_ACTIVE) const |
return a child item that matches name and satisfies the SearchStyle | |
template<typename T > | |
T::Ptr | findAs (const std::string &name, SearchStyle style=RECURSIVE_ACTIVE) |
return a child item that matches name and satisfies the SearchStyle | |
template<typename T > | |
T::ConstPtr | findAs (const std::string &name, SearchStyle style=RECURSIVE_ACTIVE) const |
return a child item that matches name and satisfies the SearchStyle | |
void | setForceRequired (bool val) |
Controls if an item should be forced to be required regardless of its local enable property. More... | |
bool | forceRequired () const |
Controls if an item should be forced to be required regardless of its local enable property. More... | |
virtual Status | assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options=CopyAssignmentOptions()) |
void | setIsIgnored (bool val) |
Controls if an item should be ignored. More... | |
bool | isIgnored () const |
Controls if an item should be ignored. More... | |
Protected Member Functions | |
ResourceItem (Attribute *owningAttribute, int itemPosition) | |
Construct an item given its owning attribute and location in the attribute. | |
ResourceItem (Item *owningItem, int myPosition, int mySubGroupPosition) | |
Construct an item given its owning item and position inside the item. | |
Protected Member Functions inherited from smtk::attribute::ReferenceItem | |
ReferenceItem (Attribute *owningAttribute, int itemPosition) | |
Construct an item given its owning attribute and location in the attribute. | |
ReferenceItem (Item *owningItem, int myPosition, int mySubGroupPosition) | |
Construct an item given its owning item and position inside the item. | |
bool | setDefinition (smtk::attribute::ConstItemDefinitionPtr def) override |
Set the definition of this attribute. | |
PersistentObjectPtr | value (const ReferenceItem::Key &key) const |
Return the object stored in this item associated with key. | |
bool | resolve () const |
Resolve the object pointers by accessing them using their associated keys. More... | |
Key | linkTo (const PersistentObjectPtr &val) |
Construct a link between the attribute that owns this item and val. | |
bool | isValidInternal (bool useCategories, const std::set< std::string > &categories) const override |
Internal implementation of calculating the validity of the item. More... | |
smtk::attribute::ItemPtr | findInternal (const std::string &name, SearchStyle style) override |
Internal implementation of the find method. | |
smtk::attribute::ConstItemPtr | findInternal (const std::string &name, SearchStyle style) const override |
void | updateActiveChildrenItems () |
Update the vector of active children based on the item's current value. | |
Protected Member Functions inherited from smtk::attribute::Item | |
Item (Attribute *owningAttribute, int itemPosition) | |
Item (Item *owningItem, int myPosition, int mySubGroupPOsition) | |
template<typename T > | |
bool | rotateVector (std::vector< T > &v, std::size_t fromPosition, std::size_t toPosition) |
Friends | |
class | ResourceItemDefinition |
class | Definition |
Additional Inherited Members | |
Static Public Member Functions inherited from smtk::attribute::Item | |
static std::string | type2String (Item::Type t) |
static Item::Type | string2Type (const std::string &s) |
Protected Attributes inherited from smtk::attribute::ReferenceItem | |
std::vector< Key > | m_keys |
smtk::attribute::WeakAttributePtr | m_referencedAttribute |
In order to clean up its links when being deleted the item needs to track its referencing attribute. More... | |
Protected Attributes inherited from smtk::attribute::Item | |
Attribute * | m_attribute |
Item * | m_owningItem |
int | m_position |
int | m_subGroupPosition |
bool | m_isEnabled |
bool | m_isIgnored |
smtk::attribute::ConstItemDefinitionPtr | m_definition |
std::map< std::string, smtk::simulation::UserDataPtr > | m_userData |
Hold resources as an attribute value.
An attribute whose value is a resource (such as a mesh resource, model manager, or even an attribute resource).
|
inline |
Append a value to the item if possible.
This method ensures compile-time type-safety while appendValue() does not.
|
overridevirtual |
Return the value of the i-th component as a string.
This returns a string of the form "[" {UUID} "," {UUID} "]" where the first UUID is the component's resource and the second UUID is the component's.
Reimplemented from smtk::attribute::ReferenceItem.