SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
Component is the base class for records stored in an smtk::resource::Resource. More...
#include <Component.h>
Classes | |
struct | ModifyName |
Public Types | |
typedef std::function< void(const ComponentPtr &)> | Visitor |
typedef detail::ComponentLinks | Links |
typedef detail::ComponentProperties | Properties |
Public Member Functions | |
smtkTypeMacro (smtk::resource::Component) | |
smtkSuperclassMacro (smtk::resource::PersistentObject) | |
smtkSharedFromThisMacro (smtk::resource::PersistentObject) | |
virtual const ResourcePtr | resource () const =0 |
Components are required to return their owning resource (if any). More... | |
virtual Resource * | parentResource () const |
Return a raw (not shared) pointer to the resource that owns this component. More... | |
template<typename ResourceType > | |
ResourceType * | parentResourceAs () const |
This variant of parentResource casts the result to the given ResourceType. | |
Links & | links () override |
Return the links that connect this component to external resources/components. | |
const Links & | links () const override |
Properties & | properties () override |
Return properties defined on this component. | |
const Properties & | properties () const override |
![]() | |
smtkTypeMacroBase (smtk::resource::PersistentObject) | |
virtual const common::UUID & | id () const =0 |
Return a unique identifier for the object which will be persistent across sessions. | |
virtual bool | setId (const common::UUID &myID)=0 |
Assign an ID to this object (used by readers; not for arbitrary reuse). More... | |
virtual std::string | name () const |
Return the name of the object - by default it will return the UUID but that can be overridden. | |
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. | |
Friends | |
class | Resource |
Component is the base class for records stored in an smtk::resource::Resource.
Components are contained inside a parent resource. Because they are written to and read from the resource's location, their scope for persistence is shared with the resource; SMTK does not provide a way to persist individual components, only resources.
A component in one resource may be linked to an external resource or to components in an external resource using Links. This allows one resource to annotate another.
Components may themselves be annotated with Properties, which are freeform storage owned by their parent resource.
Attributes, mesh sets, and model entities all inherit from this class.
|
inlinevirtual |
Return a raw (not shared) pointer to the resource that owns this component.
This method provides a slow default implementation that simply converts the shared pointer, but component subclasses can usually implement a fast version if they use smtk::common::CachedWeakPointer to hold a reference to their parent.
Reimplemented in smtk::graph::Component.
|
pure virtual |
Components are required to return their owning resource (if any).
Components may not have an owning resource at some points in their lifecycle, so be sure to verify the returned value is non-null.
Implemented in smtk::attribute::Attribute, smtk::graph::Component, smtk::model::Entity, and smtk::mesh::Component.