SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
smtk::graph::ResourceBase Class Referenceabstract

A non-templated base class for graph resources. More...

#include <ResourceBase.h>

Inheritance diagram for smtk::graph::ResourceBase:
[legend]
Collaboration diagram for smtk::graph::ResourceBase:
[legend]

Public Member Functions

 smtkTypeMacro (smtk::graph::ResourceBase)
 
 smtkSuperclassMacro (smtk::resource::DerivedFrom< ResourceBase, smtk::geometry::Resource >)
 
virtual const ArcMaparcs () const =0
 
virtual ArcMaparcs ()=0
 
virtual const std::set< smtk::string::Token > & nodeTypes () const =0
 Return a set of string-tokens holding the type-names of all accepted node types.
 
virtual const std::set< smtk::string::Token > & arcTypes () const =0
 Return a set of string-tokens holding the type-names of all accepted arc types.
 
virtual bool isNodeTypeAcceptable (const smtk::graph::ComponentPtr &node)=0
 Perform a run-time check to validate that a node is acceptable to this resource.
 
virtual bool addNode (const smtk::graph::ComponentPtr &node)
 Insert a node, checking that nodes of its type are allowed. More...
 
virtual ComponentcreateNodeOfType (smtk::string::Token typeName)=0
 Create a node given its type-name (and add it to the resource). More...
 
virtual bool connect (Component *from, Component *to, smtk::string::Token arcType)=0
 Connect two nodes with a given type of arc. More...
 
virtual bool disconnect (Component *node, bool explicitOnly=false)=0
 Disconnect all arcs from the given node. More...
 
virtual void dump (const std::string &filename, const std::string &mimeType="text/vnd.graphviz") const =0
 Dump nodes and arcs to a file. More...
 
- Public Member Functions inherited from smtk::resource::DerivedFrom< ResourceBase, 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 ComponentPtr find (const smtk::common::UUID &compId) const =0
 Given a resource component's UUID, return the resource component.
 
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 std::function< bool(const Component &)> queryOperation (const std::string &) const
 given a std::string describing a query, return a functor for performing the query (accepts component as input, returns true if the component satisfies the query parameters).
 
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
 
- 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.
 

Protected Member Functions

virtual std::size_t eraseNodes (const smtk::graph::ComponentPtr &node)=0
 Erase all of the nodes from the node storage without updating the arcs. More...
 
virtual bool insertNode (const smtk::graph::ComponentPtr &node)=0
 Unconditionally insert the given node into the container. More...
 
 ResourceBase (smtk::resource::ManagerPtr manager=nullptr)
 
 ResourceBase (const smtk::common::UUID &uid, smtk::resource::ManagerPtr manager=nullptr)
 
 ResourceBase (ResourceBase &&) noexcept=default
 
- Protected Member Functions inherited from smtk::resource::DerivedFrom< ResourceBase, 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

friend Component
 
- Protected Attributes inherited from smtk::resource::Resource
WeakManagerPtr m_manager
 

Additional Inherited Members

- Public Types inherited from smtk::resource::DerivedFrom< ResourceBase, 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
 
- Static Public Attributes inherited from smtk::resource::DerivedFrom< ResourceBase, 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()
 

Detailed Description

A non-templated base class for graph resources.

ResourceBase satisfies the API of smtk::resource::Resource and isolates graph components from the traits specification of smtk::graph::Resource.

Member Function Documentation

◆ addNode()

virtual bool smtk::graph::ResourceBase::addNode ( const smtk::graph::ComponentPtr &  node)
inlinevirtual

Insert a node, checking that nodes of its type are allowed.

This is used by JSON deserialization code and will eventually be used by python bindings to insert nodes whose type may not be known exactly at runtime (or whose owning resource type may not be available at runtime).

◆ connect()

virtual bool smtk::graph::ResourceBase::connect ( Component from,
Component to,
smtk::string::Token  arcType 
)
pure virtual

Connect two nodes with a given type of arc.

This method is pure virtual because it needs a Traits object to determine validity. It exists to make python bindings for graph resources (and python-defined graph resources) possible.

◆ createNodeOfType()

virtual Component* smtk::graph::ResourceBase::createNodeOfType ( smtk::string::Token  typeName)
pure virtual

Create a node given its type-name (and add it to the resource).

This method is pure virtual because it needs a Traits object to map the type-name to an actual type.

◆ disconnect()

virtual bool smtk::graph::ResourceBase::disconnect ( Component node,
bool  explicitOnly = false 
)
pure virtual

Disconnect all arcs from the given node.

This method is pure virtual because it needs a Traits object to iterate over all arc types for the node.

The return value indicates whether any arcs were removed.

◆ dump()

virtual void smtk::graph::ResourceBase::dump ( const std::string &  filename,
const std::string &  mimeType = "text/vnd.graphviz" 
) const
pure virtual

Dump nodes and arcs to a file.

If you pass an empty filename, then this method will dump to the console.

By default, this will dump in the graphviz "dot" language, however "text/plain" is another accepted mimeType.

◆ eraseNodes()

virtual std::size_t smtk::graph::ResourceBase::eraseNodes ( const smtk::graph::ComponentPtr &  node)
protectedpure virtual

Erase all of the nodes from the node storage without updating the arcs.

This is an internal method used for temporary removal, modification, and re-insertion in cases where node data that is indexed must be changed. In that case, arcs must not be modified.

Returns
the number of nodes removed. Usually this is either 0 or 1, however the implementation may define removal of > 1 nodes based on criteria other than id or pointer address.

◆ insertNode()

virtual bool smtk::graph::ResourceBase::insertNode ( const smtk::graph::ComponentPtr &  node)
protectedpure virtual

Unconditionally insert the given node into the container.

Does not check against NodeTypes to see whether the node type is allowed; this is assumed to have already been done.

Returns
whether or not the insertion was successful.

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