Loading...
Searching...
No Matches
simpletransformationdescriptors.hh
Go to the documentation of this file.
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 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_SIMPLETRANSFORMATIONDESCRIPTORS_HH
#define DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
#include <array>
#include <memory>
#include <vector>
#include <dune/typetree/nodeinterface.hh>
#include <dune/typetree/nodetags.hh>
#include <dune/common/exceptions.hh>
namespace Dune {
namespace TypeTree {
template<typename SourceNode, typename Transformation, typename TransformedNode>
struct SimpleLeafNodeTransformation
{
static const bool recursive = false;
typedef TransformedNode transformed_type;
typedef std::shared_ptr<transformed_type> transformed_storage_type;
static transformed_type transform(const SourceNode& s, const Transformation& t)
{
return transformed_type();
}
static transformed_storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t)
{
return std::make_shared<transformed_type>();
}
};
template<typename SourceNode, typename Transformation, template<typename Child, std::size_t> class TransformedNode>
struct SimplePowerNodeTransformation
{
static const bool recursive = true;
template<typename TC>
struct result
{
typedef TransformedNode<TC, StaticDegree<SourceNode>::value> type;
typedef std::shared_ptr<type> storage_type;
static const std::size_t degree = StaticDegree<type>::value;
};
template<typename TC>
static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::degree>& children)
{
return typename result<TC>::type(children);
}
template<typename TC>
static typename result<TC>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::degree>& children)
{
return std::make_shared<typename result<TC>::type>(children);
}
};
template<typename SourceNode, typename Transformation, template<typename Child> class TransformedNode>
struct SimpleDynamicPowerNodeTransformation
{
static const bool recursive = true;
template<typename TC>
struct result
{
typedef TransformedNode<TC> type;
typedef std::shared_ptr<type> storage_type;
};
template<typename TC>
static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const std::vector<std::shared_ptr<TC>>& children)
{
return typename result<TC>::type(children);
}
template<typename TC>
static typename result<TC>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::vector<std::shared_ptr<TC>>& children)
{
return std::make_shared<typename result<TC>::type>(children);
}
};
template<typename SourceNode, typename Transformation, template<typename...> class TransformedNode>
struct SimpleCompositeNodeTransformation
{
static const bool recursive = true;
template<typename... TC>
struct result
{
typedef TransformedNode<TC...> type;
typedef std::shared_ptr<type> storage_type;
};
template<typename... TC>
static typename result<TC...>::type transform(const SourceNode& s, const Transformation& t, std::shared_ptr<TC>... children)
{
return typename result<TC...>::type(children...);
}
template<typename... TC>
static typename result<TC...>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, std::shared_ptr<TC>... children)
{
return std::make_shared<typename result<TC...>::type>(children...);
}
};
} // namespace TypeTree
} //namespace Dune
#endif // DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
nodetags.hh
nodeinterface.hh
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
Definition accumulate_static.hh:17
Dune::TypeTree
Definition accumulate_static.hh:18
Dune::TypeTree::SimpleLeafNodeTransformation
Definition simpletransformationdescriptors.hh:28
Dune::TypeTree::SimpleLeafNodeTransformation::transform
static transformed_type transform(const SourceNode &s, const Transformation &t)
Definition simpletransformationdescriptors.hh:35
Dune::TypeTree::SimpleLeafNodeTransformation::recursive
static const bool recursive
Definition simpletransformationdescriptors.hh:30
Dune::TypeTree::SimpleLeafNodeTransformation::transformed_storage_type
std::shared_ptr< transformed_type > transformed_storage_type
Definition simpletransformationdescriptors.hh:33
Dune::TypeTree::SimpleLeafNodeTransformation::transform_storage
static transformed_storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t)
Definition simpletransformationdescriptors.hh:40
Dune::TypeTree::SimpleLeafNodeTransformation::transformed_type
TransformedNode transformed_type
Definition simpletransformationdescriptors.hh:32
Dune::TypeTree::SimplePowerNodeTransformation
Definition simpletransformationdescriptors.hh:50
Dune::TypeTree::SimplePowerNodeTransformation::transform_storage
static result< TC >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::degree > &children)
Definition simpletransformationdescriptors.hh:69
Dune::TypeTree::SimplePowerNodeTransformation::recursive
static const bool recursive
Definition simpletransformationdescriptors.hh:52
Dune::TypeTree::SimplePowerNodeTransformation::transform
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::degree > &children)
Definition simpletransformationdescriptors.hh:63
Dune::TypeTree::SimplePowerNodeTransformation::result
Definition simpletransformationdescriptors.hh:56
Dune::TypeTree::SimplePowerNodeTransformation::result::type
TransformedNode< TC, StaticDegree< SourceNode >::value > type
Definition simpletransformationdescriptors.hh:57
Dune::TypeTree::SimplePowerNodeTransformation::result::degree
static const std::size_t degree
Definition simpletransformationdescriptors.hh:59
Dune::TypeTree::SimplePowerNodeTransformation::result::storage_type
std::shared_ptr< type > storage_type
Definition simpletransformationdescriptors.hh:58
Dune::TypeTree::SimpleDynamicPowerNodeTransformation
Definition simpletransformationdescriptors.hh:79
Dune::TypeTree::SimpleDynamicPowerNodeTransformation::recursive
static const bool recursive
Definition simpletransformationdescriptors.hh:81
Dune::TypeTree::SimpleDynamicPowerNodeTransformation::transform
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const std::vector< std::shared_ptr< TC > > &children)
Definition simpletransformationdescriptors.hh:91
Dune::TypeTree::SimpleDynamicPowerNodeTransformation::transform_storage
static result< TC >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::vector< std::shared_ptr< TC > > &children)
Definition simpletransformationdescriptors.hh:97
Dune::TypeTree::SimpleDynamicPowerNodeTransformation::result
Definition simpletransformationdescriptors.hh:85
Dune::TypeTree::SimpleDynamicPowerNodeTransformation::result::type
TransformedNode< TC > type
Definition simpletransformationdescriptors.hh:86
Dune::TypeTree::SimpleDynamicPowerNodeTransformation::result::storage_type
std::shared_ptr< type > storage_type
Definition simpletransformationdescriptors.hh:87
Dune::TypeTree::SimpleCompositeNodeTransformation
Definition simpletransformationdescriptors.hh:107
Dune::TypeTree::SimpleCompositeNodeTransformation::recursive
static const bool recursive
Definition simpletransformationdescriptors.hh:109
Dune::TypeTree::SimpleCompositeNodeTransformation::transform_storage
static result< TC... >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, std::shared_ptr< TC >... children)
Definition simpletransformationdescriptors.hh:125
Dune::TypeTree::SimpleCompositeNodeTransformation::transform
static result< TC... >::type transform(const SourceNode &s, const Transformation &t, std::shared_ptr< TC >... children)
Definition simpletransformationdescriptors.hh:119
Dune::TypeTree::SimpleCompositeNodeTransformation::result
Definition simpletransformationdescriptors.hh:113
Dune::TypeTree::SimpleCompositeNodeTransformation::result::storage_type
std::shared_ptr< type > storage_type
Definition simpletransformationdescriptors.hh:115
Dune::TypeTree::SimpleCompositeNodeTransformation::result::type
TransformedNode< TC... > type
Definition simpletransformationdescriptors.hh:114