Configurator.h 1.51 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 {
	int daemonize;
	int brokerPort;
19
20
	std::string restHost;
	std::string restPort;
21
22
23
24
	std::string brokerHost;
	std::string mqttPrefix;
	std::string	tempdir;
	uint32_t threads;
25
	unsigned int cacheInterval;
26
27
28
29
	boost::log::trivial::severity_level logLevelFile;
	boost::log::trivial::severity_level logLevelCmd;
} global_t;

Micha Mueller's avatar
Micha Mueller committed
30
31
32
/**
 * Abstract base class, which defines the interface for the configurators in the shared dynamic libraries.
 */
33
34
class Configurator {
public:
35
	Configurator() : _cacheInterval(900000) {}
36
37
	virtual ~Configurator() {}

Micha Mueller's avatar
Micha Mueller committed
38
39
40
	/**
	 * Read in the given configuration
	 * @param	cfgPath Path to the config-file
41
	 * @return	true on success, false otherwise
Micha Mueller's avatar
Micha Mueller committed
42
	 */
43
	virtual bool readConfig(std::string cfgPath) = 0;
44

45
46
	virtual void setGlobalSettings(const global_t& globalSettings) {
		_mqttPrefix = globalSettings.mqttPrefix;
47
		_cacheInterval = globalSettings.cacheInterval;
48
49
	}

50
51
52
53
	std::vector<Sensor*>& getSensors() {
		return _sensors;
	}

54
55
protected:
	std::string _mqttPrefix;
56
	unsigned int _cacheInterval;
57
	std::vector<Sensor*> _sensors;
58
	boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
59
60
};

Micha Mueller's avatar
Micha Mueller committed
61
//typedef for more readable usage of create()- and destroy()-methods, required for dynamic libraries
62
63
64
65
typedef Configurator* create_t();
typedef void destroy_t(Configurator*);

#endif /* SRC_CONFIGURATOR_H_ */