KIDS  ver-0.0.1
KIDS : Kernel Integrated Dynamics Simulator
Loading...
Searching...
No Matches
PROJECT_NS::Param Class Referencefinal

this class provides an interface wrapper for the parameter data. More...

#include <Param.h>

Collaboration diagram for PROJECT_NS::Param:
Collaboration graph

Public Types

enum  LoadOption { fromString , fromFile }
 
using JSON = configor::json
 
using JSON_Exception = configor::configor_exception
 

Public Member Functions

 Param (const std::string &input, LoadOption option)
 
bool has_key (const std::string &key)
 Param &operator[](const std::string &key) { if (!has_key(key)) { throw param_illegal_key_error(key); } Param ref = Param(); ref.pj = &((*pj)[key]); return ref; }.
 
std::shared_ptr< JSONpjson ()
 
std::string repr ()
 
bool get_bool (const std::string &key, const std::string &loc, const bool &default_value)
 
bool get_bool (const std::string &key, const std::string &loc="__loc__")
 
int get_int (const std::string &key, const std::string &loc, const int &default_value)
 
int get_int (const std::string &key, const std::string &loc="__loc__")
 
std::string get_string (const std::string &key, const std::string &loc, const std::string &default_value)
 
std::string get_string (const std::string &key, const std::string &loc="__loc__")
 
double get_double (const std::string &key, const std::string &loc, const phys::dimension7 &qdim, const double &default_value=double())
 
double get_double (const std::string &key, const std::string &loc, const double &default_value)
 
double get_double (const std::string &key, const std::string &loc="__loc__")
 

Private Member Functions

template<typename T , bool Require = false>
get (const std::string &key, const std::string &loc, const phys::dimension7 &qdim, const T &default_value)
 get parameter
 

Private Attributes

std::shared_ptr< JSONpj
 

Detailed Description

this class provides an interface wrapper for the parameter data.

Note
As a realization of interface to JSON format. the json library is used with https://github.com/Nomango/configor. the used version is: https://github.com/Nomango/configor/tree/2.x
Todo
More formats should be supported in future, including:

Definition at line 82 of file Param.h.

Member Typedef Documentation

◆ JSON

using PROJECT_NS::Param::JSON = configor::json

Definition at line 84 of file Param.h.

◆ JSON_Exception

using PROJECT_NS::Param::JSON_Exception = configor::configor_exception

Definition at line 85 of file Param.h.

Member Enumeration Documentation

◆ LoadOption

See also
Param(const std::string &input, LoadOption option)
Enumerator
fromString 

construct Param from string

fromFile 

construct Param from file

Definition at line 89 of file Param.h.

Constructor & Destructor Documentation

◆ Param()

PROJECT_NS::Param::Param ( const std::string & input,
LoadOption option )
Parameters
[in]inputa Json-like string or a file path
[in]optionenum for parse input fromFile parse Param from file
fromString parse Param from string

Usages

Definition at line 15 of file Param.cpp.

References fromFile, fromString, and pj.

Member Function Documentation

◆ get()

template<typename T , bool Require = false>
T PROJECT_NS::Param::get ( const std::string & key,
const std::string & loc,
const phys::dimension7 & qdim,
const T & default_value )
private

get parameter

Parameters
key: key of the parameter
loc: location tracer (always leaves it LOC())
qdim: physics dimension for conversion in double in AU unit
default_valuedefault value is avialable
Returns
T type

Definition at line 50 of file Param.cpp.

References utils::concat(), has_key(), phys::unitsys::parse(), and pj.

Here is the call graph for this function:

◆ get_bool() [1/2]

bool PROJECT_NS::Param::get_bool ( const std::string & key,
const std::string & loc,
const bool & default_value )

Definition at line 129 of file Param.cpp.

References phys::none_d.

◆ get_bool() [2/2]

bool PROJECT_NS::Param::get_bool ( const std::string & key,
const std::string & loc = "__loc__" )

Definition at line 132 of file Param.cpp.

References phys::none_d.

◆ get_double() [1/3]

double PROJECT_NS::Param::get_double ( const std::string & key,
const std::string & loc,
const double & default_value )

Definition at line 154 of file Param.cpp.

References phys::none_d.

◆ get_double() [2/3]

double PROJECT_NS::Param::get_double ( const std::string & key,
const std::string & loc,
const phys::dimension7 & qdim,
const double & default_value = double() )

Definition at line 150 of file Param.cpp.

Referenced by PROJECT_NS::Model_HO::setInputParam_impl().

Here is the caller graph for this function:

◆ get_double() [3/3]

double PROJECT_NS::Param::get_double ( const std::string & key,
const std::string & loc = "__loc__" )

Definition at line 157 of file Param.cpp.

References phys::none_d.

◆ get_int() [1/2]

int PROJECT_NS::Param::get_int ( const std::string & key,
const std::string & loc,
const int & default_value )

Definition at line 136 of file Param.cpp.

References phys::none_d.

Referenced by PROJECT_NS::Model_HO::setInputParam_impl(), and PROJECT_NS::MODEL_MD1D::setInputParam_impl().

Here is the caller graph for this function:

◆ get_int() [2/2]

int PROJECT_NS::Param::get_int ( const std::string & key,
const std::string & loc = "__loc__" )

Definition at line 139 of file Param.cpp.

References phys::none_d.

◆ get_string() [1/2]

std::string PROJECT_NS::Param::get_string ( const std::string & key,
const std::string & loc,
const std::string & default_value )

Definition at line 143 of file Param.cpp.

References phys::none_d.

◆ get_string() [2/2]

std::string PROJECT_NS::Param::get_string ( const std::string & key,
const std::string & loc = "__loc__" )

Definition at line 146 of file Param.cpp.

References phys::none_d.

◆ has_key()

bool PROJECT_NS::Param::has_key ( const std::string & key)

Param &operator[](const std::string &key) { if (!has_key(key)) { throw param_illegal_key_error(key); } Param ref = Param(); ref.pj = &((*pj)[key]); return ref; }.

Parameters
[in]keyThe key
Returns
True if key, False otherwise.

Definition at line 42 of file Param.cpp.

References pj.

Referenced by get().

Here is the caller graph for this function:

◆ pjson()

std::shared_ptr< configor::json > PROJECT_NS::Param::pjson ( )

Definition at line 44 of file Param.cpp.

References pj.

Referenced by main().

Here is the caller graph for this function:

◆ repr()

std::string PROJECT_NS::Param::repr ( )

Definition at line 46 of file Param.cpp.

References pj.

Member Data Documentation

◆ pj

std::shared_ptr<JSON> PROJECT_NS::Param::pj
private

Definition at line 148 of file Param.h.

Referenced by get(), has_key(), Param(), pjson(), and repr().


The documentation for this class was generated from the following files: