Zivid C++ API 2.19.0+b5c53d0f-1
NetworkConfiguration.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of the Zivid API
3 *
4 * Copyright 2015-2026 (C) Zivid AS
5 * All rights reserved.
6 *
7 * Zivid Software License, v1.0
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright notice,
13 * this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 *
19 * 3. Neither the name of Zivid AS nor the names of its contributors may be used
20 * to endorse or promote products derived from this software without specific
21 * prior written permission.
22 *
23 * 4. This software, with or without modification, must not be used with any
24 * other 3D camera than from Zivid AS.
25 *
26 * 5. Any software provided in binary form under this license must not be
27 * reverse engineered, decompiled, modified and/or disassembled.
28 *
29 * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
30 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
33 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *
40 * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
41 * Info: http://www.zivid.com
42 ******************************************************************************/
43
44#pragma once
45
46#include <array>
47#include <chrono>
48#include <cmath>
49#include <ctime>
50#include <iomanip>
51#include <memory>
52#include <optional>
53#include <set>
54#include <sstream>
55#include <string>
56#include <tuple>
57#include <utility>
58#include <vector>
59
66#include "Zivid/Range.h"
67
68#ifdef _MSC_VER
69# pragma warning(push)
70# pragma warning(disable : 4251) // "X needs to have dll-interface to be used by clients of class Y."
71#endif
72
73namespace Zivid
74{
75
78
79 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
81 {
82 public:
85
87 static constexpr const char *path{ "" };
88
90 static constexpr const char *name{ "NetworkConfiguration" };
91
93 static constexpr const char *description{ R"description(Network configuration of a camera
94)description" };
95
96 static constexpr size_t version{ 2 };
97
98#ifndef NO_DOC
99 template<size_t>
100 struct Version;
101
102 using LatestVersion = Zivid::NetworkConfiguration;
103
104 // Short identifier. This value is not guaranteed to be universally unique
105 // Todo(ZIVID-2808): Move this to internal DataModelExt header
106 static constexpr std::array<uint8_t, 3> binaryId{ 'c', 'n', 'c' };
107
108#endif
109
118
119 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
121 {
122 public:
125
127 static constexpr const char *path{ "Hostname" };
128
130 static constexpr const char *name{ "Hostname" };
131
133 static constexpr const char *description{
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.
138
139Must be 1 to 15 characters long, can only consist of a-z, A-Z, 0-9 and hyphen (-), and cannot start with
140hyphen (-).
141)description"
142 };
143
145 using ValueType = std::string;
146
148 Hostname() = default;
149
151 explicit Hostname(std::string value)
152 : m_opt{ verifyValue(std::move(value)) }
153 {}
154
159 const std::string &value() const;
160
162 bool hasValue() const;
163
165 void reset();
166
168 std::string toString() const;
169
171 bool operator==(const Hostname &other) const
172 {
173 return m_opt == other.m_opt;
174 }
175
177 bool operator!=(const Hostname &other) const
178 {
179 return m_opt != other.m_opt;
180 }
181
183 bool operator<(const Hostname &other) const
184 {
185 return m_opt < other.m_opt;
186 }
187
189 bool operator>(const Hostname &other) const
190 {
191 return m_opt > other.m_opt;
192 }
193
195 bool operator<=(const Hostname &other) const
196 {
197 return m_opt <= other.m_opt;
198 }
199
201 bool operator>=(const Hostname &other) const
202 {
203 return m_opt >= other.m_opt;
204 }
205
207 friend std::ostream &operator<<(std::ostream &stream, const Hostname &value)
208 {
209 return stream << value.toString();
210 }
211
212 private:
213 void setFromString(const std::string &value);
214
215 ValueType static verifyValue(ValueType &&value)
216 {
217 return DataModel::Detail::isValidHostname(value)
218 ? std::move(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 (-)."
222 };
223 }
224
225 std::optional<std::string> m_opt;
226
227 friend struct DataModel::Detail::Befriend<Hostname>;
228 };
229
231
232 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
234 {
235 public:
238
240 static constexpr const char *path{ "IPV4" };
241
243 static constexpr const char *name{ "IPV4" };
244
246 static constexpr const char *description{ R"description(IPv4 network configuration)description" };
247
253
254 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
256 {
257 public:
260
262 static constexpr const char *path{ "IPV4/Address" };
263
265 static constexpr const char *name{ "Address" };
266
268 static constexpr const char *description{
269 R"description(The camera's IPv4 address. Only used in manual mode.
270
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.
273)description"
274 };
275
277 using ValueType = std::string;
278
280 Address() = default;
281
283 explicit Address(std::string value)
284 : m_value{ verifyValue(std::move(value)) }
285 {}
286
288 const std::string &value() const;
289
291 std::string toString() const;
292
294 bool operator==(const Address &other) const
295 {
296 return m_value == other.m_value;
297 }
298
300 bool operator!=(const Address &other) const
301 {
302 return m_value != other.m_value;
303 }
304
306 bool operator<(const Address &other) const
307 {
308 return m_value < other.m_value;
309 }
310
312 bool operator>(const Address &other) const
313 {
314 return m_value > other.m_value;
315 }
316
318 bool operator<=(const Address &other) const
319 {
320 return m_value <= other.m_value;
321 }
322
324 bool operator>=(const Address &other) const
325 {
326 return m_value >= other.m_value;
327 }
328
330 friend std::ostream &operator<<(std::ostream &stream, const Address &value)
331 {
332 return stream << value.toString();
333 }
334
335 private:
336 void setFromString(const std::string &value);
337
338 ValueType static verifyValue(ValueType &&value)
339 {
340 return DataModel::Detail::isValidIPv4Address(value)
341 ? std::move(value)
342 : throw std::invalid_argument{ "The value '" + value
343 + "' is not a valid IPv4 address." };
344 }
345
346 std::string m_value{ "172.28.60.5" };
347
348 friend struct DataModel::Detail::Befriend<Address>;
349 };
350
352
353 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
355 {
356 public:
359
361 static constexpr const char *path{ "IPV4/Mode" };
362
364 static constexpr const char *name{ "Mode" };
365
367 static constexpr const char *description{ R"description(DHCP or manual configuration)description" };
368
370 enum class ValueType
371 {
374 };
375 static const Mode dhcp;
376 static const Mode manual;
377
379 static std::set<ValueType> validValues()
380 {
382 }
383
385 Mode() = default;
386
388 explicit constexpr Mode(ValueType value)
389 : m_value{ verifyValue(value) }
390 {}
391
394
396 std::string toString() const;
397
399 friend std::ostream &operator<<(std::ostream &stream, const Mode::ValueType &value)
400 {
401 return stream << Mode{ value }.toString();
402 }
403
405 bool operator==(const Mode &other) const
406 {
407 return m_value == other.m_value;
408 }
409
411 bool operator!=(const Mode &other) const
412 {
413 return m_value != other.m_value;
414 }
415
417 friend std::ostream &operator<<(std::ostream &stream, const Mode &value)
418 {
419 return stream << value.toString();
420 }
421
422 private:
423 void setFromString(const std::string &value);
424
425 constexpr ValueType static verifyValue(const ValueType &value)
426 {
427 return value == ValueType::dhcp || value == ValueType::manual
428 ? value
429 : throw std::invalid_argument{
430 "Invalid value: Mode{ "
431 + std::to_string(static_cast<std::underlying_type<ValueType>::type>(value)) + " }"
432 };
433 }
434
436
437 friend struct DataModel::Detail::Befriend<Mode>;
438 };
439
445
446 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
448 {
449 public:
452
454 static constexpr const char *path{ "IPV4/SubnetMask" };
455
457 static constexpr const char *name{ "SubnetMask" };
458
460 static constexpr const char *description{
461 R"description(The camera's subnet mask (for example 255.255.255.0). Only used in manual mode.
462
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.
465)description"
466 };
467
469 using ValueType = std::string;
470
472 SubnetMask() = default;
473
475 explicit SubnetMask(std::string value)
476 : m_value{ verifyValue(std::move(value)) }
477 {}
478
480 const std::string &value() const;
481
483 std::string toString() const;
484
486 bool operator==(const SubnetMask &other) const
487 {
488 return m_value == other.m_value;
489 }
490
492 bool operator!=(const SubnetMask &other) const
493 {
494 return m_value != other.m_value;
495 }
496
498 bool operator<(const SubnetMask &other) const
499 {
500 return m_value < other.m_value;
501 }
502
504 bool operator>(const SubnetMask &other) const
505 {
506 return m_value > other.m_value;
507 }
508
510 bool operator<=(const SubnetMask &other) const
511 {
512 return m_value <= other.m_value;
513 }
514
516 bool operator>=(const SubnetMask &other) const
517 {
518 return m_value >= other.m_value;
519 }
520
522 friend std::ostream &operator<<(std::ostream &stream, const SubnetMask &value)
523 {
524 return stream << value.toString();
525 }
526
527 private:
528 void setFromString(const std::string &value);
529
530 ValueType static verifyValue(ValueType &&value)
531 {
532 return DataModel::Detail::isValidIPv4SubnetMask(value)
533 ? std::move(value)
534 : throw std::invalid_argument{ "The value '" + value
535 + "' is not a valid IPv4 subnet mask." };
536 }
537
538 std::string m_value{ "255.255.255.0" };
539
540 friend struct DataModel::Detail::Befriend<SubnetMask>;
541 };
542
543 using Descendants = std::tuple<
547
550
564#ifndef NO_DOC
565 template<
566 typename... Args,
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...>::
570 value,
571 int>::type = 0>
572#else
573 template<typename... Args>
574#endif
575 explicit IPV4(Args &&...args)
576 {
577 using namespace Zivid::Detail::TypeTraits;
578
579 static_assert(
580 AllArgsDecayedAreUnique<Args...>::value,
581 "Found duplicate types among the arguments passed to IPV4(...). "
582 "Types should be listed at most once.");
583
584 set(std::forward<Args>(args)...);
585 }
586
599#ifndef NO_DOC
600 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
601#else
602 template<typename... Args>
603#endif
604 void set(Args &&...args)
605 {
606 using namespace Zivid::Detail::TypeTraits;
607
608 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
609 static_assert(
610 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
611
612 static_assert(
613 AllArgsDecayedAreUnique<Args...>::value,
614 "Found duplicate types among the arguments passed to set(...). "
615 "Types should be listed at most once.");
616
617 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
618 }
619
633#ifndef NO_DOC
634 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
635#else
636 template<typename... Args>
637#endif
638 IPV4 copyWith(Args &&...args) const
639 {
640 using namespace Zivid::Detail::TypeTraits;
641
642 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
643 static_assert(
644 AllArgsAreDescendantNodes::value,
645 "All arguments passed to copyWith(...) must be descendant nodes.");
646
647 static_assert(
648 AllArgsDecayedAreUnique<Args...>::value,
649 "Found duplicate types among the arguments passed to copyWith(...). "
650 "Types should be listed at most once.");
651
652 auto copy{ *this };
653 copy.set(std::forward<Args>(args)...);
654 return copy;
655 }
656
658 const Address &address() const
659 {
660 return m_address;
661 }
662
665 {
666 return m_address;
667 }
668
670 IPV4 &set(const Address &value)
671 {
672 m_address = value;
673 return *this;
674 }
675
677 const Mode &mode() const
678 {
679 return m_mode;
680 }
681
684 {
685 return m_mode;
686 }
687
689 IPV4 &set(const Mode &value)
690 {
691 m_mode = value;
692 return *this;
693 }
694
696 const SubnetMask &subnetMask() const
697 {
698 return m_subnetMask;
699 }
700
703 {
704 return m_subnetMask;
705 }
706
708 IPV4 &set(const SubnetMask &value)
709 {
710 m_subnetMask = value;
711 return *this;
712 }
713
714 template<
715 typename T,
716 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value, int>::type = 0>
718 {
719 return m_address;
720 }
721
722 template<
723 typename T,
724 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value, int>::type = 0>
726 {
727 return m_mode;
728 }
729
730 template<
731 typename T,
732 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value, int>::type = 0>
734 {
735 return m_subnetMask;
736 }
737
738 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
740 {
741 return m_address;
742 }
743
744 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
746 {
747 return m_mode;
748 }
749
750 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
752 {
753 return m_subnetMask;
754 }
755
757 template<typename F>
758 void forEach(const F &f) const
759 {
760 f(m_address);
761 f(m_mode);
762 f(m_subnetMask);
763 }
764
766 template<typename F>
767 void forEach(const F &f)
768 {
769 f(m_address);
770 f(m_mode);
771 f(m_subnetMask);
772 }
773
775 bool operator==(const IPV4 &other) const;
776
778 bool operator!=(const IPV4 &other) const;
779
781 std::string toString() const;
782
784 friend std::ostream &operator<<(std::ostream &stream, const IPV4 &value)
785 {
786 return stream << value.toString();
787 }
788
789 private:
790 void setFromString(const std::string &value);
791
792 void setFromString(const std::string &fullPath, const std::string &value);
793
794 std::string getString(const std::string &fullPath) const;
795
796 Address m_address;
797 Mode m_mode;
798 SubnetMask m_subnetMask;
799
800 friend struct DataModel::Detail::Befriend<IPV4>;
801 };
802
803 using Descendants = std::tuple<
809
812
814 explicit NetworkConfiguration(const std::string &fileName);
815
821 [[nodiscard]] static NetworkConfiguration fromSerialized(const std::string &value);
822
828 std::string serialize() const;
829
845#ifndef NO_DOC
846 template<
847 typename... Args,
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,
851 int>::type = 0>
852#else
853 template<typename... Args>
854#endif
855 explicit NetworkConfiguration(Args &&...args)
856 {
857 using namespace Zivid::Detail::TypeTraits;
858
859 static_assert(
860 AllArgsDecayedAreUnique<Args...>::value,
861 "Found duplicate types among the arguments passed to NetworkConfiguration(...). "
862 "Types should be listed at most once.");
863
864 set(std::forward<Args>(args)...);
865 }
866
881#ifndef NO_DOC
882 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
883#else
884 template<typename... Args>
885#endif
886 void set(Args &&...args)
887 {
888 using namespace Zivid::Detail::TypeTraits;
889
890 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
891 static_assert(
892 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
893
894 static_assert(
895 AllArgsDecayedAreUnique<Args...>::value,
896 "Found duplicate types among the arguments passed to set(...). "
897 "Types should be listed at most once.");
898
899 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
900 }
901
917#ifndef NO_DOC
918 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
919#else
920 template<typename... Args>
921#endif
922 NetworkConfiguration copyWith(Args &&...args) const
923 {
924 using namespace Zivid::Detail::TypeTraits;
925
926 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
927 static_assert(
928 AllArgsAreDescendantNodes::value, "All arguments passed to copyWith(...) must be descendant nodes.");
929
930 static_assert(
931 AllArgsDecayedAreUnique<Args...>::value,
932 "Found duplicate types among the arguments passed to copyWith(...). "
933 "Types should be listed at most once.");
934
935 auto copy{ *this };
936 copy.set(std::forward<Args>(args)...);
937 return copy;
938 }
939
941 const Hostname &hostname() const
942 {
943 return m_hostname;
944 }
945
948 {
949 return m_hostname;
950 }
951
954 {
955 m_hostname = value;
956 return *this;
957 }
958
960 const IPV4 &ipv4() const
961 {
962 return m_ipv4;
963 }
964
967 {
968 return m_ipv4;
969 }
970
973 {
974 m_ipv4 = value;
975 return *this;
976 }
977
980 {
981 m_ipv4.set(value);
982 return *this;
983 }
984
987 {
988 m_ipv4.set(value);
989 return *this;
990 }
991
994 {
995 m_ipv4.set(value);
996 return *this;
997 }
998
999 template<
1000 typename T,
1001 typename std::enable_if<std::is_same<T, NetworkConfiguration::Hostname>::value, int>::type = 0>
1003 {
1004 return m_hostname;
1005 }
1006
1007 template<typename T, typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4>::value, int>::type = 0>
1009 {
1010 return m_ipv4;
1011 }
1012
1013 template<
1014 typename T,
1015 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Address>::value, int>::type = 0>
1017 {
1018 return m_ipv4.get<NetworkConfiguration::IPV4::Address>();
1019 }
1020
1021 template<
1022 typename T,
1023 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::Mode>::value, int>::type = 0>
1025 {
1026 return m_ipv4.get<NetworkConfiguration::IPV4::Mode>();
1027 }
1028
1029 template<
1030 typename T,
1031 typename std::enable_if<std::is_same<T, NetworkConfiguration::IPV4::SubnetMask>::value, int>::type = 0>
1033 {
1034 return m_ipv4.get<NetworkConfiguration::IPV4::SubnetMask>();
1035 }
1036
1037 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1039 {
1040 return m_hostname;
1041 }
1042
1043 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1045 {
1046 return m_ipv4;
1047 }
1048
1050 template<typename F>
1051 void forEach(const F &f) const
1052 {
1053 f(m_hostname);
1054 f(m_ipv4);
1055 }
1056
1058 template<typename F>
1059 void forEach(const F &f)
1060 {
1061 f(m_hostname);
1062 f(m_ipv4);
1063 }
1064
1066 bool operator==(const NetworkConfiguration &other) const;
1067
1069 bool operator!=(const NetworkConfiguration &other) const;
1070
1072 std::string toString() const;
1073
1075 friend std::ostream &operator<<(std::ostream &stream, const NetworkConfiguration &value)
1076 {
1077 return stream << value.toString();
1078 }
1079
1081 void save(const std::string &fileName) const;
1082
1084 void load(const std::string &fileName);
1085
1086 private:
1087 void setFromString(const std::string &value);
1088
1089 void setFromString(const std::string &fullPath, const std::string &value);
1090
1091 std::string getString(const std::string &fullPath) const;
1092
1093 Hostname m_hostname;
1094 IPV4 m_ipv4;
1095
1096 friend struct DataModel::Detail::Befriend<NetworkConfiguration>;
1097 };
1098
1099#ifndef NO_DOC
1100 template<>
1101 struct NetworkConfiguration::Version<2>
1102 {
1103 using Type = NetworkConfiguration;
1104 };
1105#endif
1106
1107} // namespace Zivid
1108
1109#ifndef NO_DOC
1111namespace Zivid::Detail
1112{
1113
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);
1116
1117} // namespace Zivid::Detail
1118#endif
1119
1120#ifdef _MSC_VER
1121# pragma warning(pop)
1122#endif
1123
1124#ifndef NO_DOC
1125# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1126namespace std // NOLINT
1127{
1128
1129 template<>
1130 struct tuple_size<Zivid::NetworkConfiguration::IPV4> : integral_constant<size_t, 3>
1131 {};
1132
1133 template<size_t i>
1134 struct tuple_element<i, Zivid::NetworkConfiguration::IPV4>
1135 {
1136 static_assert(i < tuple_size<Zivid::NetworkConfiguration::IPV4>::value, "Index must be less than 3");
1137
1138 using type // NOLINT
1139 = decltype(declval<Zivid::NetworkConfiguration::IPV4>().get<i>());
1140 };
1141
1142 template<>
1143 struct tuple_size<Zivid::NetworkConfiguration> : integral_constant<size_t, 2>
1144 {};
1145
1146 template<size_t i>
1147 struct tuple_element<i, Zivid::NetworkConfiguration>
1148 {
1149 static_assert(i < tuple_size<Zivid::NetworkConfiguration>::value, "Index must be less than 2");
1150
1151 using type // NOLINT
1152 = decltype(declval<Zivid::NetworkConfiguration>().get<i>());
1153 };
1154
1155} // namespace std
1156# endif
1157#endif
1158
1159// If we have access to the DataModel library, automatically include internal DataModel
1160// header. This header is necessary for serialization and deserialization.
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"
1164# endif
1165#endif
#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