SysfsConfigurator.h 1.15 KB
Newer Older
1
/*
2
 * SysfsConfigurator.h
3
4
5
6
7
 *
 *  Created on: 18.11.2017
 *      Author: Micha Mueller
 */

8
9
#ifndef SYSFSCONFIGURATOR_H_
#define SYSFSCONFIGURATOR_H_
10
11
12
13

#include "SysfsSensor.h"
#include "../../Configurator.h"
#include "../../Configuration.h"
14
#include <string>
15
16
17
18
19
20
#include <vector>
#include <map>
#include <boost/property_tree/ptree.hpp>

class SysfsConfigurator : public Configurator{

21
	typedef std::map<std::string, SysfsSensor> sensorMap_t;
22
23
24
25
26
27
28
29
30
31

public:

	SysfsConfigurator();
	virtual ~SysfsConfigurator();

	/**
	 * Read in the configuration for sysfs-sensors.
	 * @param cfgPath	Path + name of the config-file
	 */
32
	std::vector<Sensor*>& readConfig(std::string cfgPath);
33
34
35
36
37
38
39
40
41

private:
	/**
	 * Set the variables of sensor according to the values specified in config.
	 * @param sensor	The sensor to be configured
	 * @param config	A property(sub)tree containing the values
	 */
	void readSensor(SysfsSensor& sensor, boost::property_tree::iptree& config);

42
43
	std::vector<Sensor*> _sensors;
	sensorMap_t 	 	 _templateSensors;
44
45
46
47
48
49
50
51
52
53
};

extern "C" Configurator* create() {
	return new SysfsConfigurator;
}

extern "C" void destroy(Configurator* c) {
	delete c;
}

54
#endif /* SYSFSCONFIGURATOR_H_ */