SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
A definition for attribute items that store smtk::resource::PersistentObjectPtr as values. More...
#include <ReferenceItemDefinition.h>
Public Types | |
using | PersistentObjectPtr = smtk::resource::PersistentObjectPtr |
Public Member Functions | |
smtkTypeMacro (ReferenceItemDefinition) | |
Construct an item definition given a name. Names should be unique and non-empty. | |
smtkSuperclassMacro (ItemDefinition) | |
Item::Type | type () const override |
const std::multimap< std::string, std::string > & | acceptableEntries () const |
virtual bool | setAcceptsEntries (const std::string &typeName, const std::string &queryString, bool accept) |
void | clearAcceptableEntries () |
const std::multimap< std::string, std::string > & | rejectedEntries () const |
virtual bool | setRejectsEntries (const std::string &typeName, const std::string &queryString, bool accept) |
void | clearRejectedEntries () |
void | setEnforcesCategories (bool mode) |
bool | enforcesCategories () const |
virtual bool | isValueValid (resource::ConstPersistentObjectPtr entity) const |
std::size_t | numberOfRequiredValues () const |
Return the number of values required by this definition. | |
void | setNumberOfRequiredValues (std::size_t esize) |
Set the number of values required by this definition. Use 0 when there is no requirement. | |
bool | isExtensible () const |
void | setIsExtensible (bool extensible) |
std::size_t | maxNumberOfValues () const |
void | setMaxNumberOfValues (std::size_t maxNum) |
Set the maximum number of values accepted (or 0 for no limit). | |
bool | hasValueLabels () const |
Return whether the definition provides labels for each value. | |
std::string | valueLabel (std::size_t element) const |
Return the label for the i-th value. | |
void | setValueLabel (std::size_t element, const std::string &elabel) |
Set the label for the i-th value in the item. | |
void | setCommonValueLabel (const std::string &elabel) |
Indicate that all values share the elabel provided. | |
bool | usingCommonLabel () const |
Returns true when all values share a common label and false otherwise. | |
void | setLockType (smtk::resource::LockType val) |
Set/Get the reference resource's lock type (Read/Write/DoNotLock) for read lock, write lock or bypass lock. More... | |
smtk::resource::LockType | lockType () const |
smtk::resource::Links::RoleType | role () const |
Get the reference's role when generating links between the containing attribute and the reference item. More... | |
void | setRole (const smtk::resource::Links::RoleType &role) |
Set the reference's role when generating links between the containing attribute and the reference item. More... | |
void | setHoldReference (bool choice) |
Set/Get a flag to determine whether the ReferenceItem should keep an assigned reference in memory (i.e. More... | |
bool | holdReference () const |
virtual void | setOnlyResources (bool choice) |
Set/Get a flag to determine whether the ReferenceItem should only hold references. More... | |
bool | onlyResources () const |
std::size_t | numberOfChildrenItemDefinitions () const |
Return the number of children item definitions. | |
const std::map< std::string, smtk::attribute::ItemDefinitionPtr > & | childrenItemDefinitions () const |
Return the map of children item definitions. More... | |
bool | hasChildItemDefinition (const std::string &itemName) const |
returns true if this item has a child item definition of itemName | |
bool | addChildItemDefinition (smtk::attribute::ItemDefinitionPtr cdef) |
Adds a children item definition to this item definition. More... | |
bool | addItemDefinition (smtk::attribute::ItemDefinitionPtr cdef) |
This method is identical to addChildItemDefinition and exists for JSON serialization. | |
template<typename T > | |
smtk::internal::shared_ptr_type< T >::SharedPointerType | addItemDefinition (const std::string &idName) |
std::size_t | addConditional (const std::string &resourceQuery, const std::string &componentQuery, const std::vector< std::string > &itemNames) |
Add a new conditional to the definition. More... | |
bool | hasChildItemDefinition (std::size_t ith, const std::string &itemName) |
returns true if ith conditional has a child item definition of itemName | |
std::size_t | numberOfConditionals () const |
Return the number of conditionals. | |
const std::vector< std::vector< std::string > > & | conditionalInformation () const |
Return the conditional item name information. | |
const std::vector< std::string > & | conditionalItems (std::size_t ith) const |
Return the vector of item names that correspond to the i th conditional. | |
const std::vector< std::string > & | resourceQueries () const |
Return the vector of resource queries of all conditionals. | |
const std::vector< std::string > & | componentQueries () const |
Return the vector of component queries of all conditionals. | |
smtk::attribute::ItemPtr | buildItem (Attribute *owningAttribute, int itemPosition) const override |
smtk::attribute::ItemPtr | buildItem (Item *owner, int itemPos, int subGroupPosition) const override |
smtk::attribute::ItemDefinitionPtr | createCopy (smtk::attribute::ItemDefinition::CopyInfo &info) const override |
void | buildChildrenItems (ReferenceItem *ritem) const |
std::size_t | testConditionals (PersistentObjectPtr &objet) const |
![]() | |
smtkTypeMacroBase (smtk::attribute::ItemDefinition) | |
const std::string & | name () const |
const std::string & | label () const |
void | setLabel (const std::string &newLabel) |
int | version () const |
void | setVersion (int myVersion) |
bool | isOptional () const |
void | setIsOptional (bool isOptionalValue) |
bool | isEnabledByDefault () const |
void | setIsEnabledByDefault (bool isEnabledByDefaultValue) |
const smtk::attribute::Categories & | categories () const |
Returns the categories (both explicitly assigned and inherited) associated to the Item Definition. More... | |
smtk::attribute::Categories::Set & | localCategories () |
Returns the categories::Set explicitly assigned to the Items Definition. | |
const smtk::attribute::Categories::Set & | localCategories () const |
void | setLocalCategories (const smtk::attribute::Categories::Set &catSet) |
Sets the local categories. More... | |
unsigned int | advanceLevel (int mode=0) const |
unsigned int | localAdvanceLevel (int mode=0) const |
void | setLocalAdvanceLevel (int mode, unsigned int level) |
void | setLocalAdvanceLevel (unsigned int level) |
void | unsetLocalAdvanceLevel (int mode=0) |
bool | hasLocalAdvanceLevelInfo (int mode=0) const |
const std::string & | detailedDescription () const |
void | setDetailedDescription (const std::string &text) |
const std::string & | briefDescription () const |
void | setBriefDescription (const std::string &text) |
const Tags & | tags () const |
return the smtk::attribute::Tags associated with the Definition | |
const shared_ptr< units::System > & | unitsSystem () const |
Return the unitsSystem of the Definition. | |
Categories::CombinationMode | categoryInheritanceMode () const |
Determines how the Definition should combine its local category Set with the category constraints being inherited from it's owning Attribute or Item Definition. | |
void | setCategoryInheritanceMode (Categories::CombinationMode mode) |
Determines how the Definition should combine its local category Set with the category constraints being inherited from it's owning Attribute or Item Definition. | |
const Tag * | tag (const std::string &name) const |
Return a pointer to a smtk::attribute::Tag with a given name. If the Tag does not exist, return a null pointer. | |
Tag * | tag (const std::string &name) |
Return a pointer to a smtk::attribute::Tag with a given name. If the Tag does not exist, return a null pointer. | |
bool | addTag (const Tag &tag) |
Add/Remove a smtk::attribute::Tag from a Definition. | |
bool | removeTag (const std::string &name) |
Add/Remove a smtk::attribute::Tag from a Definition. | |
Static Public Member Functions | |
static ReferenceItemDefinitionPtr | New (const std::string &name) |
Static Public Attributes | |
static constexpr std::size_t | s_invalidIndex = SIZE_MAX |
Constant used to indicate an invalid conditional index. | |
Protected Member Functions | |
ReferenceItemDefinition (const std::string &myName) | |
void | copyTo (Ptr dst, smtk::attribute::ItemDefinition::CopyInfo &info) const |
Overwrite dst with a copy of this instance. | |
bool | checkResource (const smtk::resource::Resource &rsrc) const |
Return whether a resource is accepted by this definition. Used internally by isValueValid(). | |
bool | checkComponent (const smtk::resource::Component *comp) const |
Return whether a component is accepted by this definition. More... | |
bool | checkCategories (const smtk::resource::Component *comp) const |
Return whether a component passes the category requirements. More... | |
void | applyCategories (const smtk::attribute::Categories::Stack &inheritedFromParent, smtk::attribute::Categories &inheritedToParent) override |
void | setUnitsSystem (const shared_ptr< units::System > &unitsSystem) override |
Set the unitsSystem of the Definition. More... | |
![]() | |
ItemDefinition (const std::string &myname) | |
void | copyTo (ItemDefinitionPtr def) const |
virtual void | applyAdvanceLevels (const unsigned int &readLevelFromParent, const unsigned int &writeLevelFromParent) |
Protected Attributes | |
bool | m_useCommonLabel |
std::vector< std::string > | m_valueLabels |
bool | m_isExtensible |
std::size_t | m_numberOfRequiredValues |
std::size_t | m_maxNumberOfValues |
std::multimap< std::string, std::string > | m_acceptable |
std::multimap< std::string, std::string > | m_rejected |
smtk::resource::LockType | m_lockType |
smtk::resource::Links::RoleType | m_role |
bool | m_holdReference |
bool | m_enforcesCategories = false |
std::map< std::string, smtk::attribute::ItemDefinitionPtr > | m_itemDefs |
std::vector< std::string > | m_resourceQueries |
std::vector< std::string > | m_componentQueries |
std::vector< std::vector< std::string > > | m_conditionalItemNames |
![]() | |
int | m_version |
bool | m_isOptional |
bool | m_isEnabledByDefault |
std::string | m_label |
attribute::Categories::Set | m_localCategories |
attribute::Categories | m_categories |
std::string | m_detailedDescription |
std::string | m_briefDescription |
bool | m_hasLocalAdvanceLevelInfo [2] |
unsigned int | m_localAdvanceLevel [2] |
unsigned int | m_advanceLevel [2] |
attribute::Tags | m_tags |
Categories::CombinationMode | m_combinationMode |
std::shared_ptr< units::System > | m_unitsSystem |
Friends | |
class | ValueItemDefinition |
class | Definition |
A definition for attribute items that store smtk::resource::PersistentObjectPtr as values.
Subclasses should implement
bool smtk::attribute::ReferenceItemDefinition::addChildItemDefinition | ( | smtk::attribute::ItemDefinitionPtr | cdef | ) |
Adds a children item definition to this item definition.
Returns false if there is already a child item definition with the same name.
std::size_t smtk::attribute::ReferenceItemDefinition::addConditional | ( | const std::string & | resourceQuery, |
const std::string & | componentQuery, | ||
const std::vector< std::string > & | itemNames | ||
) |
Add a new conditional to the definition.
A conditional is represented by 3 things:
Note when assigning resources, only the resource query will be used, hence the component query can be empty In the case of components, the resource query can be empty iff the reference item can only be assigned to components of the same "type" of resources.
|
protected |
Return whether a component passes the category requirements.
This is used for comps that are Attributes The pointer is being based so dynamic casting can be used
|
protected |
Return whether a component is accepted by this definition.
Used internally by isValueValid(). The pointer is being based so dynamic casting can be used
|
inline |
Return the map of children item definitions.
Note that the key is the name of the item definition
|
inline |
Get the reference's role when generating links between the containing attribute and the reference item.
By default, this value is set to smtk::attribute::Resource::ReferenceRole.
|
inline |
Set/Get a flag to determine whether the ReferenceItem should keep an assigned reference in memory (i.e.
shared_ptr vs weak_ptr to the reference).
|
inline |
Set/Get the reference resource's lock type (Read/Write/DoNotLock) for read lock, write lock or bypass lock.
The default is DoNotLock.
|
inlinevirtual |
Set/Get a flag to determine whether the ReferenceItem should only hold references.
Currently, there is no convention for assigning a filter that only accepts references. This feature is required when associations (which cannot be sub-classed to ResourceItems) must be restricted as such.
|
inline |
Set the reference's role when generating links between the containing attribute and the reference item.
By default, this value is set to smtk::attribute::Resource::ReferenceRole. Note that attribute::Definition needs to be able call this method when this object is used for its association rule
|
overrideprotectedvirtual |
Set the unitsSystem of the Definition.
Note that this should be done before units are specified in the Definition
Reimplemented from smtk::attribute::ItemDefinition.