26#ifndef OPM_PROPERTY_SYSTEM_HH
27#define OPM_PROPERTY_SYSTEM_HH
29#include <dune/common/classname.hh>
40template <
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{})
70template<
class ...Tuples>
71using ConCatTuples =
decltype(std::tuple_cat(std::declval<Tuples>()...));
74template<
class TypeTag,
template<
class,
class>
class Property,
class TTagList>
78template<
class TypeTag,
template<
class,
class>
class Property,
class TTagList,
class Enable>
81template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
82struct GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>, std::enable_if_t<hasParentTypeTag<LastTypeTag>(int{}), void>>
85template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
86struct GetNextTypeTag<TypeTag, Property, std::tuple<LastTypeTag>, std::enable_if_t<!hasParentTypeTag<LastTypeTag>(int{}), void>>
89template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
90struct 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; };
93template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
94struct 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; };
97template<
class TypeTag,
template<
class,
class>
class Property,
class LastTypeTag>
98struct 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>;
117template<
class TypeTag,
template<
class,
class>
class Property,
class FirstTypeTag,
class ...Args>
118struct 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>;
135template<
class TypeTag,
class TTagList>
139template<
class TypeTag,
class TTagList,
class Enable>
142template<
class TypeTag,
class LastTypeTag>
143struct GetNextSpliceTypeTag<TypeTag, std::tuple<LastTypeTag>, std::enable_if_t<hasParentTypeTag<LastTypeTag>(int{}), void>>
146template<
class TypeTag,
class LastTypeTag>
147struct GetNextSpliceTypeTag<TypeTag, std::tuple<LastTypeTag>, std::enable_if_t<!hasParentTypeTag<LastTypeTag>(int{}), void>>
148{
using type = std::tuple<>; };
150template<
class TypeTag,
class FirstTypeTag,
class ...Args>
151struct GetNextSpliceTypeTag<TypeTag, std::tuple<FirstTypeTag, Args...>, std::enable_if_t<hasParentTypeTag<FirstTypeTag>(int{}), void>>
154template<
class TypeTag,
class FirstTypeTag,
class ...Args>
155struct 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>{})
168template<
class TypeTag,
class LastTypeTag>
174 std::tuple<LastTypeTag>,
175 typename LastSplice::type
179 using type = std::conditional_t<isDefinedSplice<LastSplice>(
int{}),
184template<
class TypeTag,
class FirstTypeTag,
class ...Args>
190 std::tuple<FirstTypeTag, Args...>,
191 typename FirstSplice::type
195 using type = std::conditional_t<isDefinedSplice<FirstSplice>(
int{}),
201template<
class TypeTag,
template<
class,
class>
class Property>
209 static_assert(!std::is_same<type, UndefinedProperty>::value,
"Property is undefined!");
212template<
class TypeTag,
class SpliceTypeTag,
template<
class,
class>
class Property>
216 static_assert(!std::is_same<type, std::tuple<>>::value,
"Splice is undefined!");
223template<
class TypeTag,
template<
class,
class>
class Property>
224using GetProp =
typename Properties::Detail::GetPropImpl<TypeTag, Property>::type;
228#pragma clang diagnostic push
229#pragma clang diagnostic ignored "-Wdeprecated-declarations"
232template<
class TypeTag,
template<
class,
class>
class Property>
235template<
class TypeTag,
class SpliceTypeTag,
template<
class,
class>
class Property>
239template<
class TypeTag,
template<
class,
class>
class Property>
243#pragma clang diagnostic pop
implementation details for template meta programming
Definition propertysystem.hh:47
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
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
decltype(std::tuple_cat(std::declval< Tuples >()...)) ConCatTuples
helper alias to concatenate multiple tuples
Definition propertysystem.hh:71
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45
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
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type GetProp
get the type of a property (equivalent to old macro GET_PROP(...))
Definition propertysystem.hh:224
helper struct to get the first property that is defined in the TypeTag hierarchy
Definition propertysystem.hh:136
helper struct to get the first property that is defined in the TypeTag hierarchy
Definition propertysystem.hh:75
helper struct to iterate over the TypeTag hierarchy
Definition propertysystem.hh:140
helper struct to iterate over the TypeTag hierarchy
Definition propertysystem.hh:79
helper struct to extract get the Property specilization given a TypeTag, asserts that the property is...
Definition propertysystem.hh:203
Definition propertysystem.hh:214
Definition propertysystem.hh:42
a tag to mark properties as undefined
Definition propertysystem.hh:38