libhomegear-base  0.7
Base library for Homegear and Homegear family modules.
PhysicalInterfaces.h
Go to the documentation of this file.
1 /* Copyright 2013-2019 Homegear GmbH
2  *
3  * Homegear is free software: you can redistribute it and/or modify
4  * 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  * Homegear 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 Homegear. 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 SYSTEMSPHYSICALINTERFACES_H_
32 #define SYSTEMSPHYSICALINTERFACES_H_
33 
34 #include "../Variable.h"
36 
37 #include <memory>
38 #include <mutex>
39 #include <string>
40 #include <map>
41 #include <vector>
42 #include <atomic>
43 #include <functional>
44 
45 namespace BaseLib {
46 
47 class SharedObjects;
48 
49 namespace Systems {
50 
51 class IPhysicalInterface;
52 
54  public:
55  PhysicalInterfaces(BaseLib::SharedObjects *bl, int32_t familyId, std::map<std::string, PPhysicalInterfaceSettings> physicalInterfaceSettings);
56  virtual ~PhysicalInterfaces();
57  void dispose();
58 
59  uint32_t count();
60  virtual void stopListening();
61  virtual void startListening();
62  bool lifetick();
63  bool isOpen();
64  void setup(int32_t userID, int32_t groupID, bool setPermissions);
65  virtual PVariable listInterfaces();
66 
67  void setRawPacketEvent(std::function<void(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)> value) { _rawPacketEvent.swap(value); }
68  protected:
70  int32_t _familyId = -1;
71  std::map<std::string, PPhysicalInterfaceSettings> _physicalInterfaceSettings;
73  std::map<std::string, std::shared_ptr<IPhysicalInterface>> _physicalInterfaces;
74 
75  std::function<void(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)> _rawPacketEvent;
76 
77  virtual void create() {};
78 
79  void rawPacketEvent(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet);
80 };
81 
82 }
83 
84 }
85 #endif
virtual void create()
Definition: PhysicalInterfaces.h:77
virtual ~PhysicalInterfaces()
Definition: PhysicalInterfaces.cpp:51
This is the base library main class.
Definition: BaseLib.h:95
virtual PVariable listInterfaces()
Definition: PhysicalInterfaces.cpp:148
std::map< std::string, std::shared_ptr< IPhysicalInterface > > _physicalInterfaces
Definition: PhysicalInterfaces.h:73
std::map< std::string, PPhysicalInterfaceSettings > _physicalInterfaceSettings
Definition: PhysicalInterfaces.h:71
Definition: BaseLib.cpp:34
bool lifetick()
Definition: PhysicalInterfaces.cpp:64
PVariable value
Definition: UiElements.h:217
std::shared_ptr< Variable > PVariable
Definition: PhysicalInterfaceSettings.h:41
BaseLib::SharedObjects * _bl
Definition: PhysicalInterfaces.h:69
Definition: PhysicalInterfaces.h:53
void setRawPacketEvent(std::function< void(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)> value)
Definition: PhysicalInterfaces.h:67
virtual void stopListening()
Definition: PhysicalInterfaces.cpp:119
int32_t familyId
Definition: Licensing.h:380
std::mutex _physicalInterfacesMutex
Definition: PhysicalInterfaces.h:72
int32_t _familyId
Definition: PhysicalInterfaces.h:70
PhysicalInterfaces(BaseLib::SharedObjects *bl, int32_t familyId, std::map< std::string, PPhysicalInterfaceSettings > physicalInterfaceSettings)
Definition: PhysicalInterfaces.cpp:40
void dispose()
Definition: PhysicalInterfaces.cpp:54
void setup(int32_t userID, int32_t groupID, bool setPermissions)
Definition: PhysicalInterfaces.cpp:131
virtual void startListening()
Definition: PhysicalInterfaces.cpp:106
std::function< void(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)> _rawPacketEvent
Definition: PhysicalInterfaces.h:75
bool isOpen()
Definition: PhysicalInterfaces.cpp:89
uint32_t count()
Definition: PhysicalInterfaces.cpp:78
void rawPacketEvent(int32_t familyId, const std::string &interfaceId, const BaseLib::PVariable &packet)
Definition: PhysicalInterfaces.cpp:179