libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
BaseLib.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * libhomegear-base is free software: you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public License as
5  * published by the Free Software Foundation, either version 3 of the
6  * License, or (at your option) any later version.
7  *
8  * libhomegear-base is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with libhomegear-base. If not, see
15  * <http://www.gnu.org/licenses/>.
16  *
17  * In addition, as a special exception, the copyright holders give
18  * permission to link the code of portions of this program with the
19  * OpenSSL library under certain conditions as described in each
20  * individual source file, and distribute linked combinations
21  * including the two.
22  * You must obey the GNU Lesser General Public License in all respects
23  * for all of the code used other than OpenSSL. If you modify
24  * file(s) with this exception, you may extend this exception to your
25  * version of the file(s), but you are not obligated to do so. If you
26  * do not wish to do so, delete this exception statement from your
27  * version. If you delete this exception statement from all source
28  * files in the program, then also delete it here.
29 */
30 
31 #ifndef BASELIB_H_
32 #define BASELIB_H_
33 
35 #include "Encoding/Ansi.h"
36 #include "Encoding/XmlrpcDecoder.h"
37 #include "Encoding/XmlrpcEncoder.h"
38 #include "Encoding/RpcDecoder.h"
39 #include "Encoding/RpcEncoder.h"
40 #include "Encoding/RpcMethod.h"
41 #include "Encoding/BinaryRpc.h"
42 #include "Encoding/JsonDecoder.h"
43 #include "Encoding/JsonEncoder.h"
44 #include "Encoding/Http.h"
45 #include "Encoding/Html.h"
46 #include "Encoding/WebSocket.h"
50 #include "Managers/ThreadManager.h"
53 #include "HelperFunctions/Color.h"
54 #include "HelperFunctions/Math.h"
55 #include "HelperFunctions/Base64.h"
56 #include "HelperFunctions/Net.h"
57 #include "HelperFunctions/Pid.h"
58 #include "HelperFunctions/Io.h"
59 #include "LowLevel/Gpio.h"
60 #include "LowLevel/Spi.h"
61 #include "Output/Output.h"
65 #include "Security/Acls.h"
66 #include "Security/Hash.h"
67 #include "Security/Mac.h"
68 #include "Security/Gcrypt.h"
69 #include "Settings/Settings.h"
70 #include "Sockets/Hgdc.h"
72 #include "Sockets/ServerInfo.h"
73 #include "Sockets/RpcClientInfo.h"
74 #include "Systems/DeviceFamily.h"
76 #include "Systems/Peer.h"
77 #include "Systems/SystemFactory.h"
78 #include "Systems/UpdateInfo.h"
80 #include "Sockets/Ssdp.h"
81 #include "IQueue.h"
82 #include "ITimedQueue.h"
83 #include "Sockets/HttpClient.h"
84 #include "Sockets/HttpServer.h"
85 #include "Sockets/Modbus.h"
86 #include "Sockets/TcpSocket.h"
87 #include "Sockets/UdpSocket.h"
88 
89 namespace BaseLib {
90 
96  public:
97  SharedObjects(const SharedObjects &) = delete; //Copy constructor
98  SharedObjects &operator=(const SharedObjects &) = delete; //Copy assignment operator
99 
103  int32_t debugLevel = 3;
104 
105  /*
106  * User ID of the Homegear process.
107  */
108  uid_t userId = 0;
109 
110  /*
111  * Group ID of the Homegear process.
112  */
113  gid_t groupId = 0;
114 
118  std::atomic_bool booting{true};
119 
123  std::atomic_bool shuttingDown{false};
124 
128  std::atomic_bool slaveMode{false};
129 
133  std::atomic_bool maintenanceMode{false};
134 
140 
145 
150 
154  std::shared_ptr<Database::IDatabaseController> db;
155 
159  uint32_t rpcPort = 0;
160 
166  int64_t getStartTime();
167 
171  void setStartTime(int64_t time);
172 
177 
183 
188 
193 
198 
203 
207  std::shared_ptr<Hgdc> hgdc;
208 
212  static sigset_t defaultSignalMask;
213 
219  explicit SharedObjects(bool testMaxThreadCount = false);
220 
224  virtual ~SharedObjects();
225 
230  static std::string version();
231  private:
232  int64_t _startTime = 0;
233 };
234 }
235 #endif
HelperFunctions hf
Functions to ease your life for a lot of standard operations.
Definition: BaseLib.h:182
FileDescriptorManager fileDescriptorManager
The FileDescriptorManager object where all file or socket descriptors should be registered.
Definition: BaseLib.h:139
Definition: ThreadManager.h:44
Definition: UpdateInfo.h:41
Definition: FileDescriptorManager.h:54
This is the base library main class.
Definition: BaseLib.h:95
Definition: BaseLib.cpp:34
Settings settings
The main.conf settings.
Definition: BaseLib.h:149
ThreadManager threadManager
The thread manager.
Definition: BaseLib.h:197
uid_t userId
Definition: BaseLib.h:108
std::atomic_bool slaveMode
True when Homegear runs in slave mode of a master/slave installation.
Definition: BaseLib.h:128
SharedObjects(const SharedObjects &)=delete
Class to print output of different kinds to the standard and error output.
Definition: Output.h:54
void setStartTime(int64_t time)
Set the start time.
Definition: BaseLib.cpp:63
SharedObjects & operator=(const SharedObjects &)=delete
Io io
Functions for io operations.
Definition: BaseLib.h:187
This class provides functions to make your life easier.
Definition: HelperFunctions.h:55
SerialDeviceManager serialDeviceManager
The serial device manager can be used to access one serial device across multiple modules...
Definition: BaseLib.h:144
gid_t groupId
Definition: BaseLib.h:113
This class provides functions to make your life easier.
Definition: Io.h:48
int64_t getStartTime()
Return the time of the creation of the object (the Homegear start time).
Definition: BaseLib.cpp:59
Output out
The main output object to print text to the standard and error output.
Definition: BaseLib.h:192
uint32_t rpcPort
Port, the non-ssl RPC server listens on.
Definition: BaseLib.h:159
Systems::GlobalServiceMessages globalServiceMessages
Global service messages.
Definition: BaseLib.h:202
virtual ~SharedObjects()
Destructor.
Definition: BaseLib.cpp:52
Systems::UpdateInfo deviceUpdateInfo
Object to store information about running updates and to only allow one update at a time...
Definition: BaseLib.h:176
Definition: Settings.h:41
std::atomic_bool maintenanceMode
True when maintenance mode is enabled.
Definition: BaseLib.h:133
int32_t debugLevel
The current debug level for logging.
Definition: BaseLib.h:103
static sigset_t defaultSignalMask
Default signal mask.
Definition: BaseLib.h:212
std::shared_ptr< Hgdc > hgdc
Homegear Daisy Chain.
Definition: BaseLib.h:207
static std::string version()
Returns the Homegear version.
Definition: BaseLib.cpp:55
std::atomic_bool shuttingDown
True when Homegear received signal 15.
Definition: BaseLib.h:123
std::shared_ptr< Database::IDatabaseController > db
Provides database access.
Definition: BaseLib.h:154
std::atomic_bool booting
True when Homegear is still starting.
Definition: BaseLib.h:118
Definition: SerialDeviceManager.h:49
Definition: GlobalServiceMessages.h:45