Configurator.h 1.28 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
19
20
21
22
23
24
25
26
typedef struct {
	int daemonize;
	int brokerPort;
	std::string brokerHost;
	std::string mqttPrefix;
	std::string	tempdir;
	uint32_t threads;
	boost::log::trivial::severity_level logLevelFile;
	boost::log::trivial::severity_level logLevelCmd;
} global_t;

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

Micha Mueller's avatar
Micha Mueller committed
35
36
37
38
39
	/**
	 * Read in the given configuration
	 * @param	cfgPath Path to the config-file
	 * @return	Reference to the vector of sensors which were created
	 */
40
	virtual std::vector<Sensor*>& readConfig(std::string cfgPath) = 0;
41

42
43
	virtual void setGlobalSettings(const global_t& globalSettings) {
		_mqttPrefix = globalSettings.mqttPrefix;
44
45
46
47
	}

protected:
	std::string _mqttPrefix;
48
	boost::log::sources::severity_logger<boost::log::trivial::severity_level> lg;
49
50
};

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

#endif /* SRC_CONFIGURATOR_H_ */