SHOGUN
v3.2.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2013 Soumyajit De 00008 */ 00009 00010 #ifndef SCALAR_RESULT_H_ 00011 #define SCALAR_RESULT_H_ 00012 00013 #include <shogun/lib/config.h> 00014 #include <shogun/lib/computation/jobresult/JobResult.h> 00015 #include <shogun/base/Parameter.h> 00016 00017 namespace shogun 00018 { 00019 00023 template<class T> class CScalarResult : public CJobResult 00024 { 00026 typedef bool supports_complex128_t; 00027 00028 public: 00030 CScalarResult() 00031 : CJobResult() 00032 { 00033 init(); 00034 00035 SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) 00036 } 00037 00043 CScalarResult(const T& scalar_result) 00044 : CJobResult() 00045 { 00046 init(); 00047 00048 m_result=scalar_result; 00049 00050 SG_GCDEBUG("%s created (%p)\n", this->get_name(), this) 00051 } 00052 00054 virtual ~CScalarResult() 00055 { 00056 SG_GCDEBUG("%s destroyed (%p)\n", this->get_name(), this) 00057 } 00058 00060 virtual const char* get_name() const 00061 { 00062 return "ScalarResult"; 00063 } 00064 00066 const T get_result() const 00067 { 00068 return m_result; 00069 } 00070 00071 protected: 00073 T m_result; 00074 00075 private: 00077 void init() 00078 { 00079 m_result=static_cast<T>(0); 00080 00081 set_generic<T>(); 00082 00083 SG_ADD(&m_result, "scalar_result", "Scalar result of a computation job", 00084 MS_NOT_AVAILABLE); 00085 } 00086 }; 00087 } 00088 00089 #endif // SCALAR_RESULT_H_