Loading...
Searching...
No Matches
generictransformationdescriptors.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_GENERICTRANSFORMATIONDESCRIPTORS_HH
#define DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
#include <array>
#include <memory>
#include <vector>
#include <dune/typetree/nodeinterface.hh>
#include <dune/typetree/nodetags.hh>
#include <dune/typetree/powercompositenodetransformationtemplates.hh>
#include <dune/common/exceptions.hh>
namespace Dune {
namespace TypeTree {
template<typename SourceNode, typename Transformation, typename TransformedNode>
struct GenericLeafNodeTransformation
{
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(s,t);
}
static transformed_type transform(std::shared_ptr<const SourceNode> s, const Transformation& t)
{
return transformed_type(s,t);
}
static transformed_storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t)
{
return std::make_shared<transformed_type>(s,t);
}
};
template<typename SourceNode, typename Transformation, template<typename Child> class TransformedNodeTemplate>
struct TemplatizedGenericPowerNodeTransformation
{
static const bool recursive = true;
template<typename TC>
struct result
{
typedef typename TransformedNodeTemplate<TC>::type 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(s,t,children);
}
template<typename TC>
static typename result<TC>::type transform(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::degree>& children)
{
return typename result<TC>::type(s,t,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>(s,t,children);
}
};
template<typename SourceNode, typename Transformation, template<typename,typename,std::size_t> class TransformedNode>
struct GenericPowerNodeTransformation
: public TemplatizedGenericPowerNodeTransformation<SourceNode,
Transformation,
GenericPowerNodeTransformationTemplate<SourceNode,
Transformation,
TransformedNode>::template result
>
{};
template<typename SourceNode, typename Transformation, template<typename Child> class TransformedNodeTemplate>
struct TemplatizedGenericDynamicPowerNodeTransformation
{
static const bool recursive = true;
template<typename TC>
struct result
{
typedef typename TransformedNodeTemplate<TC>::type 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(s,t,children);
}
template<typename TC>
static typename result<TC>::type transform(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::vector<std::shared_ptr<TC>>& children)
{
return typename result<TC>::type(s,t,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>(s,t,children);
}
};
template<typename SourceNode, typename Transformation, template<typename,typename> class TransformedNode>
struct GenericDynamicPowerNodeTransformation
: public TemplatizedGenericDynamicPowerNodeTransformation<SourceNode,
Transformation,
GenericDynamicPowerNodeTransformationTemplate<SourceNode,
Transformation,
TransformedNode>::template result
>
{};
template<typename SourceNode, typename Transformation, template<typename...> class TransformedNodeTemplate>
struct TemplatizedGenericCompositeNodeTransformation
{
static const bool recursive = true;
template<typename... TC>
struct result
{
typedef typename TransformedNodeTemplate<TC...>::type 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(s,t,children...);
}
template<typename... TC>
static typename result<TC...>::type transform(std::shared_ptr<const SourceNode> s, const Transformation& t, std::shared_ptr<TC>... children)
{
return typename result<TC...>::type(s,t,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>(s,t,children...);
}
};
template<typename SourceNode, typename Transformation, template<typename,typename...> class TransformedNode>
struct GenericCompositeNodeTransformation
: public TemplatizedGenericCompositeNodeTransformation<SourceNode,
Transformation,
GenericCompositeNodeTransformationTemplate<SourceNode,
Transformation,
TransformedNode>::template result
>
{};
} // namespace TypeTree
} //namespace Dune
#endif // DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
nodetags.hh
powercompositenodetransformationtemplates.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::GenericLeafNodeTransformation
Definition generictransformationdescriptors.hh:29
Dune::TypeTree::GenericLeafNodeTransformation::transformed_type
TransformedNode transformed_type
Definition generictransformationdescriptors.hh:33
Dune::TypeTree::GenericLeafNodeTransformation::transformed_storage_type
std::shared_ptr< transformed_type > transformed_storage_type
Definition generictransformationdescriptors.hh:34
Dune::TypeTree::GenericLeafNodeTransformation::transform
static transformed_type transform(std::shared_ptr< const SourceNode > s, const Transformation &t)
Definition generictransformationdescriptors.hh:41
Dune::TypeTree::GenericLeafNodeTransformation::recursive
static const bool recursive
Definition generictransformationdescriptors.hh:31
Dune::TypeTree::GenericLeafNodeTransformation::transform_storage
static transformed_storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t)
Definition generictransformationdescriptors.hh:46
Dune::TypeTree::GenericLeafNodeTransformation::transform
static transformed_type transform(const SourceNode &s, const Transformation &t)
Definition generictransformationdescriptors.hh:36
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation
Definition generictransformationdescriptors.hh:56
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::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 generictransformationdescriptors.hh:81
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::recursive
static const bool recursive
Definition generictransformationdescriptors.hh:58
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::transform
static result< TC >::type transform(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::degree > &children)
Definition generictransformationdescriptors.hh:75
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::transform
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::degree > &children)
Definition generictransformationdescriptors.hh:69
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::result
Definition generictransformationdescriptors.hh:62
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::result::type
TransformedNodeTemplate< TC >::type type
Definition generictransformationdescriptors.hh:63
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::result::degree
static const std::size_t degree
Definition generictransformationdescriptors.hh:65
Dune::TypeTree::TemplatizedGenericPowerNodeTransformation::result::storage_type
std::shared_ptr< type > storage_type
Definition generictransformationdescriptors.hh:64
Dune::TypeTree::GenericPowerNodeTransformation
Definition generictransformationdescriptors.hh:97
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation
Definition generictransformationdescriptors.hh:102
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation::transform
static result< TC >::type transform(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::vector< std::shared_ptr< TC > > &children)
Definition generictransformationdescriptors.hh:120
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation::recursive
static const bool recursive
Definition generictransformationdescriptors.hh:104
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation::transform
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const std::vector< std::shared_ptr< TC > > &children)
Definition generictransformationdescriptors.hh:114
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation::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 generictransformationdescriptors.hh:126
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation::result
Definition generictransformationdescriptors.hh:108
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation::result::type
TransformedNodeTemplate< TC >::type type
Definition generictransformationdescriptors.hh:109
Dune::TypeTree::TemplatizedGenericDynamicPowerNodeTransformation::result::storage_type
std::shared_ptr< type > storage_type
Definition generictransformationdescriptors.hh:110
Dune::TypeTree::GenericDynamicPowerNodeTransformation
Definition generictransformationdescriptors.hh:142
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation
Definition generictransformationdescriptors.hh:147
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation::transform
static result< TC... >::type transform(const SourceNode &s, const Transformation &t, std::shared_ptr< TC >... children)
Definition generictransformationdescriptors.hh:159
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation::transform_storage
static result< TC... >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, std::shared_ptr< TC >... children)
Definition generictransformationdescriptors.hh:171
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation::transform
static result< TC... >::type transform(std::shared_ptr< const SourceNode > s, const Transformation &t, std::shared_ptr< TC >... children)
Definition generictransformationdescriptors.hh:165
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation::recursive
static const bool recursive
Definition generictransformationdescriptors.hh:149
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation::result
Definition generictransformationdescriptors.hh:153
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation::result::type
TransformedNodeTemplate< TC... >::type type
Definition generictransformationdescriptors.hh:154
Dune::TypeTree::TemplatizedGenericCompositeNodeTransformation::result::storage_type
std::shared_ptr< type > storage_type
Definition generictransformationdescriptors.hh:155
Dune::TypeTree::GenericCompositeNodeTransformation
Definition generictransformationdescriptors.hh:187