SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Classes | Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
smtk::attribute::Resource Class Reference

Store information about attribute definitions and instances. More...

#include <Resource.h>

Inheritance diagram for smtk::attribute::Resource:
[legend]
Collaboration diagram for smtk::attribute::Resource:
[legend]

Classes

class  GuardedLinks
 

Public Types

typedef smtk::geometry::Resource ParentResource
 
- Public Types inherited from smtk::resource::DerivedFrom< Resource, smtk::geometry::Resource >
typedef smtk::geometry::Resource ParentResource
 
- Public Types inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
typedef smtk::resource::Resource ParentResource
 
- Public Types inherited from smtk::resource::Resource
typedef std::size_t Index
 
typedef smtk::resource::Metadata Metadata
 
typedef detail::ResourceLinks Links
 
typedef detail::ResourceProperties Properties
 
typedef query::Queries Queries
 

Public Member Functions

 smtkTypeMacro (smtk::attribute::Resource)
 
 smtkCreateMacro (smtk::attribute::Resource)
 
 smtkSharedFromThisMacro (smtk::resource::PersistentObject)
 
bool setUnitsSystem (const shared_ptr< units::System > &unitsSystem) override
 Sets and Gets the system of units used by this resource.
 
smtk::attribute::DefinitionPtr createDefinition (const std::string &typeName, const std::string &baseTypeName="")
 
smtk::attribute::DefinitionPtr createDefinition (const std::string &name, attribute::DefinitionPtr baseDefiniiton)
 
bool removeDefinition (smtk::attribute::DefinitionPtr def)
 
void setIsPrivate (bool isPrivateValue)
 
bool isPrivate () const
 
const std::string & defaultNameSeparator () const
 Get the separator used for new Attributes whose names are not unique.
 
void resetDefaultNameSeparator ()
 Reset the separator used for new Attributes whose names are not unique to to the default which is '-'.
 
bool setDefaultNameSeparator (const std::string &separator)
 Set the separator used for new Attributes whose names are not unique.
 
smtk::attribute::AttributePtr createAttribute (const std::string &name, const std::string &type)
 
smtk::attribute::AttributePtr createAttribute (attribute::DefinitionPtr def)
 
smtk::attribute::AttributePtr createAttribute (const std::string &type)
 
smtk::attribute::AttributePtr createAttribute (const std::string &name, attribute::DefinitionPtr def)
 
bool removeAttribute (smtk::attribute::AttributePtr att)
 
smtk::attribute::AttributePtr findAttribute (const std::string &name) const
 
smtk::attribute::AttributePtr findAttribute (const smtk::common::UUID &id) const
 
smtk::attribute::AttributePtr findAttribute (const smtk::resource::ComponentPtr &comp, const smtk::resource::Links::RoleType &role) const
 
void addUniqueRoles (const std::set< smtk::resource::Links::RoleType > &roles)
 
void addUniqueRole (const smtk::resource::Links::RoleType &role)
 
const std::set< smtk::resource::Links::RoleType > & uniqueRoles () const
 
bool isRoleUnique (const smtk::resource::Links::RoleType &role) const
 
smtk::resource::ComponentPtr find (const smtk::common::UUID &id) const override
 Given a resource component's UUID, return the resource component.
 
std::function< bool(const smtk::resource::Component &)> queryOperation (const std::string &) const override
 Given a std::string describing a query, return a functor for performing the query. More...
 
void visit (smtk::resource::Component::Visitor &) const override
 
void findAttributes (const std::string &type, std::vector< smtk::attribute::AttributePtr > &result) const
 
std::vector< smtk::attribute::AttributePtrfindAttributes (const std::string &type) const
 
void findAttributes (smtk::attribute::DefinitionPtr def, std::vector< smtk::attribute::AttributePtr > &result) const
 
smtk::attribute::DefinitionPtr findDefinition (const std::string &type) const
 
void findBaseDefinitions (std::vector< smtk::attribute::DefinitionPtr > &result) const
 
void derivedDefinitions (smtk::attribute::DefinitionPtr def, std::vector< smtk::attribute::DefinitionPtr > &result) const
 
