OGS
ProcessLib::Graph::detail Namespace Reference

Classes

struct  GetFlattenedTupleOfPassedArgs
 
struct  GetFlattenedTupleOfPassedArgs< Result(*)(DeclaredArgs...), Tuples... >
 
struct  GetFlattenedTupleOfPassedArgs< Result(Class::*)(DeclaredArgs...) const, ClassAndPassedArgsTuples... >
 
struct  GetFlattenedTupleOfPassedArgs< Result(Class::*)(DeclaredArgs...), ClassAgain, PassedArgsTuples... >
 
struct  GetFlattenedTupleTypes
 
struct  GetFunctionArgumentTypes
 
struct  GetFunctionArgumentTypes< Result(*)(Args...)>
 
struct  GetFunctionArgumentTypes< Result(Class::*)(Args...) const >
 
struct  GetFunctionArgumentTypes< Result(Class::*)(Args...)>
 
struct  GetFunctionReturnType
 
struct  GetFunctionReturnType< Result(*)(Args...)>
 
struct  GetFunctionReturnType< Result(Class::*)(Args...) const >
 
struct  GetFunctionReturnType< Result(Class::*)(Args...)>
 
struct  IsInputArgument
 
struct  IsOutputArgument
 

Typedefs

template<typename Function >
using GetFunctionArgumentTypesPlain
 

Functions

template<typename Object , typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
auto unpackAndInvoke (boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... >, Object &&o, Tuples &... ts) -> typename GetFunctionReturnType< decltype(&std::decay_t< Object >::operator())>::type
 
template<typename Result , typename Object , typename... Args, typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
Result unpackAndInvoke (boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... >, Result(Object::*m)(Args...), Object &o, Tuples &... ts)
 
template<typename Result , typename Object , typename... Args, typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
Result unpackAndInvoke (boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... >, Result(Object::*m)(Args...), Object &&o, Tuples &... ts)
 
template<typename Result , typename Object , typename... Args, typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
Result unpackAndInvoke (boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... >, Result(Object::*m)(Args...) const, Object const &o, Tuples &... ts)
 
template<typename Result , typename... Args, typename... Tuples, typename... FunctionArgumentTypesPlain>
Result unpackAndInvoke (boost::mp11::mp_list< FunctionArgumentTypesPlain... >, Result(*fct)(Args...), Tuples &... ts)
 
template<typename Function , typename... Args>
auto applyImpl (Function &&f, Args &&... args) -> typename detail::GetFunctionReturnType< std::decay_t< Function > >::type
 
template<typename Model >
bool isEvalOrderCorrectRT (std::unordered_set< std::type_index > &computed_data)
 
template<typename... Models>
bool isEvalOrderCorrectRT (boost::mp11::mp_list< Models... >, std::unordered_set< std::type_index > &&computed_data)
 
template<typename Model , typename TupleOfArgs >
Model constructModel (TupleOfArgs &args)
 
template<template< typename... > typename Tuple, typename... Models, typename TupleOfArgs >
Tuple< Models... > constructModels (std::type_identity< Tuple< Models... > >, TupleOfArgs &&args)
 
template<typename T , typename Tuple , typename... Tuples>
auto & getImpl (Tuple &t, Tuples &... ts)
 

Typedef Documentation

◆ GetFunctionArgumentTypesPlain

Initial value:
std::type_identity<boost::mp11::mp_transform<
std::remove_cvref_t,
typename GetFunctionArgumentTypes<Function>::type>>

Definition at line 49 of file Apply.h.

Function Documentation

◆ applyImpl()

template<typename Function , typename... Args>
auto ProcessLib::Graph::detail::applyImpl ( Function && f,
Args &&... args ) -> typename detail::GetFunctionReturnType<std::decay_t<Function>>::type

Invokes the passed function f.

f can be a function object, a free function, or a member function pointer. In the latter case, the first entry of args must be the object for which f shall be invoked. (The remainder of) args are an arbitrary number of tuples from which arguments to f are taken based on their types.

See also
ProcessLib::Graph::apply()

Definition at line 220 of file Apply.h.

