69# pragma warning(disable : 4251)
86 static constexpr const char *path{
"" };
89 static constexpr const char *name{
"NetworkConfiguration" };
92 static constexpr const char *description{ R
"description(Network configuration of a camera
95 static constexpr size_t version{ 1 };
105 static constexpr std::array<uint8_t, 3> binaryId{
'c',
'n',
'c' };
119 static constexpr const char *path{
"IPV4" };
122 static constexpr const char *name{
"IPV4" };
125 static constexpr const char *description{ R
"description(IPv4 network configuration)description" };
141 static constexpr const char *path{
"IPV4/Address" };
144 static constexpr const char *name{
"Address" };
147 static constexpr const char *description{
148 R
"description(The camera's IPv4 address. Only used in manual mode.
150To be able to connect to the camera, the camera's IP address must be in the same subnet as the IP
151address of the computer's local network interface.
163 : m_value{ verifyValue(std::move(value)) }
175 return m_value == other.m_value;
181 return m_value != other.m_value;
187 return m_value < other.m_value;
193 return m_value > other.m_value;
199 return m_value <= other.m_value;
205 return m_value >= other.m_value;
215 void setFromString(
const std::string &value);
217 ValueType
static verifyValue(ValueType &&value)
219 return DataModel::Detail::isValidIPv4Address(value)
221 : throw std::invalid_argument{
"The value '" + value
222 +
"' is not a valid IPv4 address." };
225 std::string m_value{
"172.28.60.5" };
227 friend struct DataModel::Detail::Befriend<
Address>;
240 static constexpr const char *path{
"IPV4/Mode" };
243 static constexpr const char *name{
"Mode" };
246 static constexpr const char *description{ R
"description(DHCP or manual configuration)description" };
260 return { ValueType::dhcp, ValueType::manual };
268 : m_value{ verifyValue(value) }
286 return m_value == other.m_value;
292 return m_value != other.m_value;
302 void setFromString(
const std::string &value);
304 constexpr ValueType
static verifyValue(
const ValueType &value)
306 return value == ValueType::dhcp || value == ValueType::manual
308 :
throw std::invalid_argument{
309 "Invalid value: Mode{ "
310 + std::to_string(
static_cast<std::underlying_type<ValueType>::type
>(value)) +
" }"
316 friend struct DataModel::Detail::Befriend<
Mode>;
333 static constexpr const char *path{
"IPV4/SubnetMask" };
336 static constexpr const char *name{
"SubnetMask" };
339 static constexpr const char *description{
340 R
"description(The camera's subnet mask (for example 255.255.255.0). Only used in manual mode.
342To be able to connect to the camera, the camera's subnet mask must be the same as the subnet mask of the
343computer's local network interface.
355 : m_value{ verifyValue(std::move(value)) }
367 return m_value == other.m_value;
373 return m_value != other.m_value;
379 return m_value < other.m_value;
385 return m_value > other.m_value;
391 return m_value <= other.m_value;
397 return m_value >= other.m_value;
407 void setFromString(
const std::string &value);
409 ValueType
static verifyValue(ValueType &&value)
411 return DataModel::Detail::isValidIPv4SubnetMask(value)
413 : throw std::invalid_argument{
"The value '" + value
414 +
"' is not a valid IPv4 subnet mask." };
417 std::string m_value{
"255.255.255.0" };
419 friend struct DataModel::Detail::Befriend<
SubnetMask>;
446 typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0,
447 typename std::enable_if<
448 Zivid::Detail::TypeTraits::AllArgsAreInTuple<
Descendants,
typename std::decay<Args>::type...>::
452 template<typename... Args>
456 using namespace Zivid::Detail::TypeTraits;
459 AllArgsDecayedAreUnique<Args...>::value,
460 "Found duplicate types among the arguments passed to IPV4(...). "
461 "Types should be listed at most once.");
463 set(std::forward<Args>(args)...);
479 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 2,
int>::type = 0>
481 template<typename... Args>
485 using namespace Zivid::Detail::TypeTraits;
487 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
489 AllArgsAreDescendantNodes::value,
"All arguments passed to set(...) must be descendant nodes.");
492 AllArgsDecayedAreUnique<Args...>::value,
493 "Found duplicate types among the arguments passed to set(...). "
494 "Types should be listed at most once.");
496 Zivid::DataModel::Detail::invokeSetWithEachArgument(*
this, std::forward<Args>(args)...);
513 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0>
515 template<typename... Args>
519 using namespace Zivid::Detail::TypeTraits;
521 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
523 AllArgsAreDescendantNodes::value,
524 "All arguments passed to copyWith(...) must be descendant nodes.");
527 AllArgsDecayedAreUnique<Args...>::value,
528 "Found duplicate types among the arguments passed to copyWith(...). "
529 "Types should be listed at most once.");
532 copy.set(std::forward<Args>(args)...);
589 m_subnetMask = value;
595 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value,
int>::type = 0>
603 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value,
int>::type = 0>
611 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value,
int>::type = 0>
617 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
623 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
629 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
669 void setFromString(
const std::string &value);
671 void setFromString(
const std::string &fullPath,
const std::string &value);
673 std::string getString(
const std::string &fullPath)
const;
679 friend struct DataModel::Detail::Befriend<
IPV4>;
725 typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0,
726 typename std::enable_if<
727 Zivid::Detail::TypeTraits::AllArgsAreInTuple<
Descendants,
typename std::decay<Args>::type...>::value,
730 template<typename... Args>
734 using namespace Zivid::Detail::TypeTraits;
737 AllArgsDecayedAreUnique<Args...>::value,
738 "Found duplicate types among the arguments passed to NetworkConfiguration(...). "
739 "Types should be listed at most once.");
741 set(std::forward<Args>(args)...);
758 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 2,
int>::type = 0>
760 template<typename... Args>
764 using namespace Zivid::Detail::TypeTraits;
766 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
768 AllArgsAreDescendantNodes::value,
"All arguments passed to set(...) must be descendant nodes.");
771 AllArgsDecayedAreUnique<Args...>::value,
772 "Found duplicate types among the arguments passed to set(...). "
773 "Types should be listed at most once.");
775 Zivid::DataModel::Detail::invokeSetWithEachArgument(*
this, std::forward<Args>(args)...);
793 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0>
795 template<typename... Args>
799 using namespace Zivid::Detail::TypeTraits;
801 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
803 AllArgsAreDescendantNodes::value,
"All arguments passed to copyWith(...) must be descendant nodes.");
806 AllArgsDecayedAreUnique<Args...>::value,
807 "Found duplicate types among the arguments passed to copyWith(...). "
808 "Types should be listed at most once.");
811 copy.set(std::forward<Args>(args)...);
855 template<typename T, typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4>::value,
int>::type = 0>
863 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value,
int>::type = 0>
871 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value,
int>::type = 0>
879 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value,
int>::type = 0>
885 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
921 void save(
const std::string &fileName)
const;
924 void load(
const std::string &fileName);
927 void setFromString(
const std::string &value);
929 void setFromString(
const std::string &fullPath,
const std::string &value);
931 std::string getString(
const std::string &fullPath)
const;
940 struct NetworkConfiguration::Version<1>
959 const std::vector<uint8_t> &data);
969# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
974 struct tuple_size<
Zivid::NetworkConfiguration::IPV4> : integral_constant<size_t, 3>
978 struct tuple_element<i,
Zivid::NetworkConfiguration::IPV4>
980 static_assert(i < tuple_size<Zivid::NetworkConfiguration::IPV4>::value,
"Index must be less than 3");
983 =
decltype(declval<Zivid::NetworkConfiguration::IPV4>().get<i>());
987 struct tuple_size<
Zivid::NetworkConfiguration> : integral_constant<size_t, 1>
991 struct tuple_element<i,
Zivid::NetworkConfiguration>
993 static_assert(i < tuple_size<Zivid::NetworkConfiguration>::value,
"Index must be less than 1");
996 =
decltype(declval<Zivid::NetworkConfiguration>().get<i>());
1005#if defined(__has_include) && !defined(NO_DOC)
1006# if __has_include("Zivid/NetworkConfigurationInternal.h") && __has_include("Zivid/DataModelNodeMetaData.h")
1007# include "Zivid/NetworkConfigurationInternal.h"
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
The camera's IPv4 address. Only used in manual mode.
Definition NetworkConfiguration.h:135
bool operator<(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:185
bool operator>(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:191
bool operator>=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:203
std::string toString() const
Get the value as string.
std::string ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:156
const std::string & value() const
Get the value.
friend std::ostream & operator<<(std::ostream &stream, const Address &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:209
Address()=default
Default constructor.
bool operator!=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:179
bool operator<=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:197
bool operator==(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:173
Address(std::string value)
Constructor.
Definition NetworkConfiguration.h:162
DHCP or manual configuration.
Definition NetworkConfiguration.h:234
ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:250
static std::set< ValueType > validValues()
All valid values of Mode.
Definition NetworkConfiguration.h:258
friend std::ostream & operator<<(std::ostream &stream, const Mode &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:296
static const Mode dhcp
dhcp
Definition NetworkConfiguration.h:254
bool operator!=(const Mode &other) const
Comparison operator.
Definition NetworkConfiguration.h:290
ValueType value() const
Get the value.
constexpr Mode(ValueType value)
Constructor.
Definition NetworkConfiguration.h:267
std::string toString() const
Get the value as string.
Mode()=default
Default constructor.
static const Mode manual
manual
Definition NetworkConfiguration.h:255
bool operator==(const Mode &other) const
Comparison operator.
Definition NetworkConfiguration.h:284
friend std::ostream & operator<<(std::ostream &stream, const Mode::ValueType &value)
Operator to serialize ValueType to a stream.
Definition NetworkConfiguration.h:278
The camera's subnet mask (for example 255.255.255.0). Only used in manual mode.
Definition NetworkConfiguration.h:327
std::string toString() const
Get the value as string.
SubnetMask()=default
Default constructor.
bool operator>=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:395
SubnetMask(std::string value)
Constructor.
Definition NetworkConfiguration.h:354
bool operator==(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:365
friend std::ostream & operator<<(std::ostream &stream, const SubnetMask &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:401
bool operator!=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:371
const std::string & value() const
Get the value.
std::string ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:348
bool operator<(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:377
bool operator>(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:383
bool operator<=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:389
IPv4 network configuration.
Definition NetworkConfiguration.h:113
SubnetMask & subnetMask()
Get SubnetMask.
Definition NetworkConfiguration.h:581
const Mode & mode() const
Get Mode.
Definition NetworkConfiguration.h:556
std::string toString() const
Get the value as string.
Address & address()
Get Address.
Definition NetworkConfiguration.h:543
const NetworkConfiguration::IPV4::Mode & get() const
Definition NetworkConfiguration.h:604
bool operator==(const IPV4 &other) const
Equality operator.
void set(Args &&...args)
Set multiple arguments.
Definition NetworkConfiguration.h:483
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:646
const Address & address() const
Get Address.
Definition NetworkConfiguration.h:537
friend std::ostream & operator<<(std::ostream &stream, const IPV4 &value)
Operator to send the value as string to a stream.
Definition NetworkConfiguration.h:663
IPV4 & set(const SubnetMask &value)
Set SubnetMask.
Definition NetworkConfiguration.h:587
Mode & mode()
Get Mode.
Definition NetworkConfiguration.h:562
std::tuple< NetworkConfiguration::IPV4::Address, NetworkConfiguration::IPV4::Mode, NetworkConfiguration::IPV4::SubnetMask > Descendants
Definition NetworkConfiguration.h:422
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:517
const SubnetMask & subnetMask() const
Get SubnetMask.
Definition NetworkConfiguration.h:575
IPV4 & set(const Address &value)
Set Address.
Definition NetworkConfiguration.h:549
const NetworkConfiguration::IPV4::SubnetMask & get() const
Definition NetworkConfiguration.h:612
IPV4 & set(const Mode &value)
Set Mode.
Definition NetworkConfiguration.h:568
const NetworkConfiguration::IPV4::Address & get() const
Definition NetworkConfiguration.h:596
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:637
Network configuration of a camera.
Definition NetworkConfiguration.h:80
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:797
void load(const std::string &fileName)
Load from the given file.
NetworkConfiguration & set(const IPV4::Mode &value)
Set IPV4::Mode.
Definition NetworkConfiguration.h:842
NetworkConfiguration(Args &&...args)
Constructor taking variadic number of arguments.
Definition NetworkConfiguration.h:732
std::tuple< NetworkConfiguration::IPV4, NetworkConfiguration::IPV4::Address, NetworkConfiguration::IPV4::Mode, NetworkConfiguration::IPV4::SubnetMask > Descendants
Definition NetworkConfiguration.h:682
const NetworkConfiguration::IPV4::Mode & get() const
Definition NetworkConfiguration.h:872
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:900
void set(Args &&...args)
Set multiple arguments.
Definition NetworkConfiguration.h:762
static NetworkConfiguration fromSerialized(const std::string &value)
Construct a new NetworkConfiguration instance from a previously serialized string.
NetworkConfiguration()
Default constructor.
friend std::ostream & operator<<(std::ostream &stream, const NetworkConfiguration &value)
Operator to send the value as string to a stream.
Definition NetworkConfiguration.h:915
NetworkConfiguration(const std::string &fileName)
Construct NetworkConfiguration by loading from file.
const IPV4 & ipv4() const
Get IPV4.
Definition NetworkConfiguration.h:816
void save(const std::string &fileName) const
Save to the given file.
NetworkConfiguration & set(const IPV4::Address &value)
Set IPV4::Address.
Definition NetworkConfiguration.h:835
bool operator==(const NetworkConfiguration &other) const
Equality operator.
std::string serialize() const
Serialize to a string.
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:893
const NetworkConfiguration::IPV4::SubnetMask & get() const
Definition NetworkConfiguration.h:880
const NetworkConfiguration::IPV4 & get() const
Definition NetworkConfiguration.h:856
std::string toString() const
Get the value as string.
NetworkConfiguration & set(const IPV4::SubnetMask &value)
Set IPV4::SubnetMask.
Definition NetworkConfiguration.h:849
NetworkConfiguration & set(const IPV4 &value)
Set IPV4.
Definition NetworkConfiguration.h:828
IPV4 & ipv4()
Get IPV4.
Definition NetworkConfiguration.h:822
const NetworkConfiguration::IPV4::Address & get() const
Definition NetworkConfiguration.h:864
bool operator!=(const NetworkConfiguration &other) const
Inequality operator.
NodeType
Definition NodeType.h:49
Definition EnvironmentInfo.h:74
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:84