Configurator.h 1.31 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
/*
 * Configurator.h
 *
 *  Created on: 13.01.2018
 *      Author: Micha Mueller
 */

#ifndef SRC_CONFIGURATOR_H_
#define SRC_CONFIGURATOR_H_

11
12
#include "Sensor.h"

13
14
#include <vector>
#include <string>
15

16
17
18
typedef struct {
	std::string mqttPrefix;
	std::string	tempdir;
19
	unsigned int cacheInterval;
20
} pluginSettings_t;
21

Micha Mueller's avatar
Micha Mueller committed
22
23
24
/**
 * Abstract base class, which defines the interface for the configurators in the shared dynamic libraries.
 */
25
26
class Configurator {
public:
27
	Configurator() : _cacheInterval(900000) {}
28
29
	virtual ~Configurator() {}

Micha Mueller's avatar
Micha Mueller committed
30
31
32
	/**
	 * Read in the given configuration
	 * @param	cfgPath Path to the config-file
33
	 * @return	true on success, false otherwise
Micha Mueller's avatar
Micha Mueller committed
34
	 */
35
	virtual bool readConfig(std::string cfgPath) = 0;
36

37
38
39
	virtual void setGlobalSettings(const pluginSettings_t& pluginSettings) {
		_mqttPrefix = pluginSettings.mqttPrefix;
		_cacheInterval = pluginSettings.cacheInterval;
40
41
	}

42
43
44
45
	std::vector<Sensor*>& getSensors() {
		return _sensors;
	}

46
47
protected:
	std::string _mqttPrefix;
48
	unsigned int _cacheInterval;
49
	std::vector<Sensor*> _sensors;
50
	boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
51
52
};

Micha Mueller's avatar
Micha Mueller committed
53
//typedef for more readable usage of create()- and destroy()-methods, required for dynamic libraries
54
55
56
57
typedef Configurator* create_t();
typedef void destroy_t(Configurator*);

#endif /* SRC_CONFIGURATOR_H_ */