222{
223 using namespace boost::mp11;
224
225 using FunctionPlain = std::decay_t<Function>;
226 using FlattenedTuple =
227 typename GetFlattenedTupleOfPassedArgs<FunctionPlain, Args...>::type;
228 using FlattenedTupleOfPlainTypes =
229 mp_transform<std::remove_cvref_t, FlattenedTuple>;
230
231 static_assert(
232 mp_is_set_v<FlattenedTupleOfPlainTypes>,
233 "The types of all elements of all passed tuples must be unique.");
234
235 using FunctionArgumentTypesPlain =
237
238 static_assert(
239 mp_is_set_v<FunctionArgumentTypesPlain>,
240 "The argument types of the function to be called must be unique.");
241
242 return unpackAndInvoke(FunctionArgumentTypesPlain{},
243 std::forward<Function>(f),
244 std::forward<Args>(args)...);
245}
auto unpackAndInvoke(boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... >, Object &&o, Tuples &... ts) -> typename GetFunctionReturnType< decltype(&std::decay_t< Object >::operator())>::type
Definition Apply.h:91
std::type_identity< boost::mp11::mp_transform< std::remove_cvref_t, typename GetFunctionArgumentTypes< Function >::type > > GetFunctionArgumentTypesPlain
Definition Apply.h:49

References unpackAndInvoke().

Referenced by ProcessLib::Graph::apply(), constructModel(), and ProcessLib::Graph::eval().

◆ constructModel()

template<typename Model , typename TupleOfArgs >
Model ProcessLib::Graph::detail::constructModel ( TupleOfArgs & args)

Definition at line 29 of file ConstructModels.h.

30{
31 if constexpr (HasCreate<Model>)
32 {
33 return applyImpl(&Model::create, args);
34 }
35 else if constexpr (std::is_default_constructible_v<Model>)
36 {
37 return Model{};
38 }
39 else
40 {
41 static_assert(std::is_default_constructible_v<
42 Model> /* This is definitely false, here. */,
43 "The model to be constructed has neither a static "
44 "create() function nor is it default constructible.");
45 }
46}
auto applyImpl(Function &&f, Args &&... args) -> typename detail::GetFunctionReturnType< std::decay_t< Function > >::type
Definition Apply.h:220

References applyImpl().

Referenced by constructModels().

◆ constructModels()

template<template< typename... > typename Tuple, typename... Models, typename TupleOfArgs >
Tuple< Models... > ProcessLib::Graph::detail::constructModels ( std::type_identity< Tuple< Models... > > ,
TupleOfArgs && args )

Definition at line 50 of file ConstructModels.h.

52{
53 return Tuple{constructModel<Models>(args)...};
54}

References constructModel().

Referenced by ProcessLib::Graph::constructModels().

◆ getImpl()

template<typename T , typename Tuple , typename... Tuples>
auto & ProcessLib::Graph::detail::getImpl ( Tuple & t,
Tuples &... ts )

Definition at line 21 of file Get.h.

22{
23 using namespace boost::mp11;
24
25 using PlainTuple = std::remove_cv_t<Tuple>;
26 using TupleOfPlainTypes = mp_transform<std::remove_cvref_t, PlainTuple>;
27 using Index = mp_find<TupleOfPlainTypes, T>;
28
29 if constexpr (Index::value != mp_size<PlainTuple>::value)
30 {
31 return std::get<Index::value>(t);
32 }
33 else
34 {
35 return getImpl<T>(ts...);
36 }
37}

References getImpl().

Referenced by ProcessLib::Graph::get(), and getImpl().

◆ isEvalOrderCorrectRT() [1/2]

template<typename... Models>
bool ProcessLib::Graph::detail::isEvalOrderCorrectRT ( boost::mp11::mp_list< Models... > ,
std::unordered_set< std::type_index > && computed_data )

Definition at line 98 of file CheckEvalOrderRT.h.

100{
101 return (isEvalOrderCorrectRT<Models>(computed_data) && ...);
102}

References ProcessLib::Graph::isEvalOrderCorrectRT().

◆ isEvalOrderCorrectRT() [2/2]

template<typename Model >
bool ProcessLib::Graph::detail::isEvalOrderCorrectRT ( std::unordered_set< std::type_index > & computed_data)

