Zivid C++ API 2.5.0+19fa6891-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-2021 (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{
120 {
121 public:
124
126 static constexpr const char *path{ "" };
127
129 static constexpr const char *name{ "CameraInfo" };
130
132 static constexpr const char *description{
133 R"description(Information about camera model, serial number etc.)description"
134 };
135
136 static constexpr size_t version{ 1 };
137
138#ifndef NO_DOC
139 template<size_t>
140 struct Version;
141
142 using LatestVersion = Zivid::CameraInfo;
143
144 // Short identifier. This value is not guaranteed to be universally unique
145 // Todo(ZIVID-2808): Move this to internal DataModelExt header
146 static constexpr std::array<uint8_t, 3> binaryId{ 'n', 'f', 'o' };
147
148#endif
149
152 {
153 public:
156
158 static constexpr const char *path{ "FirmwareVersion" };
159
161 static constexpr const char *name{ "FirmwareVersion" };
162
164 static constexpr const char *description{ R"description(The firmware version on the camera)description" };
165
167 using ValueType = std::string;
168
171 {
172 return { 0, std::numeric_limits<ValueType::size_type>::max() };
173 }
174
176 FirmwareVersion() = default;
177
179 explicit FirmwareVersion(std::string value)
180 : m_value{ std::move(value) }
181 {}
182
184 const std::string &value() const;
185
187 std::string toString() const;
188
190 bool operator==(const FirmwareVersion &other) const
191 {
192 return m_value == other.m_value;
193 }
194
196 bool operator!=(const FirmwareVersion &other) const
197 {
198 return m_value != other.m_value;
199 }
200
202 bool operator<(const FirmwareVersion &other) const
203 {
204 return m_value < other.m_value;
205 }
206
208 bool operator>(const FirmwareVersion &other) const
209 {
210 return m_value > other.m_value;
211 }
212
214 friend std::ostream &operator<<(std::ostream &stream, const FirmwareVersion &value)
215 {
216 return stream << value.toString();
217 }
218
219 private:
220 void setFromString(const std::string &value);
221
222 std::string m_value{};
223
224 friend struct DataModel::Detail::Befriend<FirmwareVersion>;
225 };
226
229 {
230 public:
233
235 static constexpr const char *path{ "Model" };
236
238 static constexpr const char *name{ "Model" };
239
241 static constexpr const char *description{ R"description(The model of the camera)description" };
242
244 enum class ValueType
245 {
246 zividOnePlusSmall,
247 zividOnePlusMedium,
248 zividOnePlusLarge,
249 zividTwo
250 };
254 static const Model zividTwo;
255
257 static std::set<ValueType> validValues()
258 {
259 return { ValueType::zividOnePlusSmall,
260 ValueType::zividOnePlusMedium,
261 ValueType::zividOnePlusLarge,
262 ValueType::zividTwo };
263 }
264
266 Model() = default;
267
269 explicit constexpr Model(ValueType value)
270 : m_value{ verifyValue(value) }
271 {}
272
275
277 std::string toString() const;
278
280 friend std::ostream &operator<<(std::ostream &stream, const Model::ValueType &value)
281 {
282 return stream << Model{ value }.toString();
283 }
284
286 bool operator==(const Model &other) const
287 {
288 return m_value == other.m_value;
289 }
290
292 bool operator!=(const Model &other) const
293 {
294 return m_value != other.m_value;
295 }
296
298 friend std::ostream &operator<<(std::ostream &stream, const Model &value)
299 {
300 return stream << value.toString();
301 }
302
303 private:
304 void setFromString(const std::string &value);
305
306 constexpr ValueType static verifyValue(const ValueType &value)
307 {
308 return value == ValueType::zividOnePlusSmall || value == ValueType::zividOnePlusMedium
309 || value == ValueType::zividOnePlusLarge || value == ValueType::zividTwo
310 ? value
311 : throw std::invalid_argument{
312 "Invalid value: Model{ "
313 + std::to_string(static_cast<std::underlying_type<ValueType>::type>(value)) + " }"
314 };
315 }
316
317 ValueType m_value{ ValueType::zividOnePlusSmall };
318
319 friend struct DataModel::Detail::Befriend<Model>;
320 };
321
324 {
325 public:
328
330 static constexpr const char *path{ "ModelName" };
331
333 static constexpr const char *name{ "ModelName" };
334
336 static constexpr const char *description{ R"description(The model name of the camera)description" };
337
339 using ValueType = std::string;
340
343 {
344 return { 0, std::numeric_limits<ValueType::size_type>::max() };
345 }
346
348 ModelName() = default;
349
351 explicit ModelName(std::string value)
352 : m_value{ std::move(value) }
353 {}
354
356 const std::string &value() const;
357
359 std::string toString() const;
360
362 bool operator==(const ModelName &other) const
363 {
364 return m_value == other.m_value;
365 }
366
368 bool operator!=(const ModelName &other) const
369 {
370 return m_value != other.m_value;
371 }
372
374 bool operator<(const ModelName &other) const
375 {
376 return m_value < other.m_value;
377 }
378
380 bool operator>(const ModelName &other) const
381 {
382 return m_value > other.m_value;
383 }
384
386 friend std::ostream &operator<<(std::ostream &stream, const ModelName &value)
387 {
388 return stream << value.toString();
389 }
390
391 private:
392 void setFromString(const std::string &value);
393
394 std::string m_value{};
395
396 friend struct DataModel::Detail::Befriend<ModelName>;
397 };
398
401 {
402 public:
405
407 static constexpr const char *path{ "Revision" };
408
410 static constexpr const char *name{ "Revision" };
411
413 static constexpr const char *description{ R"description(The hardware revision of the camera)description" };
414
417 {
418 public:
421
423 static constexpr const char *path{ "Revision/Major" };
424
426 static constexpr const char *name{ "Major" };
427
429 static constexpr const char *description{ R"description(Major hardware revision number)description" };
430
432 using ValueType = uint32_t;
433
435 static constexpr Range<uint32_t> validRange()
436 {
437 return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
438 }
439
441 Major() = default;
442
444 explicit constexpr Major(uint32_t value)
445 : m_value{ value }
446 {}
447
449 uint32_t value() const;
450
452 std::string toString() const;
453
455 bool operator==(const Major &other) const
456 {
457 return m_value == other.m_value;
458 }
459
461 bool operator!=(const Major &other) const
462 {
463 return m_value != other.m_value;
464 }
465
467 bool operator<(const Major &other) const
468 {
469 return m_value < other.m_value;
470 }
471
473 bool operator>(const Major &other) const
474 {
475 return m_value > other.m_value;
476 }
477
479 friend std::ostream &operator<<(std::ostream &stream, const Major &value)
480 {
481 return stream << value.toString();
482 }
483
484 private:
485 void setFromString(const std::string &value);
486
487 uint32_t m_value{ 0 };
488
489 friend struct DataModel::Detail::Befriend<Major>;
490 };
491
494 {
495 public:
498
500 static constexpr const char *path{ "Revision/Minor" };
501
503 static constexpr const char *name{ "Minor" };
504
506 static constexpr const char *description{ R"description(Minor hardware revision number)description" };
507
509 using ValueType = uint32_t;
510
512 static constexpr Range<uint32_t> validRange()
513 {
514 return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
515 }
516
518 Minor() = default;
519
521 explicit constexpr Minor(uint32_t value)
522 : m_value{ value }
523 {}
524
526 uint32_t value() const;
527
529 std::string toString() const;
530
532 bool operator==(const Minor &other) const
533 {
534 return m_value == other.m_value;
535 }
536
538 bool operator!=(const Minor &other) const
539 {
540 return m_value != other.m_value;
541 }
542
544 bool operator<(const Minor &other) const
545 {
546 return m_value < other.m_value;
547 }
548
550 bool operator>(const Minor &other) const
551 {
552 return m_value > other.m_value;
553 }
554
556 friend std::ostream &operator<<(std::ostream &stream, const Minor &value)
557 {
558 return stream << value.toString();
559 }
560
561 private:
562 void setFromString(const std::string &value);
563
564 uint32_t m_value{ 0 };
565
566 friend struct DataModel::Detail::Befriend<Minor>;
567 };
568
569 using Descendants = std::tuple<CameraInfo::Revision::Major, CameraInfo::Revision::Minor>;
570
573
586#ifndef NO_DOC
587 template<typename... Args,
588 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
589 typename std::enable_if<
590 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
591 typename std::decay<Args>::type...>::value,
592 int>::type = 0>
593#else
594 template<typename... Args>
595#endif
596 explicit Revision(Args &&...args)
597 {
598 using namespace Zivid::Detail::TypeTraits;
599
600 static_assert(AllArgsDecayedAreUnique<Args...>::value,
601 "Found duplicate types among the arguments passed to Revision(...). "
602 "Types should be listed at most once.");
603
604 set(std::forward<Args>(args)...);
605 }
606
618#ifndef NO_DOC
619 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
620#else
621 template<typename... Args>
622#endif
623 void set(Args &&...args)
624 {
625 using namespace Zivid::Detail::TypeTraits;
626
627 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
628 static_assert(AllArgsAreDescendantNodes::value,
629 "All arguments passed to set(...) must be descendant nodes.");
630
631 static_assert(AllArgsDecayedAreUnique<Args...>::value,
632 "Found duplicate types among the arguments passed to set(...). "
633 "Types should be listed at most once.");
634
635 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
636 }
637
650#ifndef NO_DOC
651 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
652#else
653 template<typename... Args>
654#endif
655 Revision copyWith(Args &&...args) const
656 {
657 using namespace Zivid::Detail::TypeTraits;
658
659 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
660 static_assert(AllArgsAreDescendantNodes::value,
661 "All arguments passed to copyWith(...) must be descendant nodes.");
662
663 static_assert(AllArgsDecayedAreUnique<Args...>::value,
664 "Found duplicate types among the arguments passed to copyWith(...). "
665 "Types should be listed at most once.");
666
667 auto copy{ *this };
668 copy.set(std::forward<Args>(args)...);
669 return copy;
670 }
671
673 const Major &major() const
674 {
675 return m_major;
676 }
677
680 {
681 return m_major;
682 }
683
685 Revision &set(const Major &value)
686 {
687 m_major = value;
688 return *this;
689 }
690
692 const Minor &minor() const
693 {
694 return m_minor;
695 }
696
699 {
700 return m_minor;
701 }
702
704 Revision &set(const Minor &value)
705 {
706 m_minor = value;
707 return *this;
708 }
709
710 template<typename T,
711 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
713 {
714 return m_major;
715 }
716
717 template<typename T,
718 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
720 {
721 return m_minor;
722 }
723
724 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
726 {
727 return m_major;
728 }
729
730 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
732 {
733 return m_minor;
734 }
735
737 template<typename F>
738 void forEach(const F &f) const
739 {
740 f(m_major);
741 f(m_minor);
742 }
743
745 template<typename F>
746 void forEach(const F &f)
747 {
748 f(m_major);
749 f(m_minor);
750 }
751
753 bool operator==(const Revision &other) const;
754
756 bool operator!=(const Revision &other) const;
757
759 std::string toString() const;
760
762 friend std::ostream &operator<<(std::ostream &stream, const Revision &value)
763 {
764 return stream << value.toString();
765 }
766
767 private:
768 void setFromString(const std::string &value);
769
770 void setFromString(const std::string &fullPath, const std::string &value);
771
772 std::string getString(const std::string &fullPath) const;
773
774 Major m_major;
775 Minor m_minor;
776
777 friend struct DataModel::Detail::Befriend<Revision>;
778 };
779
782 {
783 public:
786
788 static constexpr const char *path{ "SerialNumber" };
789
791 static constexpr const char *name{ "SerialNumber" };
792
794 static constexpr const char *description{ R"description(The serial number of the camera)description" };
795
797 using ValueType = std::string;
798
801 {
802 return { 0, std::numeric_limits<ValueType::size_type>::max() };
803 }
804
806 SerialNumber() = default;
807
809 explicit SerialNumber(std::string value)
810 : m_value{ std::move(value) }
811 {}
812
814 const std::string &value() const;
815
817 std::string toString() const;
818
820 bool operator==(const SerialNumber &other) const
821 {
822 return m_value == other.m_value;
823 }
824
826 bool operator!=(const SerialNumber &other) const
827 {
828 return m_value != other.m_value;
829 }
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 friend std::ostream &operator<<(std::ostream &stream, const SerialNumber &value)
845 {
846 return stream << value.toString();
847 }
848
849 private:
850 void setFromString(const std::string &value);
851
852 std::string m_value{};
853
854 friend struct DataModel::Detail::Befriend<SerialNumber>;
855 };
856
859 {
860 public:
863
865 static constexpr const char *path{ "UserData" };
866
868 static constexpr const char *name{ "UserData" };
869
871 static constexpr const char *description{
872 R"description(Information about user data capabilities of the camera)description"
873 };
874
877 {
878 public:
881
883 static constexpr const char *path{ "UserData/MaxSizeBytes" };
884
886 static constexpr const char *name{ "MaxSizeBytes" };
887
889 static constexpr const char *description{
890 R"description(The maximum number of bytes of user data that can be stored in the camera)description"
891 };
892
894 using ValueType = uint64_t;
895
897 static constexpr Range<uint64_t> validRange()
898 {
899 return { std::numeric_limits<uint64_t>::lowest(), std::numeric_limits<uint64_t>::max() };
900 }
901
903 MaxSizeBytes() = default;
904
906 explicit constexpr MaxSizeBytes(uint64_t value)
907 : m_value{ value }
908 {}
909
911 uint64_t value() const;
912
914 std::string toString() const;
915
917 bool operator==(const MaxSizeBytes &other) const
918 {
919 return m_value == other.m_value;
920 }
921
923 bool operator!=(const MaxSizeBytes &other) const
924 {
925 return m_value != other.m_value;
926 }
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 friend std::ostream &operator<<(std::ostream &stream, const MaxSizeBytes &value)
942 {
943 return stream << value.toString();
944 }
945
946 private:
947 void setFromString(const std::string &value);
948
949 uint64_t m_value{ 0 };
950
951 friend struct DataModel::Detail::Befriend<MaxSizeBytes>;
952 };
953
954 using Descendants = std::tuple<CameraInfo::UserData::MaxSizeBytes>;
955
958
970#ifndef NO_DOC
971 template<typename... Args,
972 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
973 typename std::enable_if<
974 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
975 typename std::decay<Args>::type...>::value,
976 int>::type = 0>
977#else
978 template<typename... Args>
979#endif
980 explicit UserData(Args &&...args)
981 {
982 using namespace Zivid::Detail::TypeTraits;
983
984 static_assert(AllArgsDecayedAreUnique<Args...>::value,
985 "Found duplicate types among the arguments passed to UserData(...). "
986 "Types should be listed at most once.");
987
988 set(std::forward<Args>(args)...);
989 }
990
1001#ifndef NO_DOC
1002 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1003#else
1004 template<typename... Args>
1005#endif
1006 void set(Args &&...args)
1007 {
1008 using namespace Zivid::Detail::TypeTraits;
1009
1010 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1011 static_assert(AllArgsAreDescendantNodes::value,
1012 "All arguments passed to set(...) must be descendant nodes.");
1013
1014 static_assert(AllArgsDecayedAreUnique<Args...>::value,
1015 "Found duplicate types among the arguments passed to set(...). "
1016 "Types should be listed at most once.");
1017
1018 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1019 }
1020
1032#ifndef NO_DOC
1033 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1034#else
1035 template<typename... Args>
1036#endif
1037 UserData copyWith(Args &&...args) const
1038 {
1039 using namespace Zivid::Detail::TypeTraits;
1040
1041 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1042 static_assert(AllArgsAreDescendantNodes::value,
1043 "All arguments passed to copyWith(...) must be descendant nodes.");
1044
1045 static_assert(AllArgsDecayedAreUnique<Args...>::value,
1046 "Found duplicate types among the arguments passed to copyWith(...). "
1047 "Types should be listed at most once.");
1048
1049 auto copy{ *this };
1050 copy.set(std::forward<Args>(args)...);
1051 return copy;
1052 }
1053
1056 {
1057 return m_maxSizeBytes;
1058 }
1059
1062 {
1063 return m_maxSizeBytes;
1064 }
1065
1068 {
1069 m_maxSizeBytes = value;
1070 return *this;
1071 }
1072
1073 template<typename T,
1074 typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1076 {
1077 return m_maxSizeBytes;
1078 }
1079
1080 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1082 {
1083 return m_maxSizeBytes;
1084 }
1085
1087 template<typename F>
1088 void forEach(const F &f) const
1089 {
1090 f(m_maxSizeBytes);
1091 }
1092
1094 template<typename F>
1095 void forEach(const F &f)
1096 {
1097 f(m_maxSizeBytes);
1098 }
1099
1101 bool operator==(const UserData &other) const;
1102
1104 bool operator!=(const UserData &other) const;
1105
1107 std::string toString() const;
1108
1110 friend std::ostream &operator<<(std::ostream &stream, const UserData &value)
1111 {
1112 return stream << value.toString();
1113 }
1114
1115 private:
1116 void setFromString(const std::string &value);
1117
1118 void setFromString(const std::string &fullPath, const std::string &value);
1119
1120 std::string getString(const std::string &fullPath) const;
1121
1122 MaxSizeBytes m_maxSizeBytes;
1123
1124 friend struct DataModel::Detail::Befriend<UserData>;
1125 };
1126
1136
1139
1141 explicit CameraInfo(const std::string &fileName);
1142
1162#ifndef NO_DOC
1163 template<
1164 typename... Args,
1165 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1166 typename std::enable_if<
1167 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1168 int>::type = 0>
1169#else
1170 template<typename... Args>
1171#endif
1172 explicit CameraInfo(Args &&...args)
1173 {
1174 using namespace Zivid::Detail::TypeTraits;
1175
1176 static_assert(AllArgsDecayedAreUnique<Args...>::value,
1177 "Found duplicate types among the arguments passed to CameraInfo(...). "
1178 "Types should be listed at most once.");
1179
1180 set(std::forward<Args>(args)...);
1181 }
1182
1201#ifndef NO_DOC
1202 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1203#else
1204 template<typename... Args>
1205#endif
1206 void set(Args &&...args)
1207 {
1208 using namespace Zivid::Detail::TypeTraits;
1209
1210 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1211 static_assert(AllArgsAreDescendantNodes::value,
1212 "All arguments passed to set(...) must be descendant nodes.");
1213
1214 static_assert(AllArgsDecayedAreUnique<Args...>::value,
1215 "Found duplicate types among the arguments passed to set(...). "
1216 "Types should be listed at most once.");
1217
1218 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1219 }
1220
1240#ifndef NO_DOC
1241 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1242#else
1243 template<typename... Args>
1244#endif
1245 CameraInfo copyWith(Args &&...args) const
1246 {
1247 using namespace Zivid::Detail::TypeTraits;
1248
1249 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1250 static_assert(AllArgsAreDescendantNodes::value,
1251 "All arguments passed to copyWith(...) must be descendant nodes.");
1252
1253 static_assert(AllArgsDecayedAreUnique<Args...>::value,
1254 "Found duplicate types among the arguments passed to copyWith(...). "
1255 "Types should be listed at most once.");
1256
1257 auto copy{ *this };
1258 copy.set(std::forward<Args>(args)...);
1259 return copy;
1260 }
1261
1264 {
1265 return m_firmwareVersion;
1266 }
1267
1270 {
1271 return m_firmwareVersion;
1272 }
1273
1276 {
1277 m_firmwareVersion = value;
1278 return *this;
1279 }
1280
1282 const Model &model() const
1283 {
1284 return m_model;
1285 }
1286
1289 {
1290 return m_model;
1291 }
1292
1294 CameraInfo &set(const Model &value)
1295 {
1296 m_model = value;
1297 return *this;
1298 }
1299
1301 const ModelName &modelName() const
1302 {
1303 return m_modelName;
1304 }
1305
1308 {
1309 return m_modelName;
1310 }
1311
1313 CameraInfo &set(const ModelName &value)
1314 {
1315 m_modelName = value;
1316 return *this;
1317 }
1318
1320 const Revision &revision() const
1321 {
1322 return m_revision;
1323 }
1324
1327 {
1328 return m_revision;
1329 }
1330
1332 CameraInfo &set(const Revision &value)
1333 {
1334 m_revision = value;
1335 return *this;
1336 }
1337
1340 {
1341 m_revision.set(value);
1342 return *this;
1343 }
1344
1347 {
1348 m_revision.set(value);
1349 return *this;
1350 }
1351
1354 {
1355 return m_serialNumber;
1356 }
1357
1360 {
1361 return m_serialNumber;
1362 }
1363
1366 {
1367 m_serialNumber = value;
1368 return *this;
1369 }
1370
1372 const UserData &userData() const
1373 {
1374 return m_userData;
1375 }
1376
1379 {
1380 return m_userData;
1381 }
1382
1384 CameraInfo &set(const UserData &value)
1385 {
1386 m_userData = value;
1387 return *this;
1388 }
1389
1392 {
1393 m_userData.set(value);
1394 return *this;
1395 }
1396
1397 template<typename T,
1398 typename std::enable_if<std::is_same<T, CameraInfo::FirmwareVersion>::value, int>::type = 0>
1400 {
1401 return m_firmwareVersion;
1402 }
1403
1404 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Model>::value, int>::type = 0>
1405 const CameraInfo::Model &get() const
1406 {
1407 return m_model;
1408 }
1409
1410 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::ModelName>::value, int>::type = 0>
1412 {
1413 return m_modelName;
1414 }
1415
1416 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Revision>::value, int>::type = 0>
1418 {
1419 return m_revision;
1420 }
1421
1422 template<typename T,
1423 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
1425 {
1426 return m_revision.get<CameraInfo::Revision::Major>();
1427 }
1428
1429 template<typename T,
1430 typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
1432 {
1433 return m_revision.get<CameraInfo::Revision::Minor>();
1434 }
1435
1436 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::SerialNumber>::value, int>::type = 0>
1438 {
1439 return m_serialNumber;
1440 }
1441
1442 template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::UserData>::value, int>::type = 0>
1444 {
1445 return m_userData;
1446 }
1447
1448 template<typename T,
1449 typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1451 {
1452 return m_userData.get<CameraInfo::UserData::MaxSizeBytes>();
1453 }
1454
1455 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1457 {
1458 return m_firmwareVersion;
1459 }
1460
1461 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1462 const CameraInfo::Model &get() const
1463 {
1464 return m_model;
1465 }
1466
1467 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1469 {
1470 return m_modelName;
1471 }
1472
1473 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1475 {
1476 return m_revision;
1477 }
1478
1479 template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
1481 {
1482 return m_serialNumber;
1483 }
1484
1485 template<size_t i, typename std::enable_if<i == 5, int>::type = 0>
1487 {
1488 return m_userData;
1489 }
1490
1492 template<typename F>
1493 void forEach(const F &f) const
1494 {
1495 f(m_firmwareVersion);
1496 f(m_model);
1497 f(m_modelName);
1498 f(m_revision);
1499 f(m_serialNumber);
1500 f(m_userData);
1501 }
1502
1504 template<typename F>
1505 void forEach(const F &f)
1506 {
1507 f(m_firmwareVersion);
1508 f(m_model);
1509 f(m_modelName);
1510 f(m_revision);
1511 f(m_serialNumber);
1512 f(m_userData);
1513 }
1514
1516 bool operator==(const CameraInfo &other) const;
1517
1519 bool operator!=(const CameraInfo &other) const;
1520
1522 std::string toString() const;
1523
1525 friend std::ostream &operator<<(std::ostream &stream, const CameraInfo &value)
1526 {
1527 return stream << value.toString();
1528 }
1529
1531 void save(const std::string &fileName) const;
1532
1534 void load(const std::string &fileName);
1535
1536 private:
1537 void setFromString(const std::string &value);
1538
1539 void setFromString(const std::string &fullPath, const std::string &value);
1540
1541 std::string getString(const std::string &fullPath) const;
1542
1543 FirmwareVersion m_firmwareVersion;
1544 Model m_model;
1545 ModelName m_modelName;
1546 Revision m_revision;
1547 SerialNumber m_serialNumber;
1548 UserData m_userData;
1549
1550 friend struct DataModel::Detail::Befriend<CameraInfo>;
1551 };
1552
1553#ifndef NO_DOC
1554 template<>
1555 struct CameraInfo::Version<1>
1556 {
1557 using Type = CameraInfo;
1558 };
1559#endif
1560
1561} // namespace Zivid
1562
1563#ifdef _MSC_VER
1564# pragma warning(pop)
1565#endif
1566
1567#ifndef NO_DOC
1568# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1569namespace std // NOLINT
1570{
1571 template<>
1572 struct tuple_size<Zivid::CameraInfo::Revision> : integral_constant<size_t, 2>
1573 {};
1574
1575 template<size_t i>
1576 struct tuple_element<i, Zivid::CameraInfo::Revision>
1577 {
1578 static_assert(i < tuple_size<Zivid::CameraInfo::Revision>::value, "Index must be less than 2");
1579
1580 using type // NOLINT
1581 = decltype(declval<Zivid::CameraInfo::Revision>().get<i>());
1582 };
1583
1584 template<>
1585 struct tuple_size<Zivid::CameraInfo::UserData> : integral_constant<size_t, 1>
1586 {};
1587
1588 template<size_t i>
1589 struct tuple_element<i, Zivid::CameraInfo::UserData>
1590 {
1591 static_assert(i < tuple_size<Zivid::CameraInfo::UserData>::value, "Index must be less than 1");
1592
1593 using type // NOLINT
1594 = decltype(declval<Zivid::CameraInfo::UserData>().get<i>());
1595 };
1596
1597 template<>
1598 struct tuple_size<Zivid::CameraInfo> : integral_constant<size_t, 6>
1599 {};
1600
1601 template<size_t i>
1602 struct tuple_element<i, Zivid::CameraInfo>
1603 {
1604 static_assert(i < tuple_size<Zivid::CameraInfo>::value, "Index must be less than 6");
1605
1606 using type // NOLINT
1607 = decltype(declval<Zivid::CameraInfo>().get<i>());
1608 };
1609
1610} // namespace std
1611# endif
1612#endif
#define ZIVID_CORE_EXPORT
Definition: CoreExport.h:101
The firmware version on the camera
Definition: CameraInfo.h:152
std::string toString() const
Get the value as string
bool operator==(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:190
FirmwareVersion(std::string value)
Constructor
Definition: CameraInfo.h:179
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for FirmwareVersion
Definition: CameraInfo.h:170
bool operator<(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:202
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:214
bool operator>(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:208
bool operator!=(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:196
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:167
FirmwareVersion()=default
Default constructor
The model name of the camera
Definition: CameraInfo.h:324
bool operator==(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:362
ModelName()=default
Default constructor
std::string toString() const
Get the value as string
ModelName(std::string value)
Constructor
Definition: CameraInfo.h:351
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:339
bool operator<(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:374
bool operator>(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:380
friend std::ostream & operator<<(std::ostream &stream, const ModelName &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:386
const std::string & value() const
Get the value
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for ModelName
Definition: CameraInfo.h:342
bool operator!=(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:368
The model of the camera
Definition: CameraInfo.h:229
static const Model zividOnePlusSmall
zividOnePlusSmall
Definition: CameraInfo.h:251
static const Model zividTwo
zividTwo
Definition: CameraInfo.h:254
std::string toString() const
Get the value as string
constexpr Model(ValueType value)
Constructor
Definition: CameraInfo.h:269
Model()=default
Default constructor
static const Model zividOnePlusMedium
zividOnePlusMedium
Definition: CameraInfo.h:252
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:280
friend std::ostream & operator<<(std::ostream &stream, const Model &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:298
static std::set< ValueType > validValues()
All valid values of Model
Definition: CameraInfo.h:257
ValueType
The type of the underlying value
Definition: CameraInfo.h:245
static const Model zividOnePlusLarge
zividOnePlusLarge
Definition: CameraInfo.h:253
bool operator!=(const Model &other) const
Comparison operator
Definition: CameraInfo.h:292
bool operator==(const Model &other) const
Comparison operator
Definition: CameraInfo.h:286
Major hardware revision number
Definition: CameraInfo.h:417
std::string toString() const
Get the value as string
bool operator!=(const Major &other) const
Comparison operator
Definition: CameraInfo.h:461
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:432
friend std::ostream & operator<<(std::ostream &stream, const Major &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:479
static constexpr Range< uint32_t > validRange()
The range of valid values for Major
Definition: CameraInfo.h:435
bool operator>(const Major &other) const
Comparison operator
Definition: CameraInfo.h:473
uint32_t value() const
Get the value
constexpr Major(uint32_t value)
Constructor
Definition: CameraInfo.h:444
bool operator<(const Major &other) const
Comparison operator
Definition: CameraInfo.h:467
Major()=default
Default constructor
bool operator==(const Major &other) const
Comparison operator
Definition: CameraInfo.h:455
Minor hardware revision number
Definition: CameraInfo.h:494
bool operator>(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:550
bool operator!=(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:538
constexpr Minor(uint32_t value)
Constructor
Definition: CameraInfo.h:521
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:509
friend std::ostream & operator<<(std::ostream &stream, const Minor &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:556
bool operator==(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:532
std::string toString() const
Get the value as string
Minor()=default
Default constructor
bool operator<(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:544
static constexpr Range< uint32_t > validRange()
The range of valid values for Minor
Definition: CameraInfo.h:512
uint32_t value() const
Get the value
The hardware revision of the camera
Definition: CameraInfo.h:401
const Major & major() const
Get Major
Definition: CameraInfo.h:673
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:655
Minor & minor()
Get Minor
Definition: CameraInfo.h:698
Revision & set(const Minor &value)
Set Minor
Definition: CameraInfo.h:704
std::tuple< CameraInfo::Revision::Major, CameraInfo::Revision::Minor > Descendants
Definition: CameraInfo.h:569
Revision & set(const Major &value)
Set Major
Definition: CameraInfo.h:685
bool operator==(const Revision &other) const
Equality operator
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:719
std::string toString() const
Get the value as string
const Minor & minor() const
Get Minor
Definition: CameraInfo.h:692
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:746
Major & major()
Get Major
Definition: CameraInfo.h:679
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:712
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:738
Revision(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:596
friend std::ostream & operator<<(std::ostream &stream, const Revision &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:762
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:623
bool operator!=(const Revision &other) const
Inequality operator
The serial number of the camera
Definition: CameraInfo.h:782
SerialNumber(std::string value)
Constructor
Definition: CameraInfo.h:809
const std::string & value() const
Get the value
bool operator==(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:820
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:797
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:844
std::string toString() const
Get the value as string
bool operator>(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:838
bool operator<(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:832
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for SerialNumber
Definition: CameraInfo.h:800
bool operator!=(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:826
The maximum number of bytes of user data that can be stored in the camera
Definition: CameraInfo.h:877
bool operator!=(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:923
bool operator>(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:935
MaxSizeBytes()=default
Default constructor
constexpr MaxSizeBytes(uint64_t value)
Constructor
Definition: CameraInfo.h:906
uint64_t value() const
Get the value
bool operator<(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:929
bool operator==(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:917
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:941
static constexpr Range< uint64_t > validRange()
The range of valid values for MaxSizeBytes
Definition: CameraInfo.h:897
uint64_t ValueType
The type of the underlying value
Definition: CameraInfo.h:894
Information about user data capabilities of the camera
Definition: CameraInfo.h:859
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:1095
MaxSizeBytes & maxSizeBytes()
Get MaxSizeBytes
Definition: CameraInfo.h:1061
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:1037
friend std::ostream & operator<<(std::ostream &stream, const UserData &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1110
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:1088
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1075
std::tuple< CameraInfo::UserData::MaxSizeBytes > Descendants
Definition: CameraInfo.h:954
bool operator!=(const UserData &other) const
Inequality operator
UserData()
Default constructor
UserData(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:980
const MaxSizeBytes & maxSizeBytes() const
Get MaxSizeBytes
Definition: CameraInfo.h:1055
UserData & set(const MaxSizeBytes &value)
Set MaxSizeBytes
Definition: CameraInfo.h:1067
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1006
Information about camera model, serial number etc.
Definition: CameraInfo.h:120
bool operator==(const CameraInfo &other) const
Equality operator
Revision & revision()
Get Revision
Definition: CameraInfo.h:1326
const ModelName & modelName() const
Get ModelName
Definition: CameraInfo.h:1301
FirmwareVersion & firmwareVersion()
Get FirmwareVersion
Definition: CameraInfo.h:1269
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1505
const UserData & userData() const
Get UserData
Definition: CameraInfo.h:1372
ModelName & modelName()
Get ModelName
Definition: CameraInfo.h:1307
bool operator!=(const CameraInfo &other) const
Inequality operator
CameraInfo & set(const Model &value)
Set Model
Definition: CameraInfo.h:1294
const CameraInfo::FirmwareVersion & get() const
Definition: CameraInfo.h:1399
const CameraInfo::Model & get() const
Definition: CameraInfo.h:1405
CameraInfo(const std::string &fileName)
Construct CameraInfo by loading from file
UserData & userData()
Get UserData
Definition: CameraInfo.h:1378
CameraInfo & set(const ModelName &value)
Set ModelName
Definition: CameraInfo.h:1313
const FirmwareVersion & firmwareVersion() const
Get FirmwareVersion
Definition: CameraInfo.h:1263
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1450
const Model & model() const
Get Model
Definition: CameraInfo.h:1282
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:1245
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:1493
Model & model()
Get Model
Definition: CameraInfo.h:1288
friend std::ostream & operator<<(std::ostream &stream, const CameraInfo &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1525
const CameraInfo::ModelName & get() const
Definition: CameraInfo.h:1411
CameraInfo & set(const UserData &value)
Set UserData
Definition: CameraInfo.h:1384
CameraInfo & set(const UserData::MaxSizeBytes &value)
Set UserData::MaxSizeBytes
Definition: CameraInfo.h:1391
CameraInfo(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:1172
const CameraInfo::UserData & get() const
Definition: CameraInfo.h:1443
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:1431
const SerialNumber & serialNumber() const
Get SerialNumber
Definition: CameraInfo.h:1353
SerialNumber & serialNumber()
Get SerialNumber
Definition: CameraInfo.h:1359
const Revision & revision() const
Get Revision
Definition: CameraInfo.h:1320
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:1135
void load(const std::string &fileName)
Load from the given file
CameraInfo & set(const FirmwareVersion &value)
Set FirmwareVersion
Definition: CameraInfo.h:1275
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:1424
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1206
CameraInfo & set(const Revision &value)
Set Revision
Definition: CameraInfo.h:1332
CameraInfo & set(const Revision::Major &value)
Set Revision::Major
Definition: CameraInfo.h:1339
CameraInfo & set(const SerialNumber &value)
Set SerialNumber
Definition: CameraInfo.h:1365
const CameraInfo::SerialNumber & get() const
Definition: CameraInfo.h:1437
const CameraInfo::Revision & get() const
Definition: CameraInfo.h:1417
std::string toString() const
Get the value as string
CameraInfo()
Default constructor
CameraInfo & set(const Revision::Minor &value)
Set Revision::Minor
Definition: CameraInfo.h:1346
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