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
96 static constexpr size_t version{ 1 };
106 static constexpr std::array<uint8_t, 3> binaryId{
'c',
'n',
'c' };
120 static constexpr const char *path{
"IPV4" };
123 static constexpr const char *name{
"IPV4" };
126 static constexpr const char *description{ R
"description(IPv4 network configuration)description" };
138 static constexpr const char *path{
"IPV4/Address" };
141 static constexpr const char *name{
"Address" };
144 static constexpr const char *description{
145 R
"description(IPv4 address. Only used in manual mode.)description"
156 : m_value{ verifyValue(std::move(value)) }
168 return m_value == other.m_value;
174 return m_value != other.m_value;
180 return m_value < other.m_value;
186 return m_value > other.m_value;
192 return m_value <= other.m_value;
198 return m_value >= other.m_value;
208 void setFromString(
const std::string &value);
210 ValueType
static verifyValue(ValueType &&value)
212 return DataModel::Detail::isValidIPv4Address(value)
214 : throw std::invalid_argument{
"The value '" + value
215 +
"' is not a valid IPv4 address." };
218 std::string m_value{
"172.28.60.5" };
220 friend struct DataModel::Detail::Befriend<
Address>;
233 static constexpr const char *path{
"IPV4/Mode" };
236 static constexpr const char *name{
"Mode" };
239 static constexpr const char *description{ R
"description(DHCP or manual configuration)description" };
253 return { ValueType::dhcp, ValueType::manual };
261 : m_value{ verifyValue(value) }
279 return m_value == other.m_value;
285 return m_value != other.m_value;
295 void setFromString(
const std::string &value);
297 constexpr ValueType
static verifyValue(
const ValueType &value)
299 return value == ValueType::dhcp || value == ValueType::manual
301 :
throw std::invalid_argument{
302 "Invalid value: Mode{ "
303 + std::to_string(
static_cast<std::underlying_type<ValueType>::type
>(value)) +
" }"
309 friend struct DataModel::Detail::Befriend<
Mode>;
324 static constexpr const char *path{
"IPV4/SubnetMask" };
327 static constexpr const char *name{
"SubnetMask" };
330 static constexpr const char *description{ R
"description(IPv4 subnet mask (for example 255.255.255.0).
331Only used in manual mode.
342 : m_value{ verifyValue(std::move(value)) }
354 return m_value == other.m_value;
360 return m_value != other.m_value;
366 return m_value < other.m_value;
372 return m_value > other.m_value;
378 return m_value <= other.m_value;
384 return m_value >= other.m_value;
394 void setFromString(
const std::string &value);
396 ValueType
static verifyValue(ValueType &&value)
398 return DataModel::Detail::isValidIPv4SubnetMask(value)
400 : throw std::invalid_argument{
"The value '" + value
401 +
"' is not a valid IPv4 subnet mask." };
404 std::string m_value{
"255.255.255.0" };
406 friend struct DataModel::Detail::Befriend<
SubnetMask>;
433 typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0,
434 typename std::enable_if<
435 Zivid::Detail::TypeTraits::AllArgsAreInTuple<
Descendants,
typename std::decay<Args>::type...>::
439 template<typename... Args>
443 using namespace Zivid::Detail::TypeTraits;
446 AllArgsDecayedAreUnique<Args...>::value,
447 "Found duplicate types among the arguments passed to IPV4(...). "
448 "Types should be listed at most once.");
450 set(std::forward<Args>(args)...);
466 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 2,
int>::type = 0>
468 template<typename... Args>
472 using namespace Zivid::Detail::TypeTraits;
474 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
476 AllArgsAreDescendantNodes::value,
"All arguments passed to set(...) must be descendant nodes.");
479 AllArgsDecayedAreUnique<Args...>::value,
480 "Found duplicate types among the arguments passed to set(...). "
481 "Types should be listed at most once.");
483 Zivid::DataModel::Detail::invokeSetWithEachArgument(*
this, std::forward<Args>(args)...);
500 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0>
502 template<typename... Args>
506 using namespace Zivid::Detail::TypeTraits;
508 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
510 AllArgsAreDescendantNodes::value,
511 "All arguments passed to copyWith(...) must be descendant nodes.");
514 AllArgsDecayedAreUnique<Args...>::value,
515 "Found duplicate types among the arguments passed to copyWith(...). "
516 "Types should be listed at most once.");
519 copy.
set(std::forward<Args>(args)...);
576 m_subnetMask = value;
582 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value,
int>::type = 0>
590 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value,
int>::type = 0>
598 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value,
int>::type = 0>
604 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
610 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
616 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
656 void setFromString(
const std::string &value);
658 void setFromString(
const std::string &fullPath,
const std::string &value);
660 std::string getString(
const std::string &fullPath)
const;
666 friend struct DataModel::Detail::Befriend<
IPV4>;
712 typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0,
713 typename std::enable_if<
714 Zivid::Detail::TypeTraits::AllArgsAreInTuple<
Descendants,
typename std::decay<Args>::type...>::value,
717 template<typename... Args>
721 using namespace Zivid::Detail::TypeTraits;
724 AllArgsDecayedAreUnique<Args...>::value,
725 "Found duplicate types among the arguments passed to NetworkConfiguration(...). "
726 "Types should be listed at most once.");
728 set(std::forward<Args>(args)...);
745 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 2,
int>::type = 0>
747 template<typename... Args>
751 using namespace Zivid::Detail::TypeTraits;
753 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
755 AllArgsAreDescendantNodes::value,
"All arguments passed to set(...) must be descendant nodes.");
758 AllArgsDecayedAreUnique<Args...>::value,
759 "Found duplicate types among the arguments passed to set(...). "
760 "Types should be listed at most once.");
762 Zivid::DataModel::Detail::invokeSetWithEachArgument(*
this, std::forward<Args>(args)...);
780 template<
typename... Args,
typename std::enable_if<
sizeof...(Args) >= 1,
int>::type = 0>
782 template<typename... Args>
786 using namespace Zivid::Detail::TypeTraits;
788 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
790 AllArgsAreDescendantNodes::value,
"All arguments passed to copyWith(...) must be descendant nodes.");
793 AllArgsDecayedAreUnique<Args...>::value,
794 "Found duplicate types among the arguments passed to copyWith(...). "
795 "Types should be listed at most once.");
798 copy.
set(std::forward<Args>(args)...);
842 template<typename T, typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4>::value,
int>::type = 0>
850 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value,
int>::type = 0>
858 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value,
int>::type = 0>
866 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value,
int>::type = 0>
872 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
908 void save(
const std::string &fileName)
const;
911 void load(
const std::string &fileName);
914 void setFromString(
const std::string &value);
916 void setFromString(
const std::string &fullPath,
const std::string &value);
918 std::string getString(
const std::string &fullPath)
const;
936 struct NetworkConfiguration::Version<1>
938 using Type = NetworkConfiguration;
949# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
954 struct tuple_size<
Zivid::NetworkConfiguration::IPV4> : integral_constant<size_t, 3>
958 struct tuple_element<i,
Zivid::NetworkConfiguration::IPV4>
960 static_assert(i < tuple_size<Zivid::NetworkConfiguration::IPV4>::value,
"Index must be less than 3");
963 =
decltype(declval<Zivid::NetworkConfiguration::IPV4>().get<i>());
967 struct tuple_size<
Zivid::NetworkConfiguration> : integral_constant<size_t, 1>
971 struct tuple_element<i,
Zivid::NetworkConfiguration>
973 static_assert(i < tuple_size<Zivid::NetworkConfiguration>::value,
"Index must be less than 1");
976 =
decltype(declval<Zivid::NetworkConfiguration>().get<i>());
985#if defined(__has_include) && !defined(NO_DOC)
986# if __has_include("Zivid/NetworkConfigurationInternal.h") && __has_include("Zivid/DataModelNodeMetaData.h")
987# include "Zivid/NetworkConfigurationInternal.h"
#define ZIVID_NODISCARD
Definition Attributes.h:49
#define ZIVID_CORE_EXPORT
Definition CoreExport.h:56
IPv4 address. Only used in manual mode.
Definition NetworkConfiguration.h:132
bool operator<(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:178
bool operator>(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:184
bool operator>=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:196
std::string toString() const
Get the value as string.
std::string ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:149
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:202
Address()=default
Default constructor.
bool operator!=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:172
bool operator<=(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:190
bool operator==(const Address &other) const
Comparison operator.
Definition NetworkConfiguration.h:166
Address(std::string value)
Constructor.
Definition NetworkConfiguration.h:155
DHCP or manual configuration.
Definition NetworkConfiguration.h:227
ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:243
static std::set< ValueType > validValues()
All valid values of Mode.
Definition NetworkConfiguration.h:251
friend std::ostream & operator<<(std::ostream &stream, const Mode &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:289
static const Mode dhcp
dhcp
Definition NetworkConfiguration.h:247
bool operator!=(const Mode &other) const
Comparison operator.
Definition NetworkConfiguration.h:283
ValueType value() const
Get the value.
constexpr Mode(ValueType value)
Constructor.
Definition NetworkConfiguration.h:260
std::string toString() const
Get the value as string.
Mode()=default
Default constructor.
static const Mode manual
manual
Definition NetworkConfiguration.h:248
bool operator==(const Mode &other) const
Comparison operator.
Definition NetworkConfiguration.h:277
friend std::ostream & operator<<(std::ostream &stream, const Mode::ValueType &value)
Operator to serialize ValueType to a stream.
Definition NetworkConfiguration.h:271
IPv4 subnet mask (for example 255.255.255.0). Only used in manual mode.
Definition NetworkConfiguration.h:318
std::string toString() const
Get the value as string.
SubnetMask()=default
Default constructor.
bool operator>=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:382
SubnetMask(std::string value)
Constructor.
Definition NetworkConfiguration.h:341
bool operator==(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:352
friend std::ostream & operator<<(std::ostream &stream, const SubnetMask &value)
Operator to serialize the value to a stream.
Definition NetworkConfiguration.h:388
bool operator!=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:358
const std::string & value() const
Get the value.
std::string ValueType
The type of the underlying value.
Definition NetworkConfiguration.h:335
bool operator<(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:364
bool operator>(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:370
bool operator<=(const SubnetMask &other) const
Comparison operator.
Definition NetworkConfiguration.h:376
IPv4 network configuration.
Definition NetworkConfiguration.h:114
SubnetMask & subnetMask()
Get SubnetMask.
Definition NetworkConfiguration.h:568
const Mode & mode() const
Get Mode.
Definition NetworkConfiguration.h:543
std::string toString() const
Get the value as string.
Address & address()
Get Address.
Definition NetworkConfiguration.h:530
const NetworkConfiguration::IPV4::Mode & get() const
Definition NetworkConfiguration.h:591
bool operator==(const IPV4 &other) const
Equality operator.
void set(Args &&...args)
Set multiple arguments.
Definition NetworkConfiguration.h:470
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:633
const Address & address() const
Get Address.
Definition NetworkConfiguration.h:524
friend std::ostream & operator<<(std::ostream &stream, const IPV4 &value)
Operator to send the value as string to a stream.
Definition NetworkConfiguration.h:650
IPV4 & set(const SubnetMask &value)
Set SubnetMask.
Definition NetworkConfiguration.h:574
Mode & mode()
Get Mode.
Definition NetworkConfiguration.h:549
std::tuple< NetworkConfiguration::IPV4::Address, NetworkConfiguration::IPV4::Mode, NetworkConfiguration::IPV4::SubnetMask > Descendants
Definition NetworkConfiguration.h:409
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:504
const SubnetMask & subnetMask() const
Get SubnetMask.
Definition NetworkConfiguration.h:562
IPV4 & set(const Address &value)
Set Address.
Definition NetworkConfiguration.h:536
const NetworkConfiguration::IPV4::SubnetMask & get() const
Definition NetworkConfiguration.h:599
IPV4 & set(const Mode &value)
Set Mode.
Definition NetworkConfiguration.h:555
const NetworkConfiguration::IPV4::Address & get() const
Definition NetworkConfiguration.h:583
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:624
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:784
void load(const std::string &fileName)
Load from the given file.
NetworkConfiguration & set(const IPV4::Mode &value)
Set IPV4::Mode.
Definition NetworkConfiguration.h:829
NetworkConfiguration(Args &&...args)
Constructor taking variadic number of arguments.
Definition NetworkConfiguration.h:719
std::tuple< NetworkConfiguration::IPV4, NetworkConfiguration::IPV4::Address, NetworkConfiguration::IPV4::Mode, NetworkConfiguration::IPV4::SubnetMask > Descendants
Definition NetworkConfiguration.h:669
static ZIVID_NODISCARD NetworkConfiguration fromSerialized(const std::string &value)
Construct a new NetworkConfiguration instance from a previously serialized string.
const NetworkConfiguration::IPV4::Mode & get() const
Definition NetworkConfiguration.h:859
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter.
Definition NetworkConfiguration.h:887
void set(Args &&...args)
Set multiple arguments.
Definition NetworkConfiguration.h:749
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:902
NetworkConfiguration(const std::string &fileName)
Construct NetworkConfiguration by loading from file.
const IPV4 & ipv4() const
Get IPV4.
Definition NetworkConfiguration.h:803
void save(const std::string &fileName) const
Save to the given file.
NetworkConfiguration & set(const IPV4::Address &value)
Set IPV4::Address.
Definition NetworkConfiguration.h:822
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:880
const NetworkConfiguration::IPV4::SubnetMask & get() const
Definition NetworkConfiguration.h:867
const NetworkConfiguration::IPV4 & get() const
Definition NetworkConfiguration.h:843
std::string toString() const
Get the value as string.
NetworkConfiguration & set(const IPV4::SubnetMask &value)
Set IPV4::SubnetMask.
Definition NetworkConfiguration.h:836
NetworkConfiguration & set(const IPV4 &value)
Set IPV4.
Definition NetworkConfiguration.h:815
IPV4 & ipv4()
Get IPV4.
Definition NetworkConfiguration.h:809
const NetworkConfiguration::IPV4::Address & get() const
Definition NetworkConfiguration.h:851
bool operator!=(const NetworkConfiguration &other) const
Inequality operator.
NodeType
Definition NodeType.h:55
The main Zivid namespace. All Zivid code is found here.
Definition Application.h:56