alpaqa 1.0.0a13
Nonconvex constrained optimization
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Typedefs | Functions
params.tpp File Reference
#include <alpaqa/params/params.hpp>
#include <alpaqa/config/config.hpp>
#include <alpaqa/util/demangled-typename.hpp>
#include <charconv>
#include <chrono>
#include <concepts>
#include <map>
#include <numeric>
#include <stdexcept>
#include <string_view>
#include <system_error>
#include <tuple>
#include <type_traits>

Go to the source code of this file.

Classes

struct  param_setter_fun_t< T >
 Function wrapper to set attributes of a struct, type-erasing the type of the attribute. More...
 
struct  dict_to_struct_table< T >
 Specialize this type to define the attribute name to attribute setters dictionaries for a struct type T. More...
 

Namespaces

namespace  alpaqa
 
namespace  alpaqa::params
 

Macros

#define PARAMS_TABLE(type_, ...)
 Helper macro to easily specialize alpaqa::params::dict_to_struct_table.
 
#define PARAMS_MEMBER(name)    { #name, &type::name }
 Helper macro to easily initialize a alpaqa::params::dict_to_struct_table_t.
 

Typedefs

using config_t = DefaultConfig
 
template<class T >
using dict_to_struct_table_t = std::map< std::string_view, param_setter_fun_t< T > >
 Dictionary that maps struct attribute names to type-erased functions that set those attributes.
 

Functions

template<class T >
void assert_key_empty (ParamString s)
 Throw a meaningful error when s.key is not empty, to indicate that the given type T is not of struct type and cannot be indexed into.
 
template<class T >
void unsupported_type (T &, ParamString s)
 Throw a meaningful error to indicate that parameters of type T are not supported or implemented.
 
template<>
void set_param (bool &b, ParamString s)
 
template<>
void set_param (std::string_view &v, ParamString s)
 
template<>
void set_param (std::string &v, ParamString s)
 
template<class T >
requires ((std::floating_point<T> || std::integral<T>) && !std::is_enum_v<T>)
void set_param (T &f, ParamString s)
 Update/overwrite the first argument based on the option in s.
 
template<>
void set_param (vec< config_t > &v, ParamString s)
 
template<>
void set_param (vec_from_file< config_t > &v, ParamString s)
 
template<class Rep , class Period >
void set_param (std::chrono::duration< Rep, Period > &t, ParamString s)
 
template<class T , class T_actual , class A >
auto param_setter (A T_actual::*attr)
 Return a function that applies set_param to the given attribute of a value of type T.
 
template<class T >
auto possible_keys ()
 Return a string enumerating the possible attribute names for the struct type T.
 
template<class T >
requires requires { dict_to_struct_table<T>::table; }
void set_param (T &t, ParamString s)
 Use s to index into the struct type T and overwrite the attribute given by s.key.
 

Class Documentation

◆ alpaqa::params::dict_to_struct_table

struct alpaqa::params::dict_to_struct_table
+ Collaboration diagram for dict_to_struct_table< T >:

Macro Definition Documentation

◆ PARAMS_TABLE

#define PARAMS_TABLE (   type_,
  ... 
)
Value:
template <> \
struct dict_to_struct_table<type_> { \
using type = type_; \
inline static const dict_to_struct_table_t<type> table{__VA_ARGS__}; \
}

Helper macro to easily specialize alpaqa::params::dict_to_struct_table.

Definition at line 128 of file params.tpp.

◆ PARAMS_MEMBER

#define PARAMS_MEMBER (   name)     { #name, &type::name }

Helper macro to easily initialize a alpaqa::params::dict_to_struct_table_t.

Definition at line 137 of file params.tpp.