SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Classes | Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
smtk::graph::ArcImplementation< ArcTraits > Class Template Reference

A wrapper around arc type-traits classes that provides API. More...

#include <ArcImplementation.h>

Collaboration diagram for smtk::graph::ArcImplementation< ArcTraits >:
[legend]

Classes

struct  RuntimeInVisitor
 A functor that either calls inVisitor (on arcs with reverse indices) or does nothing. More...
 
struct  RuntimeInVisitor< TraitsType, false >
 
struct  RuntimeInVisitor< TraitsType, true >
 

Public Types

using Traits = ArcTraits
 
using Directed = typename ArcTraits::Directed
 If "truthy," this arc is considered directed rather than undirected.
 
using FromType = typename ArcTraits::FromType
 The type of node that these arcs originate from.
 
using ToType = typename ArcTraits::ToType
 The type of node that these arcs point to.
 
using Ordered = typename ArcProperties< ArcTraits >::isOrdered
 If "truthy," this arc will report incoming/outgoing nodes in a (user-specified) order.
 
using Mutable = typename ArcProperties< ArcTraits >::isMutable
 If "truthy," methods that edit arcs may sometimes return true. More...
 
using Explicit = typename ArcProperties< ArcTraits >::isExplicit
 If "truthy," arc endpoint connections are explicitly stored by SMTK.
 

Public Member Functions

 ArcImplementation (const Traits &traits)
 
bool isOrdered () const
 Return whether arcs of this type are ordered (true) or unordered (false).
 
bool isDirected () const
 Return whether arcs of this type are directed (true) or undirected (false).
 
bool isMutable () const
 Return whether arcs of this type may be edited.
 
bool isExplicit () const
 Return whether arcs of this type are explicit.
 
std::string typeName () const override
 Return the type of arc this class implements.
 
Directionality directionality () const override
 
bool mutability () const override
 
bool explicitStorage () const override
 
std::unordered_set< smtk::string::TokenfromTypes () const override
 
std::unordered_set< smtk::string::TokentoTypes () const override
 
std::size_t minimumOutDegree () const override
 The minimum out-degree of a FromType node. This is not enforced.
 
std::size_t minimumInDegree () const override
 The minimum in-degree of a ToType node. This is not enforced.
 
std::size_t maximumOutDegree () const override
 The maximum out-degree of a FromType node. This is enforced.
 
std::size_t maximumInDegree () const override
 The maximum in-degree of a ToType node. This is enforced.
 
smtk::common::Visited visitOutgoingNodes (const smtk::graph::ResourceBase *resource, smtk::string::Token arcTypeName, RuntimeNodeVisitor visitor) const override
 Visit all nodes with outgoing run-time arcs.
 
bool acceptsRuntime (Component *from, Component *to, Component *beforeFrom, Component *beforeTo) const override
 
template<typename Functor >
smtk::common::Visited outVisitor (const FromType *from, Functor visitor) const
 Visit nodes attached via outgoing arcs.
 
template<typename Functor >
smtk::common::Visited inVisitor (const ToType *to, Functor visitor) const
 Visit nodes attached via incoming arcs. More...
 
ArcEndpointInterface< ArcTraits, ConstArc, OutgoingArcoutgoing (const FromType *from) const
 Return a "container" of outgoing arcs of the given from node.
 
ArcEndpointInterface< ArcTraits, NonConstArc, OutgoingArcoutgoing (FromType *from)
 
ArcEndpointInterface< ArcTraits, ConstArc, IncomingArcincoming (const ToType *to) const
 Return a "container" of incoming arcs of the given to node.
 
ArcEndpointInterface< ArcTraits, NonConstArc, IncomingArcincoming (ToType *to)
 
template<typename U = typename ArcProperties<Traits>::template hasSize< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if< U::value, bool >::type empty () const
 Return true if there are no arcs of this type in the resource. More...
 
template<typename U = typename ArcProperties<Traits>::template hasSize< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if<!U::value, bool >::type empty () const
 Return true if there are no arcs of this type in the resource. More...
 
RuntimeArcEndpoint< ConstArcoutgoingRuntime (const Component *from) const override
 Return a "container" of outgoing arcs of the given from node.
 
RuntimeArcEndpoint< NonConstArcoutgoingRuntime (const Component *from) override
 Return a "container" of outgoing arcs of the given from node.
 
RuntimeArcEndpoint< ConstArcincomingRuntime (const Component *to) const override
 Return a "container" of incoming arcs of the given to node.
 
RuntimeArcEndpoint< NonConstArcincomingRuntime (const Component *to) override
 Return a "container" of incoming arcs of the given to node.
 
