BAOS SDK v2  1.0.1
An SDK providing access to IP-BAOS devices through BAOS binary protocol version 2.x
BaosIpv4Device.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2002-2023 WEINZIERL ENGINEERING GmbH
3 // All rights reserved.
4 //
5 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
6 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
7 // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
8 // SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
9 // WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
10 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
11 //
12 
13 #ifndef __BAOSLIB_IPV4INTERFACE_H__
14 #define __BAOSLIB_IPV4INTERFACE_H__
15 
16 
17 #include "baos/config.h"
18 #include "baos/device/BaosDevice.h"
19 #include "baos/protocol/Defines.h"
20 
22 #include <memory>
23 #include <optional>
24 #include <utility>
26 
27 
33 namespace wz::baos::ip
34 {
35 
36 
37 /*******************************************
38  * BaosIp4Device
39  *******************************************/
40 
47 class BAOSLIB_EXPORT BaosIp4Device : public wz::baos::BaosDevice
48 {
49 public:
50  virtual ~BaosIp4Device() = default;
51 
58  BaosIp4Device(const std::string& ip4Address, std::uint16_t port = 12004)
59  : ip4Address_{ip4Address},
60  port_{port} {
61 
62  };
63 
73  void setConnectionData(const std::string& ip4Address, std::uint16_t port = 12004)
74  {
75  ip4Address_ = ip4Address;
76  port_ = port;
77  clearCaches();
78  clearDeviceConfigs();
79  deviceInfoLoaded_ = false;
80  }
81 
88 
89 
90 private:
91  std::string ip4Address_;
92  std::uint16_t port_;
93  std::unique_ptr<Ip4Driver> driver_;
94  WZLOGGER("BaosIp4Device", LVL_DEBUG);
95 };
96 
97 } // namespace wz::baos::ip
98 
99 #endif // __BAOSLIB_IPV4INTERFACE_H__
The high level API for BAOS devices.
Global BAOS protocol defines and types.
This class represents a BAOS device.
Definition: BaosDevice.h:58
Represents a BAOS IP4 device with an underlying TCP connection.
Definition: BaosIpv4Device.h:48
BaosConnection_UPtr getConnection() override
Get a BaosConnection to the device.
BaosIp4Device(const std::string &ip4Address, std::uint16_t port=12004)
Construct a new Baos Ip 4 Device object from an ip address and a port.
Definition: BaosIpv4Device.h:58
void setConnectionData(const std::string &ip4Address, std::uint16_t port=12004)
Construct a new Baos Ip 4 Device object from an ip address and a port.
Definition: BaosIpv4Device.h:73
Global types and configuration for the whole SDK.
std::unique_ptr< BaosConnection > BaosConnection_UPtr
Alias for a std::unique pointer of a BaosConnection.
Definition: BaosDevice.h:43