SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
smtk::attribute::Item Class Referenceabstract
Inheritance diagram for smtk::attribute::Item:
[legend]
Collaboration diagram for smtk::attribute::Item:
[legend]

Public Types

enum  Type {
  AttributeRefType, DoubleType, GroupType, IntType,
  StringType, VoidType, FileType, DirectoryType,
  ColorType, ModelEntityType, MeshEntityType, DateTimeType,
  ReferenceType, ResourceType, ComponentType, NUMBER_OF_TYPES
}
 
enum  AssignmentOptions {
  IGNORE_EXPRESSIONS = 0x001, IGNORE_MODEL_ENTITIES = 0x002, IGNORE_ATTRIBUTE_REF_ITEMS = 0x004, IGNORE_RESOURCE_COMPONENTS = 0x008,
  COPY_MODEL_ASSOCIATIONS = 0x010
}
 

Public Member Functions

 smtkTypeMacroBase (smtk::attribute::Item)
 
std::string name () const
 
std::string label () const
 
virtual Item::Type type () const =0
 
virtual bool isRelevant (bool includeCatagories=true, bool includeReadAccess=false, unsigned int readAccessLevel=0) const
 Returns true if the item is relevant. More...
 
virtual void visitChildren (std::function< void(smtk::attribute::ItemPtr, bool)> visitor, bool activeChildren=true)
 visitChildren Invoke a function on each (or, if findInActiveChildren is true, each active) child item. 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
 
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 ()
 
virtual void reset ()
 
virtual bool rotate (std::size_t fromPosition, std::size_t toPosition)
 Rotate internal data. More...
 
virtual void detachOwningResource ()
 Release the item's dependency on its parent attribute's Resource.
 
void detachOwningAttribute ()
 This should be used only by attributes.
 
void detachOwningItem ()
 This should only be called by the item that owns this one.
 
virtual bool assign (smtk::attribute::ConstItemPtr &sourceItem, unsigned int options=0)
 Assigns this item to be equivalent to another. More...
 
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...
 
void setIsIgnored (bool val)
 Controls if an item should be ignored. More...
 
bool isIgnored () const
 Controls if an item should be ignored. More...
 

Static Public Member Functions

static std::string type2String (Item::Type t)
 
static Item::Type string2Type (const std::string &s)
 

Protected Member Functions

 Item (Attribute *owningAttribute, int itemPosition)
 
 Item (Item *owningItem, int myPosition, int mySubGroupPOsition)
 
virtual bool setDefinition (smtk::attribute::ConstItemDefinitionPtr def)
 
virtual smtk::attribute::ItemPtr findInternal (const std::string &name, SearchStyle style)
 Internal implementation of the find method.
 
virtual smtk::attribute::ConstItemPtr findInternal (const std::string &name, SearchStyle style) const
 
template<typename T >
bool rotateVector (std::vector< T > &v, std::size_t fromPosition, std::size_t toPosition)
 
virtual bool isValidInternal (bool useCategories, const std::set< std::string > &categories) const =0
 Internal implementation of calculating the validity of the item. More...
 

Protected Attributes

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
 

Friends

class Definition
 
class GroupItemDefinition
 
class ReferenceItemDefinition
 
class ValueItemDefinition
 

Member Enumeration Documentation

◆ AssignmentOptions

Enumerator
IGNORE_EXPRESSIONS 

Don't assign source value item's expressions.

IGNORE_MODEL_ENTITIES 

Don't assign source model entity items.

IGNORE_ATTRIBUTE_REF_ITEMS 

Don't assign source attribute reference items.

IGNORE_RESOURCE_COMPONENTS 

Don't assign source component items.

COPY_MODEL_ASSOCIATIONS 

If creating attributes, copy their model associations.

◆ Type

Enumerator
AttributeRefType 

Needed for backward compatibility w/r XML/JSON formats < 4.0.

MeshEntityType 

Needed for backward compatibility w/r XML/JSON formats < 4.0.

Member Function Documentation

◆ advanceLevel()

unsigned int Item::advanceLevel ( int  mode = 0) const

Get the item 's advance level.

if mode is 1 then the write access level is returned; else the read access level is returned The information can either be specified directly to the item using setLocalAdvanceLevel() or from the item's definition. If this item is not owned by another item or attribute the value is simply returned. Else the max of the value and that of its owner is returned. NOTE: This information is used in GUI only

◆ assign()