template<typename U = typename ArcProperties<Traits>::template hasContains< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if<!U::value, bool >::type contains (const FromType *from, const ToType *to) const
 Test whether an arc from from to to exists.
 
template<typename U = typename ArcProperties<Traits>::template hasContains< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if< U::value, bool >::type contains (const FromType *from, const ToType *to) const
 Test whether an arc from from to to exists.
 
template<typename U = typename ArcProperties<Traits>::template hasOutNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if<!U::value, smtk::common::Visited >::type visitAllOutgoingNodes (ResourcePtr rsrc, Functor ff) const
 Visit all nodes which have outgoing arcs of this type. More...
 
template<typename U = typename ArcProperties<Traits>::template hasOutNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if< U::value, smtk::common::Visited >::type visitAllOutgoingNodes (ResourcePtr rsrc, Functor ff) const
 Visit all nodes which have outgoing arcs of this type. More...
 
template<typename U = typename ArcProperties<Traits>::template hasInNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if<!U::value, smtk::common::Visited >::type visitAllIncomingNodes (ResourcePtr rsrc, Functor ff) const
 Visit all nodes which have incoming arcs of this type. More...
 
template<typename U = typename ArcProperties<Traits>::template hasInNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if< U::value, smtk::common::Visited >::type visitAllIncomingNodes (ResourcePtr rsrc, Functor ff) const
 Visit all nodes which have incoming arcs of this type. More...
 
template<typename U = typename ArcProperties<Traits>::template hasAccepts< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if< U::value, bool >::type accepts (const FromType *from, const ToType *to, const FromType *beforeFrom=nullptr, const ToType *beforeTo=nullptr) const
 Determine whether the given arc is allowed. More...
 
template<typename U = typename ArcProperties<Traits>::template hasAccepts< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if<!U::value, bool >::type accepts (const FromType *from, const ToType *to, const FromType *beforeFrom=nullptr, const ToType *beforeTo=nullptr) const
 Determine whether the given arc is allowed. More...
 
template<typename U = Mutable>
std::enable_if<!U::value, bool >::type connect (const FromType *from, const ToType *to, const FromType *beforeFrom=nullptr, const ToType *beforeTo=nullptr)
 Insert an arc from from to to, optionally ordered by beforeFrom and beforeTo. More...
 
template<typename U = Mutable>
std::enable_if< U::value, bool >::type connect (const FromType *from, const ToType *to, const FromType *beforeFrom=nullptr, const ToType *beforeTo=nullptr)
 Insert an arc from from to to, optionally ordered by beforeFrom and beforeTo. More...
 
template<typename U = Mutable>
std::enable_if<!U::value, bool >::type disconnect (const FromType *from, const ToType *to)
 Remove an arc from from to to.
 
template<typename U = Mutable>
std::enable_if< U::value, bool >::type disconnect (const FromType *from, const ToType *to)
 Remove an arc from from to to.
 
template<typename U = typename ArcProperties<Traits>::template hasOutDegree< detail::SelectArcContainer<Traits, Traits>>, typename V = typename ArcProperties<detail::SelectArcContainer<Traits, Traits>>::isAutoUndirected>
std::enable_if<!U::value &&!V::value, std::size_t >::type outDegree (const FromType *from) const
 Compute the out-degree of the node.
 
template<typename U = typename ArcProperties<Traits>::template hasOutDegree< detail::SelectArcContainer<Traits, Traits>>, typename V = typename ArcProperties<detail::SelectArcContainer<Traits, Traits>>::isAutoUndirected>
std::enable_if<!U::value &&V::value, std::size_t >::type outDegree (const FromType *from) const
 Compute the out-degree of the node.
 
template<typename U = typename ArcProperties<Traits>::template hasOutDegree< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if< U::value, std::size_t >::type outDegree (const FromType *from) const
 Compute the out-degree of the node.
 
template<typename U = typename ArcProperties<Traits>::template hasInDegree< detail::SelectArcContainer<Traits, Traits>>, typename V = typename ArcProperties<detail::SelectArcContainer<Traits, Traits>>::isAutoUndirected>
std::enable_if<!U::value &&!V::value, std::size_t >::type inDegree (const ToType *to) const
 Compute the in-degree of the node.
 
template<typename U = typename ArcProperties<Traits>::template hasInDegree< detail::SelectArcContainer<Traits, Traits>>, typename V = typename ArcProperties<detail::SelectArcContainer<Traits, Traits>>::isAutoUndirected>
std::enable_if<!U::value &&V::value, std::size_t >::type inDegree (const ToType *to) const
 Compute the in-degree of the node.
 
