26 #ifndef OPM_PROPERTY_SYSTEM_HH 27 #define OPM_PROPERTY_SYSTEM_HH 29 #include <dune/common/classname.hh> 32 #include <type_traits> 35 namespace Properties {
40 template <
class TypeTag,
class MyTypeTag>
43 using type = std::tuple<>;
52 -> decltype(std::integral_constant<
bool, !std::is_same<typename P::type, UndefinedProperty>::value>{})
62 -> decltype(std::declval<typename T::InheritsFrom>(), std::true_type{})
70 template<
class ...Tuples>
71 using ConCatTuples = decltype(std::tuple_cat(std::declval<Tuples>()...));
74 template<
class TypeTag,
template<
class,
class>
class Property,
class TTagList>
78 template<
class TypeTag,
template<
class,
class>
class Property,
class TTagList,
class Enable>
81 template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
82 struct GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>, std::enable_if_t<hasParentTypeTag<LastTypeTag>(int{}), void>>
85 template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
86 struct GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>, std::enable_if_t<!hasParentTypeTag<LastTypeTag>(int{}), void>>
89 template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
90 struct GetNextTypeTag<TypeTag, Property, std::tuple<FirstTypeTag, Args...>, std::enable_if_t<hasParentTypeTag<FirstTypeTag>(int{}), void>>
91 {
using type =
typename GetDefined<TypeTag, Property,
ConCatTuples<
typename FirstTypeTag::InheritsFrom, std::tuple<Args...>>>::type; };
93 template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
94 struct GetNextTypeTag<TypeTag, Property, std::tuple<FirstTypeTag, Args...>, std::enable_if_t<!hasParentTypeTag<FirstTypeTag>(int{}), void>>
95 {
using type =
typename GetDefined<TypeTag, Property, std::tuple<Args...>>::type; };
97 template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
98 struct GetDefined<TypeTag, Property, std::tuple<LastTypeTag>>
106 #pragma clang diagnostic push 107 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 109 using LastType = Property<TypeTag, LastTypeTag>;
111 #pragma clang diagnostic pop 113 using type = std::conditional_t<isDefinedProperty<LastType>(
int{}), LastType,
114 typename GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>,
void>::type>;
117 template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
118 struct GetDefined<TypeTag, Property, std::tuple<FirstTypeTag, Args...>>
122 #pragma clang diagnostic push 123 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 125 using FirstType = Property<TypeTag, FirstTypeTag>;
127 #pragma clang diagnostic pop 129 using type = std::conditional_t<isDefinedProperty<FirstType>(
int{}), FirstType,
130 typename GetNextTypeTag<TypeTag, Property, std::tuple<FirstTypeTag, Args...>,
void>::type>;
135 template<
class TypeTag,
class TTagList>
139 template<
class TypeTag,
class TTagList,
class Enable>
142 template<
class TypeTag,
class LastTypeTag>
143 struct GetNextSpliceTypeTag<TypeTag, std::tuple<LastTypeTag>, std::enable_if_t<hasParentTypeTag<LastTypeTag>(int{}), void>>
146 template<
class TypeTag,
class LastTypeTag>
147 struct GetNextSpliceTypeTag<TypeTag, std::tuple<LastTypeTag>, std::enable_if_t<!hasParentTypeTag<LastTypeTag>(int{}), void>>
148 {
using type = std::tuple<>; };
150 template<
class TypeTag,
class FirstTypeTag,
class ...Args>
151 struct GetNextSpliceTypeTag<TypeTag, std::tuple<FirstTypeTag, Args...>, std::enable_if_t<hasParentTypeTag<FirstTypeTag>(int{}), void>>
154 template<
class TypeTag,
class FirstTypeTag,
class ...Args>
155 struct GetNextSpliceTypeTag<TypeTag, std::tuple<FirstTypeTag, Args...>, std::enable_if_t<!hasParentTypeTag<FirstTypeTag>(int{}), void>>
156 {
using type =
typename GetDefinedSplice<TypeTag, std::tuple<Args...>>::type; };
161 -> decltype(std::integral_constant<
bool, !std::is_same<
typename S::type, std::tuple<>>::value>{})
168 template<
class TypeTag,
class LastTypeTag>
174 std::tuple<LastTypeTag>,
175 typename LastSplice::type
179 using type = std::conditional_t<isDefinedSplice<LastSplice>(
int{}),
184 template<
class TypeTag,
class FirstTypeTag,
class ...Args>
190 std::tuple<FirstTypeTag, Args...>,
191 typename FirstSplice::type
195 using type = std::conditional_t<isDefinedSplice<FirstSplice>(
int{}),
201 template<
class TypeTag,
template<
class,
class>
class Property>
209 static_assert(!std::is_same<type, UndefinedProperty>::value,
"Property is undefined!");
212 template<
class TypeTag,
class SpliceTypeTag,
template<
class,
class>
class Property>
216 static_assert(!std::is_same<type, std::tuple<>>::value,
"Splice is undefined!");
223 template<
class TypeTag,
template<
class,
class>
class Property>
224 using GetProp =
typename Properties::Detail::GetPropImpl<TypeTag, Property>::type;
228 #pragma clang diagnostic push 229 #pragma clang diagnostic ignored "-Wdeprecated-declarations" 231 template<
class TypeTag,
template<
class,
class>
class Property>
235 template<
class TypeTag,
class SpliceTypeTag,
template<
class,
class>
class Property>
239 template<
class TypeTag,
template<
class,
class>
class Property>
243 #pragma clang diagnostic pop typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(...))
Definition: propertysystem.hh:233
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property (equivalent to old macro GET_PROP(...))
Definition: propertysystem.hh:224
constexpr auto hasParentTypeTag(int) -> decltype(std::declval< typename T::InheritsFrom >(), std::true_type
check if a TypeTag inherits from other TypeTags
Definition: propertysystem.hh:61
Definition: propertysystem.hh:41
decltype(std::tuple_cat(std::declval< Tuples >()...)) ConCatTuples
helper alias to concatenate multiple tuples
Definition: propertysystem.hh:71
a tag to mark properties as undefined
Definition: propertysystem.hh:38
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
constexpr auto getPropValue()
get the value data member of a property
Definition: propertysystem.hh:240
helper struct to get the first property that is defined in the TypeTag hierarchy
Definition: propertysystem.hh:75
helper struct to get the first property that is defined in the TypeTag hierarchy
Definition: propertysystem.hh:136
helper struct to iterate over the TypeTag hierarchy
Definition: propertysystem.hh:79
helper struct to iterate over the TypeTag hierarchy
Definition: propertysystem.hh:140
helper struct to extract get the Property specilization given a TypeTag, asserts that the property is...
Definition: propertysystem.hh:202
constexpr auto isDefinedProperty(int) -> decltype(std::integral_constant< bool, !std::is_same< typename P::type, UndefinedProperty >::value >
check if a property P is defined
Definition: propertysystem.hh:51
constexpr auto isDefinedSplice(int) -> decltype(std::integral_constant< bool, !std::is_same< typename S::type, std::tuple<>>::value >
check if a splice S is defined
Definition: propertysystem.hh:160
Definition: propertysystem.hh:213