get_type.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_GET_TYPE_HPP
14 #define MLPACK_BINDINGS_GO_GET_TYPE_HPP
15 
16 #include <mlpack/prereqs.hpp>
19 
20 namespace mlpack {
21 namespace bindings {
22 namespace go {
23 
24 template<typename T>
25 inline std::string GetType(
26  util::ParamData& /* d */,
27  const typename boost::disable_if<util::IsStdVector<T>>::type* = 0,
28  const typename boost::disable_if<data::HasSerialize<T>>::type* = 0,
29  const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0)
30 {
31  return "unknown";
32 }
33 
34 template<>
35 inline std::string GetType<int>(
36  util::ParamData& /* d */,
37  const typename boost::disable_if<util::IsStdVector<int>>::type*,
38  const typename boost::disable_if<data::HasSerialize<int>>::type*,
39  const typename boost::disable_if<arma::is_arma_type<int>>::type*)
40 {
41  return "Int";
42 }
43 
44 template<>
45 inline std::string GetType<float>(
46  util::ParamData& /* d */,
47  const typename boost::disable_if<util::IsStdVector<float>>::type*,
48  const typename boost::disable_if<data::HasSerialize<float>>::type*,
49  const typename boost::disable_if<arma::is_arma_type<float>>::type*)
50 {
51  return "Float";
52 }
53 
54 template<>
55 inline std::string GetType<double>(
56  util::ParamData& /* d */,
57  const typename boost::disable_if<util::IsStdVector<double>>::type*,
58  const typename boost::disable_if<data::HasSerialize<double>>::type*,
59  const typename boost::disable_if<arma::is_arma_type<double>>::type*)
60 {
61  return "Double";
62 }
63 
64 template<>
65 inline std::string GetType<std::string>(
66  util::ParamData& /* d */,
67  const typename boost::disable_if<util::IsStdVector<std::string>>::type*,
68  const typename boost::disable_if<data::HasSerialize<std::string>>::type*,
69  const typename boost::disable_if<arma::is_arma_type<std::string>>::type*)
70 {
71  return "String";
72 }
73 
74 template<>
75 inline std::string GetType<bool>(
76  util::ParamData& /* d */,
77  const typename boost::disable_if<util::IsStdVector<bool>>::type*,
78  const typename boost::disable_if<data::HasSerialize<bool>>::type*,
79  const typename boost::disable_if<arma::is_arma_type<bool>>::type*)
80 {
81  return "Bool";
82 }
83 
84 template<typename T>
85 inline std::string GetType(
86  util::ParamData& d,
87  const typename boost::enable_if<util::IsStdVector<T>>::type* = 0)
88 {
89  return "Vec" + GetType<typename T::value_type>(d);
90 }
91 
92 template<typename T>
93 inline std::string GetType(
94  util::ParamData& /* d */,
95  const typename boost::enable_if<arma::is_arma_type<T>>::type* = 0)
96 {
97  std::string type = "";
98  if (std::is_same<typename T::elem_type, double>::value)
99  {
100  if (T::is_row)
101  type = "Row";
102  else if (T::is_col)
103  type = "Col";
104  else
105  type = "Mat";
106  }
107  else if (std::is_same<typename T::elem_type, size_t>::value)
108  {
109  if (T::is_row)
110  type = "Urow";
111  else if (T::is_col)
112  type = "Ucol";
113  else
114  type = "Umat";
115  }
116 
117  return type;
118 }
119 
120 template<typename T>
121 inline std::string GetType(
122  util::ParamData& d,
123  const typename boost::disable_if<arma::is_arma_type<T>>::type* = 0,
124  const typename boost::enable_if<data::HasSerialize<T>>::type* = 0)
125 {
126  return d.cppType + "*";
127 }
128 
139 template<typename T>
140 void GetType(util::ParamData& d,
141  const void* /* input */,
142  void* output)
143 {
144  *((std::string*) output) =
145  GetType<typename std::remove_pointer<T>::type>(d);
146 }
147 
148 } // namespace go
149 } // namespace bindings
150 } // namespace mlpack
151 
152 #endif
std::string GetType< bool >(util::ParamData &, const typename boost::disable_if< util::IsStdVector< bool >>::type *, const typename boost::disable_if< data::HasSerialize< bool >>::type *, const typename boost::disable_if< arma::is_arma_type< bool >>::type *)
Definition: get_type.hpp:75
Linear algebra utility functions, generally performed on matrices or vectors.
The core includes that mlpack expects; standard C++ includes and Armadillo.
go
Definition: CMakeLists.txt:6
std::string GetType(util::ParamData &, const typename boost::disable_if< util::IsStdVector< T >>::type *=0, const typename boost::disable_if< data::HasSerialize< T >>::type *=0, const typename boost::disable_if< arma::is_arma_type< T >>::type *=0)
Definition: get_type.hpp:25
std::string GetType< int >(util::ParamData &, const typename boost::disable_if< util::IsStdVector< int >>::type *, const typename boost::disable_if< data::HasSerialize< int >>::type *, const typename boost::disable_if< arma::is_arma_type< int >>::type *)
Definition: get_type.hpp:35
std::string GetType< double >(util::ParamData &, const typename boost::disable_if< util::IsStdVector< double >>::type *, const typename boost::disable_if< data::HasSerialize< double >>::type *, const typename boost::disable_if< arma::is_arma_type< double >>::type *)
Definition: get_type.hpp:55
std::string GetType< float >(util::ParamData &, const typename boost::disable_if< util::IsStdVector< float >>::type *, const typename boost::disable_if< data::HasSerialize< float >>::type *, const typename boost::disable_if< arma::is_arma_type< float >>::type *)
Definition: get_type.hpp:45
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
Metaprogramming structure for vector detection.
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84