SMTK
@SMTK_VERSION@
Simulation Modeling Tool Kit
|
A resource for conceptual modeling of geometric components. More...
#include <Resource.h>
Classes | |
struct | CreateNodeOfType |
A functor to create smtk::string::Tokens of accepted node types. More... | |
struct | NodeTypeNames |
A functor to create smtk::string::Tokens of accepted node types. More... | |
Public Types | |
using | NodeContainer = typename detail::GraphTraits< Traits >::NodeContainer |
using | TypeTraits = Traits |
template<typename NodeType > | |
using | is_node = smtk::tuple_contains< NodeType, typename detail::GraphTraits< Traits >::NodeTypes > |
template<typename ArcType > | |
using | is_arc = smtk::tuple_contains< ArcType, typename detail::GraphTraits< Traits >::ArcTypes > |
Public Member Functions | |
smtkTypedefs (smtk::graph::Resource< Traits >) | |
std::string | typeName () const override |
Return the resource's type, which is used by the resource manager and for persistent storage. | |
smtkCreateMacro (smtk::graph::Resource< Traits >) | |
smtkSuperclassMacro (smtk::resource::DerivedFrom< Resource< Traits >, ResourceBase >) | |
smtkSharedFromThisMacro (smtk::resource::PersistentObject) | |
template<typename NodeType , typename... T> | |
std::enable_if< is_node< NodeType >::value, std::shared_ptr< NodeType > >::type | create (T &&... parameters) |
Create a node of type NodeType with additional constructor arguments. More... | |
template<typename NodeType > | |
std::enable_if< is_node< NodeType >::value, bool >::type | add (const std::shared_ptr< NodeType > &node) |
Add a node of type NodeType to the resource. More... | |
template<typename NodeType > | |
std::enable_if< is_node< NodeType >::value, bool >::type | remove (const std::shared_ptr< NodeType > &node) |
Remove a node from the resource. Return true if the removal took place. | |
const ArcMap & | arcs () const override |
Access the arcs of the graph resource. | |
ArcMap & | arcs () override |
std::function< bool(const smtk::resource::Component &)> | queryOperation (const std::string &filterString) const override |
Return a functor that tests a node (component) against a string query. | |
Resource (const Resource &) noexcept=delete | |
Copy construction of resources is disallowed. | |
std::shared_ptr< smtk::resource::Component > | find (const smtk::common::UUID &uuid) const override |
Return a shared pointer to a node (component) given its UUID. | |
smtk::resource::Component * | component (const smtk::common::UUID &uuid) const override |
Return a raw pointer to a node (component) given its UUID. | |
void | visit (std::function< void(const smtk::resource::ComponentPtr &)> &v) const override |
Visit all the components (nodes. | |
template<typename Functor , typename... Args> | |
void | evaluateArcs (Args &&... args) const |
Invoke a Functor on each arc-type's implementation. More... | |
template<typename Functor , typename... Args> | |
void | evaluateArcs (Args &&... args) |
const std::set< smtk::string::Token > & | nodeTypes () const override |
Return the set of node types accepted by this resource. | |
const std::set< smtk::string::Token > & | arcTypes () const override |
Return the set of arc types accepted by this resource. | |
smtk::string::Token | templateType () const override |
Override the base resource to store and retrieve a template type. | |
bool | setTemplateType (const smtk::string::Token &templateType) override |
std::size_t | templateVersion () const override |
Override the base resource to store and retrieve a template version number. | |
bool | setTemplateVersion (std::size_t templateVersion) override |
std::shared_ptr< smtk::resource::Resource > | clone (smtk::resource::CopyOptions &options) const override |
Implement clone() to make a copy of a graph resource. More... | |
bool | copyInitialize (const std::shared_ptr< const smtk::resource::Resource > &source, smtk::resource::CopyOptions &options) override |
Implement copyInitialize() to copy arcs and nodes from a non-empty resource of the same type. | |
bool | copyFinalize (const std::shared_ptr< const smtk::resource::Resource > &source, smtk::resource::CopyOptions &options) override |
Implement copyFinalize() to copy any external links from a non-empty resource of the same type. | |
Component * | createNodeOfType (smtk::string::Token nodeTypeName) override |
Implement the generic (untyped) graph API for inserting nodes. | |
bool | connect (Component *from, Component *to, smtk::string::Token arcType) override |
Implement the generic (untyped) graph API for inserting arcs. More... | |
bool | disconnect (Component *node, bool explicitOnly) override |
Remove all arcs (or only explicit arcs) from the given node. | |
void | dump (const std::string &filename, const std::string &mimeType="text/vnd.graphviz") const override |
Dump the resource nodes and arcs to a file. More... | |
Protected Member Functions | |
std::size_t | eraseNodes (const smtk::graph::ComponentPtr &node) override |
bool | insertNode (const smtk::graph::ComponentPtr &node) override |
Insert a node without performing any type-safety checks. | |
bool | isNodeTypeAcceptable (const smtk::graph::ComponentPtr &node) override |
Perform a run-time check to validate that a node is acceptable to this resource. | |
void | initializeResource () |
Resource (smtk::resource::ManagerPtr manager=nullptr) | |
Resource (const smtk::common::UUID &uid, smtk::resource::ManagerPtr manager=nullptr) | |
Protected Attributes | |
smtk::string::Token | m_templateType |
std::size_t | m_templateVersion { 0 } |
ArcMap | m_arcs |
std::set< smtk::string::Token > | m_nodeTypes |
std::set< smtk::string::Token > | m_arcTypes |
A resource for conceptual modeling of geometric components.
The smtk::graph::Resource is defined by a Traits type that defines the node types and arc types of a multipartite graph. The node types must all inherit from smtk::graph::Component and comprise the elements of the resource. The arc types can be any type, and can represent a 1-to-1 or 1-to-many relationship between node types.
|
inline |
Add a node of type NodeType to the resource.
Return true if the insertion took place.
|
override |
Implement clone() to make a copy of a graph resource.
The output copy will not have any nodes or arcs but will have any run-time arc types registered to match the originating resource if options has copyTemplateData() set to true.
|
inlineoverride |
Implement the generic (untyped) graph API for inserting arcs.
The from and to nodes are checked to ensure they are owned by this resource and the proper type for this resource. This method returns true if the arc was inserted and false if it already existed or was inappropriate.
This method is considered "untyped" because the types of both the endpoint nodes and arc are unknown at compile-time. Type safety is ensured by run-time checks.
|
inline |
Create a node of type NodeType with additional constructor arguments.
Sometimes, it is necessary to have access to a shared pointer to the constructed node during initialization (especially if using the RAII (Resource Acquisition Is Initialization) idiom). Because shared pointers to objects cannot be used within that object's constructor, this method will invoke an initializer method on the node after the node is constructed (if one exists). The initializer must be a method of NodeType named initialize() whose arguments are a the parameters passed to this method.
|
inlineoverride |
Dump the resource nodes and arcs to a file.
This is a convenience method for debugging; its arguments are easy to pass to an interactive debugger. Internally, it calls evaluateArcs<evaluators::Dump>(...) to produce output. See evaluators::Dump for more information.
|
inline |
Invoke a Functor on each arc-type's implementation.
The functor should have a templated parenthesis operator whose template parameter is the arc implementation object type, which determines the the functor's first argument type. This type varies for each ArcTraits type in TypeTraits::ArcTypes and will be ArcImplementation<ArcTraits>*
.
The following arguments the functor's parenthesis-operator takes are args forwarded from this method.
This method allows you to traverse all types of arcs present in the resource for inspection or modification.