SMTK  @SMTK_VERSION@
Simulation Modeling Tool Kit
Public Types | Public Member Functions | Static Public Attributes | List of all members
smtk::common::Links< id_type, left_type, right_type, role_type, base_type > Class Template Reference

The Links class represents a collection of Link-s. More...

#include <Links.h>

Inheritance diagram for smtk::common::Links< id_type, left_type, right_type, role_type, base_type >:
[legend]

Public Types

using Left = detail::Left
 The "Left", "Right" and "Role" tags facilitate access to views into the container that are sorted according to the left, right or role values, respectively.
 
using Right = detail::Right
 
using Role = detail::Role
 
using iterator = typename Parent::iterator
 We expose a subset of the base class's types and methods because we use them for untagged interaction (i.e. More...
 
using Link = typename Parent::value_type
 
using LinkBase = base_type
 
using IdType = id_type
 Expose template parameters.
 
using LeftType = left_type
 
using RightType = right_type
 
using RoleType = role_type
 

Public Member Functions

std::pair< iterator, bool > insert (const base_type &, const id_type &, const left_type &, const right_type &, const role_type &role=undefinedRole)
 Insertion into the container is performed by passing values for the base_type object, link id, left value, right value, and role.
 
std::pair< iterator, bool > insert (base_type &&, const id_type &, const left_type &, const right_type &, const role_type &role=undefinedRole)
 Since the base type may be large, this method facilitates its insertion using move semantics.
 
template<typename return_value = typename std::pair<iterator, bool>>
std::enable_if< std::is_default_constructible< base_type >::value, return_value >::type insert (const id_type &id, const left_type &left, const right_type &right, const role_type &role=undefinedRole)
 If the base_type is default-constructible, this insertion method allows you to omit the base_type instance. More...
 
bool contains (const id_type &key) const
 Check if a link with the input id exists.
 
template<typename tag >
bool contains (const typename LinkTraits< tag >::type &value) const
 Check if a link with the input value matching the tagged search criterion exists.
 
template<typename tag >
std::size_t size (const typename LinkTraits< tag >::type &value) const
 Return the number of links with the input value matching the tagged search criterion.
 
template<typename tag >
bool erase_all (const typename LinkTraits< tag >::type &value)
 Erase all links matching the input value for the tagged search criterion.
 
template<typename tag >
bool erase_all (const std::tuple< typename LinkTraits< tag >::type, role_type > &value)
 Erase all links matching the input value and role for the tagged search criterion.
 
template<typename tag >
bool set (const id_type &id, const typename LinkTraits< tag >::type &value)
 Access a link by its id and set its value associated with the tagged search criterion to a new value.
 
template<typename tag >
const std::set< std::reference_wrapper< const id_type > > ids (const typename LinkTraits< tag >::type &value) const
 Return a set of ids corresponding to the input value for the tagged search criterion.
 
const Link & at (const id_type &id) const
 Access the link with the input id (must be const).
 
LinkBase & value (const id_type &id)
 Access a link as its base type (can be non-const).
 
const LinkBase & value (const id_type &id) const
 
template<typename tag >
const LinkTraits< tag >::type & at (const id_type &id) const
 Access a tagged value associated with the input id (must be const; values can be modified using the "set" method).
 
template<typename tag >
const std::set< std::reference_wrapper< const typename LinkTraits< tag >::other_type >, std::less< const typename LinkTraits< tag >::other_type > > linked_to (const typename LinkTraits< tag >::type &value) const
 Given a Left or Right tag and an associated value, return a set of the other type that links to the input value.
 
template<typename tag >
const std::set< std::reference_wrapper< const typename LinkTraits< tag >::other_type >, std::less< const typename LinkTraits< tag >::other_type > > linked_to (const typename LinkTraits< tag >::type &value, const role_type &role) const
 Given a Left or Right tag, an associated value and a role, return a set of the other type that links to the input value and has the role value.
 

Static Public Attributes

static const role_type undefinedRole
 

Detailed Description

template<typename id_type, typename left_type = id_type, typename right_type = left_type, typename role_type = int, typename base_type = detail::NullLinkBase>
class smtk::common::Links< id_type, left_type, right_type, role_type, base_type >

The Links class represents a collection of Link-s.

It has a set-like interface that permits insertion, erasure, iteration, find, etc. Additionally, template methods that accept the Left, Right and Role tags facilitate return values that isolate the Left, Right and Role values (as though the container were a container of just that type). Internally, the links are held in a multiindex array to facilitate indexing according to the Id (default), Left, Right and Role values of the links.

Member Typedef Documentation

◆ iterator

template<typename id_type , typename left_type = id_type, typename right_type = left_type, typename role_type = int, typename base_type = detail::NullLinkBase>
using smtk::common::Links< id_type, left_type, right_type, role_type, base_type >::iterator = typename Parent::iterator

We expose a subset of the base class's types and methods because we use them for untagged interaction (i.e.

methods that do not use a tag) with the container.

Member Function Documentation

◆ insert()

template<typename id_type , typename left_type = id_type, typename right_type = left_type, typename role_type = int, typename base_type = detail::NullLinkBase>
template<typename return_value = typename std::pair<iterator, bool>>
std::enable_if<std::is_default_constructible<base_type>::value, return_value>::type smtk::common::Links< id_type, left_type, right_type, role_type, base_type >::insert ( const id_type &  id,
const left_type &  left,
const right_type &  right,
const role_type &  role = undefinedRole 
)
inline

If the base_type is default-constructible, this insertion method allows you to omit the base_type instance.

A new base_type will be used and the left and right types are passed to the new link using move semantics.

Member Data Documentation

◆ undefinedRole

template<typename id_type , typename left_type , typename right_type , typename role_type , typename base_type >
const role_type smtk::common::Links< id_type, left_type, right_type, role_type, base_type >::undefinedRole
static
Initial value:
=
std::numeric_limits<role_type>::lowest()

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