bool Item::assign ( smtk::attribute::ConstItemPtr sourceItem,
unsigned int  options = 0 
)
virtual

◆ forceRequired()

bool smtk::attribute::Item::forceRequired ( ) const
inline

Controls if an item should be forced to be required regardless of its local enable property.

There are cases within a work-flow when an item which can be considered optional in general must be required based on the state of the overall work-flow. These methods allow the programmer to explicitly force an optional item to be required. If the Definition states that the item is required naturally, this will have no effect. By default forceRequired is false.

◆ isEnabled()

bool Item::isEnabled ( ) const

An item is enabled under the following conditions:

  1. If it is not owned by another item (such as a group), and either it is not optional or it has been explicitly enabled
  2. If it's owning item is enabled and either it is not optional or it has been explicitly enabled

◆ isIgnored()

bool smtk::attribute::Item::isIgnored ( ) const
inline

Controls if an item should be ignored.

There are cases within a work-flow when an item may not be currently relevant and should be ignored. When setIgnored is passed true, the item::isRelevant will return false regardless of category or advance property checks By default isIgnored() will return false.

◆ isRelevant()

bool Item::isRelevant ( bool  includeCatagories = true,
bool  includeReadAccess = false,
unsigned int  readAccessLevel = 0 
) const
virtual

Returns true if the item is relevant.

If the item is marked ignored then return false. If includeCatagories is true and the item does not pass it's category checks, then return false, If includeReadAccess is true, and the item's advanceLevel is > readAccessLevel then return false. Else return true.

◆ isValid() [1/2]

bool Item::isValid ( bool  useActiveCategories = true) const

tests the validity of an item

Returns true if the item is considered valid. If a set of categories is passed into the method then they are used to "filter" the item. This means the item will check to see if it passes its passCategoryCheck method and if it fails (indicating the item is to be passed over) isValid will return true regardless of the item's contents.

In the form that takes in boolean. If useActiveCategories is true, and the attributes resource has active categories enabled, then the resource's active categories are used to before the filtering

◆ isValid() [2/2]

bool smtk::attribute::Item::isValid ( const std::set< std::string > &  categories) const
inline

tests the validity of an item

Returns true if the item is considered valid. If a set of categories is passed into the method then they are used to "filter" the item. This means the item will check to see if it passes its passCategoryCheck method and if it fails (indicating the item is to be passed over) isValid will return true regardless of the item's contents.

In the form that takes in boolean. If useActiveCategories is true, and the attributes resource has active categories enabled, then the resource's active categories are used to before the filtering

◆ isValidInternal()

virtual bool smtk::attribute::Item::isValidInternal ( bool  useCategories,
const std::set< std::string > &  categories 
) const
protectedpure virtual

Internal implementation of calculating the validity of the item.

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

Implemented in smtk::attribute::ReferenceItem, smtk::attribute::GroupItem, smtk::attribute::ValueItem, smtk::attribute::FileSystemItem, smtk::attribute::DateTimeItem, and smtk::attribute::VoidItem.

◆ position()

int smtk::attribute::Item::position ( ) const
inline

Position is the item's location w/r to the owning item if not null or the owning attribute.

Currently the only items that can own other items are GroupItem and ValueItem (for children)

◆ rotate()

bool Item::rotate ( std::size_t  fromPosition,
std::size_t  toPosition 
)
virtual

◆ setForceRequired()

void smtk::attribute::Item::setForceRequired ( bool  val)
inline

Controls if an item should be forced to be required regardless of its local enable property.

There are cases within a work-flow when an item which can be considered optional in general must be required based on the state of the overall work-flow. These methods allow the programmer to explicitly force an optional item to be required. If the Definition states that the item is required naturally, this will have no effect. By default forceRequired is false.

◆ setIsIgnored()

void smtk::attribute::Item::setIsIgnored ( bool  val)
inline

Controls if an item should be ignored.

There are cases within a work-flow when an item may not be currently relevant and should be ignored. When setIgnored is passed true, the item::isRelevant will return false regardless of category or advance property checks By default isIgnored() will return false.

◆ visitChildren()

virtual void smtk::attribute::Item::visitChildren ( std::function< void(smtk::attribute::ItemPtr, bool)>  visitor,
bool  activeChildren = true 
)
inlinevirtual

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

If a subclass presents childern items(ValueItem, Group, ...) then this function should be overriden.

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 in smtk::attribute::ReferenceItem, smtk::attribute::GroupItem, and smtk::attribute::ValueItem.


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