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

Classes

struct  WeakDefinitionPtrCompare
 

Public Types

enum  AssociationResultType { AssociationResultType::Valid, AssociationResultType::Illegal, AssociationResultType::Conflict, AssociationResultType::Prerequisite }
 Return types for canBeAssociated method. More...
 
typedef std::set< WeakDefinitionPtr, WeakDefinitionPtrCompareWeakDefinitionSet
 

Public Member Functions

 smtkTypeMacroBase (smtk::attribute::Definition)
 
const std::string & type () const
 
smtk::attribute::ResourcePtr resource () const
 
const Tags & tags () const
 return the smtk::attribute::Tags associated with the Definition
 
const std::string & displayedTypeName () const
 
const std::string & label () const
 
void setLabel (const std::string &newLabel)
 
const smtk::attribute::DefinitionPtrbaseDefinition () const
 
bool isA (smtk::attribute::ConstDefinitionPtr def) const
 
bool isRelevant (bool includeCategories=true, bool includeReadAccess=false, unsigned int readAccessLevel=0) const
 Returns true if the definition is relevant. More...
 
int version () const
 
void setVersion (int myVersion)
 
bool isAbstract () const
 
void setIsAbstract (bool isAbstractValue)
 
const smtk::attribute::Categoriescategories () const
 Returns the categories (both explicitly assigned and inherited) associated to the Definition. More...
 
smtk::attribute::Categories::SetlocalCategories ()
 Returns the categories explicitly assigned to the Definition.
 
const smtk::attribute::Categories::SetlocalCategories () const
 
void setLocalCategories (const smtk::attribute::Categories::Set &catSet)
 Sets the local categories. More...
 
template<typename T >
void filterItemDefinitions (T &values, std::function< bool(typename T::value_type)> test)
 Given a container, filter item definitions in the definition by a lambda function. More...
 
unsigned int advanceLevel (int mode=0) const
 Get the Definition 's advance level. More...
 
void setLocalAdvanceLevel (int mode, unsigned int level)
 
void setLocalAdvanceLevel (unsigned int level)
 
unsigned int localAdvanceLevel (int mode=0) const
 
void unsetLocalAdvanceLevel (int mode=0)
 
bool hasLocalAdvanceLevelInfo (int mode=0) const
 
bool isUnique () const
 
void setIsUnique (bool isUniqueValue)
 
bool isNodal () const
 
void setIsNodal (bool isNodalValue)
 
const double * notApplicableColor () const
 
void setNotApplicableColor (double r, double g, double b, double alpha)
 
void setNotApplicableColor (const double *color)
 
void unsetNotApplicableColor ()
 
bool isNotApplicableColorSet () const
 
const double * defaultColor () const
 
void setDefaultColor (double r, double g, double b, double alpha)
 
void setDefaultColor (const double *color)
 
void unsetDefaultColor ()
 
bool isDefaultColorSet () const
 
ConstReferenceItemDefinitionPtr associationRule () const
 Return the definition's rule that governs attribute associations. More...
 
ReferenceItemDefinitionPtr localAssociationRule () const
 Return the definition's local association rule that governs attribute associations. More...
 
ReferenceItemDefinitionPtr createLocalAssociationRule ()
 Create the definition's local association rule that governs attribute associations. More...
 
virtual void setLocalAssociationRule (ReferenceItemDefinitionPtr)
 Set the rule that decides which model entities may be associated with instances of this definition. More...
 
smtk::model::BitFlags associationMask () const
 Return the mask specifying which types of model entities this attribute can be associated with. More...
 
void setLocalAssociationMask (smtk::model::BitFlags mask)
 Set the mask specifying which types of model entities this attribute can be associated with. More...
 
void clearLocalAssociationRule ()
 Reoved the local assocaition rule on the definition. More...
 
bool associatesWithVertex () const
 Returns whether this attribute can be associated with vertices.
 
bool associatesWithEdge () const
 Returns whether this attribute can be associated with edges.
 
