libvisiontransfer  6.1.0
deviceinfo.h
1 /*******************************************************************************
2  * Copyright (c) 2018 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 
23 class DeviceInfo {
24 public:
25  enum DeviceModel {
26  SCENESCAN,
27  SCENESCAN_PRO
28  };
29 
30  enum NetworkProtocol {
31  PROTOCOL_TCP,
32  PROTOCOL_UDP
33  };
34 
38  DeviceInfo(): ip(""), protocol(PROTOCOL_TCP), fwVersion(""), model(SCENESCAN),
39  compatible(false) {
40  }
41 
53  DeviceInfo(const char* ip, NetworkProtocol protocol, const char* fwVersion,
54  DeviceModel model, bool compatible)
55  : ip(ip), protocol(protocol), fwVersion(fwVersion), model(model),
56  compatible(compatible) {
57  }
58 
63  std::string getIpAddress() const {return ip;}
64 
71  NetworkProtocol getNetworkProtocol() const {return protocol;}
72 
81  std::string getFirmwareVersion() const {return fwVersion;}
82 
89  DeviceModel getModel() const {return model;}
90 
91 
96  bool isCompatible() const {return compatible;}
97 
104  std::string toString() const {
105  return ip + "; SceneScan" + (model == SCENESCAN_PRO ? " Pro" : "")
106  + "; " + fwVersion + "; " + (compatible ? "compatible" : "incompatible");
107  }
108 
112  bool operator == (const DeviceInfo& other) const {
113  return ip == other.ip && protocol == other.protocol && fwVersion == other.fwVersion
114  && model == other.model && compatible == other.compatible;
115  }
116 
117 private:
118  std::string ip;
119  NetworkProtocol protocol;
120  std::string fwVersion;
121  DeviceModel model;
122  bool compatible;
123 };
124 
125 #endif
std::string toString() const
Converts this object to a printable string.
Definition: deviceinfo.h:104
NetworkProtocol getNetworkProtocol() const
Gets the network protocol of the device.
Definition: deviceinfo.h:71
bool isCompatible() const
Returns true if the device is compatible with this API version.
Definition: deviceinfo.h:96
DeviceModel getModel() const
Gets the model identifier of the discovered device.
Definition: deviceinfo.h:89
std::string getIpAddress() const
Gets the IP address of the device.
Definition: deviceinfo.h:63
bool operator==(const DeviceInfo &other) const
Comparison operator for comparing two DeviceInfo objects.
Definition: deviceinfo.h:112
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:53
DeviceInfo()
Constructs an empty object with default information.
Definition: deviceinfo.h:38
Aggregates information about a discovered device.
Definition: deviceinfo.h:23
std::string getFirmwareVersion() const
Gets the firmware version of the device.
Definition: deviceinfo.h:81
Nerian Vision Technologies