get_raw_param.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_CLI_GET_RAW_PARAM_HPP
14 #define MLPACK_BINDINGS_CLI_GET_RAW_PARAM_HPP
15 
16 #include <mlpack/prereqs.hpp>
17 #include "parameter_type.hpp"
18 
19 namespace mlpack {
20 namespace bindings {
21 namespace cli {
22 
27 template<typename T>
29  util::ParamData& d,
30  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
31  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0,
32  const typename std::enable_if<!std::is_same<T,
33  std::tuple<mlpack::data::DatasetInfo, arma::mat>>::value>::type* = 0)
34 {
35  // No mapping is needed, so just cast it directly.
36  return *boost::any_cast<T>(&d.value);
37 }
38 
42 template<typename T>
44  util::ParamData& d,
45  const typename std::enable_if<
46  arma::is_arma_type<T>::value ||
47  std::is_same<T, std::tuple<mlpack::data::DatasetInfo,
48  arma::mat>>::value>::type* = 0)
49 {
50  // Don't load the matrix.
51  typedef std::tuple<T, std::tuple<std::string, size_t, size_t>> TupleType;
52  T& value = std::get<0>(*boost::any_cast<TupleType>(&d.value));
53  return value;
54 }
55 
59 template<typename T>
61  util::ParamData& d,
62  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
63  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
64 {
65  // Don't load the model.
66  typedef std::tuple<T*, std::string> TupleType;
67  T*& value = std::get<0>(*boost::any_cast<TupleType>(&d.value));
68  return value;
69 }
70 
79 template<typename T>
81  const void* /* input */,
82  void* output)
83 {
84  // Cast to the correct type.
85  *((T**) output) = &GetRawParam<typename std::remove_pointer<T>::type>(
86  const_cast<util::ParamData&>(d));
87 }
88 
89 } // namespace cli
90 } // namespace bindings
91 } // namespace mlpack
92 
93 #endif
Auxiliary information for a dataset, including mappings to/from strings (or other types) and the data...
boost::any value
The actual value that is held.
Definition: param_data.hpp:79
Linear algebra utility functions, generally performed on matrices or vectors.
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:52
T & GetRawParam(util::ParamData &d, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0, const typename std::enable_if<!std::is_same< T, std::tuple< mlpack::data::DatasetInfo, arma::mat >>::value >::type *=0)
This overload is called when nothing special needs to happen to the name of the parameter.