The Params class holds all information about the parameters passed to a specific binding. More...
Public Types | |
typedef std::map< std::string, std::map< std::string, void(*)(ParamData &, const void *, void *)> > | FunctionMapType |
Public Member Functions | |
Params (const std::map< char, std::string > &aliases, const std::map< std::string, ParamData > ¶meters, FunctionMapType &functionMap, const std::string &bindingName, const BindingDetails &doc) | |
Create a new Params class. More... | |
Params () | |
Empty constructor. More... | |
std::map< char, std::string > & | Aliases () |
Get the map of aliases. More... | |
const std::string & | BindingName () const |
Get the binding name. More... | |
void | CheckInputMatrices () |
Check all input matrices for NaN and inf values, and throw an exception if any are found. More... | |
const BindingDetails & | Doc () const |
Get the binding details. More... | |
template < typename T > | |
T & | Get (const std::string &identifier) |
Get the value of type T found for the parameter specified by identifier . More... | |
template < typename T > | |
std::string | GetPrintable (const std::string &identifier) |
Cast the given parameter of the given type to a short, printable std::string , for use in status messages. More... | |
template < typename T > | |
T & | GetRaw (const std::string &identifier) |
Get the raw value of the parameter before any processing that Get() might normally do. More... | |
bool | Has (const std::string &identifier) const |
Return true if the specified parameter was given. More... | |
void | MakeInPlaceCopy (const std::string &outputParamName, const std::string &inputParamName) |
Given two (matrix) parameters, ensure that the first is an in-place copy of the second. More... | |
std::map< std::string, ParamData > & | Parameters () |
Get the map of parameters. More... | |
void | SetPassed (const std::string &identifier) |
Set the particular parameter as passed. More... | |
Public Attributes | |
FunctionMapType | functionMap |
Map for functions and types. More... | |
The Params class holds all information about the parameters passed to a specific binding.
Definition at line 20 of file params.hpp.
typedef std::map<std::string, std::map<std::string, void (*)(ParamData&, const void*, void*)> > FunctionMapType |
Definition at line 25 of file params.hpp.
Params | ( | const std::map< char, std::string > & | aliases, |
const std::map< std::string, ParamData > & | parameters, | ||
FunctionMapType & | functionMap, | ||
const std::string & | bindingName, | ||
const BindingDetails & | doc | ||
) |
Create a new Params class.
In general this should only be called via IO::Parameters()
.
Params | ( | ) |
Empty constructor.
For wrapping in bindings.
|
inline |
Get the map of aliases.
Definition at line 98 of file params.hpp.
|
inline |
Get the binding name.
Definition at line 101 of file params.hpp.
void CheckInputMatrices | ( | ) |
Check all input matrices for NaN and inf values, and throw an exception if any are found.
Referenced by Params::Doc().
|
inline |
Get the binding details.
Definition at line 104 of file params.hpp.
References Params::CheckInputMatrices(), and Params::SetPassed().
Referenced by mlpack::bindings::cli::ParseCommandLine().
T& Get | ( | const std::string & | identifier | ) |
Get the value of type T found for the parameter specified by identifier
.
You can set the value using this reference safely.
identifier | The name of the parameter in question. |
Referenced by mlpack::util::GetParamPtr(), mlpack::util::GetParamWithInfo(), mlpack::bindings::cli::ParseCommandLine(), mlpack::util::SetParam(), mlpack::util::SetParamPtr(), and mlpack::util::SetParamWithInfo().
std::string GetPrintable | ( | const std::string & | identifier | ) |
Cast the given parameter of the given type to a short, printable std::string
, for use in status messages.
The message returned here should be only a handful of characters, and certainly no longer than one line.
identifier | The name of the parameter in question. |
T& GetRaw | ( | const std::string & | identifier | ) |
Get the raw value of the parameter before any processing that Get() might normally do.
So, e.g., for command-line programs, this does not perform any data loading or manipulation like Get() does. So if you want to access a matrix or model (or similar) parameter before it is loaded, this is the method to use.
identifier | The name of the parameter in question. |
bool Has | ( | const std::string & | identifier | ) | const |
Return true
if the specified parameter was given.
identifier | The name of the parameter in question. |
Referenced by mlpack::bindings::cli::EndProgram(), and mlpack::bindings::cli::ParseCommandLine().
void MakeInPlaceCopy | ( | const std::string & | outputParamName, |
const std::string & | inputParamName | ||
) |
Given two (matrix) parameters, ensure that the first is an in-place copy of the second.
This will generally do nothing (as the bindings already do this automatically), except for command-line bindings, where we need to ensure that the output filename is the same as the input filename.
outputParamName | Name of output (matrix) parameter. |
inputParamName | Name of input (matrix) parameter. |
|
inline |
Get the map of parameters.
Definition at line 96 of file params.hpp.
Referenced by mlpack::bindings::cli::EndProgram(), MDOption< T >::MDOption(), mlpack::bindings::cli::ParseCommandLine(), and mlpack::bindings::python::PrintOutputProcessing().
void SetPassed | ( | const std::string & | identifier | ) |
Set the particular parameter as passed.
identifier | The name of the parameter to set as passed. |
Referenced by Params::Doc().
FunctionMapType functionMap |
Map for functions and types.
Note: this was originally created as a way to avoid virtual inheritance. However, the design would be much cleaner if we simply used virtual inheritance for different option types.
Definition at line 130 of file params.hpp.
Referenced by mlpack::bindings::cli::EndProgram(), and mlpack::bindings::cli::ParseCommandLine().