io_util.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_BINDINGS_GO_IO_UTIL_HPP
14 #define MLPACK_BINDINGS_GO_IO_UTIL_HPP
15 
16 #include <mlpack/core/util/io.hpp>
18 
19 namespace mlpack {
20 namespace util {
21 
28 template<typename T>
29 inline void SetParam(util::Params& p,
30  const std::string& identifier,
31  T& value)
32 {
33  p.Get<T>(identifier) = std::move(value);
34 }
35 
42 template<typename T>
43 inline void SetParamPtr(util::Params& p,
44  const std::string& identifier,
45  T* value)
46 {
47  p.Get<T*>(identifier) = value;
48 }
49 
54 template<typename T>
55 T* GetParamPtr(util::Params& p, const std::string& paramName)
56 {
57  return p.Get<T*>(paramName);
58 }
59 
63 inline void EnableVerbose()
64 {
65  Log::Info.ignoreInput = false;
66 }
67 
71 inline void DisableVerbose()
72 {
73  Log::Info.ignoreInput = true;
74 }
75 
79 inline void DisableBacktrace()
80 {
81  Log::Fatal.backtrace = false;
82 }
83 
84 inline void ResetTimers()
85 {
87 }
88 
92 inline void EnableTimers()
93 {
95 }
96 
97 } // namespace util
98 } // namespace mlpack
99 
100 #endif
void SetParamPtr(util::Params &p, const std::string &identifier, T *value)
Set the parameter to the given value, given that the type is a pointer.
Definition: io_util.hpp:43
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: io_util.hpp:84
Linear algebra utility functions, generally performed on matrices or vectors.
void DisableVerbose()
Turn verbose output off.
Definition: io_util.hpp:71
bool ignoreInput
Discards input, prints nothing if true.
void DisableBacktrace()
Disable backtraces.
Definition: io_util.hpp:79
void SetParam(util::Params &p, const std::string &identifier, T &value)
Set the parameter to the given value.
Definition: io_util.hpp:29
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: io_util.hpp:92
static MLPACK_EXPORT util::PrefixedOutStream Info
Prints informational messages if –verbose is specified, prefixed with [INFO ].
Definition: log.hpp:84
T & Get(const std::string &identifier)
Get the value of type T found for the parameter specified by identifier.
static void EnableTiming()
Enable timing of mlpack programs.
static void ResetAll()
Stop and reset all running timers.
void EnableVerbose()
Turn verbose output on.
Definition: io_util.hpp:63
The Params class holds all information about the parameters passed to a specific binding.
Definition: params.hpp:20
T * GetParamPtr(util::Params &p, const std::string &paramName)
Return a pointer.
Definition: io_util.hpp:55