26#ifndef DUMUX_PROPERTY_SYSTEM_HH
27#define DUMUX_PROPERTY_SYSTEM_HH
44namespace Dumux::Properties::Detail {
48constexpr auto isDefinedProperty(
int)
49->
decltype(std::integral_constant<bool, !std::is_same_v<typename P::type, UndefinedProperty>>{})
54constexpr std::true_type isDefinedProperty(...) {
return {}; }
58constexpr auto hasParentTypeTag(
int)
59->
decltype(std::declval<typename T::InheritsFrom>(), std::true_type{})
64constexpr std::false_type hasParentTypeTag(...)
68template<
class ...Tuples>
69using ConCatTuples =
decltype(std::tuple_cat(std::declval<Tuples>()...));
72template<
class TypeTag,
template<
class,
class>
class Property,
class TTagList>
76template<
class TypeTag,
template<
class,
class>
class Property,
class TTagList,
class Enable>
79template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
80struct GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>, std::enable_if_t<hasParentTypeTag<LastTypeTag>(int{}), void>>
81{
using type =
typename GetDefined<TypeTag, Property, typename LastTypeTag::InheritsFrom>::type; };
83template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
84struct GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>, std::enable_if_t<!hasParentTypeTag<LastTypeTag>(int{}), void>>
85{
using type = UndefinedProperty; };
87template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
88struct GetNextTypeTag<TypeTag, Property, std::tuple<FirstTypeTag, Args...>, std::enable_if_t<hasParentTypeTag<FirstTypeTag>(int{}), void>>
89{
using type =
typename GetDefined<TypeTag, Property, ConCatTuples<
typename FirstTypeTag::InheritsFrom, std::tuple<Args...>>>::type; };
91template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
92struct GetNextTypeTag<TypeTag, Property, std::tuple<FirstTypeTag, Args...>, std::enable_if_t<!hasParentTypeTag<FirstTypeTag>(int{}), void>>
93{
using type =
typename GetDefined<TypeTag, Property, std::tuple<Args...>>::type; };
95template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
96struct GetDefined<TypeTag, Property, std::tuple<LastTypeTag>>
104#pragma clang diagnostic push
105#pragma clang diagnostic ignored "-Wdeprecated-declarations"
107 using LastType = Property<TypeTag, LastTypeTag>;
109#pragma clang diagnostic pop
111 using type = std::conditional_t<isDefinedProperty<LastType>(
int{}), LastType,
112 typename GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>,
void>::type>;
115template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
116struct GetDefined<TypeTag, Property, std::tuple<FirstTypeTag, Args...>>
120#pragma clang diagnostic push
121#pragma clang diagnostic ignored "-Wdeprecated-declarations"
123 using FirstType = Property<TypeTag, FirstTypeTag>;
125#pragma clang diagnostic pop
127 using type = std::conditional_t<isDefinedProperty<FirstType>(
int{}), FirstType,
128 typename GetNextTypeTag<TypeTag, Property, std::tuple<FirstTypeTag, Args...>,
void>::type>;
132template<
class TypeTag,
template<
class,
class>
class Property>
135 using type =
typename Detail::GetDefined<TypeTag, Property, std::tuple<TypeTag>>::type;
136 static_assert(!std::is_same_v<type, UndefinedProperty>,
"Property is undefined!");
139template<
class TypeTag,
template<
class,
class>
class Property,
class T>
142 using PT =
typename Detail::GetDefined<TypeTag, Property, std::tuple<TypeTag>>::type;
143 struct WrapperT {
using type = T; };
144 using type = std::conditional_t<std::is_same_v<PT, UndefinedProperty>, WrapperT, PT>;
154template<
class TypeTag,
template<
class,
class>
class Property>
157 using type =
typename Detail::GetDefined<TypeTag, Property, std::tuple<TypeTag>>::type;
158 return !std::is_same_v<type, UndefinedProperty>;
166template<
class TypeTag,
template<
class,
class>
class Property>
167using GetProp =
typename Properties::Detail::GetPropImpl<TypeTag, Property>::type;
170template<
class TypeTag,
template<
class,
class>
class Property,
class T>
171using GetPropOr =
typename Properties::Detail::GetPropOrImpl<TypeTag, Property, T>::type;
175#pragma clang diagnostic push
176#pragma clang diagnostic ignored "-Wdeprecated-declarations"
179template<
class TypeTag,
template<
class,
class>
class Property>
183template<
class TypeTag,
template<
class,
class>
class Property,
class T>
187template<
class TypeTag,
template<
class,
class>
class Property>
190#pragma clang diagnostic pop
Adaption of the non-isothermal two-phase two-component flow model to problems with CO2.
Definition: adapt.hh:29
constexpr auto getPropValue()
get the value data member of a property
Definition: propertysystem.hh:188
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property
Definition: propertysystem.hh:167
typename Properties::Detail::GetPropOrImpl< TypeTag, Property, T >::type GetPropOr
get the type of a property or the type T if the property is undefined
Definition: propertysystem.hh:171
typename GetProp< TypeTag, Property >::type GetPropType
get the type alias defined in the property
Definition: propertysystem.hh:180
typename GetPropOr< TypeTag, Property, T >::type GetPropTypeOr
get the type alias defined in the property or the type T if the property is undefined
Definition: propertysystem.hh:184
Definition: common/properties.hh:37
constexpr bool hasDefinedType()
whether the property is defined/specialized for TypeTag
Definition: propertysystem.hh:155
a tag to mark properties as undefined
Definition: propertysystem.hh:35