SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
smtk::attribute::ValueItem Class Referenceabstract

A concrete base class for items that store a vector of plain-old-data (POD) as values. More...

#include <ValueItem.h>

Inheritance diagram for smtk::attribute::ValueItem:
[legend]
Collaboration diagram for smtk::attribute::ValueItem:
[legend]

Public Member Functions

 smtkTypeMacro (smtk::attribute::ValueItem)
 
virtual std::size_t numberOfValues () const
 
std::size_t numberOfRequiredValues () const
 
std::size_t maxNumberOfValues () const
 
std::string valueLabel (std::size_t element) const
 
bool isExtensible () const
 
bool allowsExpressions () const
 
bool isExpression () const
 
smtk::attribute::AttributePtr expression () const
 
bool setExpression (smtk::attribute::AttributePtr exp)
 
bool isAcceptable (const smtk::attribute::AttributePtr &exp) const
 Returns true if the expression would be acceptable based om the item's definition and units requirements.
 
virtual bool setNumberOfValues (std::size_t newSize)=0
 
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...
 
int discreteIndex (std::size_t elementIndex=0) const
 
bool isDiscrete () const
 
bool isDiscreteIndexValid (int value) const
 
bool setDiscreteIndex (int value)
 
bool setDiscreteIndex (std::size_t elementIndex, int value)
 
std::vector< std::string > relevantEnums (bool includeCategories, bool includeReadAccess, unsigned int readAccessLevel) const
 Return the enum strings that pass the Resource's active categories and/or specified advance read access level.
 
void detachOwningResource () override
 Release the item's dependency on its parent attribute's Resource.
 
void reset () override
 
bool rotate (std::size_t fromPosition, std::size_t toPosition) override
 Rotate the order between specified positions.
 
virtual bool setToDefault (std::size_t elementIndex=0)=0
 
virtual bool isUsingDefault (std::size_t elementIndex) const =0
 
virtual bool isUsingDefault () const =0
 
bool hasDefault () const
 
virtual std::string valueAsString () const
 
virtual std::string valueAsString (std::size_t elementIndex) const =0
 
virtual bool setValueFromString (const std::string &stringVal)
 
virtual bool setValueFromString (std::size_t elementIndex, const std::string &stringVal)=0
 
virtual bool isSet (std::size_t elementIndex=0) const
 
virtual void unset (std::size_t elementIndex=0)
 
smtk::attribute::ComponentItemPtr expressionReference () const
 
std::size_t numberOfChildrenItems () const
 
const std::map< std::string, smtk::attribute::ItemPtr > & childrenItems () const
 
std::size_t numberOfActiveChildrenItems () const
 
smtk::attribute::ItemPtr activeChildItem (int i) const
 
virtual const std::string & units () const
 Returns the native units of the item. More...
 
virtual std::string supportedUnits () const
 Return native units of the item that are supported by the units system assigned to its definition. More...
 
Item::Status assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options, smtk::io::Logger &logger) override
 
virtual Status assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options=CopyAssignmentOptions())
 
virtual Status assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options, smtk::io::Logger &logger)
 
ItemPtr findChild (const std::string &name, smtk::attribute::SearchStyle)
 Search the item's children - Deprecated! Please use Item::find. More...
 
ConstItemPtr findChild (const std::string &name, smtk::attribute::SearchStyle) const
 Search the item's children - Deprecated! Please use Item::find. More...
 
- Public Member Functions inherited from smtk::attribute::Item
 smtkTypeMacroBase (smtk::attribute::Item)
 
std::string name () const
 
std::string label () const
 
virtual Item::Type type () const =0
 
bool isRelevant (bool includeCatagories=true, bool includeReadAccess=false, unsigned int readAccessLevel=0) const
 Returns true if the item is relevant. More...
 
virtual bool defaultIsRelevant (bool includeCatagories, bool includeReadAccess, unsigned int readAccessLevel) const
 Default isRelevant method that returns true if the item is relevant. More...
 
const smtk::attribute::ConstItemDefinitionPtrdefinition () 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
 Return the position of the item with respects to the GroupItem that owns it. More...
 
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::Categoriescategories () 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 ()
 
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...
 
void setCustomIsRelevant (RelevanceFunc func)
 Set and Get Methods for specifying a custom isRelevant function.
 
RelevanceFunc customIsRelevant () const
 Set and Get Methods for specifying a custom isRelevant function.
 
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
 
std::string path (const std::string &sep="/") const
 Formats the full path to the item with respect to its owning attribute using sep as the path separator.
 
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

 ValueItem (Attribute *owningAttribute, int itemPosition)
 
 ValueItem (Item *owningItem, int myPosition, int mySubGroupPosition)
 
bool setDefinition (smtk::attribute::ConstItemDefinitionPtr def) override
 
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
 
virtual void updateDiscreteValue (std::size_t elementIndex)=0
 
virtual void updateActiveChildrenItems ()
 
