PerfeventConfigurator.h 1.72 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
14
#include "PerfCounter.h"
#include "../../Configurator.h"
#include "../../Configuration.h"
#include <string>
15
16
17
18
#include <vector>
#include <map>
#include <boost/property_tree/ptree.hpp>

19
class PerfeventConfigurator : public Configurator {
20

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

24
public:
25

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

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

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
40
	 * @return	true on success, false if a required value could not be parsed
41
	 */
42
	bool readCounter(PerfCounter& counter, boost::property_tree::iptree& config);
43

44
45
46
47
48
49
50
51
52
53
54
	/**
	 * 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);

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

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

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

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

70
#endif /* PERFEVENTCONFIGURATOR_H_ */