The property system. More...
Macros | |
#define | TTAG(TypeTagName) Ewoms::Properties::TTag::TypeTagName |
Convert a type tag name to a type. More... | |
#define | PTAG(PropTagName) Ewoms::Properties::PTag::PropTagName |
Makes a type out of a property tag name. More... | |
#define | NEW_TYPE_TAG(...) |
Define a new type tag. More... | |
#define | SET_SPLICES(TypeTagName, ...) |
Define splices for a given type tag. More... | |
#define | INHERITS_FROM(...) __VA_ARGS__ |
Syntactic sugar for NEW_TYPE_TAG. More... | |
#define | NEW_PROP_TAG(PTagName) |
Define a property tag. More... | |
#define | SET_PROP(EffTypeTagName, PropTagName) |
Set a property for a specific type tag. More... | |
#define | UNSET_PROP(EffTypeTagName, PropTagName) |
Explicitly unset a property for a type tag. More... | |
#define | SET_INT_PROP(EffTypeTagName, PropTagName, ...) |
Set a property to a simple constant integer value. More... | |
#define | SET_BOOL_PROP(EffTypeTagName, PropTagName, ...) |
Set a property to a simple constant boolean value. More... | |
#define | SET_TYPE_PROP(EffTypeTagName, PropTagName, ...) |
Set a property which defines a type. More... | |
#define | SET_SCALAR_PROP(EffTypeTagName, PropTagName, ...) |
Set a property to a simple constant scalar value. More... | |
#define | SET_STRING_PROP(EffTypeTagName, PropTagName, ...) |
Set a property to a simple constant string value. More... | |
#define | SET_TAG_PROP(EffTypeTagName, PropTagName, ValueTypeTagName) |
Define a property containing a type tag. More... | |
#define | GET_PROP(TypeTag, PropTagName) ::Ewoms::Properties::GetProperty<TypeTag, PTAG(PropTagName)>::p |
Retrieve a property for a type tag. More... | |
#define | GET_PROP_VALUE(TypeTag, PropTagName) ::Ewoms::Properties::GetProperty<TypeTag, PTAG(PropTagName)>::p::value |
Access the value attribute of a property for a type tag. More... | |
#define | GET_PROP_TYPE(TypeTag, PropTagName) ::Ewoms::Properties::GetProperty<TypeTag, PTAG(PropTagName)>::p::type |
Access the type attribute of a property for a type tag. More... | |
#define | PROP_DIAGNOSTIC(TypeTag, PropTagName) ::Ewoms::Properties::getDiagnostic<TypeTag>(#PropTagName) |
Return a human readable diagnostic message how exactly a property was defined. More... | |
The property system.
The purpose of the eWoms property system is to specify compile-time parameters. It can thus be used to specify types and things which cause the compiler to alter its decisions.
Semantically, the property system can be thought of being very similar to the standard C++ "traits" pattern. The advantages of the property system are that it includes build-in introspection capabilities and (more importantly) an easy to use inheritance mechanism.
#define GET_PROP | ( | TypeTag, | |
PropTagName | |||
) | ::Ewoms::Properties::GetProperty<TypeTag, PTAG(PropTagName)>::p |
Retrieve a property for a type tag.
If you use GET_PROP
within a template and want to refer to some type (including the property itself), GET_PROP
must be preceeded by the 'typename'
keyword.
#define GET_PROP_TYPE | ( | TypeTag, | |
PropTagName | |||
) | ::Ewoms::Properties::GetProperty<TypeTag, PTAG(PropTagName)>::p::type |
Access the type
attribute of a property for a type tag.
This is just for convenience and equivalent to GET_PROP(TypeTag, PropTag)::
type
. If the property doesn't have an attribute named type
, this yields a compiler error. Also, if you use this macro within a template, it must be preceeded by the typename
keyword.
#define GET_PROP_VALUE | ( | TypeTag, | |
PropTagName | |||
) | ::Ewoms::Properties::GetProperty<TypeTag, PTAG(PropTagName)>::p::value |
Access the value
attribute of a property for a type tag.
This is just for convenience and equivalent to GET_PROP(TypeTag, PropTag)::
value
. If the property doesn't have an attribute named value
, this yields a compiler error.
#define INHERITS_FROM | ( | ... | ) | __VA_ARGS__ |
Syntactic sugar for NEW_TYPE_TAG.
See the documentation for NEW_TYPE_TAG.
#define NEW_PROP_TAG | ( | PTagName | ) |
Define a property tag.
A property tag is the unique identifier for a property. It may only be declared once in your program. There is also no hierarchy of property tags as for type tags.
Examples:
#define NEW_TYPE_TAG | ( | ... | ) |
Define a new type tag.
A type tag can inherit the properties defined on up to five parent type tags. Examples:
#define PROP_DIAGNOSTIC | ( | TypeTag, | |
PropTagName | |||
) | ::Ewoms::Properties::getDiagnostic<TypeTag>(#PropTagName) |
Return a human readable diagnostic message how exactly a property was defined.
This is only enabled if the NO_PROPERTY_INTROSPECTION
macro is not defined.
Example:
#define PTAG | ( | PropTagName | ) | Ewoms::Properties::PTag::PropTagName |
Makes a type out of a property tag name.
Again property type names can be passed as template argument. This is rarely needed, though.
#define SET_BOOL_PROP | ( | EffTypeTagName, | |
PropTagName, | |||
... | |||
) |
Set a property to a simple constant boolean value.
The constant can be accessed by the value
attribute.
#define SET_INT_PROP | ( | EffTypeTagName, | |
PropTagName, | |||
... | |||
) |
Set a property to a simple constant integer value.
The constant can be accessed by the value
attribute.
#define SET_PROP | ( | EffTypeTagName, | |
PropTagName | |||
) |
Set a property for a specific type tag.
After this macro, you must to specify a complete body of a class template, including the trailing semicolon. If you need to retrieve another property within the class body, you can use TypeTag
as the argument for the type tag for the GET_PROP
macro.
Example:
};
#define SET_SCALAR_PROP | ( | EffTypeTagName, | |
PropTagName, | |||
... | |||
) |
Set a property to a simple constant scalar value.
The constant can be accessed by the value
attribute. In order to use this macro, the property tag Scalar
needs to be defined for the type tag.
#define SET_SPLICES | ( | TypeTagName, | |
... | |||
) |
Define splices for a given type tag.
Splices can be seen as children which can be overridden lower in the hierarchy. It can thus be seen as a "deferred inheritance" mechanism. Example:
#define SET_STRING_PROP | ( | EffTypeTagName, | |
PropTagName, | |||
... | |||
) |
Set a property to a simple constant string value.
The constant can be accessed by the value
attribute and is of type std::string
.
#define SET_TAG_PROP | ( | EffTypeTagName, | |
PropTagName, | |||
ValueTypeTagName | |||
) |
#define SET_TYPE_PROP | ( | EffTypeTagName, | |
PropTagName, | |||
... | |||
) |
Set a property which defines a type.
The type can be accessed by the type
attribute.
#define TTAG | ( | TypeTagName | ) | Ewoms::Properties::TTag::TypeTagName |
Convert a type tag name to a type.
The main advantage of the type of a TypeTag
is that it can be passed as a template argument.
#define UNSET_PROP | ( | EffTypeTagName, | |
PropTagName | |||
) |
Explicitly unset a property for a type tag.
This means that the property will not be inherited from the type tag's parents.
Example: