-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
ParameterObserverInterface.h
80 lines (69 loc) · 1.91 KB
/
ParameterObserverInterface.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef SHOGUN_PARAMETEROBSERVERINTERFACE_H
#define SHOGUN_PARAMETEROBSERVERINTERFACE_H
#include <stdexcept>
#include <utility>
#include <vector>
#include <rxcpp/rx-observable.hpp>
#include <shogun/lib/any.h>
namespace shogun
{
/**
* Interface for the parameter observer classes
*/
class ParameterObserverInterface
{
public:
/* One observed value, composed of:
* - step (for the graph x axis);
* - a pair composed of: parameter's name + parameter's value
*/
typedef std::pair<int64_t, std::pair<std::string, Any>> ObservedValue;
/**
* Default constructor
*/
ParameterObserverInterface();
/**
* Constructor
* @param parameters list of parameters which we want to watch over
*/
ParameterObserverInterface(std::vector<std::string>& parameters);
/**
* Constructor
* @param filename name of the generated output file
* @param parameters list of parameters which we want to watch over
*/
ParameterObserverInterface(
const std::string& filename, std::vector<std::string>& parameters);
/**
* Virtual destructor
*/
virtual ~ParameterObserverInterface();
/**
* Filter function, check if the parameter name supplied is what
* we want to monitor
* @param param the param name
* @return true if param is found inside of m_parameters list
*/
virtual bool filter(const std::string& param) = 0;
/**
* Method which will be called when the parameter observable emits a
* value.
* @param value the value emitted by the parameter observable
*/
virtual void on_next(const ObservedValue& value) = 0;
/**
* Method which will be called on errors
*/
virtual void on_error(std::exception_ptr) = 0;
/**
* Method which will be called on completion
*/
virtual void on_complete() = 0;
protected:
/**
* List of parameter's names we want to monitor
*/
std::vector<std::string> m_parameters;
};
}
#endif // SHOGUN_PARAMETEROBSERVER_H