mlpack 3.4.2
set_param.hpp
Go to the documentation of this file.
1
12#ifndef MLPACK_BINDINGS_CLI_SET_PARAM_HPP
13#define MLPACK_BINDINGS_CLI_SET_PARAM_HPP
14
15#include <mlpack/prereqs.hpp>
16#include "parameter_type.hpp"
17
18namespace mlpack {
19namespace bindings {
20namespace cli {
21
26template<typename T>
29 const boost::any& value,
30 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
31 const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
32 const typename boost::disable_if<std::is_same<T,
33 std::tuple<mlpack::data::DatasetInfo, arma::mat>>>::type* = 0,
34 const typename boost::disable_if<std::is_same<T, bool>>::type* = 0)
35{
36 // No mapping is needed.
37 d.value = value;
38}
39
43template<typename T>
46 const boost::any& /* value */,
47 const typename boost::enable_if<std::is_same<T, bool>>::type* = 0)
48{
49 // Force set to the value of whether or not this was passed.
50 d.value = d.wasPassed;
51}
52
57template<typename T>
60 const boost::any& value,
61 const typename std::enable_if<arma::is_arma_type<T>::value ||
62 std::is_same<T,
63 std::tuple<data::DatasetInfo, arma::mat>>::value>::type* = 0)
64{
65 // We're setting the string filename.
66 typedef std::tuple<T, typename ParameterType<T>::type> TupleType;
67 TupleType& tuple = *boost::any_cast<TupleType>(&d.value);
68 std::get<1>(tuple) = boost::any_cast<std::string>(value);
69}
70
75template<typename T>
78 const boost::any& value,
79 const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
80 const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
81{
82 // We're setting the string filename.
83 typedef std::tuple<T*, typename ParameterType<T>::type> TupleType;
84 TupleType& tuple = *boost::any_cast<TupleType>(&d.value);
85 std::get<1>(tuple) = boost::any_cast<std::string>(value);
86}
87
96template<typename T>
97void SetParam(util::ParamData& d, const void* input, void* /* output */)
98{
99 SetParam<typename std::remove_pointer<T>::type>(
100 const_cast<util::ParamData&>(d), *((boost::any*) input));
101}
102
103} // namespace cli
104} // namespace bindings
105} // namespace mlpack
106
107#endif
void SetParam(util::ParamData &d, const boost::any &value, const typename boost::disable_if< arma::is_arma_type< T > >::type *=0, const typename boost::disable_if< data::HasSerialize< T > >::type *=0, const typename boost::disable_if< std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat > > >::type *=0, const typename boost::disable_if< std::is_same< T, bool > >::type *=0)
This overload is called when nothing special needs to happen to the name of the parameter.
Definition: set_param.hpp:27
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
The core includes that mlpack expects; standard C++ includes and Armadillo.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:53
bool wasPassed
True if the option was passed to the program.
Definition: param_data.hpp:66
boost::any value
The actual value that is held.
Definition: param_data.hpp:82