template<typename U = typename ArcProperties<Traits>::template hasInDegree< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if< U::value, std::size_t >::type inDegree (const ToType *to) const
 Compute the in-degree of the node.
 

Static Public Attributes

static constexpr std::size_t MinOutDegree = minOutDegree<ArcTraits>(unconstrained())
 The minimum out-degree of a FromType node. This is not enforced.
 
static constexpr std::size_t MinInDegree = minInDegree<ArcTraits>(unconstrained())
 The minimum in-degree of a ToType node. This is not enforced.
 
static constexpr std::size_t MaxOutDegree = maxOutDegree<ArcTraits>(unconstrained())
 The maximum out-degree of a FromType node. This is enforced.
 
static constexpr std::size_t MaxInDegree = maxInDegree<ArcTraits>(unconstrained())
 The maximum in-degree of a ToType node. This is enforced.
 

Protected Member Functions

template<typename U = typename ArcProperties<ArcTraits>::template hasFromNodeSpecs<ArcTraits>::type>
std::enable_if<!U::value, std::unordered_set< smtk::string::Token > >::type _fromTypes () const
 
template<typename U = typename ArcProperties<ArcTraits>::template hasFromNodeSpecs<ArcTraits>::type>
std::enable_if< U::value, std::unordered_set< smtk::string::Token > >::type _fromTypes () const
 
template<typename U = typename ArcProperties<ArcTraits>::template hasToNodeSpecs<ArcTraits>::type>
std::enable_if<!U::value, std::unordered_set< smtk::string::Token > >::type _toTypes () const
 
template<typename U = typename ArcProperties<ArcTraits>::template hasToNodeSpecs<ArcTraits>::type>
std::enable_if< U::value, std::unordered_set< smtk::string::Token > >::type _toTypes () const
 
template<typename Functor , bool IsBidirectional = !ArcProperties<ArcTraits>::isOnlyForwardIndexed::value>
smtk::common::Visited inVisitorDetail (const ToType *to, Functor visitor) const
 

Protected Attributes

detail::SelectArcContainer< ArcTraits, ArcTraits > m_data
 Store arc endpoint data. More...
 

Detailed Description

template<typename ArcTraits>
class smtk::graph::ArcImplementation< ArcTraits >

A wrapper around arc type-traits classes that provides API.

Arc traits may not provide implementations for all methods (or indeed, any at all in the case of explicit arcs). This class either forwards calls to the traits object or provides implementations for methods itself.

Member Typedef Documentation

◆ Mutable

template<typename ArcTraits >
using smtk::graph::ArcImplementation< ArcTraits >::Mutable = typename ArcProperties<ArcTraits>::isMutable

If "truthy," methods that edit arcs may sometimes return true.

If "falsey," methods for editing arcs will always return false. This type can be used to optimize at compile time (by omitting code that tests the return value of methods like connect, disconnect, erase, clear, etc.).

Member Function Documentation

