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 > &parameters, 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 BindingDetailsDoc () 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...

 

Detailed Description

The Params class holds all information about the parameters passed to a specific binding.

Definition at line 20 of file params.hpp.

Member Typedef Documentation

◆ FunctionMapType

typedef std::map<std::string, std::map<std::string, void (*)(ParamData&, const void*, void*)> > FunctionMapType

Definition at line 25 of file params.hpp.

Constructor & Destructor Documentation

◆ Params() [1/2]

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() [2/2]

Params ( )

Empty constructor.

For wrapping in bindings.

Member Function Documentation

◆ Aliases()

std::map<char, std::string>& Aliases ( )
inline

Get the map of aliases.

Definition at line 98 of file params.hpp.

◆ BindingName()

const std::string& BindingName ( ) const
inline

Get the binding name.

Definition at line 101 of file params.hpp.

◆ CheckInputMatrices()

void CheckInputMatrices ( )

Check all input matrices for NaN and inf values, and throw an exception if any are found.

Referenced by Params::Doc().

◆ Doc()

const BindingDetails& Doc ( ) const
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().

◆ Get()

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.

Parameters
identifierThe 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().

◆ GetPrintable()

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.

Parameters
identifierThe name of the parameter in question.

◆ GetRaw()

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.

Parameters
identifierThe name of the parameter in question.

◆ Has()

bool Has ( const std::string &  identifier) const

Return true if the specified parameter was given.

Parameters
identifierThe name of the parameter in question.

Referenced by mlpack::bindings::cli::EndProgram(), and mlpack::bindings::cli::ParseCommandLine().

◆ MakeInPlaceCopy()

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.

Parameters
outputParamNameName of output (matrix) parameter.
inputParamNameName of input (matrix) parameter.

◆ Parameters()

std::map<std::string, ParamData>& Parameters ( )
inline

◆ SetPassed()

void SetPassed ( const std::string &  identifier)

Set the particular parameter as passed.

Parameters
identifierThe name of the parameter to set as passed.

Referenced by Params::Doc().

Member Data Documentation

◆ functionMap

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().


The documentation for this class was generated from the following file:
  • /home/ryan/src/mlpack.org/_src/mlpack-git/src/mlpack/core/util/params.hpp