void findAllDerivedDefinitions (smtk::attribute::DefinitionPtr def, bool concreteOnly, std::vector< smtk::attribute::DefinitionPtr > &result) const
 
void findDefinitionAttributes (const std::string &type, std::vector< smtk::attribute::AttributePtr > &result) const
 
void findDefinitions (unsigned long mask, std::vector< smtk::attribute::DefinitionPtr > &result) const
 Find the attribute definitions that can be associated with mask.
 
smtk::attribute::ConstDefinitionPtr findIsUniqueBaseClass (smtk::attribute::ConstDefinitionPtr attDef) const
 
bool rename (AttributePtr att, const std::string &newName)
 
smtk::attribute::Analysesanalyses ()
 
std::size_t numberOfAdvanceLevels () const
 
void addAdvanceLevel (int level, std::string label, const double *l_color=nullptr)
 
const std::map< int, std::string > & advanceLevels () const
 
const double * advanceLevelColor (int level) const
 
void setAdvanceLevelColor (int level, const double *l_color)
 
smtk::attribute::AttributePtr createAttribute (const std::string &name, const std::string &type, const smtk::common::UUID &id)
 
smtk::attribute::AttributePtr createAttribute (const std::string &name, attribute::DefinitionPtr def, const smtk::common::UUID &id)
 
std::string createUniqueName (const std::string &type) const
 
void finalizeDefinitions ()
 This method updates information passed down to Attribute and Item Definitions. More...
 
bool passActiveCategoryCheck (const smtk::attribute::Categories::Set &cats) const
 
bool passActiveCategoryCheck (const smtk::attribute::Categories &cats) const
 
void addView (smtk::view::ConfigurationPtr)
 
smtk::view::ConfigurationPtr findView (const std::string &name) const
 
smtk::view::ConfigurationPtr findViewByType (const std::string &vtype) const
 
smtk::view::ConfigurationPtr findTopLevelView () const
 
std::vector< smtk::view::ConfigurationPtrfindTopLevelViews () const
 
const std::map< std::string, smtk::view::ConfigurationPtr > & views () const
 
smtk::resource::ResourceSet associations () const
 Return a set of resources associated to this attribute resource.
 
bool associate (const smtk::resource::ResourcePtr &resource)
 Add a resource to the set of associated resources, and return true if the association is successful.
 
bool disassociate (const smtk::resource::ResourcePtr &resource)
 Remove a resource from the set of associated resources, and return true if the disassociation is successful.
 
bool hasAssociations () const
 Returns true if the attribute resource has other resources associated with it.
 
std::set< AttributePtrattributes (const smtk::resource::ConstPersistentObjectPtr &object) const
 
bool hasAttributes (const smtk::resource::ConstPersistentObjectPtr &object) const
 
bool hasAttributes () const
 
void disassociateAllAttributes (const smtk::resource::PersistentObjectPtr &object)
 
void updateDerivedDefinitionIndexOffsets (smtk::attribute::DefinitionPtr def)
 
smtk::attribute::DefinitionPtr copyDefinition (smtk::attribute::DefinitionPtr def, unsigned int options=0)
 
smtk::attribute::AttributePtr copyAttribute (const smtk::attribute::AttributePtr &att, const CopyAssignmentOptions &options=CopyAssignmentOptions())
 
void definitions (std::vector< smtk::attribute::DefinitionPtr > &result, bool sortList=false) const
 
void attributes (std::vector< smtk::attribute::AttributePtr > &result) const
 
smtk::attribute::EvaluatorFactoryevaluatorFactory ()
 
const smtk::attribute::EvaluatorFactoryevaluatorFactory () const
 
bool canEvaluate (smtk::attribute::ConstAttributePtr att)
 
std::unique_ptr< smtk::attribute::EvaluatorcreateEvaluator (smtk::attribute::ConstAttributePtr att)
 
smtk::attribute::SymbolDependencyStoragesymbolDependencyStorage ()
 
void setDirectoryInfo (const DirectoryInfo &dinfo)
 
const DirectoryInfo & directoryInfo () const
 
