PerfeventConfigurator.h 1.69 KB
Newer Older
1
/*
2
 * PerfeventConfigurator.h
3
4
5
6
7
 *
 *  Created on: 13.12.2017
 *      Author: Micha Mueller
 */

8
9
#ifndef PERFEVENTCONFIGURATOR_H_
#define PERFEVENTCONFIGURATOR_H_
10

11
12
13
#include "PerfCounter.h"
#include "../../Configurator.h"
#include <string>
14
15
16
17
#include <vector>
#include <map>
#include <boost/property_tree/ptree.hpp>

18
class PerfeventConfigurator : public Configurator {
19

20
21
	typedef std::map<std::string, PerfCounter> counterMap_t;
	typedef std::map<std::string, unsigned int> enumMap_t;
22

23
public:
24

25
26
	PerfeventConfigurator();
	virtual ~PerfeventConfigurator();
27
28
29

	/**
	 * Read the configuration for perfpusher.
30
	 * @param cfgPath	Path + name of the configuration file
31
	 */
32
	std::vector<Sensor*>& readConfig(std::string cfgPath);
33
34
35
36
37
38

private:
	/**
	 * Set the variables of counter according to the values specified in config.
	 * @param counter	The counter to be configured
	 * @param config	A property(sub)tree containing the values
39
	 * @return	true on success, false if a required value could not be parsed
40
	 */
41
	bool readCounter(PerfCounter& counter, boost::property_tree::iptree& config);
42

43
44
45
46
47
48
49
50
51
52
53
	/**
	 * Increase the mqtt by val means
	 * Example: increaseMqtt("003F", 1) 	returns "0040"
	 * 			increaseMqtt("003F", 15)	returns "004D"
	 *
	 * @param mqtt	The mqtt-topic to be increased
	 * @param val	The value by which the mqtt-topic should be increased
	 * @return	The increased mqtt-topic
	 */
	const std::string increaseMqtt(const std::string& mqtt, int val);

54
55
	std::vector<Sensor*> _sensors;
	counterMap_t _templateCounters;
56

57
58
	enumMap_t _enumType;
	enumMap_t _enumConfig;
59
60
};

61
62
63
64
65
66
67
68
extern "C" Configurator* create() {
	return new PerfeventConfigurator;
}

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

69
#endif /* PERFEVENTCONFIGURATOR_H_ */