Zivid C++ API 2.6.1+6cec8609-3
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 };
255 static const Model zividTwo;
256
258 static std::set<ValueType> validValues()
259 {
260 return { ValueType::zividOnePlusSmall,
261 ValueType::zividOnePlusMedium,
262 ValueType::zividOnePlusLarge,
263 ValueType::zividTwo };
264 }
265
267 Model() = default;
268
270 explicit constexpr Model(ValueType value)
271 : m_value{ verifyValue(value) }
272 {}
273
276
278 std::string toString() const;
279
281 friend std::ostream &operator<<(std::ostream &stream, const Model::ValueType &value)
282 {
283 return stream << Model{ value }.toString();
284 }
285
287 bool operator==(const Model &other) const
288 {
289 return m_value == other.m_value;
290 }
291
293 bool operator!=(const Model &other) const
294 {
295 return m_value != other.m_value;
296 }
297
299 friend std::ostream &operator<<(std::ostream &stream, const Model &value)
300 {
301 return stream << value.toString();
302 }
303
304 private:
305 void setFromString(const std::string &value);
306
307 constexpr ValueType static verifyValue(const ValueType &value)
308 {
309 return value == ValueType::zividOnePlusSmall || value == ValueType::zividOnePlusMedium
310 || value == ValueType::zividOnePlusLarge || value == ValueType::zividTwo
311 ? value
312 : throw std::invalid_argument{
313 "Invalid value: Model{ "
314 + std::to_string(static_cast<std::underlying_type<ValueType>::type>(value)) + " }"
315 };
316 }
317
318 ValueType m_value{ ValueType::zividOnePlusSmall };
319
320 friend struct DataModel::Detail::Befriend<Model>;
321 };
322
325 {
326 public:
329
331 static constexpr const char *path{ "ModelName" };
332
334 static constexpr const char *name{ "ModelName" };
335
337 static constexpr const char *description{ R"description(The model name of the camera)description" };
338
340 using ValueType = std::string;
341
344 {
345 return { 0, std::numeric_limits<ValueType::size_type>::max() };
346 }
347
349 ModelName() = default;
350
352 explicit ModelName(std::string value)
353 : m_value{ std::move(value) }
354 {}
355
357 const std::string &value() const;
358
360 std::string toString() const;
361
363 bool operator==(const ModelName &other) const
364 {
365 return m_value == other.m_value;
366 }
367
369 bool operator!=(const ModelName &other) const
370 {
371 return m_value != other.m_value;
372 }
373
375 bool operator<(const ModelName &other) const
376 {
377 return m_value < other.m_value;
378 }
379
381 bool operator>(const ModelName &other) const
382 {
383 return m_value > other.m_value;
384 }
385
387 friend std::ostream &operator<<(std::ostream &stream, const ModelName &value)
388 {
389 return stream << value.toString();
390 }
391
392 private:
393 void setFromString(const std::string &value);
394
395 std::string m_value{};
396
397 friend struct DataModel::Detail::Befriend<ModelName>;
398 };
399
402 {
403 public:
406
408 static constexpr const char *path{ "Revision" };
409
411 static constexpr const char *name{ "Revision" };
412
414 static constexpr const char *description{ R"description(The hardware revision of the camera)description" };
415
418 {
419 public:
422
424 static constexpr const char *path{ "Revision/Major" };
425
427 static constexpr const char *name{ "Major" };
428
430 static constexpr const char *description{ R"description(Major hardware revision number)description" };
431
433 using ValueType = uint32_t;
434
436 static constexpr Range<uint32_t> validRange()
437 {
438 return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
439 }
440
442 Major() = default;
443
445 explicit constexpr Major(uint32_t value)
446 : m_value{ value }
447 {}
448
450 uint32_t value() const;
451
453 std::string toString() const;
454
456 bool operator==(const Major &other) const
457 {
458 return m_value == other.m_value;
459 }
460
462 bool operator!=(const Major &other) const
463 {
464 return m_value != other.m_value;
465 }
466
468 bool operator<(const Major &other) const
469 {
470 return m_value < other.m_value;
471 }
472
474 bool operator>(const Major &other) const
475 {
476 return m_value > other.m_value;
477 }
478
480 friend std::ostream &operator<<(std::ostream &stream, const Major &value)
481 {
482 return stream << value.toString();
483 }
484
485 private:
486 void setFromString(const std::string &value);
487
488 uint32_t m_value{ 0 };
489
490 friend struct DataModel::Detail::Befriend<Major>;
491 };
492
495 {
496 public:
499
501 static constexpr const char *path{ "Revision/Minor" };
502
504 static constexpr const char *name{ "Minor" };
505
507 static constexpr const char *description{ R"description(Minor hardware revision number)description" };
508
510 using ValueType = uint32_t;
511
513 static constexpr Range<uint32_t> validRange()
514 {
515 return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
516 }
517
519 Minor() = default;
520
522 explicit constexpr Minor(uint32_t value)
523 : m_value{ value }
524 {}
525
527 uint32_t value() const;
528
530 std::string toString() const;
531
533 bool operator==(const Minor &other) const
534 {
535 return m_value == other.m_value;
536 }
537
539 bool operator!=(const Minor &other) const
540 {
541 return m_value != other.m_value;
542 }
543
545 bool operator<(const Minor &other) const
546 {
547 return m_value < other.m_value;
548 }
549
551 bool operator>(const Minor &other) const
552 {
553 return m_value > other.m_value;
554 }
555
557 friend std::ostream &operator<<(std::ostream &stream, const Minor &value)
558 {
559 return stream << value.toString();
560 }
561
562 private:
563 void setFromString(const std::string &value);
564
565 uint32_t m_value{ 0 };
566
567 friend struct DataModel::Detail::Befriend<Minor>;
568 };
569
570 using Descendants = std::tuple<CameraInfo::Revision::Major, CameraInfo::Revision::Minor>;
571
574
587#ifndef NO_DOC
588 template<
589 typename... Args,
590 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
591 typename std::enable_if<
592 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::
593 value,
594 int>::type = 0>
595#else
596 template<typename... Args>
597#endif
598 explicit Revision(Args &&...args)
599 {
600 using namespace Zivid::Detail::TypeTraits;
601
602 static_assert(
603 AllArgsDecayedAreUnique<Args...>::value,
604 "Found duplicate types among the arguments passed to Revision(...). "
605 "Types should be listed at most once.");
606
607 set(std::forward<Args>(args)...);
608 }
609
621#ifndef NO_DOC
622 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
623#else
624 template<typename... Args>
625#endif
626 void set(Args &&...args)
627 {
628 using namespace Zivid::Detail::TypeTraits;
629
630 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
631 static_assert(
632 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
633
634 static_assert(
635 AllArgsDecayedAreUnique<Args...>::value,
636 "Found duplicate types among the arguments passed to set(...). "
637 "Types should be listed at most once.");
638
639 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
640 }
641
654#ifndef NO_DOC
655 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
656#else
657 template<typename... Args>
658#endif
659 Revision copyWith(Args &&...args) const
660 {
661 using namespace Zivid::Detail::TypeTraits;
662
663 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
664 static_assert(
665 AllArgsAreDescendantNodes::value,
666 "All arguments passed to copyWith(...) must be descendant nodes.");
667
668 static_assert(
669 AllArgsDecayedAreUnique<Args...>::value,
670 "Found duplicate types among the arguments passed to copyWith(...). "
671 "Types should be listed at most once.");
672
673 auto copy{ *this };
674 copy.set(std::forward<Args>(args)...);
675 return copy;
676 }
677
679 const Major &major() const
680 {
681 return m_major;
682 }
683
686 {
687 return m_major;
688 }
689
691 Revision &set(const Major &value)
692 {
693 m_major = value;
694 return *this;
695 }
696
698 const Minor &minor() const
699 {
700 return m_minor;
701 }
702
705 {
706 return m_minor;
707 }
708
710 Revision &set(const Minor &value)
711 {
712 m_minor = value;
713 return *this;
714 }
715
716 template<
717 typename T,
718 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
720 {
721 return m_major;
722 }
723
724 template<
725 typename T,
726 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
728 {
729 return m_minor;
730 }
731
732 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
734 {
735 return m_major;
736 }
737
738 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
740 {
741 return m_minor;
742 }
743
745 template<typename F>
746 void forEach(const F &f) const
747 {
748 f(m_major);
749 f(m_minor);
750 }
751
753 template<typename F>
754 void forEach(const F &f)
755 {
756 f(m_major);
757 f(m_minor);
758 }
759
761 bool operator==(const Revision &other) const;
762
764 bool operator!=(const Revision &other) const;
765
767 std::string toString() const;
768
770 friend std::ostream &operator<<(std::ostream &stream, const Revision &value)
771 {
772 return stream << value.toString();
773 }
774
775 private:
776 void setFromString(const std::string &value);
777
778 void setFromString(const std::string &fullPath, const std::string &value);
779
780 std::string getString(const std::string &fullPath) const;
781
782 Major m_major;
783 Minor m_minor;
784
785 friend struct DataModel::Detail::Befriend<Revision>;
786 };
787
790 {
791 public:
794
796 static constexpr const char *path{ "SerialNumber" };
797
799 static constexpr const char *name{ "SerialNumber" };
800
802 static constexpr const char *description{ R"description(The serial number of the camera)description" };
803
805 using ValueType = std::string;
806
809 {
810 return { 0, std::numeric_limits<ValueType::size_type>::max() };
811 }
812
814 SerialNumber() = default;
815
817 explicit SerialNumber(std::string value)
818 : m_value{ std::move(value) }
819 {}
820
822 const std::string &value() const;
823
825 std::string toString() const;
826
828 bool operator==(const SerialNumber &other) const
829 {
830 return m_value == other.m_value;
831 }
832
834 bool operator!=(const SerialNumber &other) const
835 {
836 return m_value != other.m_value;
837 }
838
840 bool operator<(const SerialNumber &other) const
841 {
842 return m_value < other.m_value;
843 }
844
846 bool operator>(const SerialNumber &other) const
847 {
848 return m_value > other.m_value;
849 }
850
852 friend std::ostream &operator<<(std::ostream &stream, const SerialNumber &value)
853 {
854 return stream << value.toString();
855 }
856
857 private:
858 void setFromString(const std::string &value);
859
860 std::string m_value{};
861
862 friend struct DataModel::Detail::Befriend<SerialNumber>;
863 };
864
867 {
868 public:
871
873 static constexpr const char *path{ "UserData" };
874
876 static constexpr const char *name{ "UserData" };
877
879 static constexpr const char *description{
880 R"description(Information about user data capabilities of the camera)description"
881 };
882
885 {
886 public:
889
891 static constexpr const char *path{ "UserData/MaxSizeBytes" };
892
894 static constexpr const char *name{ "MaxSizeBytes" };
895
897 static constexpr const char *description{
898 R"description(The maximum number of bytes of user data that can be stored in the camera)description"
899 };
900
902 using ValueType = uint64_t;
903
905 static constexpr Range<uint64_t> validRange()
906 {
907 return { std::numeric_limits<uint64_t>::lowest(), std::numeric_limits<uint64_t>::max() };
908 }
909
911 MaxSizeBytes() = default;
912
914 explicit constexpr MaxSizeBytes(uint64_t value)
915 : m_value{ value }
916 {}
917
919 uint64_t value() const;
920
922 std::string toString() const;
923
925 bool operator==(const MaxSizeBytes &other) const
926 {
927 return m_value == other.m_value;
928 }
929
931 bool operator!=(const MaxSizeBytes &other) const
932 {
933 return m_value != other.m_value;
934 }
935
937 bool operator<(const MaxSizeBytes &other) const
938 {
939 return m_value < other.m_value;
940 }
941
943 bool operator>(const MaxSizeBytes &other) const
944 {
945 return m_value > other.m_value;
946 }
947
949 friend std::ostream &operator<<(std::ostream &stream, const MaxSizeBytes &value)
950 {
951 return stream << value.toString();
952 }
953
954 private:
955 void setFromString(const std::string &value);
956
957 uint64_t m_value{ 0 };
958
959 friend struct DataModel::Detail::Befriend<MaxSizeBytes>;
960 };
961
962 using Descendants = std::tuple<CameraInfo::UserData::MaxSizeBytes>;
963
966
978#ifndef NO_DOC
979 template<
980 typename... Args,
981 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
982 typename std::enable_if<
983 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::
984 value,
985 int>::type = 0>
986#else
987 template<typename... Args>
988#endif
989 explicit UserData(Args &&...args)
990 {
991 using namespace Zivid::Detail::TypeTraits;
992
993 static_assert(
994 AllArgsDecayedAreUnique<Args...>::value,
995 "Found duplicate types among the arguments passed to UserData(...). "
996 "Types should be listed at most once.");
997
998 set(std::forward<Args>(args)...);
999 }
1000
1011#ifndef NO_DOC
1012 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1013#else
1014 template<typename... Args>
1015#endif
1016 void set(Args &&...args)
1017 {
1018 using namespace Zivid::Detail::TypeTraits;
1019
1020 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1021 static_assert(
1022 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
1023
1024 static_assert(
1025 AllArgsDecayedAreUnique<Args...>::value,
1026 "Found duplicate types among the arguments passed to set(...). "
1027 "Types should be listed at most once.");
1028
1029 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1030 }
1031
1043#ifndef NO_DOC
1044 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1045#else
1046 template<typename... Args>
1047#endif
1048 UserData copyWith(Args &&...args) const
1049 {
1050 using namespace Zivid::Detail::TypeTraits;
1051
1052 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1053 static_assert(
1054 AllArgsAreDescendantNodes::value,
1055 "All arguments passed to copyWith(...) must be descendant nodes.");
1056
1057 static_assert(
1058 AllArgsDecayedAreUnique<Args...>::value,
1059 "Found duplicate types among the arguments passed to copyWith(...). "
1060 "Types should be listed at most once.");
1061
1062 auto copy{ *this };
1063 copy.set(std::forward<Args>(args)...);
1064 return copy;
1065 }
1066
1069 {
1070 return m_maxSizeBytes;
1071 }
1072
1075 {
1076 return m_maxSizeBytes;
1077 }
1078
1081 {
1082 m_maxSizeBytes = value;
1083 return *this;
1084 }
1085
1086 template<
1087 typename T,
1088 typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1090 {
1091 return m_maxSizeBytes;
1092 }
1093
1094 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1096 {
1097 return m_maxSizeBytes;
1098 }
1099
1101 template<typename F>
1102 void forEach(const F &f) const
1103 {
1104 f(m_maxSizeBytes);
1105 }
1106
1108 template<typename F>
1109 void forEach(const F &f)
1110 {
1111 f(m_maxSizeBytes);
1112 }
1113
1115 bool operator==(const UserData &other) const;
1116
1118 bool operator!=(const UserData &other) const;
1119
1121 std::string toString() const;
1122
1124 friend std::ostream &operator<<(std::ostream &stream, const UserData &value)
1125 {
1126 return stream << value.toString();
1127 }
1128
1129 private:
1130 void setFromString(const std::string &value);
1131
1132 void setFromString(const std::string &fullPath, const std::string &value);
1133
1134 std::string getString(const std::string &fullPath) const;
1135
1136 MaxSizeBytes m_maxSizeBytes;
1137
1138 friend struct DataModel::Detail::Befriend<UserData>;
1139 };
1140
1141 using Descendants = std::tuple<
1151
1154
1156 explicit CameraInfo(const std::string &fileName);
1157
1177#ifndef NO_DOC
1178 template<
1179 typename... Args,
1180 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1181 typename std::enable_if<
1182 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1183 int>::type = 0>
1184#else
1185 template<typename... Args>
1186#endif
1187 explicit CameraInfo(Args &&...args)
1188 {
1189 using namespace Zivid::Detail::TypeTraits;
1190
1191 static_assert(
1192 AllArgsDecayedAreUnique<Args...>::value,
1193 "Found duplicate types among the arguments passed to CameraInfo(...). "
1194 "Types should be listed at most once.");
1195
1196 set(std::forward<Args>(args)...);
1197 }
1198
1217#ifndef NO_DOC
1218 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1219#else
1220 template<typename... Args>
1221#endif
1222 void set(Args &&...args)
1223 {
1224 using namespace Zivid::Detail::TypeTraits;
1225
1226 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1227 static_assert(
1228 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
1229
1230 static_assert(
1231 AllArgsDecayedAreUnique<Args...>::value,
1232 "Found duplicate types among the arguments passed to set(...). "
1233 "Types should be listed at most once.");
1234
1235 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1236 }
1237
1257#ifndef NO_DOC
1258 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1259#else
1260 template<typename... Args>
1261#endif
1262 CameraInfo copyWith(Args &&...args) const
1263 {
1264 using namespace Zivid::Detail::TypeTraits;
1265
1266 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1267 static_assert(
1268 AllArgsAreDescendantNodes::value, "All arguments passed to copyWith(...) must be descendant nodes.");
1269
1270 static_assert(
1271 AllArgsDecayedAreUnique<Args...>::value,
1272 "Found duplicate types among the arguments passed to copyWith(...). "
1273 "Types should be listed at most once.");
1274
1275 auto copy{ *this };
1276 copy.set(std::forward<Args>(args)...);
1277 return copy;
1278 }
1279
1282 {
1283 return m_firmwareVersion;
1284 }
1285
1288 {
1289 return m_firmwareVersion;
1290 }
1291
1294 {
1295 m_firmwareVersion = value;
1296 return *this;
1297 }
1298
1300 const Model &model() const
1301 {
1302 return m_model;
1303 }
1304
1307 {
1308 return m_model;
1309 }
1310
1312 CameraInfo &set(const Model &value)
1313 {
1314 m_model = value;
1315 return *this;
1316 }
1317
1319 const ModelName &modelName() const
1320 {
1321 return m_modelName;
1322 }
1323
1326 {
1327 return m_modelName;
1328 }
1329
1331 CameraInfo &set(const ModelName &value)
1332 {
1333 m_modelName = value;
1334 return *this;
1335 }
1336
1338 const Revision &revision() const
1339 {
1340 return m_revision;
1341 }
1342
1345 {
1346 return m_revision;
1347 }
1348
1350 CameraInfo &set(const Revision &value)
1351 {
1352 m_revision = value;
1353 return *this;
1354 }
1355
1358 {
1359 m_revision.set(value);
1360 return *this;
1361 }
1362
1365 {
1366 m_revision.set(value);
1367 return *this;
1368 }
1369
1372 {
1373 return m_serialNumber;
1374 }
1375
1378 {
1379 return m_serialNumber;
1380 }
1381
1384 {
1385 m_serialNumber = value;
1386 return *this;
1387 }
1388
1390 const UserData &userData() const
1391 {
1392 return m_userData;
1393 }
1394
1397 {
1398 return m_userData;
1399 }
1400
1402 CameraInfo &set(const UserData &value)
1403 {
1404 m_userData = value;
1405 return *this;
1406 }
1407
1410 {
1411 m_userData.set(value);
1412 return *this;
1413 }
1414
1415 template<
1416 typename T,
1417 typename std::enable_if<std::is_same<T, CameraInfo::FirmwareVersion>::value, int>::type = 0>
1419 {
1420 return m_firmwareVersion;
1421 }
1422
1423 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Model>::value, int>::type = 0>
1424 const CameraInfo::Model &get() const
1425 {
1426 return m_model;
1427 }
1428
1429 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::ModelName>::value, int>::type = 0>
1431 {
1432 return m_modelName;
1433 }
1434
1435 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Revision>::value, int>::type = 0>
1437 {
1438 return m_revision;
1439 }
1440
1441 template<
1442 typename T,
1443 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
1445 {
1446 return m_revision.get<CameraInfo::Revision::Major>();
1447 }
1448
1449 template<
1450 typename T,
1451 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
1453 {
1454 return m_revision.get<CameraInfo::Revision::Minor>();
1455 }
1456
1457 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::SerialNumber>::value, int>::type = 0>
1459 {
1460 return m_serialNumber;
1461 }
1462
1463 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::UserData>::value, int>::type = 0>
1465 {
1466 return m_userData;
1467 }
1468
1469 template<
1470 typename T,
1471 typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1473 {
1474 return m_userData.get<CameraInfo::UserData::MaxSizeBytes>();
1475 }
1476
1477 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1479 {
1480 return m_firmwareVersion;
1481 }
1482
1483 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1484 const CameraInfo::Model &get() const
1485 {
1486 return m_model;
1487 }
1488
1489 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1491 {
1492 return m_modelName;
1493 }
1494
1495 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1497 {
1498 return m_revision;
1499 }
1500
1501 template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
1503 {
1504 return m_serialNumber;
1505 }
1506
1507 template<size_t i, typename std::enable_if<i == 5, int>::type = 0>
1509 {
1510 return m_userData;
1511 }
1512
1514 template<typename F>
1515 void forEach(const F &f) const
1516 {
1517 f(m_firmwareVersion);
1518 f(m_model);
1519 f(m_modelName);
1520 f(m_revision);
1521 f(m_serialNumber);
1522 f(m_userData);
1523 }
1524
1526 template<typename F>
1527 void forEach(const F &f)
1528 {
1529 f(m_firmwareVersion);
1530 f(m_model);
1531 f(m_modelName);
1532 f(m_revision);
1533 f(m_serialNumber);
1534 f(m_userData);
1535 }
1536
1538 bool operator==(const CameraInfo &other) const;
1539
1541 bool operator!=(const CameraInfo &other) const;
1542
1544 std::string toString() const;
1545
1547 friend std::ostream &operator<<(std::ostream &stream, const CameraInfo &value)
1548 {
1549 return stream << value.toString();
1550 }
1551
1553 void save(const std::string &fileName) const;
1554
1556 void load(const std::string &fileName);
1557
1558 private:
1559 void setFromString(const std::string &value);
1560
1561 void setFromString(const std::string &fullPath, const std::string &value);
1562
1563 std::string getString(const std::string &fullPath) const;
1564
1565 FirmwareVersion m_firmwareVersion;
1566 Model m_model;
1567 ModelName m_modelName;
1568 Revision m_revision;
1569 SerialNumber m_serialNumber;
1570 UserData m_userData;
1571
1572 friend struct DataModel::Detail::Befriend<CameraInfo>;
1573 };
1574
1575#ifndef NO_DOC
1576 template<>
1577 struct CameraInfo::Version<1>
1578 {
1579 using Type = CameraInfo;
1580 };
1581#endif
1582
1583} // namespace Zivid
1584
1585#ifdef _MSC_VER
1586# pragma warning(pop)
1587#endif
1588
1589#ifndef NO_DOC
1590# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1591namespace std // NOLINT
1592{
1593
1594 template<>
1595 struct tuple_size<Zivid::CameraInfo::Revision> : integral_constant<size_t, 2>
1596 {};
1597
1598 template<size_t i>
1599 struct tuple_element<i, Zivid::CameraInfo::Revision>
1600 {
1601 static_assert(i < tuple_size<Zivid::CameraInfo::Revision>::value, "Index must be less than 2");
1602
1603 using type // NOLINT
1604 = decltype(declval<Zivid::CameraInfo::Revision>().get<i>());
1605 };
1606
1607 template<>
1608 struct tuple_size<Zivid::CameraInfo::UserData> : integral_constant<size_t, 1>
1609 {};
1610
1611 template<size_t i>
1612 struct tuple_element<i, Zivid::CameraInfo::UserData>
1613 {
1614 static_assert(i < tuple_size<Zivid::CameraInfo::UserData>::value, "Index must be less than 1");
1615
1616 using type // NOLINT
1617 = decltype(declval<Zivid::CameraInfo::UserData>().get<i>());
1618 };
1619
1620 template<>
1621 struct tuple_size<Zivid::CameraInfo> : integral_constant<size_t, 6>
1622 {};
1623
1624 template<size_t i>
1625 struct tuple_element<i, Zivid::CameraInfo>
1626 {
1627 static_assert(i < tuple_size<Zivid::CameraInfo>::value, "Index must be less than 6");
1628
1629 using type // NOLINT
1630 = decltype(declval<Zivid::CameraInfo>().get<i>());
1631 };
1632
1633} // namespace std
1634# endif
1635#endif
1636
1637// If we have access to the DataModel library, automatically include internal DataModel
1638// header. This header is necessary for serialization and deserialization.
1639#if defined(__has_include) && !defined(NO_DOC)
1640# if __has_include("Zivid/CameraInfoInternal.h") && __has_include("Zivid/DataModelSerializationMetaData.h")
1641# include "Zivid/CameraInfoInternal.h"
1642# endif
1643#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:325
bool operator==(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:363
ModelName()=default
Default constructor
std::string toString() const
Get the value as string
ModelName(std::string value)
Constructor
Definition: CameraInfo.h:352
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:340
bool operator<(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:375
bool operator>(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:381
friend std::ostream & operator<<(std::ostream &stream, const ModelName &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:387
const std::string & value() const
Get the value
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for ModelName
Definition: CameraInfo.h:343
bool operator!=(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:369
The model of the camera
Definition: CameraInfo.h:230
static const Model zividOnePlusSmall
zividOnePlusSmall
Definition: CameraInfo.h:252
static const Model zividTwo
zividTwo
Definition: CameraInfo.h:255
std::string toString() const
Get the value as string
constexpr Model(ValueType value)
Constructor
Definition: CameraInfo.h:270
Model()=default
Default constructor
static const Model zividOnePlusMedium
zividOnePlusMedium
Definition: CameraInfo.h:253
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:281
friend std::ostream & operator<<(std::ostream &stream, const Model &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:299
static std::set< ValueType > validValues()
All valid values of Model
Definition: CameraInfo.h:258
ValueType
The type of the underlying value
Definition: CameraInfo.h:246
static const Model zividOnePlusLarge
zividOnePlusLarge
Definition: CameraInfo.h:254
bool operator!=(const Model &other) const
Comparison operator
Definition: CameraInfo.h:293
bool operator==(const Model &other) const
Comparison operator
Definition: CameraInfo.h:287
Major hardware revision number
Definition: CameraInfo.h:418
std::string toString() const
Get the value as string
bool operator!=(const Major &other) const
Comparison operator
Definition: CameraInfo.h:462
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:433
friend std::ostream & operator<<(std::ostream &stream, const Major &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:480
static constexpr Range< uint32_t > validRange()
The range of valid values for Major
Definition: CameraInfo.h:436
bool operator>(const Major &other) const
Comparison operator
Definition: CameraInfo.h:474
uint32_t value() const
Get the value
constexpr Major(uint32_t value)
Constructor
Definition: CameraInfo.h:445
bool operator<(const Major &other) const
Comparison operator
Definition: CameraInfo.h:468
Major()=default
Default constructor
bool operator==(const Major &other) const
Comparison operator
Definition: CameraInfo.h:456
Minor hardware revision number
Definition: CameraInfo.h:495
bool operator>(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:551
bool operator!=(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:539
constexpr Minor(uint32_t value)
Constructor
Definition: CameraInfo.h:522
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:510
friend std::ostream & operator<<(std::ostream &stream, const Minor &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:557
bool operator==(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:533
std::string toString() const
Get the value as string
Minor()=default
Default constructor
bool operator<(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:545
static constexpr Range< uint32_t > validRange()
The range of valid values for Minor
Definition: CameraInfo.h:513
uint32_t value() const
Get the value
The hardware revision of the camera
Definition: CameraInfo.h:402
const Major & major() const
Get Major
Definition: CameraInfo.h:679
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:659
Minor & minor()
Get Minor
Definition: CameraInfo.h:704
Revision & set(const Minor &value)
Set Minor
Definition: CameraInfo.h:710
std::tuple< CameraInfo::Revision::Major, CameraInfo::Revision::Minor > Descendants
Definition: CameraInfo.h:570
Revision & set(const Major &value)
Set Major
Definition: CameraInfo.h:691
bool operator==(const Revision &other) const
Equality operator
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:727
std::string toString() const
Get the value as string
const Minor & minor() const
Get Minor
Definition: CameraInfo.h:698
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:754
Major & major()
Get Major
Definition: CameraInfo.h:685
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:719
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:746
Revision(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:598
friend std::ostream & operator<<(std::ostream &stream, const Revision &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:770
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:626
bool operator!=(const Revision &other) const
Inequality operator
The serial number of the camera
Definition: CameraInfo.h:790
SerialNumber(std::string value)
Constructor
Definition: CameraInfo.h:817
const std::string & value() const
Get the value
bool operator==(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:828
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:805
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:852
std::string toString() const
Get the value as string
bool operator>(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:846
bool operator<(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:840
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for SerialNumber
Definition: CameraInfo.h:808
bool operator!=(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:834
The maximum number of bytes of user data that can be stored in the camera
Definition: CameraInfo.h:885
bool operator!=(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:931
bool operator>(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:943
MaxSizeBytes()=default
Default constructor
constexpr MaxSizeBytes(uint64_t value)
Constructor
Definition: CameraInfo.h:914
uint64_t value() const
Get the value
bool operator<(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:937
bool operator==(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:925
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:949
static constexpr Range< uint64_t > validRange()
The range of valid values for MaxSizeBytes
Definition: CameraInfo.h:905
uint64_t ValueType
The type of the underlying value
Definition: CameraInfo.h:902
Information about user data capabilities of the camera
Definition: CameraInfo.h:867
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:1109
MaxSizeBytes & maxSizeBytes()
Get MaxSizeBytes
Definition: CameraInfo.h:1074
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:1048
friend std::ostream & operator<<(std::ostream &stream, const UserData &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1124
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:1102
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1089
std::tuple< CameraInfo::UserData::MaxSizeBytes > Descendants
Definition: CameraInfo.h:962
bool operator!=(const UserData &other) const
Inequality operator
UserData()
Default constructor
UserData(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:989
const MaxSizeBytes & maxSizeBytes() const
Get MaxSizeBytes
Definition: CameraInfo.h:1068
UserData & set(const MaxSizeBytes &value)
Set MaxSizeBytes
Definition: CameraInfo.h:1080
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1016
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:1344
const ModelName & modelName() const
Get ModelName
Definition: CameraInfo.h:1319
FirmwareVersion & firmwareVersion()
Get FirmwareVersion
Definition: CameraInfo.h:1287
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1527
const UserData & userData() const
Get UserData
Definition: CameraInfo.h:1390
ModelName & modelName()
Get ModelName
Definition: CameraInfo.h:1325
bool operator!=(const CameraInfo &other) const
Inequality operator
CameraInfo & set(const Model &value)
Set Model
Definition: CameraInfo.h:1312
const CameraInfo::FirmwareVersion & get() const
Definition: CameraInfo.h:1418
const CameraInfo::Model & get() const
Definition: CameraInfo.h:1424
CameraInfo(const std::string &fileName)
Construct CameraInfo by loading from file
UserData & userData()
Get UserData
Definition: CameraInfo.h:1396
CameraInfo & set(const ModelName &value)
Set ModelName
Definition: CameraInfo.h:1331
const FirmwareVersion & firmwareVersion() const
Get FirmwareVersion
Definition: CameraInfo.h:1281
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1472
const Model & model() const
Get Model
Definition: CameraInfo.h:1300
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:1262
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:1515
Model & model()
Get Model
Definition: CameraInfo.h:1306
friend std::ostream & operator<<(std::ostream &stream, const CameraInfo &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1547
const CameraInfo::ModelName & get() const
Definition: CameraInfo.h:1430
CameraInfo & set(const UserData &value)
Set UserData
Definition: CameraInfo.h:1402
CameraInfo & set(const UserData::MaxSizeBytes &value)
Set UserData::MaxSizeBytes
Definition: CameraInfo.h:1409
CameraInfo(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:1187
const CameraInfo::UserData & get() const
Definition: CameraInfo.h:1464
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:1452
const SerialNumber & serialNumber() const
Get SerialNumber
Definition: CameraInfo.h:1371
SerialNumber & serialNumber()
Get SerialNumber
Definition: CameraInfo.h:1377
const Revision & revision() const
Get Revision
Definition: CameraInfo.h:1338
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:1150
void load(const std::string &fileName)
Load from the given file
CameraInfo & set(const FirmwareVersion &value)
Set FirmwareVersion
Definition: CameraInfo.h:1293
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:1444
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1222
CameraInfo & set(const Revision &value)
Set Revision
Definition: CameraInfo.h:1350
CameraInfo & set(const Revision::Major &value)
Set Revision::Major
Definition: CameraInfo.h:1357
CameraInfo & set(const SerialNumber &value)
Set SerialNumber
Definition: CameraInfo.h:1383
const CameraInfo::SerialNumber & get() const
Definition: CameraInfo.h:1458
const CameraInfo::Revision & get() const
Definition: CameraInfo.h:1436
std::string toString() const
Get the value as string
CameraInfo()
Default constructor
CameraInfo & set(const Revision::Minor &value)
Set Revision::Minor
Definition: CameraInfo.h:1364
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