CustomItemDefinitionFactorycustomItemDefinitionFactory ()
 
const CustomItemDefinitionFactorycustomItemDefinitionFactory () const
 
AssociationRulesassociationRules ()
 
const AssociationRulesassociationRules () const
 
const GuardedLinks guardedLinks () const
 
GuardedLinks guardedLinks ()
 
std::mutex & mutex () const
 
virtual bool setTemplateType (const smtk::string::Token &templateType)
 Set/get the "type" of a resource's template. More...
 
const smtk::string::TokentemplateType () const
 
virtual bool setTemplateVersion (std::size_t templateVersion)
 Set/get the version of the template this instance of the resource is based upon. More...
 
std::size_t templateVersion () const
 
std::size_t numberOfCategories () const
 API for accessing Category information. More...
 
const std::set< std::string > & categories () const
 API for accessing Category information. More...
 
void setActiveCategoriesEnabled (bool mode)
 API for setting and accessing Active Category information. More...
 
bool activeCategoriesEnabled () const
 API for setting and accessing Active Category information. More...
 
void setActiveCategories (const std::set< std::string > &cats)
 API for setting and accessing Active Category information. More...
 
const std::set< std::string > & activeCategories () const
 API for setting and accessing Active Category information. More...
 
void addStyle (const std::string &definitionType, smtk::view::Configuration::Component style)
 API for setting and accessing style information. More...
 
const smtk::view::Configuration::ComponentfindStyle (const smtk::attribute::DefinitionPtr &def, const std::string &styleName="") const
 API for setting and accessing style information. More...
 
const std::map< std::string, smtk::view::Configuration::Component > & findStyles (const smtk::attribute::DefinitionPtr &def) const
 API for setting and accessing style information. More...
 
const std::map< std::string, std::map< std::string, smtk::view::Configuration::Component > > & styles () const
 API for setting and accessing style information. More...
 
- Public Member Functions inherited from smtk::resource::DerivedFrom< Resource, smtk::geometry::Resource >
bool isOfType (const Resource::Index &index) const override
 given a resource index, return whether or not this resource is or is derived from the resource described by the index.
 
bool isOfType (const std::string &typeName) const override
 given a resource's unique name, return whether or not this resource is or is derived from the resource described by the name.
 
int numberOfGenerationsFromBase (const std::string &typeName) const override
 
 DerivedFrom (const DerivedFrom &)=delete
 
- Public Member Functions inherited from smtk::geometry::Resource
 smtkTypeMacro (smtk::geometry::Resource)
 
 smtkSuperclassMacro (smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >)
 
 smtkSharedFromThisMacro (smtk::resource::PersistentObject)
 
std::unique_ptr< Geometry > & geometry (const Backend &backend)
 Given a backend, return a provider of geometry for that backend. More...
 
std::unique_ptr< Geometry > & geometry ()
 Return the first geometry provider (for any backend). More...
 
void visitGeometry (std::function< void(std::unique_ptr< Geometry > &)> visitor)
 Visit all existing geometry providers for this resource. More...
 
 Resource (Resource &&)=default
 
- Public Member Functions inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
bool isOfType (const Resource::Index &index) const override
 given a resource index, return whether or not this resource is or is derived from the resource described by the index.
 
bool isOfType (const std::string &typeName) const override
 given a resource's unique name, return whether or not this resource is or is derived from the resource described by the name.
 
int numberOfGenerationsFromBase (const std::string &typeName) const override
 
 DerivedFrom (const DerivedFrom &)=delete
 
- Public Member Functions inherited from smtk::resource::Resource
 smtkTypeMacro (smtk::resource::Resource)
 
 smtkSuperclassMacro (smtk::resource::PersistentObject)
 
 smtkSharedFromThisMacro (smtk::resource::PersistentObject)
 
virtual Index index () const
 index is a compile-time intrinsic of the derived resource; as such, it cannot be set.
 
template<class ResourceType >
bool isOfType () const
 given a resource type, return whether or not this resource is or is derived from the resource described by the index.
 