bool associatesWithFace () const
 Returns whether this attribute can be associated with faces.
 
bool associatesWithVolume () const
 Returns whether this attribute can be associated with volumes.
 
bool associatesWithModel () const
 Returns whether this attribute can be associated with models.
 
bool associatesWithGroup () const
 Returns whether this attribute can be associated with groups.
 
bool canBeAssociated (smtk::model::BitFlags maskType) const
 Return whether this attribute can be associated with entities that have the given flag value.
 
AssociationResultType canBeAssociated (smtk::resource::ConstPersistentObjectPtr object, AttributePtr &conflictAtt, DefinitionPtr &prerequisiteDef) const
 Return whether this attribute can be associated with the given object. More...
 
bool checkAssociationRules (smtk::resource::ConstPersistentObjectPtr object) const
 
AttributePtr checkForConflicts (smtk::resource::ConstPersistentObjectPtr object) const
 
DefinitionPtr checkForPrerequisites (smtk::resource::ConstPersistentObjectPtr object) const
 
std::set< AttributePtrattributes (const smtk::resource::ConstPersistentObjectPtr &object) const
 
bool conflicts (smtk::attribute::DefinitionPtr definition) const
 
std::size_t numberOfItemDefinitions () const
 
smtk::attribute::ItemDefinitionPtr itemDefinition (int ith) const
 
const std::vector< smtk::attribute::ItemDefinitionPtr > & localItemDefinitions () const
 
bool addItemDefinition (smtk::attribute::ItemDefinitionPtr cdef)
 
template<typename T >
smtk::internal::shared_ptr_type< T >::SharedPointerType addItemDefinition (const std::string &name)
 
bool removeItemDefinition (ItemDefinitionPtr itemDef)
 
int findItemPosition (const std::string &name) const
 
const std::string & detailedDescription () const
 
void setDetailedDescription (const std::string &text)
 
const std::string & briefDescription () const
 
void setBriefDescription (const std::string &text)
 
void buildAttribute (smtk::attribute::Attribute *attribute) const
 
void setRootName (const std::string &val)
 
std::string rootName () const
 
void resetItemOffset ()
 
std::size_t itemOffset () const
 
void setIncludeIndex (std::size_t index)
 
std::size_t includeIndex () const
 
void addExclusion (smtk::attribute::DefinitionPtr def)
 
void removeExclusion (smtk::attribute::DefinitionPtr def)
 
const WeakDefinitionSet exclusions () const
 
std::vector< std::string > excludedTypeNames () const
 
void addPrerequisite (smtk::attribute::DefinitionPtr def)
 
bool isUsedAsAPrerequisite () const
 Returns true if the definition is used as a prerequisite.
 
void removePrerequisite (smtk::attribute::DefinitionPtr def)
 
const WeakDefinitionSet prerequisites () const
 
std::vector< std::string > prerequisiteTypeNames () const
 
smtk::attribute::ConstDefinitionPtr hasPrerequisite (smtk::attribute::ConstDefinitionPtr def) const
 
bool hasPrerequisites () const
 Returns true if the definition has prerequisites (which can be inherited)
 
