|
roadrunner
2.6.0
Fast simulator for SBML models
|
Store a roadrunner option (or setting) as a Variant type. More...
#include <Setting.h>
Public Types | |
| enum | TypeId { EMPTY = 0 , STRING = 1 , BOOL = 2 , INT32 = 3 , UINT32 = 4 , INT64 = 5 , UINT64 = 6 , FLOAT = 7 , DOUBLE = 8 , CHAR = 9 , UCHAR = 10 , DOUBLEVECTOR = 11 } |
| types that correspond to the index of the position of the type in the variant template. More... | |
Public Member Functions | |
| Setting (setting_t value) | |
| constructor to take any type accepted by setting_t and store as a variant. | |
| template<class T > | |
| Setting (T settingValue) | |
| constructor for creating a Setting from a supperted type T. More... | |
| Setting (const char *settingValue) | |
| constructor for enabling creation of a Setting from a string literal. More... | |
| Setting (std::int64_t settingValue) | |
| construct from a long. More... | |
| Setting ()=default | |
| default constructor. More... | |
| TypeId | type () const |
| returns the type of std::variant contained within this Setting. More... | |
| template<class T > | |
| bool | isType () |
| determines whether the current value of Setting is of type T. More... | |
| template<class T > | |
| T * | get_if () |
| get the value of this Setting as type T if the value in this Setting is of type T. More... | |
| template<class SettingType > | |
| SettingType | get () |
| return the value held by this Setting as a type SettingType. More... | |
| template<class As > | |
| As | getAs () const |
| explicitly convert this Setting to type As. More... | |
| template<class SettingType > | |
| SettingType | get () const |
| return the value held by this setting as type SettingType. More... | |
| template<typename T > | |
| operator T () const | |
| implicit type conversion support for the Setting class. More... | |
| operator std::vector< double > () | |
| implicit cast this Setting to a std::vector<double>. More... | |
| template<class Func > | |
| decltype(auto) | visit (Func function) const |
| equality operator for comparing object otherSetting of type T against the Setting contained within this Setting.value_. More... | |
| const std::type_info & | typeInfo () const |
| returns the std::type_info for the object type contained within this Setting. More... | |
| Setting & | operator= (const Setting &setting) |
| move assignment operator for when rhs is a Setting. More... | |
| Setting & | operator= (Setting &&setting) noexcept |
| Move assignment operator for Setting with another Setting. | |
| Setting (const Setting &setting) | |
| Copy constructor for Setting with another Setting. | |
| Setting (Setting &&setting) noexcept | |
| Move constructor for Setting with another Setting. | |
| const setting_t & | getValue () const |
| getter for the std::variant_t underlying this Setting. | |
| std::string | pythonRepr () const |
| Convert to Python-compatible representation. More... | |
| bool | isString () const |
| is this variant a std::string. | |
| bool | isInteger () const |
| was an integer stored here. | |
| bool | isNumeric () const |
| is this a numeric type. | |
| bool | isBool () const |
| is this a boolean type. | |
| bool | isEmpty () const |
| true if empty. | |
| bool | isSigned () const |
| true if this is a signed number. | |
| bool | isDoubleVector () const |
| true if this is a std::vector of doubles | |
| bool | isDouble () const |
| true if this is a double | |
| std::string | toString () |
| gets a string representation of the type stored in this Setting. | |
Static Public Member Functions | |
| template<class T > | |
| static bool | isValidType () |
| test for membership of type T in setting_t, aka supported types | |
| static Setting | parse (std::string &val) |
| Parses the std::string which must be in JSON format. More... | |
Store a roadrunner option (or setting) as a Variant type.
Uses a std::variant to hold one of the following types , std::monostate, std::string, bool, std::int32_t, std::uint32_t, std::int64_t, std::uint64_t, float, double, char, unsigned char, std::vector<double>
| enum rr::Setting::TypeId |
types that correspond to the index of the position of the type in the variant template.
i.e. std::string is index 0.
|
inline |
| rr::Setting::Setting | ( | const char * | settingValue | ) |
|
explicit |
construct from a long.
(std::int64_t is a long long, which matters on windows)
|
default |
default constructor.
Allows instantiating of an empty setting. The empty setting will have a type of std::monostate, which is index 0 in setting_t
|
inline |
return the value held by this Setting as a type SettingType.
simple wrapper around std::get.
|
inline |
return the value held by this setting as type SettingType.
const version of SettingType::get()
|
inline |
|
inline |
explicitly convert this Setting to type As.
type contained by this Setting must be readily convertible to type As and throws std::invalid_argument if not.
|
inline |
|
inline |
implicit cast this Setting to a std::vector<double>.
If this operator is used and the type contained by this Setting is not a double vector, an std::invalid_argument error is thrown.
the generic operator T() method does not cover the case when we have a vector of doubles, so we must implement this manually. We could write another template for the more general case, but only support for std::vector<double> is needed.
|
inline |
implicit type conversion support for the Setting class.
this method is responsible for enabling implicit conversion between Setting and its supported types. Moreover, it enables one to implicitly convert (say) a int to a long, in contexts that make sense (as determined by std::is_convertible_v). Some situations are explicitly prohibited from implicit type conversion. These include
move assignment operator for when rhs is a Setting.
|
static |
Parses the std::string which must be in JSON format.
This is a common way to read a Variant from a file or create a new one from a std::string:
| std::string rr::Setting::pythonRepr | ( | ) | const |
Convert to Python-compatible representation.
| Setting::TypeId rr::Setting::type | ( | ) | const |
| const std::type_info & rr::Setting::typeInfo | ( | ) | const |
returns the std::type_info for the object type contained within this Setting.
(aka one of the types within setting_t)
|
inline |
equality operator for comparing object otherSetting of type T against the Setting contained within this Setting.value_.
Enables the following types of comparisons