Zivid C++ API 2.6.1+6cec8609-3
Defining the Future of 3D Machine Vision
CameraState.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{ "CameraState" };
131
133 static constexpr const char *description{
134 R"description(Information about camera connection state, temperatures, etc.)description"
135 };
136
137 static constexpr size_t version{ 2 };
138
139#ifndef NO_DOC
140 template<size_t>
141 struct Version;
142
143 using LatestVersion = Zivid::CameraState;
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{ 'c', 's', 't' };
148
149#endif
150
153 {
154 public:
157
159 static constexpr const char *path{ "Available" };
160
162 static constexpr const char *name{ "Available" };
163
165 static constexpr const char *description{
166 R"description(Flag if camera is physically connected to the computer, but not connected in software. When the camera is in this state, you can call connect().)description"
167 };
168
170 using ValueType = bool;
171 static const Available yes;
172 static const Available no;
173
175 static std::set<bool> validValues()
176 {
177 return { false, true };
178 }
179
181 Available() = default;
182
184 explicit constexpr Available(bool value)
185 : m_value{ value }
186 {}
187
189 bool value() const;
190
192 std::string toString() const;
193
195 explicit operator bool() const
196 {
197 return m_value;
198 }
199
201 bool operator==(const Available &other) const
202 {
203 return m_value == other.m_value;
204 }
205
207 bool operator!=(const Available &other) const
208 {
209 return m_value != other.m_value;
210 }
211
213 friend std::ostream &operator<<(std::ostream &stream, const Available &value)
214 {
215 return stream << value.toString();
216 }
217
218 private:
219 void setFromString(const std::string &value);
220
221 bool m_value{ false };
222
223 friend struct DataModel::Detail::Befriend<Available>;
224 };
225
228 {
229 public:
232
234 static constexpr const char *path{ "Connected" };
235
237 static constexpr const char *name{ "Connected" };
238
240 static constexpr const char *description{
241 R"description(Flag if camera is connected in software)description"
242 };
243
245 using ValueType = bool;
246 static const Connected yes;
247 static const Connected no;
248
250 static std::set<bool> validValues()
251 {
252 return { false, true };
253 }
254
256 Connected() = default;
257
259 explicit constexpr Connected(bool value)
260 : m_value{ value }
261 {}
262
264 bool value() const;
265
267 std::string toString() const;
268
270 explicit operator bool() const
271 {
272 return m_value;
273 }
274
276 bool operator==(const Connected &other) const
277 {
278 return m_value == other.m_value;
279 }
280
282 bool operator!=(const Connected &other) const
283 {
284 return m_value != other.m_value;
285 }
286
288 friend std::ostream &operator<<(std::ostream &stream, const Connected &value)
289 {
290 return stream << value.toString();
291 }
292
293 private:
294 void setFromString(const std::string &value);
295
296 bool m_value{ false };
297
298 friend struct DataModel::Detail::Befriend<Connected>;
299 };
300
303 {
304 public:
307
309 static constexpr const char *path{ "Temperature" };
310
312 static constexpr const char *name{ "Temperature" };
313
315 static constexpr const char *description{ R"description(Current temperature(s))description" };
316
319 {
320 public:
323
325 static constexpr const char *path{ "Temperature/DMD" };
326
328 static constexpr const char *name{ "DMD" };
329
331 static constexpr const char *description{ R"description(DMD temperature)description" };
332
334 using ValueType = double;
335
337 static constexpr Range<double> validRange()
338 {
339 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
340 }
341
343 DMD() = default;
344
346 explicit constexpr DMD(double value)
347 : m_value{ value }
348 {}
349
351 double value() const;
352
354 std::string toString() const;
355
357 bool operator==(const DMD &other) const
358 {
359 return m_value == other.m_value;
360 }
361
363 bool operator!=(const DMD &other) const
364 {
365 return m_value != other.m_value;
366 }
367
369 bool operator<(const DMD &other) const
370 {
371 return m_value < other.m_value;
372 }
373
375 bool operator>(const DMD &other) const
376 {
377 return m_value > other.m_value;
378 }
379
381 friend std::ostream &operator<<(std::ostream &stream, const DMD &value)
382 {
383 return stream << value.toString();
384 }
385
386 private:
387 void setFromString(const std::string &value);
388
389 double m_value{ 0.0 };
390
391 friend struct DataModel::Detail::Befriend<DMD>;
392 };
393
396 {
397 public:
400
402 static constexpr const char *path{ "Temperature/General" };
403
405 static constexpr const char *name{ "General" };
406
408 static constexpr const char *description{ R"description(General temperature)description" };
409
411 using ValueType = double;
412
414 static constexpr Range<double> validRange()
415 {
416 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
417 }
418
420 General() = default;
421
423 explicit constexpr General(double value)
424 : m_value{ value }
425 {}
426
428 double value() const;
429
431 std::string toString() const;
432
434 bool operator==(const General &other) const
435 {
436 return m_value == other.m_value;
437 }
438
440 bool operator!=(const General &other) const
441 {
442 return m_value != other.m_value;
443 }
444
446 bool operator<(const General &other) const
447 {
448 return m_value < other.m_value;
449 }
450
452 bool operator>(const General &other) const
453 {
454 return m_value > other.m_value;
455 }
456
458 friend std::ostream &operator<<(std::ostream &stream, const General &value)
459 {
460 return stream << value.toString();
461 }
462
463 private:
464 void setFromString(const std::string &value);
465
466 double m_value{ 0.0 };
467
468 friend struct DataModel::Detail::Befriend<General>;
469 };
470
473 {
474 public:
477
479 static constexpr const char *path{ "Temperature/LED" };
480
482 static constexpr const char *name{ "LED" };
483
485 static constexpr const char *description{ R"description(LED temperature)description" };
486
488 using ValueType = double;
489
491 static constexpr Range<double> validRange()
492 {
493 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
494 }
495
497 LED() = default;
498
500 explicit constexpr LED(double value)
501 : m_value{ value }
502 {}
503
505 double value() const;
506
508 std::string toString() const;
509
511 bool operator==(const LED &other) const
512 {
513 return m_value == other.m_value;
514 }
515
517 bool operator!=(const LED &other) const
518 {
519 return m_value != other.m_value;
520 }
521
523 bool operator<(const LED &other) const
524 {
525 return m_value < other.m_value;
526 }
527
529 bool operator>(const LED &other) const
530 {
531 return m_value > other.m_value;
532 }
533
535 friend std::ostream &operator<<(std::ostream &stream, const LED &value)
536 {
537 return stream << value.toString();
538 }
539
540 private:
541 void setFromString(const std::string &value);
542
543 double m_value{ 0.0 };
544
545 friend struct DataModel::Detail::Befriend<LED>;
546 };
547
550 {
551 public:
554
556 static constexpr const char *path{ "Temperature/Lens" };
557
559 static constexpr const char *name{ "Lens" };
560
562 static constexpr const char *description{ R"description(Lens temperature)description" };
563
565 using ValueType = double;
566
568 static constexpr Range<double> validRange()
569 {
570 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
571 }
572
574 Lens() = default;
575
577 explicit constexpr Lens(double value)
578 : m_value{ value }
579 {}
580
582 double value() const;
583
585 std::string toString() const;
586
588 bool operator==(const Lens &other) const
589 {
590 return m_value == other.m_value;
591 }
592
594 bool operator!=(const Lens &other) const
595 {
596 return m_value != other.m_value;
597 }
598
600 bool operator<(const Lens &other) const
601 {
602 return m_value < other.m_value;
603 }
604
606 bool operator>(const Lens &other) const
607 {
608 return m_value > other.m_value;
609 }
610
612 friend std::ostream &operator<<(std::ostream &stream, const Lens &value)
613 {
614 return stream << value.toString();
615 }
616
617 private:
618 void setFromString(const std::string &value);
619
620 double m_value{ 0.0 };
621
622 friend struct DataModel::Detail::Befriend<Lens>;
623 };
624
627 {
628 public:
631
633 static constexpr const char *path{ "Temperature/PCB" };
634
636 static constexpr const char *name{ "PCB" };
637
639 static constexpr const char *description{ R"description(PCB temperature)description" };
640
642 using ValueType = double;
643
645 static constexpr Range<double> validRange()
646 {
647 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
648 }
649
651 PCB() = default;
652
654 explicit constexpr PCB(double value)
655 : m_value{ value }
656 {}
657
659 double value() const;
660
662 std::string toString() const;
663
665 bool operator==(const PCB &other) const
666 {
667 return m_value == other.m_value;
668 }
669
671 bool operator!=(const PCB &other) const
672 {
673 return m_value != other.m_value;
674 }
675
677 bool operator<(const PCB &other) const
678 {
679 return m_value < other.m_value;
680 }
681
683 bool operator>(const PCB &other) const
684 {
685 return m_value > other.m_value;
686 }
687
689 friend std::ostream &operator<<(std::ostream &stream, const PCB &value)
690 {
691 return stream << value.toString();
692 }
693
694 private:
695 void setFromString(const std::string &value);
696
697 double m_value{ 0.0 };
698
699 friend struct DataModel::Detail::Befriend<PCB>;
700 };
701
702 using Descendants = std::tuple<
708
711
727#ifndef NO_DOC
728 template<
729 typename... Args,
730 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
731 typename std::enable_if<
732 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::
733 value,
734 int>::type = 0>
735#else
736 template<typename... Args>
737#endif
738 explicit Temperature(Args &&...args)
739 {
740 using namespace Zivid::Detail::TypeTraits;
741
742 static_assert(
743 AllArgsDecayedAreUnique<Args...>::value,
744 "Found duplicate types among the arguments passed to Temperature(...). "
745 "Types should be listed at most once.");
746
747 set(std::forward<Args>(args)...);
748 }
749
764#ifndef NO_DOC
765 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
766#else
767 template<typename... Args>
768#endif
769 void set(Args &&...args)
770 {
771 using namespace Zivid::Detail::TypeTraits;
772
773 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
774 static_assert(
775 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
776
777 static_assert(
778 AllArgsDecayedAreUnique<Args...>::value,
779 "Found duplicate types among the arguments passed to set(...). "
780 "Types should be listed at most once.");
781
782 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
783 }
784
800#ifndef NO_DOC
801 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
802#else
803 template<typename... Args>
804#endif
805 Temperature copyWith(Args &&...args) const
806 {
807 using namespace Zivid::Detail::TypeTraits;
808
809 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
810 static_assert(
811 AllArgsAreDescendantNodes::value,
812 "All arguments passed to copyWith(...) must be descendant nodes.");
813
814 static_assert(
815 AllArgsDecayedAreUnique<Args...>::value,
816 "Found duplicate types among the arguments passed to copyWith(...). "
817 "Types should be listed at most once.");
818
819 auto copy{ *this };
820 copy.set(std::forward<Args>(args)...);
821 return copy;
822 }
823
825 const DMD &dmd() const
826 {
827 return m_dmd;
828 }
829
832 {
833 return m_dmd;
834 }
835
837 Temperature &set(const DMD &value)
838 {
839 m_dmd = value;
840 return *this;
841 }
842
844 const General &general() const
845 {
846 return m_general;
847 }
848
851 {
852 return m_general;
853 }
854
856 Temperature &set(const General &value)
857 {
858 m_general = value;
859 return *this;
860 }
861
863 const LED &led() const
864 {
865 return m_led;
866 }
867
870 {
871 return m_led;
872 }
873
875 Temperature &set(const LED &value)
876 {
877 m_led = value;
878 return *this;
879 }
880
882 const Lens &lens() const
883 {
884 return m_lens;
885 }
886
889 {
890 return m_lens;
891 }
892
894 Temperature &set(const Lens &value)
895 {
896 m_lens = value;
897 return *this;
898 }
899
901 const PCB &pcb() const
902 {
903 return m_pcb;
904 }
905
908 {
909 return m_pcb;
910 }
911
913 Temperature &set(const PCB &value)
914 {
915 m_pcb = value;
916 return *this;
917 }
918
919 template<
920 typename T,
921 typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
923 {
924 return m_dmd;
925 }
926
927 template<
928 typename T,
929 typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
931 {
932 return m_general;
933 }
934
935 template<
936 typename T,
937 typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
939 {
940 return m_led;
941 }
942
943 template<
944 typename T,
945 typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
947 {
948 return m_lens;
949 }
950
951 template<
952 typename T,
953 typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
955 {
956 return m_pcb;
957 }
958
959 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
961 {
962 return m_dmd;
963 }
964
965 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
967 {
968 return m_general;
969 }
970
971 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
973 {
974 return m_led;
975 }
976
977 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
979 {
980 return m_lens;
981 }
982
983 template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
985 {
986 return m_pcb;
987 }
988
990 template<typename F>
991 void forEach(const F &f) const
992 {
993 f(m_dmd);
994 f(m_general);
995 f(m_led);
996 f(m_lens);
997 f(m_pcb);
998 }
999
1001 template<typename F>
1002 void forEach(const F &f)
1003 {
1004 f(m_dmd);
1005 f(m_general);
1006 f(m_led);
1007 f(m_lens);
1008 f(m_pcb);
1009 }
1010
1012 bool operator==(const Temperature &other) const;
1013
1015 bool operator!=(const Temperature &other) const;
1016
1018 std::string toString() const;
1019
1021 friend std::ostream &operator<<(std::ostream &stream, const Temperature &value)
1022 {
1023 return stream << value.toString();
1024 }
1025
1026 private:
1027 void setFromString(const std::string &value);
1028
1029 void setFromString(const std::string &fullPath, const std::string &value);
1030
1031 std::string getString(const std::string &fullPath) const;
1032
1033 DMD m_dmd;
1034 General m_general;
1035 LED m_led;
1036 Lens m_lens;
1037 PCB m_pcb;
1038
1039 friend struct DataModel::Detail::Befriend<Temperature>;
1040 };
1041
1042 using Descendants = std::tuple<
1051
1054
1056 explicit CameraState(const std::string &fileName);
1057
1076#ifndef NO_DOC
1077 template<
1078 typename... Args,
1079 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1080 typename std::enable_if<
1081 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1082 int>::type = 0>
1083#else
1084 template<typename... Args>
1085#endif
1086 explicit CameraState(Args &&...args)
1087 {
1088 using namespace Zivid::Detail::TypeTraits;
1089
1090 static_assert(
1091 AllArgsDecayedAreUnique<Args...>::value,
1092 "Found duplicate types among the arguments passed to CameraState(...). "
1093 "Types should be listed at most once.");
1094
1095 set(std::forward<Args>(args)...);
1096 }
1097
1115#ifndef NO_DOC
1116 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1117#else
1118 template<typename... Args>
1119#endif
1120 void set(Args &&...args)
1121 {
1122 using namespace Zivid::Detail::TypeTraits;
1123
1124 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1125 static_assert(
1126 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
1127
1128 static_assert(
1129 AllArgsDecayedAreUnique<Args...>::value,
1130 "Found duplicate types among the arguments passed to set(...). "
1131 "Types should be listed at most once.");
1132
1133 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1134 }
1135
1154#ifndef NO_DOC
1155 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1156#else
1157 template<typename... Args>
1158#endif
1159 CameraState copyWith(Args &&...args) const
1160 {
1161 using namespace Zivid::Detail::TypeTraits;
1162
1163 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1164 static_assert(
1165 AllArgsAreDescendantNodes::value, "All arguments passed to copyWith(...) must be descendant nodes.");
1166
1167 static_assert(
1168 AllArgsDecayedAreUnique<Args...>::value,
1169 "Found duplicate types among the arguments passed to copyWith(...). "
1170 "Types should be listed at most once.");
1171
1172 auto copy{ *this };
1173 copy.set(std::forward<Args>(args)...);
1174 return copy;
1175 }
1176
1178 const Available &isAvailable() const
1179 {
1180 return m_available;
1181 }
1182
1185 {
1186 return m_available;
1187 }
1188
1191 {
1192 m_available = value;
1193 return *this;
1194 }
1195
1197 const Connected &isConnected() const
1198 {
1199 return m_connected;
1200 }
1201
1204 {
1205 return m_connected;
1206 }
1207
1210 {
1211 m_connected = value;
1212 return *this;
1213 }
1214
1217 {
1218 return m_temperature;
1219 }
1220
1223 {
1224 return m_temperature;
1225 }
1226
1229 {
1230 m_temperature = value;
1231 return *this;
1232 }
1233
1236 {
1237 m_temperature.set(value);
1238 return *this;
1239 }
1240
1243 {
1244 m_temperature.set(value);
1245 return *this;
1246 }
1247
1250 {
1251 m_temperature.set(value);
1252 return *this;
1253 }
1254
1257 {
1258 m_temperature.set(value);
1259 return *this;
1260 }
1261
1264 {
1265 m_temperature.set(value);
1266 return *this;
1267 }
1268
1269 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Available>::value, int>::type = 0>
1271 {
1272 return m_available;
1273 }
1274
1275 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Connected>::value, int>::type = 0>
1277 {
1278 return m_connected;
1279 }
1280
1281 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Temperature>::value, int>::type = 0>
1283 {
1284 return m_temperature;
1285 }
1286
1287 template<
1288 typename T,
1289 typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
1291 {
1292 return m_temperature.get<CameraState::Temperature::DMD>();
1293 }
1294
1295 template<
1296 typename T,
1297 typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
1299 {
1300 return m_temperature.get<CameraState::Temperature::General>();
1301 }
1302
1303 template<
1304 typename T,
1305 typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
1307 {
1308 return m_temperature.get<CameraState::Temperature::LED>();
1309 }
1310
1311 template<
1312 typename T,
1313 typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
1315 {
1316 return m_temperature.get<CameraState::Temperature::Lens>();
1317 }
1318
1319 template<
1320 typename T,
1321 typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
1323 {
1324 return m_temperature.get<CameraState::Temperature::PCB>();
1325 }
1326
1327 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1329 {
1330 return m_available;
1331 }
1332
1333 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1335 {
1336 return m_connected;
1337 }
1338
1339 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1341 {
1342 return m_temperature;
1343 }
1344
1346 template<typename F>
1347 void forEach(const F &f) const
1348 {
1349 f(m_available);
1350 f(m_connected);
1351 f(m_temperature);
1352 }
1353
1355 template<typename F>
1356 void forEach(const F &f)
1357 {
1358 f(m_available);
1359 f(m_connected);
1360 f(m_temperature);
1361 }
1362
1364 bool operator==(const CameraState &other) const;
1365
1367 bool operator!=(const CameraState &other) const;
1368
1370 std::string toString() const;
1371
1373 friend std::ostream &operator<<(std::ostream &stream, const CameraState &value)
1374 {
1375 return stream << value.toString();
1376 }
1377
1379 void save(const std::string &fileName) const;
1380
1382 void load(const std::string &fileName);
1383
1384 private:
1385 void setFromString(const std::string &value);
1386
1387 void setFromString(const std::string &fullPath, const std::string &value);
1388
1389 std::string getString(const std::string &fullPath) const;
1390
1391 Available m_available;
1392 Connected m_connected;
1393 Temperature m_temperature;
1394
1395 friend struct DataModel::Detail::Befriend<CameraState>;
1396 };
1397
1398#ifndef NO_DOC
1399 template<>
1400 struct CameraState::Version<2>
1401 {
1402 using Type = CameraState;
1403 };
1404#endif
1405
1406} // namespace Zivid
1407
1408#ifdef _MSC_VER
1409# pragma warning(pop)
1410#endif
1411
1412#ifndef NO_DOC
1413# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1414namespace std // NOLINT
1415{
1416
1417 template<>
1418 struct tuple_size<Zivid::CameraState::Temperature> : integral_constant<size_t, 5>
1419 {};
1420
1421 template<size_t i>
1422 struct tuple_element<i, Zivid::CameraState::Temperature>
1423 {
1424 static_assert(i < tuple_size<Zivid::CameraState::Temperature>::value, "Index must be less than 5");
1425
1426 using type // NOLINT
1427 = decltype(declval<Zivid::CameraState::Temperature>().get<i>());
1428 };
1429
1430 template<>
1431 struct tuple_size<Zivid::CameraState> : integral_constant<size_t, 3>
1432 {};
1433
1434 template<size_t i>
1435 struct tuple_element<i, Zivid::CameraState>
1436 {
1437 static_assert(i < tuple_size<Zivid::CameraState>::value, "Index must be less than 3");
1438
1439 using type // NOLINT
1440 = decltype(declval<Zivid::CameraState>().get<i>());
1441 };
1442
1443} // namespace std
1444# endif
1445#endif
1446
1447// If we have access to the DataModel library, automatically include internal DataModel
1448// header. This header is necessary for serialization and deserialization.
1449#if defined(__has_include) && !defined(NO_DOC)
1450# if __has_include("Zivid/CameraStateInternal.h") && __has_include("Zivid/DataModelSerializationMetaData.h")
1451# include "Zivid/CameraStateInternal.h"
1452# endif
1453#endif
#define ZIVID_CORE_EXPORT
Definition: CoreExport.h:101
Flag if camera is physically connected to the computer, but not connected in software....
Definition: CameraState.h:153
static std::set< bool > validValues()
All valid values of Available
Definition: CameraState.h:175
static const Available no
Off/disabled.
Definition: CameraState.h:172
bool operator==(const Available &other) const
Comparison operator
Definition: CameraState.h:201
std::string toString() const
Get the value as string
bool ValueType
The type of the underlying value
Definition: CameraState.h:170
static const Available yes
On/enabled.
Definition: CameraState.h:171
friend std::ostream & operator<<(std::ostream &stream, const Available &value)
Operator to serialize the value to a stream
Definition: CameraState.h:213
bool operator!=(const Available &other) const
Comparison operator
Definition: CameraState.h:207
constexpr Available(bool value)
Constructor
Definition: CameraState.h:184
bool value() const
Get the value
Available()=default
Default constructor
Flag if camera is connected in software
Definition: CameraState.h:228
Connected()=default
Default constructor
static const Connected yes
On/enabled.
Definition: CameraState.h:246
static const Connected no
Off/disabled.
Definition: CameraState.h:247
bool operator!=(const Connected &other) const
Comparison operator
Definition: CameraState.h:282
constexpr Connected(bool value)
Constructor
Definition: CameraState.h:259
bool value() const
Get the value
std::string toString() const
Get the value as string
friend std::ostream & operator<<(std::ostream &stream, const Connected &value)
Operator to serialize the value to a stream
Definition: CameraState.h:288
static std::set< bool > validValues()
All valid values of Connected
Definition: CameraState.h:250
bool operator==(const Connected &other) const
Comparison operator
Definition: CameraState.h:276
bool ValueType
The type of the underlying value
Definition: CameraState.h:245
DMD temperature
Definition: CameraState.h:319
bool operator>(const DMD &other) const
Comparison operator
Definition: CameraState.h:375
std::string toString() const
Get the value as string
double value() const
Get the value
bool operator!=(const DMD &other) const
Comparison operator
Definition: CameraState.h:363
bool operator<(const DMD &other) const
Comparison operator
Definition: CameraState.h:369
double ValueType
The type of the underlying value
Definition: CameraState.h:334
friend std::ostream & operator<<(std::ostream &stream, const DMD &value)
Operator to serialize the value to a stream
Definition: CameraState.h:381
constexpr DMD(double value)
Constructor
Definition: CameraState.h:346
bool operator==(const DMD &other) const
Comparison operator
Definition: CameraState.h:357
static constexpr Range< double > validRange()
The range of valid values for DMD
Definition: CameraState.h:337
DMD()=default
Default constructor
General temperature
Definition: CameraState.h:396
double ValueType
The type of the underlying value
Definition: CameraState.h:411
std::string toString() const
Get the value as string
double value() const
Get the value
bool operator<(const General &other) const
Comparison operator
Definition: CameraState.h:446
constexpr General(double value)
Constructor
Definition: CameraState.h:423
static constexpr Range< double > validRange()
The range of valid values for General
Definition: CameraState.h:414
bool operator==(const General &other) const
Comparison operator
Definition: CameraState.h:434
General()=default
Default constructor
bool operator!=(const General &other) const
Comparison operator
Definition: CameraState.h:440
bool operator>(const General &other) const
Comparison operator
Definition: CameraState.h:452
friend std::ostream & operator<<(std::ostream &stream, const General &value)
Operator to serialize the value to a stream
Definition: CameraState.h:458
LED temperature
Definition: CameraState.h:473
std::string toString() const
Get the value as string
bool operator<(const LED &other) const
Comparison operator
Definition: CameraState.h:523
double value() const
Get the value
LED()=default
Default constructor
constexpr LED(double value)
Constructor
Definition: CameraState.h:500
friend std::ostream & operator<<(std::ostream &stream, const LED &value)
Operator to serialize the value to a stream
Definition: CameraState.h:535
bool operator!=(const LED &other) const
Comparison operator
Definition: CameraState.h:517
bool operator==(const LED &other) const
Comparison operator
Definition: CameraState.h:511
bool operator>(const LED &other) const
Comparison operator
Definition: CameraState.h:529
static constexpr Range< double > validRange()
The range of valid values for LED
Definition: CameraState.h:491
double ValueType
The type of the underlying value
Definition: CameraState.h:488
Lens temperature
Definition: CameraState.h:550
double ValueType
The type of the underlying value
Definition: CameraState.h:565
bool operator==(const Lens &other) const
Comparison operator
Definition: CameraState.h:588
Lens()=default
Default constructor
double value() const
Get the value
bool operator>(const Lens &other) const
Comparison operator
Definition: CameraState.h:606
bool operator!=(const Lens &other) const
Comparison operator
Definition: CameraState.h:594
std::string toString() const
Get the value as string
constexpr Lens(double value)
Constructor
Definition: CameraState.h:577
static constexpr Range< double > validRange()
The range of valid values for Lens
Definition: CameraState.h:568
bool operator<(const Lens &other) const
Comparison operator
Definition: CameraState.h:600
friend std::ostream & operator<<(std::ostream &stream, const Lens &value)
Operator to serialize the value to a stream
Definition: CameraState.h:612
PCB temperature
Definition: CameraState.h:627
bool operator!=(const PCB &other) const
Comparison operator
Definition: CameraState.h:671
constexpr PCB(double value)
Constructor
Definition: CameraState.h:654
static constexpr Range< double > validRange()
The range of valid values for PCB
Definition: CameraState.h:645
PCB()=default
Default constructor
friend std::ostream & operator<<(std::ostream &stream, const PCB &value)
Operator to serialize the value to a stream
Definition: CameraState.h:689
bool operator==(const PCB &other) const
Comparison operator
Definition: CameraState.h:665
double value() const
Get the value
bool operator>(const PCB &other) const
Comparison operator
Definition: CameraState.h:683
double ValueType
The type of the underlying value
Definition: CameraState.h:642
std::string toString() const
Get the value as string
bool operator<(const PCB &other) const
Comparison operator
Definition: CameraState.h:677
Current temperature(s)
Definition: CameraState.h:303
DMD & dmd()
Get DMD
Definition: CameraState.h:831
Temperature & set(const General &value)
Set General
Definition: CameraState.h:856
const PCB & pcb() const
Get PCB
Definition: CameraState.h:901
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:946
Temperature & set(const Lens &value)
Set Lens
Definition: CameraState.h:894
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:922
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:954
const CameraState::Temperature::General & get() const
Definition: CameraState.h:930
Temperature & set(const PCB &value)
Set PCB
Definition: CameraState.h:913
const General & general() const
Get General
Definition: CameraState.h:844
bool operator!=(const Temperature &other) const
Inequality operator
const LED & led() const
Get LED
Definition: CameraState.h:863
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:991
Temperature(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:738
friend std::ostream & operator<<(std::ostream &stream, const Temperature &value)
Operator to send the value as string to a stream
Definition: CameraState.h:1021
std::tuple< CameraState::Temperature::DMD, CameraState::Temperature::General, CameraState::Temperature::LED, CameraState::Temperature::Lens, CameraState::Temperature::PCB > Descendants
Definition: CameraState.h:707
Temperature & set(const LED &value)
Set LED
Definition: CameraState.h:875
std::string toString() const
Get the value as string
LED & led()
Get LED
Definition: CameraState.h:869
bool operator==(const Temperature &other) const
Equality operator
const Lens & lens() const
Get Lens
Definition: CameraState.h:882
Temperature copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraState.h:805
General & general()
Get General
Definition: CameraState.h:850
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:769
const DMD & dmd() const
Get DMD
Definition: CameraState.h:825
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:1002
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:938
Lens & lens()
Get Lens
Definition: CameraState.h:888
Temperature()
Default constructor
Temperature & set(const DMD &value)
Set DMD
Definition: CameraState.h:837
PCB & pcb()
Get PCB
Definition: CameraState.h:907
Information about camera connection state, temperatures, etc.
Definition: CameraState.h:121
const Temperature & temperature() const
Get Temperature
Definition: CameraState.h:1216
CameraState copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraState.h:1159
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:1314
void load(const std::string &fileName)
Load from the given file
CameraState(const std::string &fileName)
Construct CameraState by loading from file
CameraState & set(const Temperature &value)
Set Temperature
Definition: CameraState.h:1228
const CameraState::Connected & get() const
Definition: CameraState.h:1276
Temperature & temperature()
Get Temperature
Definition: CameraState.h:1222
const CameraState::Temperature::General & get() const
Definition: CameraState.h:1298
std::string toString() const
Get the value as string
const CameraState::Available & get() const
Definition: CameraState.h:1270
std::tuple< CameraState::Available, CameraState::Connected, CameraState::Temperature, CameraState::Temperature::DMD, CameraState::Temperature::General, CameraState::Temperature::LED, CameraState::Temperature::Lens, CameraState::Temperature::PCB > Descendants
Definition: CameraState.h:1050
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:1356
void save(const std::string &fileName) const
Save to the given file
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:1322
CameraState & set(const Temperature::PCB &value)
Set Temperature::PCB
Definition: CameraState.h:1263
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:1306
CameraState & set(const Temperature::General &value)
Set Temperature::General
Definition: CameraState.h:1242
friend std::ostream & operator<<(std::ostream &stream, const CameraState &value)
Operator to send the value as string to a stream
Definition: CameraState.h:1373
bool operator!=(const CameraState &other) const
Inequality operator
const Available & isAvailable() const
Get Available
Definition: CameraState.h:1178
Connected & isConnected()
Get Connected
Definition: CameraState.h:1203
CameraState & set(const Temperature::Lens &value)
Set Temperature::Lens
Definition: CameraState.h:1256
CameraState & set(const Available &value)
Set Available
Definition: CameraState.h:1190
CameraState & set(const Temperature::DMD &value)
Set Temperature::DMD
Definition: CameraState.h:1235
bool operator==(const CameraState &other) const
Equality operator
CameraState()
Default constructor
CameraState & set(const Connected &value)
Set Connected
Definition: CameraState.h:1209
CameraState(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:1086
const CameraState::Temperature & get() const
Definition: CameraState.h:1282
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:1347
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:1120
CameraState & set(const Temperature::LED &value)
Set Temperature::LED
Definition: CameraState.h:1249
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:1290
const Connected & isConnected() const
Get Connected
Definition: CameraState.h:1197
Available & isAvailable()
Get Available
Definition: CameraState.h:1184
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