alpaqa 1.0.0a14
Nonconvex constrained optimization
Loading...
Searching...
No Matches
structs.hpp
Go to the documentation of this file.
1#include <map>
2#include <string_view>
3
4namespace alpaqa::params {
5
6/// Function wrapper to set attributes of a struct, type-erasing the type of the
7/// attribute.
8template <class T, class S>
10
11/// Dictionary that maps struct attribute names to type-erased functions that
12/// set those attributes.
13template <class T, class S>
14using attribute_table_t = std::map<std::string_view, attribute_accessor<T, S>>;
15
16/// Specialize this type to define the attribute name to attribute setters
17/// dictionaries for a struct type @p T.
18template <class T, class S>
20
21/// Helper macro to easily specialize @ref alpaqa::params::attribute_table.
22#define PARAMS_TABLE(type_, ...) \
23 template <class S> \
24 struct attribute_table<type_, S> { \
25 using type = type_; \
26 inline static const attribute_table_t<type, S> table{__VA_ARGS__}; \
27 }
28
29/// Helper macro to easily initialize a
30/// @ref alpaqa::params::attribute_table_t.
31#define PARAMS_MEMBER(name) \
32 { #name, &type::name }
33
34/// Dictionary that maps struct attribute names to type-erased functions that
35/// set those attributes.
36template <class T, class S>
37using attribute_alias_table_t = std::map<std::string_view, std::string_view>;
38
39/// Specialize this type to define the alternative attribute name to attribute
40/// setters dictionaries for a struct type @p T.
41template <class T, class S>
43
44/// Helper macro to easily specialize @ref alpaqa::params::attribute_alias_table.
45#define PARAMS_ALIAS_TABLE(type_, ...) \
46 template <class S> \
47 struct attribute_alias_table<type_, S> { \
48 using type = type_; \
49 inline static const attribute_alias_table_t<type, S> table{ \
50 __VA_ARGS__}; \
51 }
52
53/// Helper macro to easily initialize a
54/// @ref alpaqa::params::attribute_alias_table_t.
55#define PARAMS_MEMBER_ALIAS(alias, name) \
56 { #alias, #name }
57
58} // namespace alpaqa::params
std::map< std::string_view, attribute_accessor< T, S > > attribute_table_t
Dictionary that maps struct attribute names to type-erased functions that set those attributes.
Definition structs.hpp:14
std::map< std::string_view, std::string_view > attribute_alias_table_t
Dictionary that maps struct attribute names to type-erased functions that set those attributes.
Definition structs.hpp:37
Function wrapper to set attributes of a struct, type-erasing the type of the attribute.
Definition structs.hpp:9
Specialize this type to define the alternative attribute name to attribute setters dictionaries for a...
Definition structs.hpp:42
Specialize this type to define the attribute name to attribute setters dictionaries for a struct type...
Definition structs.hpp:19