mlpack  3.1.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
print_param_defn.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_JULIA_PRINT_PARAM_DEFN_HPP
14 #define MLPACK_BINDINGS_JULIA_PRINT_PARAM_DEFN_HPP
15 
16 #include "strip_type.hpp"
17 
18 namespace mlpack {
19 namespace bindings {
20 namespace julia {
21 
25 template<typename T>
27  const util::ParamData& /* d */,
28  const std::string& /* programName */,
29  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
30  const typename std::enable_if<!data::HasSerialize<T>::value>::type* = 0)
31 {
32  // Do nothing.
33 }
34 
38 template<typename T>
40  const util::ParamData& /* d */,
41  const std::string& /* programName */,
42  const typename std::enable_if<arma::is_arma_type<T>::value>::type* = 0)
43 {
44  // Do nothing.
45 }
46 
50 template<typename T>
52  const util::ParamData& d,
53  const std::string& programName,
54  const typename std::enable_if<!arma::is_arma_type<T>::value>::type* = 0,
55  const typename std::enable_if<data::HasSerialize<T>::value>::type* = 0)
56 {
57  // We need to print something of the form below:
58  //
59  // function CLIGetParam<Type>Ptr(paramName::String)
60  // return ccall((:CLIGetParam<Type>Ptr, <programName>Library),
61  // Ptr{Nothing}, (Cstring,), paramName)
62  // end
63  //
64  // function CLISetParam<Type>Ptr(paramName::String, ptr::Ptr{Nothing})
65  // ccall((:CLISetParam<Type>Ptr, <programName>Library), Nothing,
66  // (Cstring, Ptr{Nothing}), paramName, ptr)
67  // end
68  std::string type = StripType(d.cppType);
69  std::cout << "\" Get the value of a model pointer parameter of type " << type
70  << ".\"" << std::endl;
71  std::cout << "function CLIGetParam" << type << "Ptr(paramName::String)"
72  << std::endl;
73  std::cout << " return ccall((:CLI_GetParam" << type << "Ptr, "
74  << programName << "Library), Ptr{Nothing}, "
75  << "(Cstring,), paramName)" << std::endl;
76  std::cout << "end" << std::endl;
77  std::cout << std::endl;
78 
79  std::cout << "\" Set the value of a model pointer parameter of type " << type
80  << ".\"" << std::endl;
81  std::cout << "function CLISetParam" << type << "Ptr(paramName::String, "
82  << "ptr::Ptr{Nothing})" << std::endl;
83  std::cout << " ccall((:CLI_SetParam" << type << "Ptr, "
84  << programName << "Library), Nothing, (Cstring, "
85  << "Ptr{Nothing}), paramName, ptr)" << std::endl;
86  std::cout << "end" << std::endl;
87  std::cout << std::endl;
88 }
89 
94 template<typename T>
96  const void* input,
97  void* /* output */)
98 {
99  PrintParamDefn<typename std::remove_pointer<T>::type>(d,
100  *(std::string*) input);
101 }
102 
103 } // namespace julia
104 } // namespace bindings
105 } // namespace mlpack
106 
107 #endif
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
string(REGEX REPLACE".*#define MLPACK_VERSION_MINOR ([0-9]+).*""\\1"MLPACK_VERSION_MINOR"${VERSION_HPP_CONTENTS}") string(REGEX REPLACE".* "\\1" MLPACK_VERSION_PATCH "$
Definition: CMakeLists.txt:35
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:28