print_param_defn.hpp
Go to the documentation of this file.
1 
8 #ifndef MLPACK_BINDINGS_JULIA_PRINT_PARAM_DEFN_HPP
9 #define MLPACK_BINDINGS_JULIA_PRINT_PARAM_DEFN_HPP
10 
11 #include "strip_type.hpp"
12 
13 namespace mlpack {
14 namespace bindings {
15 namespace julia {
16 
20 template<typename T>
22  const util::ParamData& /* d */,
23  const std::string& /* programName */,
24  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
25  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
26 {
27  // Do nothing.
28 }
29 
33 template<typename T>
35  const util::ParamData& /* d */,
36  const std::string& /* programName */,
37  const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
38 {
39  // Do nothing.
40 }
41 
45 template<typename T>
47  const util::ParamData& d,
48  const std::string& programName,
49  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
50  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
51 {
52  // We need to print something of the form below:
53  //
54  // function CLIGetParam<Type>Ptr(paramName::String)
55  // return ccall((:CLIGetParam<Type>Ptr, <programName>Library),
56  // Ptr{Nothing}, (Cstring,), paramName)
57  // end
58  //
59  // function CLISetParam<Type>Ptr(paramName::String, ptr::Ptr{Nothing})
60  // ccall((:CLISetParam<Type>Ptr, <programName>Library), Nothing,
61  // (Cstring, Ptr{Nothing}), paramName, ptr)
62  // end
63  std::string type = StripType(d.cppType);
64  std::cout << "\" Get the value of a model pointer parameter of type " << type
65  << ".\"" << std::endl;
66  std::cout << "function CLIGetParam" << type << "Ptr(paramName::String)"
67  << std::endl;
68  std::cout << " return ccall((:CLI_GetParam" << type << "Ptr, "
69  << programName << "Library), Ptr{Nothing}, "
70  << "(Cstring,), paramName)" << std::endl;
71  std::cout << "end" << std::endl;
72  std::cout << std::endl;
73 
74  std::cout << "\" Set the value of a model pointer parameter of type " << type
75  << ".\"" << std::endl;
76  std::cout << "function CLISetParam" << type << "Ptr(paramName::String, "
77  << "ptr::Ptr{Nothing})" << std::endl;
78  std::cout << " ccall((:CLI_SetParam" << type << "Ptr, "
79  << programName << "Library), Nothing, (Cstring, "
80  << "Ptr{Nothing}), paramName, ptr)" << std::endl;
81  std::cout << "end" << std::endl;
82  std::cout << std::endl;
83 }
84 
89 template<typename T>
91  const void* input,
92  void* /* output */)
93 {
94  PrintParamDefn<typename std::remove_pointer<T>::type>(d,
95  *(std::string*) input);
96 }
97 
98 } // namespace julia
99 } // namespace bindings
100 } // namespace mlpack
101 
102 #endif
strip_type.hpp
Definition: add_to_po.hpp:21
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:52
void PrintParamDefn(const util::ParamData &, const std::string &, const typename std::enable_if<!arma::is_arma_type< T >::value >::type *=0, const typename std::enable_if<!data::HasSerialize< T >::value >::type *=0)
If the type is not serializable, print nothing.
std::string cppType
The true name of the type, as it would be written in C++.
Definition: param_data.hpp:84
std::string StripType(std::string cppType)
Given a C++ type name, turn it into something that has no special characters that can simply be print...
Definition: strip_type.hpp:23