const smtk::common::UUIDid () const override
 id and location are run-time intrinsics of the derived resource; we need to allow the user to reset these values.
 
const std::string & location () const
 
bool setId (const smtk::common::UUID &myID) override
 Assign an ID to this object (used by readers; not for arbitrary reuse). More...
 
bool setLocation (const std::string &location)
 
std::string name () const override
 Return the user-assigned name of the resource. More...
 
bool setName (const std::string &name)
 
bool isNameSet ()
 
virtual bool clean () const
 Indicate whether the resource is in sync with its location. More...
 
void setClean (bool state=true)
 
void setMarkedForRemoval (bool val)
 Mark the resource to indicate it is about to removed (meaning it is being removed from memory not necessarily for deletion)
 
virtual bool isMarkedForRemoval () const
 Return whether the object is marked for removal.
 
ManagerPtr manager () const
 Resources that are managed have a non-null pointer to their manager.
 
virtual Componentcomponent (const smtk::common::UUID &compId) const
 Given a component's UUID, return a raw pointer to the component.
 
template<typename ComponentType >
ComponentType * componentAs (const smtk::common::UUID &uuid) const
 A templated version of component() that casts its result to a type. More...
 
virtual void visit (std::function< void(const ComponentPtr &)> &v) const =0
 visit all components in a resource.
 
ComponentSet filter (const std::string &queryString) const
 
template<typename Collection >
Collection filterAs (const std::string &queryString) const
 given a a std::string describing a query and a type of container, return a set of components that satisfy both. More...
 
Linkslinks () override
 
const Linkslinks () const override
 
Propertiesproperties () override
 
const Propertiesproperties () const override
 
const Queriesqueries () const
 
Queriesqueries ()
 
Locklock (Key()) const
 classes that are granted permission to the key may retrieve the resource's lock.
 
LockType locked () const
 Anyone can query whether or not the resource is locked.
 
 Resource (Resource &&) noexcept
 
const shared_ptr< units::System > & unitsSystem () const
 Sets and Gets the system of units used by this resource.
 
- Public Member Functions inherited from smtk::resource::PersistentObject
 smtkTypeMacroBase (smtk::resource::PersistentObject)
 
template<typename T >
T::Ptr as ()
 Attempt to cast this object to a subclass.
 
template<typename T >
T::ConstPtr as () const
 Attempt to cast this object to a subclass.
 

Static Public Member Functions

static std::string createAttributeQuery (const smtk::attribute::DefinitionPtr &def)
 Given an attribute definition, construct a valid query to retrive attributes of that type.
 
static std::string createAttributeQuery (const std::string &defType)
 

Public Attributes

SMTK_DEPRECATED_IN_22_11("Replaced by copyAttribute(const AttributePtr&, const AttributeCopyOptions&, const " "ItemAssignmentOptions&, smtk::io::Logger&).") smtk smtk::attribute::AttributePtr copyAttribute (const smtk::attribute::AttributePtr &att, const CopyAssignmentOptions &options, smtk::io::Logger &logger)
 Copies attribute. More...
 

Static Public Attributes

static constexpr smtk::resource::Links::RoleType AssociationRole = -1
 
static constexpr smtk::resource::Links::RoleType ReferenceRole = -2
 
- Static Public Attributes inherited from smtk::resource::DerivedFrom< Resource, smtk::geometry::Resource >
static const Resource::Index type_index
 A static index for this resource type. More...
 
- Static Public Attributes inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
static const Resource::Index type_index
 A static index for this resource type. More...
 
- Static Public Attributes inherited from smtk::resource::Resource
static const Resource::Index type_index = std::type_index(typeid(Resource)).hash_code()
 

Protected Member Functions

 Resource (const smtk::common::UUID &myID, smtk::resource::ManagerPtr manager)
 
 Resource (smtk::resource::ManagerPtr manager=nullptr)
 
void internalFindAllDerivedDefinitions (smtk::attribute::DefinitionPtr def, bool onlyConcrete, std::vector< smtk::attribute::DefinitionPtr > &result) const
 
void internalFindAttributes (attribute::DefinitionPtr def, std::vector< smtk::attribute::AttributePtr > &result) const
 
