-
Notifications
You must be signed in to change notification settings - Fork 3
/
observable.h
68 lines (52 loc) · 1.66 KB
/
observable.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
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. See the enclosed file LICENSE for a copy or if
* that was not distributed with this file, You can obtain one at
* http://mozilla.org/MPL/2.0/.
*
* Copyright 2017 Max H. Gerlach
*
* */
/*
* observable.h
*
* Created on: Feb 4, 2013
* Author: gerlach
*/
#ifndef OBSERVABLE_H_
#define OBSERVABLE_H_
#include <string>
#include <functional> // reference_wrapper
#include <armadillo>
typedef double num;
//share this between replica and observable handler classes
template <typename ObsType>
struct Observable {
typedef std::reference_wrapper<const ObsType> RefType;
RefType valRef;
std::string name;
std::string shortName;
Observable(RefType v, const std::string& name_, const std::string& short_)
: valRef(v), name(name_), shortName(short_)
{ }
virtual ~Observable() { }
};
typedef Observable<num> ScalarObservable;
struct VectorObservable : public Observable<arma::Col<num>> {
uint32_t vectorSize;
VectorObservable(RefType v, uint32_t vectorSize_,
const std::string& name_, const std::string& short_)
: Observable<arma::Col<num>>(v, name_, short_),
vectorSize(vectorSize_)
{ }
};
struct KeyValueObservable : public VectorObservable {
arma::Col<num> keys;
std::string keyName;
KeyValueObservable(RefType v, const arma::Col<num>& keys_,
const std::string& keyName_,
const std::string& name_, const std::string& short_)
: VectorObservable(v, keys_.n_elem, name_, short_), keys(keys_),
keyName(keyName_)
{ }
};
#endif /* OBSERVABLE_H_ */