Loading...
Searching...
No Matches
nodeinterface.hh
Go to the documentation of this file.
// -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=8 sw=2 sts=2:
// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
// SPDX-License-Identifier: LGPL-3.0-or-later OR LicenseRef-GPL-2.0-only-with-PDELab-exception
#ifndef DUNE_TYPETREE_NODEINTERFACE_HH
#define DUNE_TYPETREE_NODEINTERFACE_HH
#include <cstddef>
#include <type_traits>
#include <dune/common/documentation.hh>
namespace Dune {
namespace TypeTree {
struct NodeInterface
{
static const bool isLeaf = implementationDefined;
static const bool isPower = implementationDefined;
static const bool isComposite = implementationDefined;
static auto degree();
typedef ImplementationDefined NodeTag;
typedef ImplementationDefined NodeStorage;
};
template<typename Node>
using NodeTag = typename std::decay_t<Node>::NodeTag;
template<typename T>
using ImplementationTag = typename std::decay_t<T>::ImplementationTag;
template<typename Node>
std::size_t degree(const Node& node)
{
return degree(&node,NodeTag<Node>());
}
#ifndef DOXYGEN
template<typename Node, typename NodeTag>
std::size_t degree(const Node* node, NodeTag)
{
return node->degree();
}
#endif // DOXYGEN
template<typename Node>
using StaticDegree = decltype(Node::degree());
} // namespace TypeTree
} //namespace Dune
#endif // DUNE_TYPETREE_NODEINTERFACE_HH
Dune::TypeTree::degree
std::size_t degree(const Node &node)
Returns the degree of node as run time information.
Definition nodeinterface.hh:79
Dune::TypeTree::ImplementationTag
typename std::decay_t< T >::ImplementationTag ImplementationTag
Returns the implementation tag of the given Node.
Definition nodeinterface.hh:74
Dune::TypeTree::StaticDegree
decltype(Node::degree()) StaticDegree
Returns the statically known degree of the given Node type as a std::integral_constant.
Definition nodeinterface.hh:107
Dune::TypeTree::NodeTag
typename std::decay_t< Node >::NodeTag NodeTag
Returns the node tag of the given Node.
Definition nodeinterface.hh:70
Dune
Definition accumulate_static.hh:17
Dune::TypeTree
Definition accumulate_static.hh:18
Dune::TypeTree::NodeInterface
Interface for nodes in a dune-typetree.
Definition nodeinterface.hh:35
Dune::TypeTree::NodeInterface::degree
static auto degree()
Number of children of this node in the dune-typetree.
Dune::TypeTree::NodeInterface::isPower
static const bool isPower
Whether this is a power node in the dune-typetree.
Definition nodeinterface.hh:40
Dune::TypeTree::NodeInterface::isLeaf
static const bool isLeaf
Whether this is a leaf node in a dune-typetree.
Definition nodeinterface.hh:37
Dune::TypeTree::NodeInterface::NodeStorage
ImplementationDefined NodeStorage
container type to pass around a collection of children
Definition nodeinterface.hh:65
Dune::TypeTree::NodeInterface::isComposite
static const bool isComposite
Whether this is a composite node in the dune-typetree.
Definition nodeinterface.hh:43
Dune::TypeTree::NodeInterface::NodeTag
ImplementationDefined NodeTag
The type tag that describes what kind of node this is.
Definition nodeinterface.hh:59