const Tagtag (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.
 
Tagtag (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.
 
bool isOkToInherit () const
 Indicates if the Definition can inherit categories based on it's parent Definition or its owning Attribute Definition. More...
 
void setIsOkToInherit (bool isOkToInheritValue)
 Indicates if the Definition can inherit categories based on it's parent Definition or its owning Attribute Definition. More...
 
Categories::CombinationMode categoryInheritanceMode () const
 Determines how the Definition should combine its local category Set with the category constraints being inherited from it's Base Definition (if one exists)
 
void setCategoryInheritanceMode (Categories::CombinationMode mode)
 Determines how the Definition should combine its local category Set with the category constraints being inherited from it's Base Definition (if one exists)
 

Protected Member Functions

 Definition (const std::string &myType, smtk::attribute::DefinitionPtr myBaseDef, smtk::attribute::ResourcePtr myResource)
 
void clearResource ()
 
void applyCategories (smtk::attribute::Categories::Stack inherited)
 apply the local categories of the definition and its items. More...
 
void updateDerivedDefinitions ()
 
virtual void applyAdvanceLevels (const unsigned int &readLevelFromParent, const unsigned int &writeLevelFromParent)
 update the advance level information of the definition and its items. More...
 

Protected Attributes

smtk::attribute::WeakResourcePtr m_resource
 
int m_version
 
bool m_isAbstract
 
smtk::attribute::DefinitionPtr m_baseDefinition
 
std::string m_type
 
std::string m_label
 
bool m_isNodal
 
attribute::Categories::Set m_localCategories
 
attribute::Categories m_categories
 
bool m_hasLocalAdvanceLevelInfo [2]
 
unsigned int m_localAdvanceLevel [2]
 
unsigned int m_advanceLevel [2]
 
WeakDefinitionSet m_exclusionDefs
 
WeakDefinitionSet m_prerequisiteDefs
 
size_t m_prerequisiteUsageCount
 Used to keep track of how many definitions are using this one as a prerequisite.
 
std::vector< smtk::attribute::ItemDefinitionPtrm_itemDefs
 
std::map< std::string, int > m_itemDefPositions
 
bool m_isUnique
 
bool m_isRequired
 
bool m_isNotApplicableColorSet
 
bool m_isDefaultColorSet
 
smtk::attribute::ReferenceItemDefinitionPtr m_acceptsRules
 
std::string m_detailedDescription
 
std::string m_briefDescription
 
std::size_t m_baseItemOffset
 
std::string m_rootName
 
Tags m_tags
 
std::size_t m_includeIndex
 
Categories::CombinationMode m_combinationMode
 

Friends

class smtk::attribute::Resource
 

Member Enumeration Documentation

◆ AssociationResultType

Return types for canBeAssociated method.

Enumerator
Valid 

Association is allowed.

Illegal 

Association with the given component type is disallowed.

Conflict 

An association with a mutually exclusive attribute already exists.

Prerequisite 

A prerequisite association does not yet exist.

Member Function Documentation

◆ advanceLevel()

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

Get the Definition '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 specificied directly to the definition using setLocalAdvanceLevel() or from the definition's base definition. If the definition does not have either a local advance level or a base definition, then 0 is returned. NOTE: This information is used in GUI only

◆ applyAdvanceLevels()

void Definition::applyAdvanceLevels ( const unsigned int &  readLevelFromParent,
const unsigned int &  writeLevelFromParent 
)
protectedvirtual

update the advance level information of the definition and its items.

readLevelFromParent and writeLevelFromParent are the advance level information coming from the Definition's Base Definition. The Definition's advance level member are set to these values if the Definition does not have local versions set.

◆ applyCategories()

void Definition::applyCategories ( smtk::attribute::Categories::Stack  inherited)
protected

apply the local categories of the definition and its items.

inherited is an initial set passed down from the definition's base.

◆ associationMask()

smtk::model::BitFlags Definition::associationMask ( ) const

Return the mask specifying which types of model entities this attribute can be associated with.

As with the associationRule() method, the mask can be inherited from the Base Definition if it is not set locally

◆ associationRule()

ConstReferenceItemDefinitionPtr Definition::associationRule ( ) const

Return the definition's rule that governs attribute associations.

A ReferenceItemDefinition is used to store information about the allowable associations that may be made between attributes specified by this definition and model entities.

The definition's list of acceptable resources/components serves as a mask for allowable associations while the definition's minimum and maximum number of associations can be used to indicate whether an association is required, optional, and/or extensible.

A Definition can inherit the association rule from its Base Definition when it does not have a local association rule specified.

◆ canBeAssociated()

Definition::AssociationResultType Definition::canBeAssociated ( smtk::resource::ConstPersistentObjectPtr  object,
AttributePtr conflictAtt,
DefinitionPtr prerequisiteDef 
) const

Return whether this attribute can be associated with the given object.

This method first tests to see if the attribute can be associated with the object based on the attribute definition's association rules. If the object fails the check AssociationResultType::Illegal is returned. Else the attribute definition's exclusion rules are checked. If it fails this test, Definition::AssociationResultType::Conflict is returned along with the conflicting attributes. Finally, the attribute definition's prerequisite rules are tested. If it fails this test, Definition::AssociationResultType::Prerequisite is returned along with the missing prerequiste attribute definition. If all checks pass, Definition::AssociationResultType::Valid is returned.

Note that testing is stop when the first issue is found so there may be additional issues beyond the one reported. For example, there may be multiple conflicts and/or missing prerequisites

◆ categories()

const smtk::attribute::Categories& smtk::attribute::Definition::categories ( ) const
inline

Returns the categories (both explicitly assigned and inherited) associated to the Definition.

The categories that the attribute applies to. Typically a category will be a simulation type like heat transfer, fluid flow, etc.

◆ clearLocalAssociationRule()

void Definition::clearLocalAssociationRule ( )

Reoved the local assocaition rule on the definition.

The Definition will now inherit its association rule from its Base Definition.

◆ createLocalAssociationRule()

ReferenceItemDefinitionPtr Definition::createLocalAssociationRule ( )

Create the definition's local association rule that governs attribute associations.

A Definition's local association rule overrides the rule it inherits from its Base Definition. This creates a local association rule (if one does not already exist) and returns it. The default is to create an empty association rule (nothing can be associated).

◆ filterItemDefinitions()

template<typename T >
void smtk::attribute::Definition::filterItemDefinitions ( T &  values,
std::function< bool(typename T::value_type)>  test 
)

Given a container, filter item definitions in the definition by a lambda function.

Parameters
valuesa container which holds definitions
testa lambda function which would be applied on children item definitions Example filter double and int item definitions [](Item::Ptr item) { return item->type() == DOUBLE || item->type() == INT; } Example filter modelEntity item definitions [](ModelEntity::Ptr item) { return true; }

◆ isOkToInherit()

bool Definition::isOkToInherit ( ) const

Indicates if the Definition can inherit categories based on it's parent Definition or its owning Attribute Definition.

The default is true.

◆ isRelevant()

bool Definition::isRelevant ( bool  includeCategories = true,
bool  includeReadAccess = false,
unsigned int  readAccessLevel = 0 
) const

Returns true if the definition is relevant.

If includeCatagories is true and the definition does not pass it's category checks with respects to the resource's active category settings then return false, If includeReadAccess is true, and if all of the item definitions in the attribute have their advanceLevel > readAccessLevel then return false. Else return true.

◆ localAssociationRule()

ReferenceItemDefinitionPtr Definition::localAssociationRule ( ) const

Return the definition's local association rule that governs attribute associations.

A Definition's local association rule overrides the rule it inherits from its Base Definition. This method can return a nullptr. Note that the ReferenceDefinition returned is not constant. Modifying it will change the Definition's association behavior.

◆ setIsOkToInherit()

void Definition::setIsOkToInherit ( bool  isOkToInheritValue)

Indicates if the Definition can inherit categories based on it's parent Definition or its owning Attribute Definition.

The default is true.

◆ setLocalAssociationMask()

void Definition::setLocalAssociationMask ( smtk::model::BitFlags  mask)

Set the mask specifying which types of model entities this attribute can be associated with.

Note that this will create a local association rule if the Definition did not already have one specified

◆ setLocalAssociationRule()

void Definition::setLocalAssociationRule ( ReferenceItemDefinitionPtr  rule)
virtual

Set the rule that decides which model entities may be associated with instances of this definition.

This will override the association rule the definition inherits from the Definition's Base Definition.

◆ setLocalCategories()

void smtk::attribute::Definition::setLocalCategories ( const smtk::attribute::Categories::Set catSet)
inline

Sets the local categories.

This method is intended for use by Python applications, because Python code cannot manipulate the reference returned by the localCategories() method.


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