◆ accepts() [1/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasAccepts< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if<U::value, bool>::type smtk::graph::ArcImplementation< ArcTraits >::accepts ( const FromType from,
const ToType to,
const FromType beforeFrom = nullptr,
const ToType beforeTo = nullptr 
) const
inline

Determine whether the given arc is allowed.

If the decorated traits object provides an "accepts()" method, return the result of that. Otherwise, consider only whether the compile-time constraints are satisfied.

Note that if "accepts()" is not provided, this method may eventually be implemented by checking the maximum incoming and outgoing degree constraints; that can be slow since degree() could be called on each node.

◆ accepts() [2/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasAccepts< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if<!U::value, bool>::type smtk::graph::ArcImplementation< ArcTraits >::accepts ( const FromType from,
const ToType to,
const FromType beforeFrom = nullptr,
const ToType beforeTo = nullptr 
) const
inline

Determine whether the given arc is allowed.

If the decorated traits object provides an "accepts()" method, return the result of that. Otherwise, consider only whether the compile-time constraints are satisfied.

Note that if "accepts()" is not provided, this method may eventually be implemented by checking the maximum incoming and outgoing degree constraints; that can be slow since degree() could be called on each node.

◆ connect() [1/2]

template<typename ArcTraits >
template<typename U = Mutable>
std::enable_if<!U::value, bool>::type smtk::graph::ArcImplementation< ArcTraits >::connect ( const FromType from,
const ToType to,
const FromType beforeFrom = nullptr,
const ToType beforeTo = nullptr 
)
inline

Insert an arc from from to to, optionally ordered by beforeFrom and beforeTo.

If the arc is ordered, then beforeFrom indicates where from should be placed in the order of incoming nodes and similarly for beforeTo and to. If the arc is not ordered, then beforeFrom and beforeTo are ignored.

◆ connect() [2/2]

template<typename ArcTraits >
template<typename U = Mutable>
std::enable_if<U::value, bool>::type smtk::graph::ArcImplementation< ArcTraits >::connect ( const FromType from,
const ToType to,
const FromType beforeFrom = nullptr,
const ToType beforeTo = nullptr 
)
inline

Insert an arc from from to to, optionally ordered by beforeFrom and beforeTo.

If the arc is ordered, then beforeFrom indicates where from should be placed in the order of incoming nodes and similarly for beforeTo and to. If the arc is not ordered, then beforeFrom and beforeTo are ignored.

◆ empty() [1/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasSize< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if<U::value, bool>::type smtk::graph::ArcImplementation< ArcTraits >::empty ( ) const
inline

Return true if there are no arcs of this type in the resource.

Note that this method may return false even when there are no arcs of this type because the arc-traits object does not provide an efficient way to obtain the number of arcs.

◆ empty() [2/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasSize< detail::SelectArcContainer<Traits, Traits>>>
std::enable_if<!U::value, bool>::type smtk::graph::ArcImplementation< ArcTraits >::empty ( ) const
inline

Return true if there are no arcs of this type in the resource.

Note that this method may return false even when there are no arcs of this type because the arc-traits object does not provide an efficient way to obtain the number of arcs.

◆ inVisitor()

template<typename ArcTraits >
template<typename Functor >
smtk::common::Visited smtk::graph::ArcImplementation< ArcTraits >::inVisitor ( const ToType to,
Functor  visitor 
) const
inline

Visit nodes attached via incoming arcs.

This method will only be provided for

  • explicit arc-traits which do not include a truthy ForwardIndexOnly type-alias; and
  • implicit arc-traits which provide an inVisitor method.

◆ visitAllIncomingNodes() [1/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasInNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if<!U::value, smtk::common::Visited>::type smtk::graph::ArcImplementation< ArcTraits >::visitAllIncomingNodes ( ResourcePtr  rsrc,
Functor  ff 
) const
inline

Visit all nodes which have incoming arcs of this type.

If the traits object does not provide its own implementation, the ArcImplementation will simply visit all nodes of type ToType and invoke the visitor on each.

The intent is for traits objects to provide a fast method that only visits nodes which have incoming arcs of this type.

◆ visitAllIncomingNodes() [2/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasInNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if<U::value, smtk::common::Visited>::type smtk::graph::ArcImplementation< ArcTraits >::visitAllIncomingNodes ( ResourcePtr  rsrc,
Functor  ff 
) const
inline

Visit all nodes which have incoming arcs of this type.

If the traits object does not provide its own implementation, the ArcImplementation will simply visit all nodes of type ToType and invoke the visitor on each.

The intent is for traits objects to provide a fast method that only visits nodes which have incoming arcs of this type.

◆ visitAllOutgoingNodes() [1/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasOutNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if<!U::value, smtk::common::Visited>::type smtk::graph::ArcImplementation< ArcTraits >::visitAllOutgoingNodes ( ResourcePtr  rsrc,
Functor  ff 
) const
inline

Visit all nodes which have outgoing arcs of this type.

If the traits object does not provide its own implementation, the ArcImplementation will simply visit all nodes of type FromType and invoke the visitor on each.

The intent is for traits objects to provide a fast method that only visits nodes which have outgoing arcs of this type.

◆ visitAllOutgoingNodes() [2/2]

template<typename ArcTraits >
template<typename U = typename ArcProperties<Traits>::template hasOutNodeVisitor< detail::SelectArcContainer<Traits, Traits>>, typename ResourcePtr , typename Functor >
std::enable_if<U::value, smtk::common::Visited>::type smtk::graph::ArcImplementation< ArcTraits >::visitAllOutgoingNodes ( ResourcePtr  rsrc,
Functor  ff 
) const
inline

Visit all nodes which have outgoing arcs of this type.

If the traits object does not provide its own implementation, the ArcImplementation will simply visit all nodes of type FromType and invoke the visitor on each.

The intent is for traits objects to provide a fast method that only visits nodes which have outgoing arcs of this type.

Member Data Documentation

◆ m_data

template<typename ArcTraits >
detail::SelectArcContainer<ArcTraits, ArcTraits> smtk::graph::ArcImplementation< ArcTraits >::m_data
protected

Store arc endpoint data.

This will be either ArcTraits or ExplicitArcs<ArcTraits>, depending on whether ArcTraits is implicit or explicit. If ArcTraits is implicit, m_data will typically not store components or their IDs directly. If ArcTraits is explicit, m_data will hold a multi-index container of arc endpoints.


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