Definition at line 45 of file CheckEvalOrderRT.h.

46{
47 using namespace boost::mp11;
48
49 using ModelArgs =
50 typename GetFunctionArgumentTypes<decltype(&Model::eval)>::type;
51 using ModelInputs = mp_filter<IsInputArgument, ModelArgs>;
52 using ModelOutputs = mp_filter<IsOutputArgument, ModelArgs>;
53
54 using ModelInputsWrapped = mp_transform<mp_identity, ModelInputs>;
55
56 // Check that all inputs have already been computed before.
57 bool all_inputs_computed = true;
58 mp_for_each<ModelInputsWrapped>(
59 [&computed_data,
60 &all_inputs_computed]<typename Input>(mp_identity<Input>)
61 {
62 if (!computed_data.contains(std::type_index{typeid(Input)}))
63 {
64 ERR("Input {} of model {} has not been computed/set before the "
65 "model evaluation.",
66 typeid(Input).name(), typeid(Model).name());
67 all_inputs_computed = false;
68 }
69 });
70 if (!all_inputs_computed)
71 {
72 return false;
73 }
74
75 using ModelOutputsWrapped = mp_transform<mp_identity, ModelOutputs>;
76
77 // All outputs are "computed data", now.
78 bool no_output_precomputed = true;
79 mp_for_each<ModelOutputsWrapped>(
80 [&computed_data,
81 &no_output_precomputed]<typename Output>(mp_identity<Output>)
82 {
83 auto const [it, emplaced] = computed_data.emplace(typeid(Output));
84
85 if (!emplaced)
86 {
87 ERR("Output {} of model {} is computed more than once.",
88 typeid(Output).name(),
89 typeid(Model).name());
90 no_output_precomputed = false;
91 }
92 });
93
94 return no_output_precomputed;
95}
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:45

References ERR().

Referenced by ProcessLib::Graph::isEvalOrderCorrectRT().

◆ unpackAndInvoke() [1/5]

template<typename Result , typename... Args, typename... Tuples, typename... FunctionArgumentTypesPlain>
Result ProcessLib::Graph::detail::unpackAndInvoke ( boost::mp11::mp_list< FunctionArgumentTypesPlain... > ,
Result(* fct )(Args...),
Tuples &... ts )

Definition at line 155 of file Apply.h.

158{
160}
auto & get(Tuples &... ts)
Definition Get.h:59

References ProcessLib::Graph::get().

◆ unpackAndInvoke() [2/5]

template<typename Object , typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
auto ProcessLib::Graph::detail::unpackAndInvoke ( boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... > ,
Object && o,
Tuples &... ts ) -> typename GetFunctionReturnType< decltype(&std::decay_t<Object>::operator())>::type

Definition at line 91 of file Apply.h.

97{
98 return o(
100}

References ProcessLib::Graph::get().

Referenced by applyImpl().

◆ unpackAndInvoke() [3/5]

template<typename Result , typename Object , typename... Args, typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
Result ProcessLib::Graph::detail::unpackAndInvoke ( boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... > ,
Result(Object::* )(Args...) const,
Object const & o,
Tuples &... ts )

Definition at line 140 of file Apply.h.

145{
146 return (o.*m)(
148}

References ProcessLib::Graph::get().

◆ unpackAndInvoke() [4/5]

template<typename Result , typename Object , typename... Args, typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
Result ProcessLib::Graph::detail::unpackAndInvoke ( boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... > ,
Result(Object::* )(Args...),
Object && o,
Tuples &... ts )

Definition at line 124 of file Apply.h.

129{
130 return (o.*m)(
132}

References ProcessLib::Graph::get().

◆ unpackAndInvoke() [5/5]

template<typename Result , typename Object , typename... Args, typename... Tuples, typename... MemberFunctionArgumentTypesPlain>
Result ProcessLib::Graph::detail::unpackAndInvoke ( boost::mp11::mp_list< MemberFunctionArgumentTypesPlain... > ,
Result(Object::* )(Args...),
Object & o,
Tuples &... ts )

Definition at line 108 of file Apply.h.

113{
114 return (o.*m)(
116}

References ProcessLib::Graph::get().