bool isValidInternal (bool useCategories, const std::set< std::string > &categories) const override
 Internal implementation of calculating the validity of the item. More...
 
virtual bool initializeValues ()=0
 
- 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)
 

Protected Attributes

std::vector< int > m_discreteIndices
 
std::vector< bool > m_isSet
 
smtk::attribute::ComponentItemPtr m_expression
 
std::map< std::string, smtk::attribute::ItemPtrm_childrenItems
 
std::vector< smtk::attribute::ItemPtrm_activeChildrenItems
 
- Protected Attributes inherited from smtk::attribute::Item
Attributem_attribute
 
Itemm_owningItem
 
int m_position
 
int m_subGroupPosition
 
bool m_isEnabled
 
bool m_isIgnored
 
smtk::attribute::ConstItemDefinitionPtr m_definition
 
std::map< std::string, smtk::simulation::UserDataPtrm_userData
 
RelevanceFunc m_customIsRelevant = nullptr
 

Friends

class ValueItemDefinition
 

Additional Inherited Members

- 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
}
 
typedef std::function< bool(const Item *, bool includeCatagories, bool includeReadAccess, unsigned int readAccessLevel)> RelevanceFunc
 Typedef for custom relevance functions.
 
using Status = smtk::common::Status
 
- Static Public Member Functions inherited from smtk::attribute::Item
static std::string type2String (Item::Type t)
 
static Item::Type string2Type (const std::string &s)
 

Detailed Description

A concrete base class for items that store a vector of plain-old-data (POD) as values.

The ValueItemTemplate<T> template inherits this class; it in turn is inherited by StringItem, IntItem, and DoubleItem.

Besides POD, this class adds the concepts of items that can take on values only from a discrete set and expressions that can be evaluated to produce values rather than storing only raw values.

Member Function Documentation

◆ assign() [1/2]

Item::Status ValueItem::assign ( const smtk::attribute::ConstItemPtr sourceItem,
const CopyAssignmentOptions options,
smtk::io::Logger logger 
)
overridevirtual

Assigns this item to be equivalent to another. Options are processed by derived item classes. The options are defined in Item.h.

This method returns a Status object that indicates both success/failure and modification/stasis. If cast to a boolean, the Status object returns true for success and false for failure.

Reimplemented from smtk::attribute::Item.

Reimplemented in smtk::attribute::ValueItemTemplate< DataT >, smtk::attribute::ValueItemTemplate< double >, smtk::attribute::ValueItemTemplate< std::string >, and smtk::attribute::ValueItemTemplate< int >.

◆ assign() [2/2]

Item::Status Item::assign

Assigns this item to be equivalent to another. Options are processed by derived item classes. The options are defined in Item.h.

This method returns a Status object that indicates both success/failure and modification/stasis. If cast to a boolean, the Status object returns true for success and false for failure.

◆ findChild() [1/2]

smtk::attribute::ItemPtr ValueItem::findChild ( const std::string &  cname,
smtk::attribute::SearchStyle  style 
)

Search the item's children - Deprecated! Please use Item::find.

Find a child of this item with the given name - To Be Deprecated (please use find!)

If the style is ALL_CHILDREN or ACTIVE_CHILDREN, any of this item's children that are ValueItems will be asked to search their children recursively.

◆ findChild() [2/2]

smtk::attribute::ConstItemPtr ValueItem::findChild ( const std::string &  name,
smtk::attribute::SearchStyle  style 
) const

Search the item's children - Deprecated! Please use Item::find.

Find a child of this item with the given name - To Be Deprecated (please use find!)

If the style is ALL_CHILDREN or ACTIVE_CHILDREN, any of this item's children that are ValueItems will be asked to search their children recursively.

◆ isValidInternal()

bool ValueItem::isValidInternal ( bool  useCategories,
const std::set< std::string > &  categories 
) const
overrideprotectedvirtual

Internal implementation of calculating the validity of the item.

If useCategories is true then the set of categories will be taken into consideration.

Implements smtk::attribute::Item.

◆ supportedUnits()

std::string ValueItem::supportedUnits ( ) const
virtual

Return native units of the item that are supported by the units system assigned to its definition.

If there is no units system assigned to the definition or if the item's native units are not supported by the units system, an empty string is returned.

◆ units()

const std::string & ValueItem::units ( ) const
virtual

Returns the native units of the item.

These are the units that the item's value methods are returned in and are by default specified by the item's definition

Reimplemented in smtk::attribute::DoubleItem.

◆ visitChildren()

void ValueItem::visitChildren ( std::function< void(smtk::attribute::ItemPtr, bool)>  visitor,
bool  activeChildren = true 
)
overridevirtual

visitChildren Invoke a function on each (or, if findInActiveChildren is true, each active) child item.

If a subclass presents children items(ValueItem, Group, ComponentItem, ...) then this function should be overridden.

Parameters
visitora lambda function which would be applied on children items
activeChildrena flag indicating whether it should be applied to active children only or not

Reimplemented from smtk::attribute::Item.


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