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 <boost/any.hpp>
22 
23 #include <mlpack/prereqs.hpp>
24 
25 #include "timers.hpp"
26 #include "binding_details.hpp"
27 #include "program_doc.hpp"
28 #include "version.hpp"
29 
30 #include "param_data.hpp"
31 #include "params.hpp"
32 
35 
36 // TODO: this entire set of code is related to the bindings and maybe should go
37 // into src/mlpack/bindings/util/.
38 namespace mlpack {
39 
40 // TODO: completely go through this documentation and clean it up
176 class IO
177 {
178  public:
187  static void AddParameter(const std::string& bindingName, util::ParamData&& d);
188 
196  static void AddFunction(const std::string& type,
197  const std::string& name,
198  void (*func)(util::ParamData&, const void*, void*));
199 
206  static void AddBindingName(const std::string& bindingName,
207  const std::string& name);
208 
215  static void AddShortDescription(const std::string& bindingName,
216  const std::string& shortDescription);
217 
224  static void AddLongDescription(
225  const std::string& bindingName,
226  const std::function<std::string()>& longDescription);
227 
234  static void AddExample(const std::string& bindingName,
235  const std::function<std::string()>& example);
236 
244  static void AddSeeAlso(const std::string& bindingName,
245  const std::string& description,
246  const std::string& link);
247 
253  static util::Params Parameters(const std::string& bindingName);
254 
266  static IO& GetSingleton();
267 
271  static util::Timers& GetTimers();
272 
273  private:
275  std::mutex mapMutex;
277  std::map<std::string, std::map<char, std::string>> aliases;
279  std::map<std::string, std::map<std::string, util::ParamData>> parameters;
282  typedef std::map<std::string, std::map<std::string,
283  void (*)(util::ParamData&, const void*, void*)>> FunctionMapType;
284  FunctionMapType functionMap;
285 
287  std::mutex docMutex;
289  std::map<std::string, util::BindingDetails> docs;
290 
292  util::Timers timer;
293 
295  friend class Timer;
296 
300  IO();
301 
303  IO(const IO& other);
305  IO& operator=(const IO& other);
306 };
307 
308 } // namespace mlpack
309 
310 #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:52
Parses the command line for parameters and holds user-specified parameters.
Definition: io.hpp:176
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.