SysfsSensor.h 1.09 KB
Newer Older
1
2
3
4
/*
 * SYSFSSensor.h
 *
 *  Created on: 18.11.2017
5
 *      Author: Michael Ott (original), Micha Mueller
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
 */

#ifndef SYSFSSENSOR_H_
#define SYSFSSENSOR_H_

#include "../../Sensor.h"
#include <regex>

class SysfsSensor : public Sensor {

public:
	SysfsSensor(const std::string& name);
	virtual ~SysfsSensor();

	const std::string& getPath() const {
		return _path;
	}

	void setPath(const std::string& path) {
		_path = path;
	}

	FILE* getFile() const {
		return _file;
	}

	void setFile(FILE* file) {
		_file = file;
	}

	bool hasFilter() const {
		return _filter;
	}

	void setFilter(bool filter) {
		_filter = filter;
	}

	std::regex getRegex() const {
		return _regx;
	}

	void setRegex(std::regex regx) {
		_regx = regx;
	}

	const std::string& getSubstitution() const {
		return _substitution;
	}

	void setSubstitution(const std::string& substitution) {
		_substitution = substitution;
	}

	void read();

	void readAsync();

64
65
66
	void startPolling();

	void stopPolling();
67
68
69
70
71
72
73
74
75
76
77

private:
	std::string _path;
	FILE* _file;
	bool _filter;
	std::regex _regx;
	std::string _substitution;

};

#endif /* SYSFSSENSOR_H_ */