io.hpp
Go to the documentation of this file.
1 
13 #ifndef MLPACK_CORE_UTIL_IO_HPP
14 #define MLPACK_CORE_UTIL_IO_HPP
15 
16 #include <iostream>
17 #include <list>
18 #include <map>
19 #include <string>
20 
21 #include <mlpack/prereqs.hpp>
22 
23 #include "timers.hpp"
24 #include "binding_details.hpp"
25 #include "program_doc.hpp"
26 #include "version.hpp"
27 
28 #include "param_data.hpp"
29 #include "params.hpp"
30 
33 
34 // TODO: this entire set of code is related to the bindings and maybe should go
35 // into src/mlpack/bindings/util/.
36 namespace mlpack {
37 
38 // TODO: completely go through this documentation and clean it up
174 class IO
175 {
176  public:
185  static void AddParameter(const std::string& bindingName, util::ParamData&& d);
186 
194  static void AddFunction(const std::string& type,
195  const std::string& name,
196  void (*func)(util::ParamData&, const void*, void*));
197 
204  static void AddBindingName(const std::string& bindingName,
205  const std::string& name);
206 
213  static void AddShortDescription(const std::string& bindingName,
214  const std::string& shortDescription);
215 
222  static void AddLongDescription(
223  const std::string& bindingName,
224  const std::function<std::string()>& longDescription);
225 
232  static void AddExample(const std::string& bindingName,
233  const std::function<std::string()>& example);
234 
242  static void AddSeeAlso(const std::string& bindingName,
243  const std::string& description,
244  const std::string& link);
245 
251  static util::Params Parameters(const std::string& bindingName);
252 
264  static IO& GetSingleton();
265 
269  static util::Timers& GetTimers();
270 
271  private:
273  std::mutex mapMutex;
275  std::map<std::string, std::map<char, std::string>> aliases;
277  std::map<std::string, std::map<std::string, util::ParamData>> parameters;
280  typedef std::map<std::string, std::map<std::string,
281  void (*)(util::ParamData&, const void*, void*)>> FunctionMapType;
282  FunctionMapType functionMap;
283 
285  std::mutex docMutex;
287  std::map<std::string, util::BindingDetails> docs;
288 
290  util::Timers timer;
291 
293  friend class Timer;
294 
298  IO();
299 
301  IO(const IO& other);
303  IO& operator=(const IO& other);
304 };
305 
306 } // namespace mlpack
307 
308 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
static util::Params Parameters(const std::string &bindingName)
Return a new Params object initialized with all the parameters of the binding bindingName.
The core includes that mlpack expects; standard C++ includes and Armadillo.
static void AddExample(const std::string &bindingName, const std::function< std::string()> &example)
Add an example for a binding.
This structure holds all of the information about a single parameter, including its value (which is s...
Definition: param_data.hpp:51
Parses the command line for parameters and holds user-specified parameters.
Definition: io.hpp:174
static IO & GetSingleton()
Retrieve the singleton.
The timer class provides a way for mlpack methods to be timed.
Definition: timers.hpp:46
static void AddFunction(const std::string &type, const std::string &name, void(*func)(util::ParamData &, const void *, void *))
Add a function to the function map.
static void AddParameter(const std::string &bindingName, util::ParamData &&d)
Adds a parameter to the hierarchy; use the PARAM_*() macros instead of this (i.e. ...
static util::Timers & GetTimers()
Retrieve the global Timers object.
static void AddSeeAlso(const std::string &bindingName, const std::string &description, const std::string &link)
Add a SeeAlso for a binding.
The Params class holds all information about the parameters passed to a specific binding.
Definition: params.hpp:20
static void AddBindingName(const std::string &bindingName, const std::string &name)
Add a user-friendly name for a binding.
static void AddLongDescription(const std::string &bindingName, const std::function< std::string()> &longDescription)
Add a long description for a binding.
static void AddShortDescription(const std::string &bindingName, const std::string &shortDescription)
Add a short description for a binding.