cli_util.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_CLI_UTIL_HPP
14 #define MLPACK_BINDINGS_GO_CLI_UTIL_HPP
15 
16 #include <mlpack/core/util/cli.hpp>
18 
19 namespace mlpack {
20 namespace util {
21 
28 template<typename T>
29 inline void SetParam(const std::string& identifier, T& value)
30 {
31  CLI::GetParam<T>(identifier) = std::move(value);
32 }
33 
40 template<typename T>
41 inline void SetParamPtr(const std::string& identifier,
42  T* value)
43 {
44  CLI::GetParam<T*>(identifier) = value;
45 }
46 
51 template<typename T>
52 T* GetParamPtr(const std::string& paramName)
53 {
54  return CLI::GetParam<T*>(paramName);
55 }
56 
60 inline void EnableVerbose()
61 {
62  Log::Info.ignoreInput = false;
63 }
64 
68 inline void DisableVerbose()
69 {
70  Log::Info.ignoreInput = true;
71 }
72 
76 inline void DisableBacktrace()
77 {
78  Log::Fatal.backtrace = false;
79 }
80 
84 inline void ResetTimers()
85 {
86  // Just get a new object---removes all old timers.
88 }
89 
93 inline void EnableTimers()
94 {
96 }
97 
98 } // namespace util
99 } // namespace mlpack
100 
101 #endif
bool backtrace
If true, on a fatal error, a backtrace will be printed if HAS_BFD_DL is defined.
void ResetTimers()
Reset the status of all timers.
Definition: cli_util.hpp:84
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: add_to_po.hpp:21
static CLI & GetSingleton()
Retrieve the singleton.
void SetParamPtr(const std::string &identifier, T *value)
Set the parameter to the given value, given that the type is a pointer.
Definition: cli_util.hpp:41
void DisableVerbose()
Turn verbose output off.
Definition: cli_util.hpp:68
Timers timer
Holds the timer objects.
Definition: cli.hpp:318
bool ignoreInput
Discards input, prints nothing if true.
void DisableBacktrace()
Disable backtraces.
Definition: cli_util.hpp:76
static MLPACK_EXPORT util::PrefixedOutStream Fatal
Prints fatal messages prefixed with [FATAL], then terminates the program.
Definition: log.hpp:90
void EnableTimers()
Enable timing.
Definition: cli_util.hpp:93
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ].
Definition: log.hpp:84
T * GetParamPtr(const std::string &paramName)
Return a pointer.
Definition: cli_util.hpp:52
void SetParam(const std::string &identifier, T &value)
Set the parameter to the given value.
Definition: cli_util.hpp:29
static void EnableTiming()
Enable timing of mlpack programs.
void EnableVerbose()
Turn verbose output on.
Definition: cli_util.hpp:60
void Reset()
Reset the timers.