RelatedStateValuePrevious.hpp 1.67 KB
Newer Older
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
1
/*
2
 * Copyright (C) 2014-2021 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
 * 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
9
 *
10
11
12
 * PipeFabric is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
 * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
13
 *
14
15
 * You should have received a copy of the GNU General Public License along with PipeFabric. If not,
 * see <http://www.gnu.org/licenses/>.
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
16
17
18
19
20
21
22
 */

#ifndef RelatedStateValuePrevious_hpp_
#define RelatedStateValuePrevious_hpp_

#include "RelatedStateValue.hpp"
namespace pfabric {
Omran Saleh's avatar
Omran Saleh committed
23
24
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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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
40
	void updateValue(const TinPtr& e) {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
41
42
43
44
45
46
		previousValue = std::get<Index>(*e);
	}
	/**
	 * initializes the value by an event
	 * @param e
	 */
Omran Saleh's avatar
Omran Saleh committed
47
	void initValue(const TinPtr& e) {
Kai-Uwe Sattler's avatar
Kai-Uwe Sattler committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
		updateValue(e);
	}
	/**
	 * constructor
	 */
	RelatedStateValuePrevious() {
		previousValue = StorageType();
	}
	/**
	 * destructor
	 */
	virtual ~RelatedStateValuePrevious() {}
};
}
#endif /* RelatedStateValuePrevious_hpp_ */