SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
The base class for items that hold information inside an attribute. More...
#include <Item.h>
Public Types | |
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 | |
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::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 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. | |
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()) |
virtual Status | assign (const smtk::attribute::ConstItemPtr &sourceItem, const CopyAssignmentOptions &options, smtk::io::Logger &logger) |
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 | |
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 |
Friends | |
class | Definition |
class | GroupItemDefinition |
class | ReferenceItemDefinition |
class | ValueItemDefinition |
The base class for items that hold information inside an attribute.
An attribute is an atomic unit of useful, related information. Items exist within the attribute to structure the information the attribute collects.
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
|
virtual |
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 in smtk::attribute::ReferenceItem, smtk::attribute::GroupItem, smtk::attribute::ValueItem, smtk::attribute::ValueItemTemplate< DataT >, smtk::attribute::ValueItemTemplate< double >, smtk::attribute::ValueItemTemplate< std::string >, smtk::attribute::ValueItemTemplate< int >, smtk::attribute::FileSystemItem, smtk::attribute::DateTimeItem, smtk::attribute::StringItem, smtk::attribute::DoubleItem, and smtk::attribute::IntItem.
|
virtual |
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.
|
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.
bool Item::isEnabled | ( | ) | const |
An item is enabled under the following conditions:
|
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.
|
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.
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
|
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
|
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.
|
inline |
|
virtual |
Rotate internal data.
Implementation to be added in sub-classes. Default behavior here is no-op (returns false).
Reimplemented in smtk::attribute::GroupItem, smtk::attribute::ValueItem, smtk::attribute::ValueItemTemplate< DataT >, smtk::attribute::ValueItemTemplate< double >, smtk::attribute::ValueItemTemplate< std::string >, smtk::attribute::ValueItemTemplate< int >, and smtk::attribute::DoubleItem.
|
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.
|
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.
|
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.
visitor | a lambda function which would be applied on children items |
activeChildren | a flag indicating whether it should be applied to active children only or not |
Reimplemented in smtk::attribute::ReferenceItem, smtk::attribute::ValueItem, and smtk::attribute::GroupItem.