SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ScalarResult.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Soumyajit De
8  */
9 
10 #ifndef SCALAR_RESULT_H_
11 #define SCALAR_RESULT_H_
12 
13 #include <shogun/lib/config.h>
15 #include <shogun/base/Parameter.h>
16 
17 namespace shogun
18 {
19 
23 template<class T> class CScalarResult : public CJobResult
24 {
26 typedef bool supports_complex128_t;
27 
28 public:
31  : CJobResult()
32  {
33  init();
34 
35  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
36  }
37 
43  CScalarResult(const T& scalar_result)
44  : CJobResult()
45  {
46  init();
47 
48  m_result=scalar_result;
49 
50  SG_GCDEBUG("%s created (%p)\n", this->get_name(), this)
51  }
52 
54  virtual ~CScalarResult()
55  {
56  SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this)
57  }
58 
60  virtual const char* get_name() const
61  {
62  return "ScalarResult";
63  }
64 
66  const T get_result() const
67  {
68  return m_result;
69  }
70 
71 protected:
74 
75 private:
77  void init()
78  {
79  m_result=static_cast<T>(0);
80 
81  set_generic<T>();
82 
83  SG_ADD(&m_result, "scalar_result", "Scalar result of a computation job",
85  }
86 };
87 }
88 
89 #endif // SCALAR_RESULT_H_

SHOGUN Machine Learning Toolbox - Documentation