libvisiontransfer  6.4.0
deviceinfo.h
1 /*******************************************************************************
2  * Copyright (c) 2019 Nerian Vision GmbH
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a copy
5  * of this software and associated documentation files (the "Software"), to deal
6  * in the Software without restriction, including without limitation the rights
7  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8  * copies of the Software, and to permit persons to whom the Software is
9  * furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice shall be included in
12  * all copies or substantial portions of the Software.
13  *******************************************************************************/
14 
15 #ifndef VISIONTRANSFER_DEVICEINFO_H
16 #define VISIONTRANSFER_DEVICEINFO_H
17 
18 #include <string>
19 
20 namespace visiontransfer {
21 
25 class DeviceInfo {
26 public:
27  enum DeviceModel {
28  SCENESCAN,
29  SCENESCAN_PRO
30  };
31 
32  enum NetworkProtocol {
33  PROTOCOL_TCP,
34  PROTOCOL_UDP
35  };
36 
40  DeviceInfo(): ip(""), protocol(PROTOCOL_TCP), fwVersion(""), model(SCENESCAN),
41  compatible(false) {
42  }
43 
55  DeviceInfo(const char* ip, NetworkProtocol protocol, const char* fwVersion,
56  DeviceModel model, bool compatible)
57  : ip(ip), protocol(protocol), fwVersion(fwVersion), model(model),
58  compatible(compatible) {
59  }
60 
65  std::string getIpAddress() const {return ip;}
66 
73  NetworkProtocol getNetworkProtocol() const {return protocol;}
74 
83  std::string getFirmwareVersion() const {return fwVersion;}
84 
91  DeviceModel getModel() const {return model;}
92 
93 
98  bool isCompatible() const {return compatible;}
99 
106  std::string toString() const {
107  return ip + "; SceneScan" + (model == SCENESCAN_PRO ? " Pro" : "")
108  + "; " + fwVersion + "; " + (compatible ? "compatible" : "incompatible");
109  }
110 
114  bool operator == (const DeviceInfo& other) const {
115  return ip == other.ip && protocol == other.protocol && fwVersion == other.fwVersion
116  && model == other.model && compatible == other.compatible;
117  }
118 
119 private:
120  std::string ip;
121  NetworkProtocol protocol;
122  std::string fwVersion;
123  DeviceModel model;
124  bool compatible;
125 };
126 
127 } // namespace
128 
129 #endif
DeviceModel getModel() const
Gets the model identifier of the discovered device.
Definition: deviceinfo.h:91
bool operator==(const DeviceInfo &other) const
Comparison operator for comparing two DeviceInfo objects.
Definition: deviceinfo.h:114
std::string getIpAddress() const
Gets the IP address of the device.
Definition: deviceinfo.h:65
DeviceInfo(const char *ip, NetworkProtocol protocol, const char *fwVersion, DeviceModel model, bool compatible)
Constructs an object by initializing all members with data from the given parameters.
Definition: deviceinfo.h:55
std::string toString() const
Converts this object to a printable string.
Definition: deviceinfo.h:106
std::string getFirmwareVersion() const
Gets the firmware version of the device.
Definition: deviceinfo.h:83
Aggregates information about a discovered device.
Definition: deviceinfo.h:25
bool isCompatible() const
Returns true if the device is compatible with this API version.
Definition: deviceinfo.h:98
DeviceInfo()
Constructs an empty object with default information.
Definition: deviceinfo.h:40
NetworkProtocol getNetworkProtocol() const
Gets the network protocol of the device.
Definition: deviceinfo.h:73
Nerian Vision Technologies