Configuration.h 2.14 KB
Newer Older
1
2
3
4
/*
 * Configuration.h
 *
 *  Created on: 13.12.2017
5
 *      Author: Michael Ott (original), Micha Mueller
6
7
8
9
10
11
12
 */

#ifndef CONFIGURATION_H_
#define CONFIGURATION_H_

#include <set>

13
#include "HttpsServer.h"
14
#include <boost/log/trivial.hpp>
15
#include "includes/PluginDefinitions.h"
16

Alessio Netti's avatar
Alessio Netti committed
17
18
19
#define BROKERPORT 1883
#define BROKERHOST "127.0.0.1"

20
21
22
/**
 * Class responsible of reading the global configuration as well as loading and invoking required dynamic libraries.
 */
Alessio Netti's avatar
Alessio Netti committed
23
24
class Configuration : public GlobalConfiguration {
	
25
public:
Alessio Netti's avatar
Alessio Netti committed
26
	
27
	/**
Alessio Netti's avatar
Alessio Netti committed
28
29
30
31
32
33
34
     * Create new Configuration. Sets global config file to read from to cfgFile.
     * 
     * @param cfgFilePath	Path to where all config-files are located
     * @param cfgFileName   Name of the file containing the config
     */
	Configuration(const std::string& cfgFilePath, const std::string& cfgFileName) : GlobalConfiguration(cfgFilePath, cfgFileName) {}
	
35
	virtual ~Configuration();
Alessio Netti's avatar
Alessio Netti committed
36
	
37
	/**
38
	 * Reads the authentication keys and forwards them to the HttpsServer
39
	 *
40
	 * @param server	The Rest API server where to add the authkeys
41
42
	 * @return	true on success, false otherwise
	 */
43
	bool readAuthkeys(HttpsServer* server);
44

45
	/**
46
47
48
	 * Reads the plugin configuration section from global.conf (located at _cfgFilePath).
	 * Detects which sensor types are required and dynamically opens required plugins.
	 * Invokes the plugin to read its configuration and generate specified sensors.
49
50
51
	 *
	 * @return	true on success, false otherwise
	 */
52
	bool readPlugins();
Alessio Netti's avatar
Alessio Netti committed
53
	
54
	/**
55
56
	 * Return all plugins (in form of their dl_t struct)
	 */
Alessio Netti's avatar
Alessio Netti committed
57
58
59
60
61
62
	pluginVector_t& getPlugins() { return _plugins; }
	
	// Additional configuration parameters to be parsed and stored in the global block
	int qosLevel = 1;
	unsigned int maxInflightMsgNum = 20;
	unsigned int maxQueuedMsgNum = 0;
Alessio Netti's avatar
Alessio Netti committed
63
64
	int brokerPort = BROKERPORT;
	std::string brokerHost = BROKERHOST;
Alessio Netti's avatar
Alessio Netti committed
65
66
67
68
69
70
	int maxMsgNum = 0;
	
protected:

	bool readAdditionalValues(boost::property_tree::iptree::value_type &global) override;
	
71
72
73
74
	/**
	 * Vector which holds data of the opened plugins.
	 * Only references to this member should be handed around, to keep the plugins everywhere in sync.
	 */
75
	pluginVector_t _plugins;
76
77
78
};

#endif /* CONFIGURATION_H_ */