bool copyDefinitionImpl (smtk::attribute::DefinitionPtr sourceDef, smtk::attribute::ItemDefinition::CopyInfo &info)
 
- Protected Member Functions inherited from smtk::resource::DerivedFrom< Resource, smtk::geometry::Resource >
 DerivedFrom (T &&... all)
 Forward all constructor arguments to the parent class.
 
 DerivedFrom (DerivedFrom &&rhs) noexcept=default
 
- Protected Member Functions inherited from smtk::geometry::Resource
 Resource (const smtk::common::UUID &myID, smtk::resource::ManagerPtr manager)
 
 Resource (const smtk::common::UUID &myID)
 
 Resource (smtk::resource::ManagerPtr manager=nullptr)
 
- Protected Member Functions inherited from smtk::resource::DerivedFrom< Resource, smtk::resource::Resource >
 DerivedFrom (T &&... all)
 Forward all constructor arguments to the parent class.
 
 DerivedFrom (DerivedFrom &&rhs) noexcept=default
 
- Protected Member Functions inherited from smtk::resource::Resource
 Resource (const smtk::common::UUID &, ManagerPtr manager=nullptr)
 
 Resource (ManagerPtr manager=nullptr)
 

Protected Attributes

std::map< std::string, smtk::attribute::DefinitionPtrm_definitions
 
std::map< std::string, std::set< smtk::attribute::AttributePtr, Attribute::CompareByName > > m_attributeClusters
 
std::map< std::string, smtk::attribute::AttributePtrm_attributes
 
std::map< smtk::common::UUID, smtk::attribute::AttributePtrm_attributeIdMap
 
std::map< smtk::attribute::DefinitionPtr, std::set< smtk::attribute::WeakDefinitionPtr, Definition::WeakDefinitionPtrCompare > > m_derivedDefInfo
 
std::set< std::string > m_categories
 
std::set< std::string > m_activeCategories
 
bool m_activeCategoriesEnabled = false
 
smtk::attribute::Analyses m_analyses
 
std::map< std::string, smtk::view::ConfigurationPtrm_views
 
std::map< std::string, std::map< std::string, smtk::view::Configuration::Component > > m_styles
 
std::map< int, std::string > m_advLevels
 
std::map< int, std::vector< double > > m_advLevelColors
 
DirectoryInfo m_directoryInfo
 
std::set< smtk::resource::Links::RoleType > m_roles
 
CustomItemDefinitionFactory m_customItemDefinitionFactory
 
AssociationRules m_associationRules
 
bool m_isPrivate = false
 
EvaluatorFactory m_evaluatorFactory
 
std::string m_defaultAttNameSeparator = "-"
 
smtk::string::Token m_templateType
 
std::size_t m_templateVersion = 0
 
- Protected Attributes inherited from smtk::resource::Resource
WeakManagerPtr m_manager
 
std::shared_ptr< units::System > m_unitsSystem
 

Detailed Description

Store information about attribute definitions and instances.

This subclass of smtk::geometry::Resource holds attribute data. The file contains at least a schema (definitions and item-definitions) but may also contain attribute instances that conform to the schema as well as information about how to present the attribute system through a series of views.

This class inherits smtk::geometry::Resource so that attributes may (if desired) provide geometric data via a plugin. By default, no geometry will be available since attributes model information that is not spatial in nature and are instead associated with geometric components from other resources.

Member Function Documentation

◆ activeCategories()

const std::set<std::string>& smtk::attribute::Resource::activeCategories ( ) const
inline

API for setting and accessing Active Category information.

Active Categories are used to determine attribute/item validity as well as item values. If m_ActiveCategoriesEnabled is true then active categories will be taken into consideration.

◆ activeCategoriesEnabled()

bool smtk::attribute::Resource::activeCategoriesEnabled ( ) const
inline

API for setting and accessing Active Category information.

Active Categories are used to determine attribute/item validity as well as item values. If m_ActiveCategoriesEnabled is true then active categories will be taken into consideration.

◆ addStyle()

