RelatedStateValuePrevious.hpp 1.68 KB
Newer Older
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
1
/*
2
 * Copyright (C) 2014-2019 DBIS Group - TU Ilmenau, All Rights Reserved.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
3
4
5
 *
 * This file is part of the PipeFabric package.
 *
6
7
8
9
 * PipeFabric is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
10
 *
11
 * PipeFabric is distributed in the hope that it will be useful,
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
14
15
16
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
17
 * along with PipeFabric. If not, see <http://www.gnu.org/licenses/>.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
18
19
20
21
22
23
24
 */

#ifndef RelatedStateValuePrevious_hpp_
#define RelatedStateValuePrevious_hpp_

#include "RelatedStateValue.hpp"
namespace pfabric {
Omran Saleh's avatar
Omran Saleh committed
25
26
template <class TinPtr, class StorageType, class ResultType, int Index>
class RelatedStateValuePrevious: public RelatedStateValue<TinPtr, StorageType, ResultType,Index> {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
private:
	StorageType previousValue;
public:
	/**
	 * Gets the current value
	 * @return the current value
	 */
	ResultType getValue() {
		return previousValue;
	}

	/**
	 * Updates the value
	 * @param e the newly selected event
	 */
Omran Saleh's avatar
Omran Saleh committed
42
	void updateValue(const TinPtr& e) {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
43
44
45
46
47
48
		previousValue = std::get<Index>(*e);
	}
	/**
	 * initializes the value by an event
	 * @param e
	 */
Omran Saleh's avatar
Omran Saleh committed
49
	void initValue(const TinPtr& e) {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
		updateValue(e);
	}
	/**
	 * constructor
	 */
	RelatedStateValuePrevious() {
		previousValue = StorageType();
	}
	/**
	 * destructor
	 */
	virtual ~RelatedStateValuePrevious() {}
};
}
#endif /* RelatedStateValuePrevious_hpp_ */