70# pragma warning(disable : 4251)
87 static constexpr const char *
path{
"" };
90 static constexpr const char *
name{
"NetworkConfiguration" };
93 static constexpr const char *
description{ R
"description(Network configuration of a camera
106 static constexpr std::array<uint8_t, 3> binaryId{
'c',
'n',
'c' };
127 static constexpr const char *
path{
"Hostname" };
130 static constexpr const char *
name{
"Hostname" };
134 R
"description(Configure the camera's hostname. If unset, the camera will use the default hostname based on the serial
135number: `zivid-<serial>`. Note that `fetchNetworkConfig` will not return the default hostname in this field.
136If the camera is using the default hostname, then this field will be unset. Use
137`CameraState/Network/Hostname` instead, which returns the camera's current hostname.
139Must be 1 to 15 characters long, can only consist of a-z, A-Z, 0-9 and hyphen (-), and cannot start with
152 : m_opt{ verifyValue(std::move(
value)) }
173 return m_opt == other.m_opt;
179 return m_opt != other.m_opt;
185 return m_opt < other.m_opt;
191 return m_opt > other.m_opt;
197 return m_opt <= other.m_opt;
203 return m_opt >= other.m_opt;
209 return stream <<
value.toString();
213 void setFromString(
const std::string &value);
215 ValueType
static verifyValue(ValueType &&value)
217 return DataModel::Detail::isValidHostname(value)
219 : throw std::invalid_argument{
220 "The value '" + value
221 +
"' is not a valid hostname. A hostname must be 1 to 15 characters long, can only consist of a-z, A-Z, 0-9 and hyphen (-), and cannot start with hyphen (-)."
225 std::optional<std::string> m_opt;
227 friend struct DataModel::Detail::Befriend<
Hostname>;
240 static constexpr const char *
path{
"IPV4" };
243 static constexpr const char *
name{
"IPV4" };
246 static constexpr const char *
description{ R
"description(IPv4 network configuration)description" };
262 static constexpr const char *
path{
"IPV4/Address" };
265 static constexpr const char *
name{
"Address" };
269 R
"description(The camera's IPv4 address. Only used in manual mode.
271To be able to connect to the camera, the camera's IP address must be in the same subnet as the IP
272address of the computer's local network interface.
284 : m_value{ verifyValue(std::move(
value)) }
296 return m_value == other.m_value;
302 return m_value != other.m_value;
308 return m_value < other.m_value;
314 return m_value > other.m_value;
320 return m_value <= other.m_value;
326 return m_value >= other.m_value;
332 return stream <<
value.toString();
336 void setFromString(
const std::string &value);
338 ValueType
static verifyValue(ValueType &&value)
340 return DataModel::Detail::isValidIPv4Address(value)
342 : throw std::invalid_argument{
"The value '" + value
343 +
"' is not a valid IPv4 address." };
346 std::string m_value{
"172.28.60.5" };
348 friend struct DataModel::Detail::Befriend<
Address>;
361 static constexpr const char *
path{
"IPV4/Mode" };
364 static constexpr const char *
name{
"Mode" };
367 static constexpr const char *
description{ R
"description(DHCP or manual configuration)description" };
389 : m_value{ verifyValue(
value) }
401 return stream <<
Mode{
value }.toString();
407 return m_value == other.m_value;
413 return m_value != other.m_value;
419 return stream <<
value.toString();
423 void setFromString(
const std::string &value);
425 constexpr ValueType
static verifyValue(
const ValueType &value)
427 return value == ValueType::dhcp || value == ValueType::manual
429 :
throw std::invalid_argument{
430 "Invalid value: Mode{ "
431 + std::to_string(
static_cast<std::underlying_type<ValueType>::type
>(value)) +
" }"
437 friend struct DataModel::Detail::Befriend<
Mode>;
454 static constexpr const char *
path{
"IPV4/SubnetMask" };
457 static constexpr const char *
name{
"SubnetMask" };
461 R
"description(The camera's subnet mask (for example 255.255.255.0). Only used in manual mode.
463To be able to connect to the camera, the camera's subnet mask must be the same as the subnet mask of the
464computer's local network interface.
476 : m_value{ verifyValue(std::move(
value)) }
488 return m_value == other.m_value;
494 return m_value != other.m_value;
500 return m_value < other.m_value;
506 return m_value > other.m_value;
512 return m_value <= other.m_value;
518 return m_value >= other.m_value;
524 return stream <<
value.toString();
528 void setFromString(
const std::string &value);
530 ValueType
static verifyValue(ValueType &&value)
532 return DataModel::Detail::isValidIPv4SubnetMask(value)
534 : throw std::invalid_argument{
"The value '" + value
535 +
"' is not a valid IPv4 subnet mask." };
538 std::string m_value{
"255.255.255.0" };
540 friend struct DataModel::Detail::Befriend<
SubnetMask>;
567 typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0,
568 typename std::enable_if<
569 Zivid::Detail::TypeTraits::AllArgsAreInTuple<
Descendants,
typename std::decay<Args>::type...>::
573 template<typename... Args>
577 using namespace Zivid::Detail::TypeTraits;
580 AllArgsDecayedAreUnique<Args...>::value,
581 "Found duplicate types among the arguments passed to IPV4(...). "
582 "Types should be listed at most once.");
584 set(std::forward<Args>(args)...);
600 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 2,
int>::type = 0>
602 template<typename... Args>
606 using namespace Zivid::Detail::TypeTraits;
608 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
610 AllArgsAreDescendantNodes::value,
"All arguments passed to set(...) must be descendant nodes.");
613 AllArgsDecayedAreUnique<Args...>::value,
614 "Found duplicate types among the arguments passed to set(...). "
615 "Types should be listed at most once.");
617 Zivid::DataModel::Detail::invokeSetWithEachArgument(*
this, std::forward<Args>(args)...);
634 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0>
636 template<typename... Args>
640 using namespace Zivid::Detail::TypeTraits;
642 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
644 AllArgsAreDescendantNodes::value,
645 "All arguments passed to copyWith(...) must be descendant nodes.");
648 AllArgsDecayedAreUnique<Args...>::value,
649 "Found duplicate types among the arguments passed to copyWith(...). "
650 "Types should be listed at most once.");
653 copy.set(std::forward<Args>(args)...);
710 m_subnetMask = value;
716 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value,
int>::type = 0>
724 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value,
int>::type = 0>
732 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value,
int>::type = 0>
738 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
744 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
750 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
790 void setFromString(
const std::string &value);
792 void setFromString(
const std::string &fullPath,
const std::string &value);
794 std::string getString(
const std::string &fullPath)
const;
800 friend struct DataModel::Detail::Befriend<
IPV4>;
848 typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0,
849 typename std::enable_if<
850 Zivid::Detail::TypeTraits::AllArgsAreInTuple<
Descendants,
typename std::decay<Args>::type...>::value,
853 template<typename... Args>
857 using namespace Zivid::Detail::TypeTraits;
860 AllArgsDecayedAreUnique<Args...>::value,
861 "Found duplicate types among the arguments passed to NetworkConfiguration(...). "
862 "Types should be listed at most once.");
864 set(std::forward<Args>(args)...);
882 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 2,
int>::type = 0>
884 template<typename... Args>
888 using namespace Zivid::Detail::TypeTraits;
890 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
892 AllArgsAreDescendantNodes::value,
"All arguments passed to set(...) must be descendant nodes.");
895 AllArgsDecayedAreUnique<Args...>::value,
896 "Found duplicate types among the arguments passed to set(...). "
897 "Types should be listed at most once.");
899 Zivid::DataModel::Detail::invokeSetWithEachArgument(*
this, std::forward<Args>(args)...);
918 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0>
920 template<typename... Args>
924 using namespace Zivid::Detail::TypeTraits;
926 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
928 AllArgsAreDescendantNodes::value,
"All arguments passed to copyWith(...) must be descendant nodes.");
931 AllArgsDecayedAreUnique<Args...>::value,
932 "Found duplicate types among the arguments passed to copyWith(...). "
933 "Types should be listed at most once.");
936 copy.set(std::forward<Args>(args)...);
1001 typename std::enable_if<std::is_same<T, NetworkConfiguration::Hostname>::value,
int>::type = 0>
1007 template<typename T, typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4>::value,
int>::type = 0>
1015 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value,
int>::type = 0>
1023 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value,
int>::type = 0>
1031 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value,
int>::type = 0>
1037 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1043 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1050 template<
typename F>
1058 template<
typename F>
1081 void save(
const std::string &fileName)
const;
1084 void load(
const std::string &fileName);
1087 void setFromString(
const std::string &value);
1089 void setFromString(
const std::string &fullPath,
const std::string &value);
1091 std::string getString(
const std::string &fullPath)
const;
1101 struct NetworkConfiguration::Version<2>
1114 ZIVID_CORE_EXPORT void save(
const Zivid::NetworkConfiguration &dataModel, std::ostream &ostream);
1115 ZIVID_CORE_EXPORT void load(Zivid::NetworkConfiguration &dataModel, std::istream &istream);
1121# pragma warning(pop)
1125# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1130 struct tuple_size<Zivid::NetworkConfiguration::IPV4> : integral_constant<size_t, 3>
1134 struct tuple_element<i, Zivid::NetworkConfiguration::IPV4>
1136 static_assert(i < tuple_size<Zivid::NetworkConfiguration::IPV4>::value,
"Index must be less than 3");
1139 =
decltype(declval<Zivid::NetworkConfiguration::IPV4>().get<i>());
1143 struct tuple_size<Zivid::NetworkConfiguration> : integral_constant<size_t, 2>
1147 struct tuple_element<i, Zivid::NetworkConfiguration>
1149 static_assert(i < tuple_size<Zivid::NetworkConfiguration>::value,
"Index must be less than 2");
1152 =
decltype(declval<Zivid::NetworkConfiguration>().get<i>());
1161#if defined(__has_include) && !defined(NO_DOC)
1162# if __has_include("Zivid/NetworkConfigurationInternal.h") && __has_include("Zivid/DataModelNodeMetaData.h")
1163# include "Zivid/NetworkConfigurationInternal.h"
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
Configure the camera's hostname. If unset, the camera will use the default hostname based on the seri...
Definition NetworkConfiguration.h:121
Hostname()=default
Default constructor.
bool operator>=(const Hostname &other) const
Comparison operator.
Definition NetworkConfiguration.h:201
std::string ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:145
friend std::ostream & operator<<(std::ostream &stream, const Hostname &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:207
bool operator!=(const Hostname &other) const
Comparison operator.
Definition NetworkConfiguration.h:177
const std::string & value() const
Get the value.
bool hasValue() const
Check if the value is set.
bool operator==(const Hostname &other) const
Comparison operator.
Definition NetworkConfiguration.h:171
static constexpr DataModel::NodeType nodeType
The type of this node.
Definition NetworkConfiguration.h:124
Hostname(std::string value)
Constructor.
Definition NetworkConfiguration.h:151
void reset()
Reset the node to unset state.
bool operator>(const Hostname &other) const
Comparison operator.
Definition NetworkConfiguration.h:189
static constexpr const char * path
The full path for this value.
Definition NetworkConfiguration.h:127
static constexpr const char * description
The description for this value.
Definition NetworkConfiguration.h:133
std::string toString() const
Get the value as string.
bool operator<(const Hostname &other) const
Comparison operator.
Definition NetworkConfiguration.h:183
bool operator<=(const Hostname &other) const
Comparison operator.
Definition NetworkConfiguration.h:195
static constexpr const char * name
The name of this value.
Definition NetworkConfiguration.h:130
The camera's IPv4 address. Only used in manual mode.
Definition NetworkConfiguration.h:256
bool operator<(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:306
static constexpr DataModel::NodeType nodeType
The type of this node.
Definition NetworkConfiguration.h:259
bool operator>(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:312
bool operator>=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:324
static constexpr const char * name
The name of this value.
Definition NetworkConfiguration.h:265
static constexpr const char * description
The description for this value.
Definition NetworkConfiguration.h:268
std::string toString() const
Get the value as string.
std::string ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:277
const std::string & value() const
Get the value.
static constexpr const char * path
The full path for this value.
Definition NetworkConfiguration.h:262
friend std::ostream & operator<<(std::ostream &stream, const Address &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:330
Address()=default
Default constructor.
bool operator!=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:300
bool operator<=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:318
bool operator==(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:294
Address(std::string value)
Constructor.
Definition NetworkConfiguration.h:283
DHCP or manual configuration.
Definition NetworkConfiguration.h:355
ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:371
@ manual
Definition NetworkConfiguration.h:373
@ dhcp
Definition NetworkConfiguration.h:372
static std::set< ValueType > validValues()
All valid values of Mode.
Definition NetworkConfiguration.h:379
static constexpr DataModel::NodeType nodeType
The type of this node.
Definition NetworkConfiguration.h:358
friend std::ostream & operator<<(std::ostream &stream, const Mode &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:417
static const Mode dhcp
dhcp
Definition NetworkConfiguration.h:375
static constexpr const char * path
The full path for this value.
Definition NetworkConfiguration.h:361
bool operator!=(const Mode &other) const
Comparison operator.
Definition NetworkConfiguration.h:411
static constexpr const char * description
The description for this value.
Definition NetworkConfiguration.h:367
ValueType value() const
Get the value.
constexpr Mode(ValueType value)
Constructor.
Definition NetworkConfiguration.h:388
std::string toString() const
Get the value as string.
Mode()=default
Default constructor.
static const Mode manual
manual
Definition NetworkConfiguration.h:376
static constexpr const char * name
The name of this value.
Definition NetworkConfiguration.h:364
bool operator==(const Mode &other) const
Comparison operator.
Definition NetworkConfiguration.h:405
friend std::ostream & operator<<(std::ostream &stream, const Mode::ValueType &value)
Operator to serialize ValueType to a stream.
Definition NetworkConfiguration.h:399
The camera's subnet mask (for example 255.255.255.0). Only used in manual mode.
Definition NetworkConfiguration.h:448
std::string toString() const
Get the value as string.
SubnetMask()=default
Default constructor.
static constexpr const char * description
The description for this value.
Definition NetworkConfiguration.h:460
bool operator>=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:516
SubnetMask(std::string value)
Constructor.
Definition NetworkConfiguration.h:475
bool operator==(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:486
static constexpr const char * path
The full path for this value.
Definition NetworkConfiguration.h:454
friend std::ostream & operator<<(std::ostream &stream, const SubnetMask &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:522
bool operator!=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:492
static constexpr const char * name
The name of this value.
Definition NetworkConfiguration.h:457
static constexpr DataModel::NodeType nodeType
The type of this node.
Definition NetworkConfiguration.h:451
const std::string & value() const
Get the value.
std::string ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:469
bool operator<(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:498
bool operator>(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:504
bool operator<=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:510
IPv4 network configuration.
Definition NetworkConfiguration.h:234
SubnetMask & subnetMask()
Get SubnetMask.
Definition NetworkConfiguration.h:702
const Mode & mode() const
Get Mode.
Definition NetworkConfiguration.h:677
std::string toString() const
Get the value as string.
Address & address()
Get Address.
Definition NetworkConfiguration.h:664
const NetworkConfiguration::IPV4::Mode & get() const
Definition NetworkConfiguration.h:725
bool operator==(const IPV4 &other) const
Equality operator.
static constexpr const char * name
The name of this value.
Definition NetworkConfiguration.h:243
void set(Args &&...args)
Set multiple arguments.
Definition NetworkConfiguration.h:604
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:767
const Address & address() const
Get Address.
Definition NetworkConfiguration.h:658
static constexpr const char * path
The full path for this value.
Definition NetworkConfiguration.h:240
friend std::ostream & operator<<(std::ostream &stream, const IPV4 &value)
Operator to send the value as string to a stream.
Definition NetworkConfiguration.h:784
IPV4 & set(const SubnetMask &value)
Set SubnetMask.
Definition NetworkConfiguration.h:708
Mode & mode()
Get Mode.
Definition NetworkConfiguration.h:683
std::tuple< NetworkConfiguration::IPV4::Address, NetworkConfiguration::IPV4::Mode, NetworkConfiguration::IPV4::SubnetMask > Descendants
Definition NetworkConfiguration.h:543
IPV4 copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition NetworkConfiguration.h:638
const SubnetMask & subnetMask() const
Get SubnetMask.
Definition NetworkConfiguration.h:696
static constexpr DataModel::NodeType nodeType
The type of this node.
Definition NetworkConfiguration.h:237
IPV4 & set(const Address &value)
Set Address.
Definition NetworkConfiguration.h:670
const NetworkConfiguration::IPV4::SubnetMask & get() const
Definition NetworkConfiguration.h:733
IPV4 & set(const Mode &value)
Set Mode.
Definition NetworkConfiguration.h:689
static constexpr const char * description
The description for this value.
Definition NetworkConfiguration.h:246
const NetworkConfiguration::IPV4::Address & get() const
Definition NetworkConfiguration.h:717
bool operator!=(const IPV4 &other) const
Inequality operator.
IPV4()
Default constructor.
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:758
Network configuration of a camera.
Definition NetworkConfiguration.h:81
NetworkConfiguration copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition NetworkConfiguration.h:922
void load(const std::string &fileName)
Load from the given file.
NetworkConfiguration & set(const IPV4::Mode &value)
Set IPV4::Mode.
Definition NetworkConfiguration.h:986
Hostname & hostname()
Get Hostname.
Definition NetworkConfiguration.h:947
NetworkConfiguration & set(const Hostname &value)
Set Hostname.
Definition NetworkConfiguration.h:953
static constexpr const char * path
The full path for this value.
Definition NetworkConfiguration.h:87
const NetworkConfiguration::Hostname & get() const
Definition NetworkConfiguration.h:1002
NetworkConfiguration(Args &&...args)
Constructor taking variadic number of arguments.
Definition NetworkConfiguration.h:855
const NetworkConfiguration::IPV4::Mode & get() const
Definition NetworkConfiguration.h:1024
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:1059
static constexpr const char * description
The description for this value.
Definition NetworkConfiguration.h:93
static constexpr DataModel::NodeType nodeType
The type of this node.
Definition NetworkConfiguration.h:84
void set(Args &&...args)
Set multiple arguments.
Definition NetworkConfiguration.h:886
static NetworkConfiguration fromSerialized(const std::string &value)
Construct a new NetworkConfiguration instance from a previously serialized string.
NetworkConfiguration()
Default constructor.
std::tuple< NetworkConfiguration::Hostname, NetworkConfiguration::IPV4, NetworkConfiguration::IPV4::Address, NetworkConfiguration::IPV4::Mode, NetworkConfiguration::IPV4::SubnetMask > Descendants
Definition NetworkConfiguration.h:803
friend std::ostream & operator<<(std::ostream &stream, const NetworkConfiguration &value)
Operator to send the value as string to a stream.
Definition NetworkConfiguration.h:1075
NetworkConfiguration(const std::string &fileName)
Construct NetworkConfiguration by loading from file.
const IPV4 & ipv4() const
Get IPV4.
Definition NetworkConfiguration.h:960
static constexpr size_t version
Definition NetworkConfiguration.h:96
void save(const std::string &fileName) const
Save to the given file.
NetworkConfiguration & set(const IPV4::Address &value)
Set IPV4::Address.
Definition NetworkConfiguration.h:979
bool operator==(const NetworkConfiguration &other) const
Equality operator.
std::string serialize() const
Serialize to a string.
static constexpr const char * name
The name of this value.
Definition NetworkConfiguration.h:90
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:1051
const NetworkConfiguration::IPV4::SubnetMask & get() const
Definition NetworkConfiguration.h:1032
const Hostname & hostname() const
Get Hostname.
Definition NetworkConfiguration.h:941
const NetworkConfiguration::IPV4 & get() const
Definition NetworkConfiguration.h:1008
std::string toString() const
Get the value as string.
NetworkConfiguration & set(const IPV4::SubnetMask &value)
Set IPV4::SubnetMask.
Definition NetworkConfiguration.h:993
NetworkConfiguration & set(const IPV4 &value)
Set IPV4.
Definition NetworkConfiguration.h:972
IPV4 & ipv4()
Get IPV4.
Definition NetworkConfiguration.h:966
const NetworkConfiguration::IPV4::Address & get() const
Definition NetworkConfiguration.h:1016
bool operator!=(const NetworkConfiguration &other) const
Inequality operator.
NodeType
Definition NodeType.h:49
@ leafValue
Definition NodeType.h:52
@ group
Definition NodeType.h:50
Definition EnvironmentInfo.h:74
Get version information for the library.
Definition Version.h:58
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:85