void Resource::addStyle ( const std::string &  definitionType,
smtk::view::Configuration::Component  style 
)

API for setting and accessing style information.

A style is represented as a smtk::view::Configuration::Component and represents customizations for displaying the attribute in a GUI.

◆ categories()

const std::set<std::string>& smtk::attribute::Resource::categories ( ) const
inline

API for accessing Category information.

These categories are specified when defining Definitions and are gathered as a result of calling finalizeDefinitions.

◆ finalizeDefinitions()

void Resource::finalizeDefinitions ( )

This method updates information passed down to Attribute and Item Definitions.

It should be called whenever shared information such as local categories and local advance information is changed. Note that this method can be called multiple times without issue.

◆ findStyle()

const smtk::view::Configuration::Component & Resource::findStyle ( const smtk::attribute::DefinitionPtr def,
const std::string &  styleName = "" 
) const

API for setting and accessing style information.

A style is represented as a smtk::view::Configuration::Component and represents customizations for displaying the attribute in a GUI.

◆ findStyles()

const std::map< std::string, smtk::view::Configuration::Component > & Resource::findStyles ( const smtk::attribute::DefinitionPtr def) const

API for setting and accessing style information.

A style is represented as a smtk::view::Configuration::Component and represents customizations for displaying the attribute in a GUI.

◆ numberOfCategories()

std::size_t smtk::attribute::Resource::numberOfCategories ( ) const
inline

API for accessing Category information.

These categories are specified when defining Definitions and are gathered as a result of calling finalizeDefinitions.

◆ queryOperation()

std::function< bool(const smtk::resource::Component &)> Resource::queryOperation ( const std::string &  filterString) const
overridevirtual

Given a std::string describing a query, return a functor for performing the query.

Currently, the query string must be either empty, *, any, or of the form ‘attribute[type='xxx’], wherexxx` specifies the name of a definition that the resulting attributes instantiate. Note that if an attribute type xxx is provided, any attribute whose definition inherits from xxx as a base will be included, not just those whose immediate, concrete type is xxx.

If the query string filters attributes by their definition types, note that the definition must exist at the time that queryOperation() is called. This requirement allows faster repeated evaluation of the query.

Reimplemented from smtk::resource::Resource.

◆ setActiveCategories()

void Resource::setActiveCategories ( const std::set< std::string > &  cats)

API for setting and accessing Active Category information.

Active Categories are used to determine attribute/item validity as well as item values. If m_ActiveCategoriesEnabled is true then active categories will be taken into consideration.

◆ setActiveCategoriesEnabled()

void Resource::setActiveCategoriesEnabled ( bool  mode)

API for setting and accessing Active Category information.

Active Categories are used to determine attribute/item validity as well as item values. If m_ActiveCategoriesEnabled is true then active categories will be taken into consideration.

◆ setTemplateType()

bool Resource::setTemplateType ( const smtk::string::Token templateType)
virtual

Set/get the "type" of a resource's template.

A resource template-type is not required, but if present it can be used to register updaters for migrating from an old template to a newer version.

◆ setTemplateVersion()

bool Resource::setTemplateVersion ( std::size_t  templateVersion)
virtual

Set/get the version of the template this instance of the resource is based upon.

If non-zero, this number indicates the version number of the template (i.e., SBT file) the definitions in the current resource are drawn from. It is used during the update process to determine which updaters are applicable.

◆ styles()

const std::map<std::string, std::map<std::string, smtk::view::Configuration::Component> >& smtk::attribute::Resource::styles ( ) const
inline

API for setting and accessing style information.

A style is represented as a smtk::view::Configuration::Component and represents customizations for displaying the attribute in a GUI.

Member Data Documentation

◆ copyAttribute

smtk::attribute::AttributePtr Resource::copyAttribute

Copies attribute.

Will create a copy of an attribute. Note that the source attribute can belong to a different attribute resource. The logger will contain any information including warnings or errors encountered in the copying/assignment process. If errors occur that prevent the copy process from successfully completing, no attribute will be created. - see CopyAssignmentOptions.h for attribute and item assignment/copy options.


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