Zivid C++ API 2.8.1+dd4dffea-1
Defining the Future of 3D Machine Vision
CameraInfo.h
Go to the documentation of this file.
1
2
3/*******************************************************************************
4
5 * This file is part of the Zivid 3D Camera API
6
7 *
8
9 * Copyright 2015-2022 (C) Zivid AS
10
11 * All rights reserved.
12
13 *
14
15 * Zivid Software License, v1.0
16
17 *
18
19 * Redistribution and use in source and binary forms, with or without
20
21 * modification, are permitted provided that the following conditions are met:
22
23 *
24
25 * 1. Redistributions of source code must retain the above copyright notice,
26
27 * this list of conditions and the following disclaimer.
28
29 *
30
31 * 2. Redistributions in binary form must reproduce the above copyright notice,
32
33 * this list of conditions and the following disclaimer in the documentation
34
35 * and/or other materials provided with the distribution.
36
37 *
38
39 * 3. Neither the name of Zivid AS nor the names of its contributors may be used
40
41 * to endorse or promote products derived from this software without specific
42
43 * prior written permission.
44
45 *
46
47 * 4. This software, with or without modification, must not be used with any
48
49 * other 3D camera than from Zivid AS.
50
51 *
52
53 * 5. Any software provided in binary form under this license must not be
54
55 * reverse engineered, decompiled, modified and/or disassembled.
56
57 *
58
59 * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
60
61 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
62
63 * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
64
65 * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
66
67 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
68
69 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
70
71 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
72
73 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74
75 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
76
77 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78
79 *
80
81 * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
82
83 * Info: http://www.zivid.com
84
85 ******************************************************************************/
86
87
88
89#pragma once
90
91#include <array>
92#include <chrono>
93#include <cmath>
94#include <ctime>
95#include <iomanip>
96#include <memory>
97#include <set>
98#include <sstream>
99#include <string>
100#include <tuple>
101#include <utility>
102#include <vector>
103
109#include "Zivid/Range.h"
110
111#ifdef _MSC_VER
112# pragma warning(push)
113# pragma warning(disable : 4251) // "X needs to have dll-interface to be used by clients of class Y."
114#endif
115
116namespace Zivid
117{
118
121 {
122 public:
125
127 static constexpr const char *path{ "" };
128
130 static constexpr const char *name{ "CameraInfo" };
131
133 static constexpr const char *description{
134 R"description(Information about camera model, serial number etc.)description"
135 };
136
137 static constexpr size_t version{ 1 };
138
139#ifndef NO_DOC
140 template<size_t>
141 struct Version;
142
143 using LatestVersion = Zivid::CameraInfo;
144
145 // Short identifier. This value is not guaranteed to be universally unique
146 // Todo(ZIVID-2808): Move this to internal DataModelExt header
147 static constexpr std::array<uint8_t, 3> binaryId{ 'n', 'f', 'o' };
148
149#endif
150
153 {
154 public:
157
159 static constexpr const char *path{ "FirmwareVersion" };
160
162 static constexpr const char *name{ "FirmwareVersion" };
163
165 static constexpr const char *description{ R"description(The firmware version on the camera)description" };
166
168 using ValueType = std::string;
169
172 {
173 return { 0, std::numeric_limits<ValueType::size_type>::max() };
174 }
175
177 FirmwareVersion() = default;
178
180 explicit FirmwareVersion(std::string value)
181 : m_value{ std::move(value) }
182 {}
183
185 const std::string &value() const;
186
188 std::string toString() const;
189
191 bool operator==(const FirmwareVersion &other) const
192 {
193 return m_value == other.m_value;
194 }
195
197 bool operator!=(const FirmwareVersion &other) const
198 {
199 return m_value != other.m_value;
200 }
201
203 bool operator<(const FirmwareVersion &other) const
204 {
205 return m_value < other.m_value;
206 }
207
209 bool operator>(const FirmwareVersion &other) const
210 {
211 return m_value > other.m_value;
212 }
213
215 friend std::ostream &operator<<(std::ostream &stream, const FirmwareVersion &value)
216 {
217 return stream << value.toString();
218 }
219
220 private:
221 void setFromString(const std::string &value);
222
223 std::string m_value{};
224
225 friend struct DataModel::Detail::Befriend<FirmwareVersion>;
226 };
227
230 {
231 public:
234
236 static constexpr const char *path{ "Model" };
237
239 static constexpr const char *name{ "Model" };
240
242 static constexpr const char *description{ R"description(The model of the camera)description" };
243
245 enum class ValueType
246 {
247 zividOnePlusSmall,
248 zividOnePlusMedium,
249 zividOnePlusLarge,
250 zividTwo,
251 zividTwoL100
252 };
256 static const Model zividTwo;
257 static const Model zividTwoL100;
258
260 static std::set<ValueType> validValues()
261 {
262 return { ValueType::zividOnePlusSmall,
263 ValueType::zividOnePlusMedium,
264 ValueType::zividOnePlusLarge,
265 ValueType::zividTwo,
266 ValueType::zividTwoL100 };
267 }
268
270 Model() = default;
271
273 explicit constexpr Model(ValueType value)
274 : m_value{ verifyValue(value) }
275 {}
276
279
281 std::string toString() const;
282
284 friend std::ostream &operator<<(std::ostream &stream, const Model::ValueType &value)
285 {
286 return stream << Model{ value }.toString();
287 }
288
290 bool operator==(const Model &other) const
291 {
292 return m_value == other.m_value;
293 }
294
296 bool operator!=(const Model &other) const
297 {
298 return m_value != other.m_value;
299 }
300
302 friend std::ostream &operator<<(std::ostream &stream, const Model &value)
303 {
304 return stream << value.toString();
305 }
306
307 private:
308 void setFromString(const std::string &value);
309
310 constexpr ValueType static verifyValue(const ValueType &value)
311 {
312 return value == ValueType::zividOnePlusSmall || value == ValueType::zividOnePlusMedium
313 || value == ValueType::zividOnePlusLarge || value == ValueType::zividTwo
314 || value == ValueType::zividTwoL100
315 ? value
316 : throw std::invalid_argument{
317 "Invalid value: Model{ "
318 + std::to_string(static_cast<std::underlying_type<ValueType>::type>(value)) + " }"
319 };
320 }
321
322 ValueType m_value{ ValueType::zividOnePlusSmall };
323
324 friend struct DataModel::Detail::Befriend<Model>;
325 };
326
329 {
330 public:
333
335 static constexpr const char *path{ "ModelName" };
336
338 static constexpr const char *name{ "ModelName" };
339
341 static constexpr const char *description{ R"description(The model name of the camera)description" };
342
344 using ValueType = std::string;
345
348 {
349 return { 0, std::numeric_limits<ValueType::size_type>::max() };
350 }
351
353 ModelName() = default;
354
356 explicit ModelName(std::string value)
357 : m_value{ std::move(value) }
358 {}
359
361 const std::string &value() const;
362
364 std::string toString() const;
365
367 bool operator==(const ModelName &other) const
368 {
369 return m_value == other.m_value;
370 }
371
373 bool operator!=(const ModelName &other) const
374 {
375 return m_value != other.m_value;
376 }
377
379 bool operator<(const ModelName &other) const
380 {
381 return m_value < other.m_value;
382 }
383
385 bool operator>(const ModelName &other) const
386 {
387 return m_value > other.m_value;
388 }
389
391 friend std::ostream &operator<<(std::ostream &stream, const ModelName &value)
392 {
393 return stream << value.toString();
394 }
395
396 private:
397 void setFromString(const std::string &value);
398
399 std::string m_value{};
400
401 friend struct DataModel::Detail::Befriend<ModelName>;
402 };
403
406 {
407 public:
410
412 static constexpr const char *path{ "Revision" };
413
415 static constexpr const char *name{ "Revision" };
416
418 static constexpr const char *description{ R"description(The hardware revision of the camera)description" };
419
422 {
423 public:
426
428 static constexpr const char *path{ "Revision/Major" };
429
431 static constexpr const char *name{ "Major" };
432
434 static constexpr const char *description{ R"description(Major hardware revision number)description" };
435
437 using ValueType = uint32_t;
438
440 static constexpr Range<uint32_t> validRange()
441 {
442 return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
443 }
444
446 Major() = default;
447
449 explicit constexpr Major(uint32_t value)
450 : m_value{ value }
451 {}
452
454 uint32_t value() const;
455
457 std::string toString() const;
458
460 bool operator==(const Major &other) const
461 {
462 return m_value == other.m_value;
463 }
464
466 bool operator!=(const Major &other) const
467 {
468 return m_value != other.m_value;
469 }
470
472 bool operator<(const Major &other) const
473 {
474 return m_value < other.m_value;
475 }
476
478 bool operator>(const Major &other) const
479 {
480 return m_value > other.m_value;
481 }
482
484 friend std::ostream &operator<<(std::ostream &stream, const Major &value)
485 {
486 return stream << value.toString();
487 }
488
489 private:
490 void setFromString(const std::string &value);
491
492 uint32_t m_value{ 0 };
493
494 friend struct DataModel::Detail::Befriend<Major>;
495 };
496
499 {
500 public:
503
505 static constexpr const char *path{ "Revision/Minor" };
506
508 static constexpr const char *name{ "Minor" };
509
511 static constexpr const char *description{ R"description(Minor hardware revision number)description" };
512
514 using ValueType = uint32_t;
515
517 static constexpr Range<uint32_t> validRange()
518 {
519 return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
520 }
521
523 Minor() = default;
524
526 explicit constexpr Minor(uint32_t value)
527 : m_value{ value }
528 {}
529
531 uint32_t value() const;
532
534 std::string toString() const;
535
537 bool operator==(const Minor &other) const
538 {
539 return m_value == other.m_value;
540 }
541
543 bool operator!=(const Minor &other) const
544 {
545 return m_value != other.m_value;
546 }
547
549 bool operator<(const Minor &other) const
550 {
551 return m_value < other.m_value;
552 }
553
555 bool operator>(const Minor &other) const
556 {
557 return m_value > other.m_value;
558 }
559
561 friend std::ostream &operator<<(std::ostream &stream, const Minor &value)
562 {
563 return stream << value.toString();
564 }
565
566 private:
567 void setFromString(const std::string &value);
568
569 uint32_t m_value{ 0 };
570
571 friend struct DataModel::Detail::Befriend<Minor>;
572 };
573
574 using Descendants = std::tuple<CameraInfo::Revision::Major, CameraInfo::Revision::Minor>;
575
578
591#ifndef NO_DOC
592 template<
593 typename... Args,
594 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
595 typename std::enable_if<
596 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::
597 value,
598 int>::type = 0>
599#else
600 template<typename... Args>
601#endif
602 explicit Revision(Args &&...args)
603 {
604 using namespace Zivid::Detail::TypeTraits;
605
606 static_assert(
607 AllArgsDecayedAreUnique<Args...>::value,
608 "Found duplicate types among the arguments passed to Revision(...). "
609 "Types should be listed at most once.");
610
611 set(std::forward<Args>(args)...);
612 }
613
625#ifndef NO_DOC
626 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
627#else
628 template<typename... Args>
629#endif
630 void set(Args &&...args)
631 {
632 using namespace Zivid::Detail::TypeTraits;
633
634 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
635 static_assert(
636 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
637
638 static_assert(
639 AllArgsDecayedAreUnique<Args...>::value,
640 "Found duplicate types among the arguments passed to set(...). "
641 "Types should be listed at most once.");
642
643 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
644 }
645
658#ifndef NO_DOC
659 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
660#else
661 template<typename... Args>
662#endif
663 Revision copyWith(Args &&...args) const
664 {
665 using namespace Zivid::Detail::TypeTraits;
666
667 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
668 static_assert(
669 AllArgsAreDescendantNodes::value,
670 "All arguments passed to copyWith(...) must be descendant nodes.");
671
672 static_assert(
673 AllArgsDecayedAreUnique<Args...>::value,
674 "Found duplicate types among the arguments passed to copyWith(...). "
675 "Types should be listed at most once.");
676
677 auto copy{ *this };
678 copy.set(std::forward<Args>(args)...);
679 return copy;
680 }
681
683 const Major &major() const
684 {
685 return m_major;
686 }
687
690 {
691 return m_major;
692 }
693
695 Revision &set(const Major &value)
696 {
697 m_major = value;
698 return *this;
699 }
700
702 const Minor &minor() const
703 {
704 return m_minor;
705 }
706
709 {
710 return m_minor;
711 }
712
714 Revision &set(const Minor &value)
715 {
716 m_minor = value;
717 return *this;
718 }
719
720 template<
721 typename T,
722 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
724 {
725 return m_major;
726 }
727
728 template<
729 typename T,
730 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
732 {
733 return m_minor;
734 }
735
736 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
738 {
739 return m_major;
740 }
741
742 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
744 {
745 return m_minor;
746 }
747
749 template<typename F>
750 void forEach(const F &f) const
751 {
752 f(m_major);
753 f(m_minor);
754 }
755
757 template<typename F>
758 void forEach(const F &f)
759 {
760 f(m_major);
761 f(m_minor);
762 }
763
765 bool operator==(const Revision &other) const;
766
768 bool operator!=(const Revision &other) const;
769
771 std::string toString() const;
772
774 friend std::ostream &operator<<(std::ostream &stream, const Revision &value)
775 {
776 return stream << value.toString();
777 }
778
779 private:
780 void setFromString(const std::string &value);
781
782 void setFromString(const std::string &fullPath, const std::string &value);
783
784 std::string getString(const std::string &fullPath) const;
785
786 Major m_major;
787 Minor m_minor;
788
789 friend struct DataModel::Detail::Befriend<Revision>;
790 };
791
794 {
795 public:
798
800 static constexpr const char *path{ "SerialNumber" };
801
803 static constexpr const char *name{ "SerialNumber" };
804
806 static constexpr const char *description{ R"description(The serial number of the camera)description" };
807
809 using ValueType = std::string;
810
813 {
814 return { 0, std::numeric_limits<ValueType::size_type>::max() };
815 }
816
818 SerialNumber() = default;
819
821 explicit SerialNumber(std::string value)
822 : m_value{ std::move(value) }
823 {}
824
826 const std::string &value() const;
827
829 std::string toString() const;
830
832 bool operator==(const SerialNumber &other) const
833 {
834 return m_value == other.m_value;
835 }
836
838 bool operator!=(const SerialNumber &other) const
839 {
840 return m_value != other.m_value;
841 }
842
844 bool operator<(const SerialNumber &other) const
845 {
846 return m_value < other.m_value;
847 }
848
850 bool operator>(const SerialNumber &other) const
851 {
852 return m_value > other.m_value;
853 }
854
856 friend std::ostream &operator<<(std::ostream &stream, const SerialNumber &value)
857 {
858 return stream << value.toString();
859 }
860
861 private:
862 void setFromString(const std::string &value);
863
864 std::string m_value{};
865
866 friend struct DataModel::Detail::Befriend<SerialNumber>;
867 };
868
871 {
872 public:
875
877 static constexpr const char *path{ "UserData" };
878
880 static constexpr const char *name{ "UserData" };
881
883 static constexpr const char *description{
884 R"description(Information about user data capabilities of the camera)description"
885 };
886
889 {
890 public:
893
895 static constexpr const char *path{ "UserData/MaxSizeBytes" };
896
898 static constexpr const char *name{ "MaxSizeBytes" };
899
901 static constexpr const char *description{
902 R"description(The maximum number of bytes of user data that can be stored in the camera)description"
903 };
904
906 using ValueType = uint64_t;
907
909 static constexpr Range<uint64_t> validRange()
910 {
911 return { std::numeric_limits<uint64_t>::lowest(), std::numeric_limits<uint64_t>::max() };
912 }
913
915 MaxSizeBytes() = default;
916
918 explicit constexpr MaxSizeBytes(uint64_t value)
919 : m_value{ value }
920 {}
921
923 uint64_t value() const;
924
926 std::string toString() const;
927
929 bool operator==(const MaxSizeBytes &other) const
930 {
931 return m_value == other.m_value;
932 }
933
935 bool operator!=(const MaxSizeBytes &other) const
936 {
937 return m_value != other.m_value;
938 }
939
941 bool operator<(const MaxSizeBytes &other) const
942 {
943 return m_value < other.m_value;
944 }
945
947 bool operator>(const MaxSizeBytes &other) const
948 {
949 return m_value > other.m_value;
950 }
951
953 friend std::ostream &operator<<(std::ostream &stream, const MaxSizeBytes &value)
954 {
955 return stream << value.toString();
956 }
957
958 private:
959 void setFromString(const std::string &value);
960
961 uint64_t m_value{ 0 };
962
963 friend struct DataModel::Detail::Befriend<MaxSizeBytes>;
964 };
965
966 using Descendants = std::tuple<CameraInfo::UserData::MaxSizeBytes>;
967
970
982#ifndef NO_DOC
983 template<
984 typename... Args,
985 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
986 typename std::enable_if<
987 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::
988 value,
989 int>::type = 0>
990#else
991 template<typename... Args>
992#endif
993 explicit UserData(Args &&...args)
994 {
995 using namespace Zivid::Detail::TypeTraits;
996
997 static_assert(
998 AllArgsDecayedAreUnique<Args...>::value,
999 "Found duplicate types among the arguments passed to UserData(...). "
1000 "Types should be listed at most once.");
1001
1002 set(std::forward<Args>(args)...);
1003 }
1004
1015#ifndef NO_DOC
1016 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1017#else
1018 template<typename... Args>
1019#endif
1020 void set(Args &&...args)
1021 {
1022 using namespace Zivid::Detail::TypeTraits;
1023
1024 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1025 static_assert(
1026 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
1027
1028 static_assert(
1029 AllArgsDecayedAreUnique<Args...>::value,
1030 "Found duplicate types among the arguments passed to set(...). "
1031 "Types should be listed at most once.");
1032
1033 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1034 }
1035
1047#ifndef NO_DOC
1048 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1049#else
1050 template<typename... Args>
1051#endif
1052 UserData copyWith(Args &&...args) const
1053 {
1054 using namespace Zivid::Detail::TypeTraits;
1055
1056 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1057 static_assert(
1058 AllArgsAreDescendantNodes::value,
1059 "All arguments passed to copyWith(...) must be descendant nodes.");
1060
1061 static_assert(
1062 AllArgsDecayedAreUnique<Args...>::value,
1063 "Found duplicate types among the arguments passed to copyWith(...). "
1064 "Types should be listed at most once.");
1065
1066 auto copy{ *this };
1067 copy.set(std::forward<Args>(args)...);
1068 return copy;
1069 }
1070
1073 {
1074 return m_maxSizeBytes;
1075 }
1076
1079 {
1080 return m_maxSizeBytes;
1081 }
1082
1085 {
1086 m_maxSizeBytes = value;
1087 return *this;
1088 }
1089
1090 template<
1091 typename T,
1092 typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1094 {
1095 return m_maxSizeBytes;
1096 }
1097
1098 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1100 {
1101 return m_maxSizeBytes;
1102 }
1103
1105 template<typename F>
1106 void forEach(const F &f) const
1107 {
1108 f(m_maxSizeBytes);
1109 }
1110
1112 template<typename F>
1113 void forEach(const F &f)
1114 {
1115 f(m_maxSizeBytes);
1116 }
1117
1119 bool operator==(const UserData &other) const;
1120
1122 bool operator!=(const UserData &other) const;
1123
1125 std::string toString() const;
1126
1128 friend std::ostream &operator<<(std::ostream &stream, const UserData &value)
1129 {
1130 return stream << value.toString();
1131 }
1132
1133 private:
1134 void setFromString(const std::string &value);
1135
1136 void setFromString(const std::string &fullPath, const std::string &value);
1137
1138 std::string getString(const std::string &fullPath) const;
1139
1140 MaxSizeBytes m_maxSizeBytes;
1141
1142 friend struct DataModel::Detail::Befriend<UserData>;
1143 };
1144
1145 using Descendants = std::tuple<
1155
1158
1160 explicit CameraInfo(const std::string &fileName);
1161
1181#ifndef NO_DOC
1182 template<
1183 typename... Args,
1184 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1185 typename std::enable_if<
1186 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1187 int>::type = 0>
1188#else
1189 template<typename... Args>
1190#endif
1191 explicit CameraInfo(Args &&...args)
1192 {
1193 using namespace Zivid::Detail::TypeTraits;
1194
1195 static_assert(
1196 AllArgsDecayedAreUnique<Args...>::value,
1197 "Found duplicate types among the arguments passed to CameraInfo(...). "
1198 "Types should be listed at most once.");
1199
1200 set(std::forward<Args>(args)...);
1201 }
1202
1221#ifndef NO_DOC
1222 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1223#else
1224 template<typename... Args>
1225#endif
1226 void set(Args &&...args)
1227 {
1228 using namespace Zivid::Detail::TypeTraits;
1229
1230 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1231 static_assert(
1232 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
1233
1234 static_assert(
1235 AllArgsDecayedAreUnique<Args...>::value,
1236 "Found duplicate types among the arguments passed to set(...). "
1237 "Types should be listed at most once.");
1238
1239 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1240 }
1241
1261#ifndef NO_DOC
1262 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1263#else
1264 template<typename... Args>
1265#endif
1266 CameraInfo copyWith(Args &&...args) const
1267 {
1268 using namespace Zivid::Detail::TypeTraits;
1269
1270 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1271 static_assert(
1272 AllArgsAreDescendantNodes::value, "All arguments passed to copyWith(...) must be descendant nodes.");
1273
1274 static_assert(
1275 AllArgsDecayedAreUnique<Args...>::value,
1276 "Found duplicate types among the arguments passed to copyWith(...). "
1277 "Types should be listed at most once.");
1278
1279 auto copy{ *this };
1280 copy.set(std::forward<Args>(args)...);
1281 return copy;
1282 }
1283
1286 {
1287 return m_firmwareVersion;
1288 }
1289
1292 {
1293 return m_firmwareVersion;
1294 }
1295
1298 {
1299 m_firmwareVersion = value;
1300 return *this;
1301 }
1302
1304 const Model &model() const
1305 {
1306 return m_model;
1307 }
1308
1311 {
1312 return m_model;
1313 }
1314
1316 CameraInfo &set(const Model &value)
1317 {
1318 m_model = value;
1319 return *this;
1320 }
1321
1323 const ModelName &modelName() const
1324 {
1325 return m_modelName;
1326 }
1327
1330 {
1331 return m_modelName;
1332 }
1333
1335 CameraInfo &set(const ModelName &value)
1336 {
1337 m_modelName = value;
1338 return *this;
1339 }
1340
1342 const Revision &revision() const
1343 {
1344 return m_revision;
1345 }
1346
1349 {
1350 return m_revision;
1351 }
1352
1354 CameraInfo &set(const Revision &value)
1355 {
1356 m_revision = value;
1357 return *this;
1358 }
1359
1362 {
1363 m_revision.set(value);
1364 return *this;
1365 }
1366
1369 {
1370 m_revision.set(value);
1371 return *this;
1372 }
1373
1376 {
1377 return m_serialNumber;
1378 }
1379
1382 {
1383 return m_serialNumber;
1384 }
1385
1388 {
1389 m_serialNumber = value;
1390 return *this;
1391 }
1392
1394 const UserData &userData() const
1395 {
1396 return m_userData;
1397 }
1398
1401 {
1402 return m_userData;
1403 }
1404
1406 CameraInfo &set(const UserData &value)
1407 {
1408 m_userData = value;
1409 return *this;
1410 }
1411
1414 {
1415 m_userData.set(value);
1416 return *this;
1417 }
1418
1419 template<
1420 typename T,
1421 typename std::enable_if<std::is_same<T, CameraInfo::FirmwareVersion>::value, int>::type = 0>
1423 {
1424 return m_firmwareVersion;
1425 }
1426
1427 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Model>::value, int>::type = 0>
1428 const CameraInfo::Model &get() const
1429 {
1430 return m_model;
1431 }
1432
1433 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::ModelName>::value, int>::type = 0>
1435 {
1436 return m_modelName;
1437 }
1438
1439 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Revision>::value, int>::type = 0>
1441 {
1442 return m_revision;
1443 }
1444
1445 template<
1446 typename T,
1447 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
1449 {
1450 return m_revision.get<CameraInfo::Revision::Major>();
1451 }
1452
1453 template<
1454 typename T,
1455 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
1457 {
1458 return m_revision.get<CameraInfo::Revision::Minor>();
1459 }
1460
1461 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::SerialNumber>::value, int>::type = 0>
1463 {
1464 return m_serialNumber;
1465 }
1466
1467 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::UserData>::value, int>::type = 0>
1469 {
1470 return m_userData;
1471 }
1472
1473 template<
1474 typename T,
1475 typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1477 {
1478 return m_userData.get<CameraInfo::UserData::MaxSizeBytes>();
1479 }
1480
1481 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1483 {
1484 return m_firmwareVersion;
1485 }
1486
1487 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1488 const CameraInfo::Model &get() const
1489 {
1490 return m_model;
1491 }
1492
1493 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1495 {
1496 return m_modelName;
1497 }
1498
1499 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1501 {
1502 return m_revision;
1503 }
1504
1505 template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
1507 {
1508 return m_serialNumber;
1509 }
1510
1511 template<size_t i, typename std::enable_if<i == 5, int>::type = 0>
1513 {
1514 return m_userData;
1515 }
1516
1518 template<typename F>
1519 void forEach(const F &f) const
1520 {
1521 f(m_firmwareVersion);
1522 f(m_model);
1523 f(m_modelName);
1524 f(m_revision);
1525 f(m_serialNumber);
1526 f(m_userData);
1527 }
1528
1530 template<typename F>
1531 void forEach(const F &f)
1532 {
1533 f(m_firmwareVersion);
1534 f(m_model);
1535 f(m_modelName);
1536 f(m_revision);
1537 f(m_serialNumber);
1538 f(m_userData);
1539 }
1540
1542 bool operator==(const CameraInfo &other) const;
1543
1545 bool operator!=(const CameraInfo &other) const;
1546
1548 std::string toString() const;
1549
1551 friend std::ostream &operator<<(std::ostream &stream, const CameraInfo &value)
1552 {
1553 return stream << value.toString();
1554 }
1555
1557 void save(const std::string &fileName) const;
1558
1560 void load(const std::string &fileName);
1561
1562 private:
1563 void setFromString(const std::string &value);
1564
1565 void setFromString(const std::string &fullPath, const std::string &value);
1566
1567 std::string getString(const std::string &fullPath) const;
1568
1569 FirmwareVersion m_firmwareVersion;
1570 Model m_model;
1571 ModelName m_modelName;
1572 Revision m_revision;
1573 SerialNumber m_serialNumber;
1574 UserData m_userData;
1575
1576 friend struct DataModel::Detail::Befriend<CameraInfo>;
1577 };
1578
1579#ifndef NO_DOC
1580 template<>
1581 struct CameraInfo::Version<1>
1582 {
1583 using Type = CameraInfo;
1584 };
1585#endif
1586
1587} // namespace Zivid
1588
1589#ifdef _MSC_VER
1590# pragma warning(pop)
1591#endif
1592
1593#ifndef NO_DOC
1594# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1595namespace std // NOLINT
1596{
1597
1598 template<>
1599 struct tuple_size<Zivid::CameraInfo::Revision> : integral_constant<size_t, 2>
1600 {};
1601
1602 template<size_t i>
1603 struct tuple_element<i, Zivid::CameraInfo::Revision>
1604 {
1605 static_assert(i < tuple_size<Zivid::CameraInfo::Revision>::value, "Index must be less than 2");
1606
1607 using type // NOLINT
1608 = decltype(declval<Zivid::CameraInfo::Revision>().get<i>());
1609 };
1610
1611 template<>
1612 struct tuple_size<Zivid::CameraInfo::UserData> : integral_constant<size_t, 1>
1613 {};
1614
1615 template<size_t i>
1616 struct tuple_element<i, Zivid::CameraInfo::UserData>
1617 {
1618 static_assert(i < tuple_size<Zivid::CameraInfo::UserData>::value, "Index must be less than 1");
1619
1620 using type // NOLINT
1621 = decltype(declval<Zivid::CameraInfo::UserData>().get<i>());
1622 };
1623
1624 template<>
1625 struct tuple_size<Zivid::CameraInfo> : integral_constant<size_t, 6>
1626 {};
1627
1628 template<size_t i>
1629 struct tuple_element<i, Zivid::CameraInfo>
1630 {
1631 static_assert(i < tuple_size<Zivid::CameraInfo>::value, "Index must be less than 6");
1632
1633 using type // NOLINT
1634 = decltype(declval<Zivid::CameraInfo>().get<i>());
1635 };
1636
1637} // namespace std
1638# endif
1639#endif
1640
1641// If we have access to the DataModel library, automatically include internal DataModel
1642// header. This header is necessary for serialization and deserialization.
1643#if defined(__has_include) && !defined(NO_DOC)
1644# if __has_include("Zivid/CameraInfoInternal.h") && __has_include("Zivid/DataModelSerializationMetaData.h")
1645# include "Zivid/CameraInfoInternal.h"
1646# endif
1647#endif
#define ZIVID_CORE_EXPORT
Definition: CoreExport.h:101
The firmware version on the camera
Definition: CameraInfo.h:153
std::string toString() const
Get the value as string
bool operator==(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:191
FirmwareVersion(std::string value)
Constructor
Definition: CameraInfo.h:180
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for FirmwareVersion
Definition: CameraInfo.h:171
bool operator<(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:203
const std::string & value() const
Get the value
friend std::ostream & operator<<(std::ostream &stream, const FirmwareVersion &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:215
bool operator>(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:209
bool operator!=(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:197
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:168
FirmwareVersion()=default
Default constructor
The model name of the camera
Definition: CameraInfo.h:329
bool operator==(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:367
ModelName()=default
Default constructor
std::string toString() const
Get the value as string
ModelName(std::string value)
Constructor
Definition: CameraInfo.h:356
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:344
bool operator<(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:379
bool operator>(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:385
friend std::ostream & operator<<(std::ostream &stream, const ModelName &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:391
const std::string & value() const
Get the value
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for ModelName
Definition: CameraInfo.h:347
bool operator!=(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:373
The model of the camera
Definition: CameraInfo.h:230
static const Model zividOnePlusSmall
zividOnePlusSmall
Definition: CameraInfo.h:253
static const Model zividTwo
zividTwo
Definition: CameraInfo.h:256
std::string toString() const
Get the value as string
constexpr Model(ValueType value)
Constructor
Definition: CameraInfo.h:273
Model()=default
Default constructor
static const Model zividOnePlusMedium
zividOnePlusMedium
Definition: CameraInfo.h:254
ValueType value() const
Get the value
friend std::ostream & operator<<(std::ostream &stream, const Model::ValueType &value)
Operator to serialize ValueType to a stream
Definition: CameraInfo.h:284
friend std::ostream & operator<<(std::ostream &stream, const Model &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:302
static std::set< ValueType > validValues()
All valid values of Model
Definition: CameraInfo.h:260
ValueType
The type of the underlying value
Definition: CameraInfo.h:246
static const Model zividOnePlusLarge
zividOnePlusLarge
Definition: CameraInfo.h:255
bool operator!=(const Model &other) const
Comparison operator
Definition: CameraInfo.h:296
static const Model zividTwoL100
zividTwoL100
Definition: CameraInfo.h:257
bool operator==(const Model &other) const
Comparison operator
Definition: CameraInfo.h:290
Major hardware revision number
Definition: CameraInfo.h:422
std::string toString() const
Get the value as string
bool operator!=(const Major &other) const
Comparison operator
Definition: CameraInfo.h:466
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:437
friend std::ostream & operator<<(std::ostream &stream, const Major &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:484
static constexpr Range< uint32_t > validRange()
The range of valid values for Major
Definition: CameraInfo.h:440
bool operator>(const Major &other) const
Comparison operator
Definition: CameraInfo.h:478
uint32_t value() const
Get the value
constexpr Major(uint32_t value)
Constructor
Definition: CameraInfo.h:449
bool operator<(const Major &other) const
Comparison operator
Definition: CameraInfo.h:472
Major()=default
Default constructor
bool operator==(const Major &other) const
Comparison operator
Definition: CameraInfo.h:460
Minor hardware revision number
Definition: CameraInfo.h:499
bool operator>(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:555
bool operator!=(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:543
constexpr Minor(uint32_t value)
Constructor
Definition: CameraInfo.h:526
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:514
friend std::ostream & operator<<(std::ostream &stream, const Minor &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:561
bool operator==(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:537
std::string toString() const
Get the value as string
Minor()=default
Default constructor
bool operator<(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:549
static constexpr Range< uint32_t > validRange()
The range of valid values for Minor
Definition: CameraInfo.h:517
uint32_t value() const
Get the value
The hardware revision of the camera
Definition: CameraInfo.h:406
const Major & major() const
Get Major
Definition: CameraInfo.h:683
Revision copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraInfo.h:663
Minor & minor()
Get Minor
Definition: CameraInfo.h:708
Revision & set(const Minor &value)
Set Minor
Definition: CameraInfo.h:714
std::tuple< CameraInfo::Revision::Major, CameraInfo::Revision::Minor > Descendants
Definition: CameraInfo.h:574
Revision & set(const Major &value)
Set Major
Definition: CameraInfo.h:695
bool operator==(const Revision &other) const
Equality operator
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:731
std::string toString() const
Get the value as string
const Minor & minor() const
Get Minor
Definition: CameraInfo.h:702
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:758
Major & major()
Get Major
Definition: CameraInfo.h:689
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:723
Revision()
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: CameraInfo.h:750
Revision(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:602
friend std::ostream & operator<<(std::ostream &stream, const Revision &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:774
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:630
bool operator!=(const Revision &other) const
Inequality operator
The serial number of the camera
Definition: CameraInfo.h:794
SerialNumber(std::string value)
Constructor
Definition: CameraInfo.h:821
const std::string & value() const
Get the value
bool operator==(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:832
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:809
SerialNumber()=default
Default constructor
friend std::ostream & operator<<(std::ostream &stream, const SerialNumber &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:856
std::string toString() const
Get the value as string
bool operator>(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:850
bool operator<(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:844
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for SerialNumber
Definition: CameraInfo.h:812
bool operator!=(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:838
The maximum number of bytes of user data that can be stored in the camera
Definition: CameraInfo.h:889
bool operator!=(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:935
bool operator>(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:947
MaxSizeBytes()=default
Default constructor
constexpr MaxSizeBytes(uint64_t value)
Constructor
Definition: CameraInfo.h:918
uint64_t value() const
Get the value
bool operator<(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:941
bool operator==(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:929
std::string toString() const
Get the value as string
friend std::ostream & operator<<(std::ostream &stream, const MaxSizeBytes &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:953
static constexpr Range< uint64_t > validRange()
The range of valid values for MaxSizeBytes
Definition: CameraInfo.h:909
uint64_t ValueType
The type of the underlying value
Definition: CameraInfo.h:906
Information about user data capabilities of the camera
Definition: CameraInfo.h:871
bool operator==(const UserData &other) const
Equality operator
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1113
MaxSizeBytes & maxSizeBytes()
Get MaxSizeBytes
Definition: CameraInfo.h:1078
UserData copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraInfo.h:1052
friend std::ostream & operator<<(std::ostream &stream, const UserData &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1128
std::string toString() const
Get the value as string
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1106
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1093
std::tuple< CameraInfo::UserData::MaxSizeBytes > Descendants
Definition: CameraInfo.h:966
bool operator!=(const UserData &other) const
Inequality operator
UserData()
Default constructor
UserData(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:993
const MaxSizeBytes & maxSizeBytes() const
Get MaxSizeBytes
Definition: CameraInfo.h:1072
UserData & set(const MaxSizeBytes &value)
Set MaxSizeBytes
Definition: CameraInfo.h:1084
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1020
Information about camera model, serial number etc.
Definition: CameraInfo.h:121
bool operator==(const CameraInfo &other) const
Equality operator
Revision & revision()
Get Revision
Definition: CameraInfo.h:1348
const ModelName & modelName() const
Get ModelName
Definition: CameraInfo.h:1323
FirmwareVersion & firmwareVersion()
Get FirmwareVersion
Definition: CameraInfo.h:1291
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1531
const UserData & userData() const
Get UserData
Definition: CameraInfo.h:1394
ModelName & modelName()
Get ModelName
Definition: CameraInfo.h:1329
bool operator!=(const CameraInfo &other) const
Inequality operator
CameraInfo & set(const Model &value)
Set Model
Definition: CameraInfo.h:1316
const CameraInfo::FirmwareVersion & get() const
Definition: CameraInfo.h:1422
const CameraInfo::Model & get() const
Definition: CameraInfo.h:1428
CameraInfo(const std::string &fileName)
Construct CameraInfo by loading from file
UserData & userData()
Get UserData
Definition: CameraInfo.h:1400
CameraInfo & set(const ModelName &value)
Set ModelName
Definition: CameraInfo.h:1335
const FirmwareVersion & firmwareVersion() const
Get FirmwareVersion
Definition: CameraInfo.h:1285
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1476
const Model & model() const
Get Model
Definition: CameraInfo.h:1304
CameraInfo copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraInfo.h:1266
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1519
Model & model()
Get Model
Definition: CameraInfo.h:1310
friend std::ostream & operator<<(std::ostream &stream, const CameraInfo &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1551
const CameraInfo::ModelName & get() const
Definition: CameraInfo.h:1434
CameraInfo & set(const UserData &value)
Set UserData
Definition: CameraInfo.h:1406
CameraInfo & set(const UserData::MaxSizeBytes &value)
Set UserData::MaxSizeBytes
Definition: CameraInfo.h:1413
CameraInfo(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:1191
const CameraInfo::UserData & get() const
Definition: CameraInfo.h:1468
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:1456
const SerialNumber & serialNumber() const
Get SerialNumber
Definition: CameraInfo.h:1375
SerialNumber & serialNumber()
Get SerialNumber
Definition: CameraInfo.h:1381
const Revision & revision() const
Get Revision
Definition: CameraInfo.h:1342
std::tuple< CameraInfo::FirmwareVersion, CameraInfo::Model, CameraInfo::ModelName, CameraInfo::Revision, CameraInfo::Revision::Major, CameraInfo::Revision::Minor, CameraInfo::SerialNumber, CameraInfo::UserData, CameraInfo::UserData::MaxSizeBytes > Descendants
Definition: CameraInfo.h:1154
void load(const std::string &fileName)
Load from the given file
CameraInfo & set(const FirmwareVersion &value)
Set FirmwareVersion
Definition: CameraInfo.h:1297
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:1448
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1226
CameraInfo & set(const Revision &value)
Set Revision
Definition: CameraInfo.h:1354
CameraInfo & set(const Revision::Major &value)
Set Revision::Major
Definition: CameraInfo.h:1361
CameraInfo & set(const SerialNumber &value)
Set SerialNumber
Definition: CameraInfo.h:1387
const CameraInfo::SerialNumber & get() const
Definition: CameraInfo.h:1462
const CameraInfo::Revision & get() const
Definition: CameraInfo.h:1440
std::string toString() const
Get the value as string
CameraInfo()
Default constructor
CameraInfo & set(const Revision::Minor &value)
Set Revision::Minor
Definition: CameraInfo.h:1368
void save(const std::string &fileName) const
Save to the given file
Class describing a range of values for a given type T
Definition: Range.h:102
NodeType
Definition: NodeType.h:100
The main Zivid namespace. All Zivid code is found here
Definition: Application.h:99