SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Stores the definition of an attribute. More...
#include <Definition.h>
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, WeakDefinitionPtrCompare > | WeakDefinitionSet |
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::DefinitionPtr & | baseDefinition () 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::Categories & | categories () const |
Returns the categories (both explicitly assigned and inherited) associated to the Definition. More... | |
smtk::attribute::Categories::Set & | localCategories () |
Returns the categories explicitly assigned to the Definition. | |
const smtk::attribute::Categories::Set & | localCategories () 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) |
unsetLocalAdvanceLevel causes the definition to return its base definition advance level information for the specified mode when calling the advanceLevel(mode) method or 0 if there is no base definition | |
bool | hasLocalAdvanceLevelInfo (int mode=0) const |
Returns true if the definition is returning its local advance level information. | |
bool | isUnique () const |
Indicates if a persistent object can have multiple attributes of this type associated with it (true means it can not) | |
void | setIsUnique (bool isUniqueValue) |
Setting isUnique to be true indicates that only one attribute of this defintion (or any definition derived from this) can be associated to a persistent object. | |
bool | isNodal () const |
Indicates if the attribute applies to the nodes of the analysis mesh. | |
void | setIsNodal (bool isNodalValue) |
const double * | notApplicableColor () const |
Color Specifications Color in the case the attribute does not exist on the model entity If the color has not been set and the def has no base definition it will return s_notApplicableBaseColor. | |
void | setNotApplicableColor (double r, double g, double b, double alpha) |
void | setNotApplicableColor (const double *color) |
void | unsetNotApplicableColor () |
By unsetting the color it is now inherited from the def's base definition. | |
bool | isNotApplicableColorSet () const |
const double * | defaultColor () const |
Default Color for attributes created from this definition - If the color has not been set and the def has no base definition it will return s_defaultBaseColor. | |
void | setDefaultColor (double r, double g, double b, double alpha) |
void | setDefaultColor (const double *color) |
void | unsetDefaultColor () |
By unsetting the color it is now inherited from the def's base definition. | |
bool | isDefaultColorSet () const |
ConstReferenceItemDefinitionPtr | associationRule () const |
Return the definition's rule that governs attribute associations. More... | |
ReferenceItemDefinitionPtr | localAssociationRule () const |
Return the local association rule if one is set. More... | |
ReferenceItemDefinitionPtr | createLocalAssociationRule (const std::string &name=std::string()) |
Create a new local association rule (if needed) and returns it. More... | |
virtual void | setLocalAssociationRule (ReferenceItemDefinitionPtr) |
Set the local Association Rule for the definition that overrides the base definition rule. More... | |
smtk::model::BitFlags | associationMask () const |
Returns the association mask used by the definition for model association Note that this may come from the base definition if there is no local association rule. More... | |
void | setLocalAssociationMask (smtk::model::BitFlags mask) |
Sets the association mask - note that this will always create a local association rule. More... | |
void | clearLocalAssociationRule () |
Removes the local association rule. 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 |
Tests to see if attributes based on this definition can be associated with a persistent object - see the documentation for AssociationResultType for details on return values. More... | |
bool | checkAssociationRules (smtk::resource::ConstPersistentObjectPtr object) const |
Check the association rules of the definition (and the definiion it derived from) to see if the object can be associated. | |
AttributePtr | checkForConflicts (smtk::resource::ConstPersistentObjectPtr object) const |
Test to see if there is a conflict between this definition and attributes already associated to the object. More... | |
DefinitionPtr | checkForPrerequisites (smtk::resource::ConstPersistentObjectPtr object) const |
Test to see if there is a missing prerequisite attribute that would prevent attributes of this type from being associated to the object. More... | |
std::set< AttributePtr > | attributes (const smtk::resource::ConstPersistentObjectPtr &object) const |
Return all of the attributes associated with object that are derived from this definition. | |
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) |
Item definitions are the definitions of what data is stored in the attribute. More... | |
template<typename T > | |
smtk::internal::shared_ptr_type< T >::SharedPointerType | addItemDefinition (const std::string &name) |
bool | removeItemDefinition (ItemDefinitionPtr itemDef) |
This method will only remove the specified ItemDefinition (if it exists) from the class internals. More... | |
int | findItemPosition (const std::string &name) const |
Return the integer offset of the item with the given name or -1 if not found. | |
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 |
Build an attribute corresponding to this definition. More... | |
void | setRootName (const std::string &val) |
Sets and returns the root name to be used to construct the name for an attribute. More... | |
std::string | rootName () const |
void | resetItemOffset () |
This method resets the definition item offset - this is used by the resource when a definition is modified. | |
std::size_t | itemOffset () const |
void | setIncludeIndex (std::size_t index) |
These methods are use primarily by I/O operations. More... | |
std::size_t | includeIndex () const |
void | addExclusion (smtk::attribute::DefinitionPtr def) |
Since Exclusion Constraints are symmetric this method will also insert this "definiton" into def. | |
void | removeExclusion (smtk::attribute::DefinitionPtr def) |
Since Exclusion Constriants are symmetric this method will also remove this "definition" from def. | |
const WeakDefinitionSet | exclusions () const |
std::vector< std::string > | excludedTypeNames () const |
Return a list of sorted type names that exlude this type of attribute. | |
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 |
Return a sort of list of type names that are prerequisite to the type of attribute. | |
smtk::attribute::ConstDefinitionPtr | hasPrerequisite (smtk::attribute::ConstDefinitionPtr def) const |
Return nullptr if def is not a prerequisite of this Definition else return the prerequisite definition that def is derived from. | |
bool | hasPrerequisites () const |
Returns true if the definition has prerequisites (which can be inherited) | |
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. | |
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) | |
class | smtk::attribute::Resource |
Used to keep track of how many definitions are using this one as a prerequisite. | |
smtk::attribute::WeakResourcePtr | m_resource |
Used to keep track of how many definitions are using this one as a prerequisite. | |
int | m_version |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | m_isAbstract |
Used to keep track of how many definitions are using this one as a prerequisite. | |
smtk::attribute::DefinitionPtr | m_baseDefinition |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::string | m_type |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::string | m_label |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | m_isNodal |
Used to keep track of how many definitions are using this one as a prerequisite. | |
attribute::Categories::Set | m_localCategories |
Used to keep track of how many definitions are using this one as a prerequisite. | |
attribute::Categories | m_categories |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | m_hasLocalAdvanceLevelInfo [2] |
Used to keep track of how many definitions are using this one as a prerequisite. | |
unsigned int | m_localAdvanceLevel [2] |
Used to keep track of how many definitions are using this one as a prerequisite. | |
unsigned int | m_advanceLevel [2] |
Used to keep track of how many definitions are using this one as a prerequisite. | |
WeakDefinitionSet | m_exclusionDefs |
Used to keep track of how many definitions are using this one as a prerequisite. | |
WeakDefinitionSet | m_prerequisiteDefs |
Used to keep track of how many definitions are using this one as a prerequisite. | |
size_t | m_prerequisiteUsageCount |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::vector< smtk::attribute::ItemDefinitionPtr > | m_itemDefs |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::map< std::string, int > | m_itemDefPositions |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | m_isUnique |
Is Unique indicates if more than one attribute of this type can be assigned to a model entity - this constraint is implimented by using adding the definition itself into its exclusion list. | |
bool | m_isRequired |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | m_isNotApplicableColorSet |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | m_isDefaultColorSet |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | m_ignoreCategories = false |
Used to keep track of how many definitions are using this one as a prerequisite. | |
smtk::attribute::ReferenceItemDefinitionPtr | m_acceptsRules |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::string | m_detailedDescription |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::string | m_briefDescription |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::size_t | m_baseItemOffset |
Used by the find method to calculate an item's position. | |
std::string | m_rootName |
Used to keep track of how many definitions are using this one as a prerequisite. | |
Tags | m_tags |
Used to keep track of how many definitions are using this one as a prerequisite. | |
std::size_t | m_includeIndex |
Used to keep track of how many definitions are using this one as a prerequisite. | |
Categories::CombinationMode | m_combinationMode |
Used to keep track of how many definitions are using this one as a prerequisite. | |
bool | ignoreCategories () const |
Indicates that the Definition's validity (and relevancy) does not depends on the Resource's set of active categories. More... | |
void | setIgnoreCategories (bool val) |
Used to keep track of how many definitions are using this one as a prerequisite. | |
Definition (const std::string &myType, smtk::attribute::DefinitionPtr myBaseDef, smtk::attribute::ResourcePtr myResource) | |
AttributeDefinitions can only be created by an attribute resource. | |
void | clearResource () |
Used to keep track of how many definitions are using this one as a prerequisite. | |
void | applyCategories (smtk::attribute::Categories::Stack inherited) |
apply the local categories of the definition and its items. More... | |
void | updateDerivedDefinitions () |
This method updates derived definitions when this definition's items have been changed. | |
virtual void | applyAdvanceLevels (const unsigned int &readLevelFromParent, const unsigned int &writeLevelFromParent) |
update the advance level information of the definition and its items. More... | |
void | setItemDefinitionUnitsSystem (const smtk::attribute::ItemDefinitionPtr &itemDef) const |
Used to keep track of how many definitions are using this one as a prerequisite. | |
Stores the definition of an attribute.
Stores all of the necessary information for a definition of a single attribute. Instances of a definition should be created through Resource::createAttribute().
bool Definition::addItemDefinition | ( | smtk::attribute::ItemDefinitionPtr | cdef | ) |
Item definitions are the definitions of what data is stored in the attribute.
For example, an IntItemDefinition would store an integer value.
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
|
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.
|
protected |
apply the local categories of the definition and its items.
inherited is an initial set passed down from the definition's base.
smtk::model::BitFlags Definition::associationMask | ( | ) | const |
Returns the association mask used by the definition for model association Note that this may come from the base definition if there is no local association rule.
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
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.
void Definition::buildAttribute | ( | smtk::attribute::Attribute * | attribute | ) | const |
Build an attribute corresponding to this definition.
If the attribute already has items, clear them out.
Definition::AssociationResultType Definition::canBeAssociated | ( | smtk::resource::ConstPersistentObjectPtr | object, |
AttributePtr & | conflictAtt, | ||
DefinitionPtr & | prerequisiteDef | ||
) | const |
Tests to see if attributes based on this definition can be associated with a persistent object - see the documentation for AssociationResultType for details on return values.
Return whether this attribute can be associated with the given object.
If a conflict is found, conflictAtt is set to the conflicting attribute If a prerequisite is missing, prerequisiteDef is set to the missing requirement NOTE - testing is completed once a problem has been detected. There maybe be other issues preventing association so this method may need be called multiple times
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
|
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.
AttributePtr Definition::checkForConflicts | ( | smtk::resource::ConstPersistentObjectPtr | object | ) | const |
Test to see if there is a conflict between this definition and attributes already associated to the object.
Returns the conflicting attribute if there is a conflict
DefinitionPtr Definition::checkForPrerequisites | ( | smtk::resource::ConstPersistentObjectPtr | object | ) | const |
Test to see if there is a missing prerequisite attribute that would prevent attributes of this type from being associated to the object.
Returns the missing prerequisite definition
void Definition::clearLocalAssociationRule | ( | ) |
Removes the local association rule.
Reoved the local assocaition rule on the definition.
The Definition will now inherit its association rule from its Base Definition.
ReferenceItemDefinitionPtr Definition::createLocalAssociationRule | ( | const std::string & | name = std::string() | ) |
Create a new local association rule (if needed) and returns it.
Create the definition's local association rule that governs attribute associations.
If a non-empty name is provided and there is no pre-existing association rule, the newly-created instance will be given the name.
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).
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.
values | a container which holds definitions |
test | a 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; } |
|
inline |
Indicates that the Definition's validity (and relevancy) does not depends on the Resource's set of active categories.
This is very useful for modeling information such as Analysis Definitions since they set active categories but don't use categories themselves.
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.
ReferenceItemDefinitionPtr Definition::localAssociationRule | ( | ) | const |
Return the local association rule if one is set.
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.
bool Definition::removeItemDefinition | ( | ItemDefinitionPtr | itemDef | ) |
This method will only remove the specified ItemDefinition (if it exists) from the class internals.
Only ItemDefinitions local to this Definition can be removed. Remove inherited ItemDefinitinos directy from the inherited type.
Warning: It is up to the caller to ensure integrity of the attribute::Resource instance (e.g. Attribute instances of this Definition type need to be cleansed from the Resource).
|
inline |
These methods are use primarily by I/O operations.
The include ID corresponds to the include directory information store in the attribute reosurce and is used when writing out the resource to use include files
void Definition::setLocalAssociationMask | ( | smtk::model::BitFlags | mask | ) |
Sets the association mask - note that this will always create a local association rule.
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
|
virtual |
Set the local Association Rule for the definition that overrides the base definition rule.
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.
|
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.
|
inline |
Sets and returns the root name to be used to construct the name for an attribute.
This is used by the attribute resource when creating an attribute without specifying a name - by default it is set to be the type name of the definition