Zivid C++ API 2.9.0+4dbba385-1
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-2023 (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
120
121 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
123 {
124 public:
127
129 static constexpr const char *path{ "" };
130
132 static constexpr const char *name{ "CameraState" };
133
135 static constexpr const char *description{
136 R"description(Information about camera connection state, temperatures, etc.)description"
137 };
138
139 static constexpr size_t version{ 2 };
140
141#ifndef NO_DOC
142 template<size_t>
143 struct Version;
144
145 using LatestVersion = Zivid::CameraState;
146
147 // Short identifier. This value is not guaranteed to be universally unique
148 // Todo(ZIVID-2808): Move this to internal DataModelExt header
149 static constexpr std::array<uint8_t, 3> binaryId{ 'c', 's', 't' };
150
151#endif
152
154
155 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
157 {
158 public:
161
163 static constexpr const char *path{ "Available" };
164
166 static constexpr const char *name{ "Available" };
167
169 static constexpr const char *description{
170 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"
171 };
172
174 using ValueType = bool;
175 static const Available yes;
176 static const Available no;
177
179 static std::set<bool> validValues()
180 {
181 return { false, true };
182 }
183
185 Available() = default;
186
188 explicit constexpr Available(bool value)
189 : m_value{ value }
190 {}
191
193 bool value() const;
194
196 std::string toString() const;
197
199 explicit operator bool() const
200 {
201 return m_value;
202 }
203
205 bool operator==(const Available &other) const
206 {
207 return m_value == other.m_value;
208 }
209
211 bool operator!=(const Available &other) const
212 {
213 return m_value != other.m_value;
214 }
215
217 friend std::ostream &operator<<(std::ostream &stream, const Available &value)
218 {
219 return stream << value.toString();
220 }
221
222 private:
223 void setFromString(const std::string &value);
224
225 bool m_value{ false };
226
227 friend struct DataModel::Detail::Befriend<Available>;
228 };
229
231
232 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
234 {
235 public:
238
240 static constexpr const char *path{ "Connected" };
241
243 static constexpr const char *name{ "Connected" };
244
246 static constexpr const char *description{
247 R"description(Flag if camera is connected in software)description"
248 };
249
251 using ValueType = bool;
252 static const Connected yes;
253 static const Connected no;
254
256 static std::set<bool> validValues()
257 {
258 return { false, true };
259 }
260
262 Connected() = default;
263
265 explicit constexpr Connected(bool value)
266 : m_value{ value }
267 {}
268
270 bool value() const;
271
273 std::string toString() const;
274
276 explicit operator bool() const
277 {
278 return m_value;
279 }
280
282 bool operator==(const Connected &other) const
283 {
284 return m_value == other.m_value;
285 }
286
288 bool operator!=(const Connected &other) const
289 {
290 return m_value != other.m_value;
291 }
292
294 friend std::ostream &operator<<(std::ostream &stream, const Connected &value)
295 {
296 return stream << value.toString();
297 }
298
299 private:
300 void setFromString(const std::string &value);
301
302 bool m_value{ false };
303
304 friend struct DataModel::Detail::Befriend<Connected>;
305 };
306
308
309 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
311 {
312 public:
315
317 static constexpr const char *path{ "Temperature" };
318
320 static constexpr const char *name{ "Temperature" };
321
323 static constexpr const char *description{ R"description(Current temperature(s))description" };
324
326
327 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
329 {
330 public:
333
335 static constexpr const char *path{ "Temperature/DMD" };
336
338 static constexpr const char *name{ "DMD" };
339
341 static constexpr const char *description{ R"description(DMD temperature)description" };
342
344 using ValueType = double;
345
347 static constexpr Range<double> validRange()
348 {
349 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
350 }
351
353 DMD() = default;
354
356 explicit constexpr DMD(double value)
357 : m_value{ value }
358 {}
359
361 double value() const;
362
364 std::string toString() const;
365
367 bool operator==(const DMD &other) const
368 {
369 return m_value == other.m_value;
370 }
371
373 bool operator!=(const DMD &other) const
374 {
375 return m_value != other.m_value;
376 }
377
379 bool operator<(const DMD &other) const
380 {
381 return m_value < other.m_value;
382 }
383
385 bool operator>(const DMD &other) const
386 {
387 return m_value > other.m_value;
388 }
389
391 bool operator<=(const DMD &other) const
392 {
393 return m_value <= other.m_value;
394 }
395
397 bool operator>=(const DMD &other) const
398 {
399 return m_value >= other.m_value;
400 }
401
403 friend std::ostream &operator<<(std::ostream &stream, const DMD &value)
404 {
405 return stream << value.toString();
406 }
407
408 private:
409 void setFromString(const std::string &value);
410
411 double m_value{ 0.0 };
412
413 friend struct DataModel::Detail::Befriend<DMD>;
414 };
415
417
418 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
420 {
421 public:
424
426 static constexpr const char *path{ "Temperature/General" };
427
429 static constexpr const char *name{ "General" };
430
432 static constexpr const char *description{ R"description(General temperature)description" };
433
435 using ValueType = double;
436
438 static constexpr Range<double> validRange()
439 {
440 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
441 }
442
444 General() = default;
445
447 explicit constexpr General(double value)
448 : m_value{ value }
449 {}
450
452 double value() const;
453
455 std::string toString() const;
456
458 bool operator==(const General &other) const
459 {
460 return m_value == other.m_value;
461 }
462
464 bool operator!=(const General &other) const
465 {
466 return m_value != other.m_value;
467 }
468
470 bool operator<(const General &other) const
471 {
472 return m_value < other.m_value;
473 }
474
476 bool operator>(const General &other) const
477 {
478 return m_value > other.m_value;
479 }
480
482 bool operator<=(const General &other) const
483 {
484 return m_value <= other.m_value;
485 }
486
488 bool operator>=(const General &other) const
489 {
490 return m_value >= other.m_value;
491 }
492
494 friend std::ostream &operator<<(std::ostream &stream, const General &value)
495 {
496 return stream << value.toString();
497 }
498
499 private:
500 void setFromString(const std::string &value);
501
502 double m_value{ 0.0 };
503
504 friend struct DataModel::Detail::Befriend<General>;
505 };
506
508
509 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
511 {
512 public:
515
517 static constexpr const char *path{ "Temperature/LED" };
518
520 static constexpr const char *name{ "LED" };
521
523 static constexpr const char *description{ R"description(LED temperature)description" };
524
526 using ValueType = double;
527
529 static constexpr Range<double> validRange()
530 {
531 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
532 }
533
535 LED() = default;
536
538 explicit constexpr LED(double value)
539 : m_value{ value }
540 {}
541
543 double value() const;
544
546 std::string toString() const;
547
549 bool operator==(const LED &other) const
550 {
551 return m_value == other.m_value;
552 }
553
555 bool operator!=(const LED &other) const
556 {
557 return m_value != other.m_value;
558 }
559
561 bool operator<(const LED &other) const
562 {
563 return m_value < other.m_value;
564 }
565
567 bool operator>(const LED &other) const
568 {
569 return m_value > other.m_value;
570 }
571
573 bool operator<=(const LED &other) const
574 {
575 return m_value <= other.m_value;
576 }
577
579 bool operator>=(const LED &other) const
580 {
581 return m_value >= other.m_value;
582 }
583
585 friend std::ostream &operator<<(std::ostream &stream, const LED &value)
586 {
587 return stream << value.toString();
588 }
589
590 private:
591 void setFromString(const std::string &value);
592
593 double m_value{ 0.0 };
594
595 friend struct DataModel::Detail::Befriend<LED>;
596 };
597
599
600 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
602 {
603 public:
606
608 static constexpr const char *path{ "Temperature/Lens" };
609
611 static constexpr const char *name{ "Lens" };
612
614 static constexpr const char *description{ R"description(Lens temperature)description" };
615
617 using ValueType = double;
618
620 static constexpr Range<double> validRange()
621 {
622 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
623 }
624
626 Lens() = default;
627
629 explicit constexpr Lens(double value)
630 : m_value{ value }
631 {}
632
634 double value() const;
635
637 std::string toString() const;
638
640 bool operator==(const Lens &other) const
641 {
642 return m_value == other.m_value;
643 }
644
646 bool operator!=(const Lens &other) const
647 {
648 return m_value != other.m_value;
649 }
650
652 bool operator<(const Lens &other) const
653 {
654 return m_value < other.m_value;
655 }
656
658 bool operator>(const Lens &other) const
659 {
660 return m_value > other.m_value;
661 }
662
664 bool operator<=(const Lens &other) const
665 {
666 return m_value <= other.m_value;
667 }
668
670 bool operator>=(const Lens &other) const
671 {
672 return m_value >= other.m_value;
673 }
674
676 friend std::ostream &operator<<(std::ostream &stream, const Lens &value)
677 {
678 return stream << value.toString();
679 }
680
681 private:
682 void setFromString(const std::string &value);
683
684 double m_value{ 0.0 };
685
686 friend struct DataModel::Detail::Befriend<Lens>;
687 };
688
690
691 // NOLINTNEXTLINE(clang-analyzer-optin.performance.Padding)
693 {
694 public:
697
699 static constexpr const char *path{ "Temperature/PCB" };
700
702 static constexpr const char *name{ "PCB" };
703
705 static constexpr const char *description{ R"description(PCB temperature)description" };
706
708 using ValueType = double;
709
711 static constexpr Range<double> validRange()
712 {
713 return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
714 }
715
717 PCB() = default;
718
720 explicit constexpr PCB(double value)
721 : m_value{ value }
722 {}
723
725 double value() const;
726
728 std::string toString() const;
729
731 bool operator==(const PCB &other) const
732 {
733 return m_value == other.m_value;
734 }
735
737 bool operator!=(const PCB &other) const
738 {
739 return m_value != other.m_value;
740 }
741
743 bool operator<(const PCB &other) const
744 {
745 return m_value < other.m_value;
746 }
747
749 bool operator>(const PCB &other) const
750 {
751 return m_value > other.m_value;
752 }
753
755 bool operator<=(const PCB &other) const
756 {
757 return m_value <= other.m_value;
758 }
759
761 bool operator>=(const PCB &other) const
762 {
763 return m_value >= other.m_value;
764 }
765
767 friend std::ostream &operator<<(std::ostream &stream, const PCB &value)
768 {
769 return stream << value.toString();
770 }
771
772 private:
773 void setFromString(const std::string &value);
774
775 double m_value{ 0.0 };
776
777 friend struct DataModel::Detail::Befriend<PCB>;
778 };
779
780 using Descendants = std::tuple<
786
789
805#ifndef NO_DOC
806 template<
807 typename... Args,
808 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
809 typename std::enable_if<
810 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::
811 value,
812 int>::type = 0>
813#else
814 template<typename... Args>
815#endif
816 explicit Temperature(Args &&...args)
817 {
818 using namespace Zivid::Detail::TypeTraits;
819
820 static_assert(
821 AllArgsDecayedAreUnique<Args...>::value,
822 "Found duplicate types among the arguments passed to Temperature(...). "
823 "Types should be listed at most once.");
824
825 set(std::forward<Args>(args)...);
826 }
827
842#ifndef NO_DOC
843 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
844#else
845 template<typename... Args>
846#endif
847 void set(Args &&...args)
848 {
849 using namespace Zivid::Detail::TypeTraits;
850
851 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
852 static_assert(
853 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
854
855 static_assert(
856 AllArgsDecayedAreUnique<Args...>::value,
857 "Found duplicate types among the arguments passed to set(...). "
858 "Types should be listed at most once.");
859
860 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
861 }
862
878#ifndef NO_DOC
879 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
880#else
881 template<typename... Args>
882#endif
883 Temperature copyWith(Args &&...args) const
884 {
885 using namespace Zivid::Detail::TypeTraits;
886
887 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
888 static_assert(
889 AllArgsAreDescendantNodes::value,
890 "All arguments passed to copyWith(...) must be descendant nodes.");
891
892 static_assert(
893 AllArgsDecayedAreUnique<Args...>::value,
894 "Found duplicate types among the arguments passed to copyWith(...). "
895 "Types should be listed at most once.");
896
897 auto copy{ *this };
898 copy.set(std::forward<Args>(args)...);
899 return copy;
900 }
901
903 const DMD &dmd() const
904 {
905 return m_dmd;
906 }
907
910 {
911 return m_dmd;
912 }
913
915 Temperature &set(const DMD &value)
916 {
917 m_dmd = value;
918 return *this;
919 }
920
922 const General &general() const
923 {
924 return m_general;
925 }
926
929 {
930 return m_general;
931 }
932
934 Temperature &set(const General &value)
935 {
936 m_general = value;
937 return *this;
938 }
939
941 const LED &led() const
942 {
943 return m_led;
944 }
945
948 {
949 return m_led;
950 }
951
953 Temperature &set(const LED &value)
954 {
955 m_led = value;
956 return *this;
957 }
958
960 const Lens &lens() const
961 {
962 return m_lens;
963 }
964
967 {
968 return m_lens;
969 }
970
972 Temperature &set(const Lens &value)
973 {
974 m_lens = value;
975 return *this;
976 }
977
979 const PCB &pcb() const
980 {
981 return m_pcb;
982 }
983
986 {
987 return m_pcb;
988 }
989
991 Temperature &set(const PCB &value)
992 {
993 m_pcb = value;
994 return *this;
995 }
996
997 template<
998 typename T,
999 typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
1001 {
1002 return m_dmd;
1003 }
1004
1005 template<
1006 typename T,
1007 typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
1009 {
1010 return m_general;
1011 }
1012
1013 template<
1014 typename T,
1015 typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
1017 {
1018 return m_led;
1019 }
1020
1021 template<
1022 typename T,
1023 typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
1025 {
1026 return m_lens;
1027 }
1028
1029 template<
1030 typename T,
1031 typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
1033 {
1034 return m_pcb;
1035 }
1036
1037 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1039 {
1040 return m_dmd;
1041 }
1042
1043 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1045 {
1046 return m_general;
1047 }
1048
1049 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1051 {
1052 return m_led;
1053 }
1054
1055 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1057 {
1058 return m_lens;
1059 }
1060
1061 template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
1063 {
1064 return m_pcb;
1065 }
1066
1068 template<typename F>
1069 void forEach(const F &f) const
1070 {
1071 f(m_dmd);
1072 f(m_general);
1073 f(m_led);
1074 f(m_lens);
1075 f(m_pcb);
1076 }
1077
1079 template<typename F>
1080 void forEach(const F &f)
1081 {
1082 f(m_dmd);
1083 f(m_general);
1084 f(m_led);
1085 f(m_lens);
1086 f(m_pcb);
1087 }
1088
1090 bool operator==(const Temperature &other) const;
1091
1093 bool operator!=(const Temperature &other) const;
1094
1096 std::string toString() const;
1097
1099 friend std::ostream &operator<<(std::ostream &stream, const Temperature &value)
1100 {
1101 return stream << value.toString();
1102 }
1103
1104 private:
1105 void setFromString(const std::string &value);
1106
1107 void setFromString(const std::string &fullPath, const std::string &value);
1108
1109 std::string getString(const std::string &fullPath) const;
1110
1111 DMD m_dmd;
1112 General m_general;
1113 LED m_led;
1114 Lens m_lens;
1115 PCB m_pcb;
1116
1117 friend struct DataModel::Detail::Befriend<Temperature>;
1118 };
1119
1120 using Descendants = std::tuple<
1129
1132
1134 explicit CameraState(const std::string &fileName);
1135
1154#ifndef NO_DOC
1155 template<
1156 typename... Args,
1157 typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1158 typename std::enable_if<
1159 Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1160 int>::type = 0>
1161#else
1162 template<typename... Args>
1163#endif
1164 explicit CameraState(Args &&...args)
1165 {
1166 using namespace Zivid::Detail::TypeTraits;
1167
1168 static_assert(
1169 AllArgsDecayedAreUnique<Args...>::value,
1170 "Found duplicate types among the arguments passed to CameraState(...). "
1171 "Types should be listed at most once.");
1172
1173 set(std::forward<Args>(args)...);
1174 }
1175
1193#ifndef NO_DOC
1194 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1195#else
1196 template<typename... Args>
1197#endif
1198 void set(Args &&...args)
1199 {
1200 using namespace Zivid::Detail::TypeTraits;
1201
1202 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1203 static_assert(
1204 AllArgsAreDescendantNodes::value, "All arguments passed to set(...) must be descendant nodes.");
1205
1206 static_assert(
1207 AllArgsDecayedAreUnique<Args...>::value,
1208 "Found duplicate types among the arguments passed to set(...). "
1209 "Types should be listed at most once.");
1210
1211 Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1212 }
1213
1232#ifndef NO_DOC
1233 template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1234#else
1235 template<typename... Args>
1236#endif
1237 CameraState copyWith(Args &&...args) const
1238 {
1239 using namespace Zivid::Detail::TypeTraits;
1240
1241 using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1242 static_assert(
1243 AllArgsAreDescendantNodes::value, "All arguments passed to copyWith(...) must be descendant nodes.");
1244
1245 static_assert(
1246 AllArgsDecayedAreUnique<Args...>::value,
1247 "Found duplicate types among the arguments passed to copyWith(...). "
1248 "Types should be listed at most once.");
1249
1250 auto copy{ *this };
1251 copy.set(std::forward<Args>(args)...);
1252 return copy;
1253 }
1254
1256 const Available &isAvailable() const
1257 {
1258 return m_available;
1259 }
1260
1263 {
1264 return m_available;
1265 }
1266
1269 {
1270 m_available = value;
1271 return *this;
1272 }
1273
1275 const Connected &isConnected() const
1276 {
1277 return m_connected;
1278 }
1279
1282 {
1283 return m_connected;
1284 }
1285
1288 {
1289 m_connected = value;
1290 return *this;
1291 }
1292
1295 {
1296 return m_temperature;
1297 }
1298
1301 {
1302 return m_temperature;
1303 }
1304
1307 {
1308 m_temperature = value;
1309 return *this;
1310 }
1311
1314 {
1315 m_temperature.set(value);
1316 return *this;
1317 }
1318
1321 {
1322 m_temperature.set(value);
1323 return *this;
1324 }
1325
1328 {
1329 m_temperature.set(value);
1330 return *this;
1331 }
1332
1335 {
1336 m_temperature.set(value);
1337 return *this;
1338 }
1339
1342 {
1343 m_temperature.set(value);
1344 return *this;
1345 }
1346
1347 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Available>::value, int>::type = 0>
1349 {
1350 return m_available;
1351 }
1352
1353 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Connected>::value, int>::type = 0>
1355 {
1356 return m_connected;
1357 }
1358
1359 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Temperature>::value, int>::type = 0>
1361 {
1362 return m_temperature;
1363 }
1364
1365 template<
1366 typename T,
1367 typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
1369 {
1370 return m_temperature.get<CameraState::Temperature::DMD>();
1371 }
1372
1373 template<
1374 typename T,
1375 typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
1377 {
1378 return m_temperature.get<CameraState::Temperature::General>();
1379 }
1380
1381 template<
1382 typename T,
1383 typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
1385 {
1386 return m_temperature.get<CameraState::Temperature::LED>();
1387 }
1388
1389 template<
1390 typename T,
1391 typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
1393 {
1394 return m_temperature.get<CameraState::Temperature::Lens>();
1395 }
1396
1397 template<
1398 typename T,
1399 typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
1401 {
1402 return m_temperature.get<CameraState::Temperature::PCB>();
1403 }
1404
1405 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1407 {
1408 return m_available;
1409 }
1410
1411 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1413 {
1414 return m_connected;
1415 }
1416
1417 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1419 {
1420 return m_temperature;
1421 }
1422
1424 template<typename F>
1425 void forEach(const F &f) const
1426 {
1427 f(m_available);
1428 f(m_connected);
1429 f(m_temperature);
1430 }
1431
1433 template<typename F>
1434 void forEach(const F &f)
1435 {
1436 f(m_available);
1437 f(m_connected);
1438 f(m_temperature);
1439 }
1440
1442 bool operator==(const CameraState &other) const;
1443
1445 bool operator!=(const CameraState &other) const;
1446
1448 std::string toString() const;
1449
1451 friend std::ostream &operator<<(std::ostream &stream, const CameraState &value)
1452 {
1453 return stream << value.toString();
1454 }
1455
1457 void save(const std::string &fileName) const;
1458
1460 void load(const std::string &fileName);
1461
1462 private:
1463 void setFromString(const std::string &value);
1464
1465 void setFromString(const std::string &fullPath, const std::string &value);
1466
1467 std::string getString(const std::string &fullPath) const;
1468
1469 Available m_available;
1470 Connected m_connected;
1471 Temperature m_temperature;
1472
1473 friend struct DataModel::Detail::Befriend<CameraState>;
1474 };
1475
1476#ifndef NO_DOC
1478 namespace Detail
1479 {
1480 ZIVID_CORE_EXPORT void save(const CameraState &dataModel, std::ostream &ostream);
1481 ZIVID_CORE_EXPORT void load(CameraState &dataModel, std::istream &istream);
1482 } // namespace Detail
1483#endif
1484
1485#ifndef NO_DOC
1486 template<>
1487 struct CameraState::Version<2>
1488 {
1489 using Type = CameraState;
1490 };
1491#endif
1492
1493} // namespace Zivid
1494
1495#ifdef _MSC_VER
1496# pragma warning(pop)
1497#endif
1498
1499#ifndef NO_DOC
1500# if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1501namespace std // NOLINT
1502{
1503
1504 template<>
1505 struct tuple_size<Zivid::CameraState::Temperature> : integral_constant<size_t, 5>
1506 {};
1507
1508 template<size_t i>
1509 struct tuple_element<i, Zivid::CameraState::Temperature>
1510 {
1511 static_assert(i < tuple_size<Zivid::CameraState::Temperature>::value, "Index must be less than 5");
1512
1513 using type // NOLINT
1514 = decltype(declval<Zivid::CameraState::Temperature>().get<i>());
1515 };
1516
1517 template<>
1518 struct tuple_size<Zivid::CameraState> : integral_constant<size_t, 3>
1519 {};
1520
1521 template<size_t i>
1522 struct tuple_element<i, Zivid::CameraState>
1523 {
1524 static_assert(i < tuple_size<Zivid::CameraState>::value, "Index must be less than 3");
1525
1526 using type // NOLINT
1527 = decltype(declval<Zivid::CameraState>().get<i>());
1528 };
1529
1530} // namespace std
1531# endif
1532#endif
1533
1534// If we have access to the DataModel library, automatically include internal DataModel
1535// header. This header is necessary for serialization and deserialization.
1536#if defined(__has_include) && !defined(NO_DOC)
1537# if __has_include("Zivid/CameraStateInternal.h") && __has_include("Zivid/DataModelNodeMetaData.h")
1538# include "Zivid/CameraStateInternal.h"
1539# endif
1540#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:157
static std::set< bool > validValues()
All valid values of Available
Definition: CameraState.h:179
static const Available no
Off/disabled.
Definition: CameraState.h:176
bool operator==(const Available &other) const
Comparison operator
Definition: CameraState.h:205
std::string toString() const
Get the value as string
bool ValueType
The type of the underlying value
Definition: CameraState.h:174
static const Available yes
On/enabled.
Definition: CameraState.h:175
friend std::ostream & operator<<(std::ostream &stream, const Available &value)
Operator to serialize the value to a stream
Definition: CameraState.h:217
bool operator!=(const Available &other) const
Comparison operator
Definition: CameraState.h:211
constexpr Available(bool value)
Constructor
Definition: CameraState.h:188
bool value() const
Get the value
Available()=default
Default constructor
Flag if camera is connected in software
Definition: CameraState.h:234
Connected()=default
Default constructor
static const Connected yes
On/enabled.
Definition: CameraState.h:252
static const Connected no
Off/disabled.
Definition: CameraState.h:253
bool operator!=(const Connected &other) const
Comparison operator
Definition: CameraState.h:288
constexpr Connected(bool value)
Constructor
Definition: CameraState.h:265
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:294
static std::set< bool > validValues()
All valid values of Connected
Definition: CameraState.h:256
bool operator==(const Connected &other) const
Comparison operator
Definition: CameraState.h:282
bool ValueType
The type of the underlying value
Definition: CameraState.h:251
DMD temperature
Definition: CameraState.h:329
bool operator>(const DMD &other) const
Comparison operator
Definition: CameraState.h:385
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:373
bool operator<(const DMD &other) const
Comparison operator
Definition: CameraState.h:379
bool operator>=(const DMD &other) const
Comparison operator
Definition: CameraState.h:397
double ValueType
The type of the underlying value
Definition: CameraState.h:344
bool operator<=(const DMD &other) const
Comparison operator
Definition: CameraState.h:391
friend std::ostream & operator<<(std::ostream &stream, const DMD &value)
Operator to serialize the value to a stream
Definition: CameraState.h:403
constexpr DMD(double value)
Constructor
Definition: CameraState.h:356
bool operator==(const DMD &other) const
Comparison operator
Definition: CameraState.h:367
static constexpr Range< double > validRange()
The range of valid values for DMD
Definition: CameraState.h:347
DMD()=default
Default constructor
General temperature
Definition: CameraState.h:420
double ValueType
The type of the underlying value
Definition: CameraState.h:435
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:470
constexpr General(double value)
Constructor
Definition: CameraState.h:447
static constexpr Range< double > validRange()
The range of valid values for General
Definition: CameraState.h:438
bool operator==(const General &other) const
Comparison operator
Definition: CameraState.h:458
General()=default
Default constructor
bool operator<=(const General &other) const
Comparison operator
Definition: CameraState.h:482
bool operator!=(const General &other) const
Comparison operator
Definition: CameraState.h:464
bool operator>(const General &other) const
Comparison operator
Definition: CameraState.h:476
friend std::ostream & operator<<(std::ostream &stream, const General &value)
Operator to serialize the value to a stream
Definition: CameraState.h:494
bool operator>=(const General &other) const
Comparison operator
Definition: CameraState.h:488
LED temperature
Definition: CameraState.h:511
bool operator<=(const LED &other) const
Comparison operator
Definition: CameraState.h:573
std::string toString() const
Get the value as string
bool operator<(const LED &other) const
Comparison operator
Definition: CameraState.h:561
double value() const
Get the value
LED()=default
Default constructor
constexpr LED(double value)
Constructor
Definition: CameraState.h:538
friend std::ostream & operator<<(std::ostream &stream, const LED &value)
Operator to serialize the value to a stream
Definition: CameraState.h:585
bool operator!=(const LED &other) const
Comparison operator
Definition: CameraState.h:555
bool operator==(const LED &other) const
Comparison operator
Definition: CameraState.h:549
bool operator>=(const LED &other) const
Comparison operator
Definition: CameraState.h:579
bool operator>(const LED &other) const
Comparison operator
Definition: CameraState.h:567
static constexpr Range< double > validRange()
The range of valid values for LED
Definition: CameraState.h:529
double ValueType
The type of the underlying value
Definition: CameraState.h:526
Lens temperature
Definition: CameraState.h:602
double ValueType
The type of the underlying value
Definition: CameraState.h:617
bool operator==(const Lens &other) const
Comparison operator
Definition: CameraState.h:640
Lens()=default
Default constructor
bool operator<=(const Lens &other) const
Comparison operator
Definition: CameraState.h:664
double value() const
Get the value
bool operator>(const Lens &other) const
Comparison operator
Definition: CameraState.h:658
bool operator!=(const Lens &other) const
Comparison operator
Definition: CameraState.h:646
bool operator>=(const Lens &other) const
Comparison operator
Definition: CameraState.h:670
std::string toString() const
Get the value as string
constexpr Lens(double value)
Constructor
Definition: CameraState.h:629
static constexpr Range< double > validRange()
The range of valid values for Lens
Definition: CameraState.h:620
bool operator<(const Lens &other) const
Comparison operator
Definition: CameraState.h:652
friend std::ostream & operator<<(std::ostream &stream, const Lens &value)
Operator to serialize the value to a stream
Definition: CameraState.h:676
PCB temperature
Definition: CameraState.h:693
bool operator!=(const PCB &other) const
Comparison operator
Definition: CameraState.h:737
constexpr PCB(double value)
Constructor
Definition: CameraState.h:720
static constexpr Range< double > validRange()
The range of valid values for PCB
Definition: CameraState.h:711
bool operator>=(const PCB &other) const
Comparison operator
Definition: CameraState.h:761
PCB()=default
Default constructor
bool operator<=(const PCB &other) const
Comparison operator
Definition: CameraState.h:755
friend std::ostream & operator<<(std::ostream &stream, const PCB &value)
Operator to serialize the value to a stream
Definition: CameraState.h:767
bool operator==(const PCB &other) const
Comparison operator
Definition: CameraState.h:731
double value() const
Get the value
bool operator>(const PCB &other) const
Comparison operator
Definition: CameraState.h:749
double ValueType
The type of the underlying value
Definition: CameraState.h:708
std::string toString() const
Get the value as string
bool operator<(const PCB &other) const
Comparison operator
Definition: CameraState.h:743
Current temperature(s)
Definition: CameraState.h:311
DMD & dmd()
Get DMD
Definition: CameraState.h:909
Temperature & set(const General &value)
Set General
Definition: CameraState.h:934
const PCB & pcb() const
Get PCB
Definition: CameraState.h:979
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:1024
Temperature & set(const Lens &value)
Set Lens
Definition: CameraState.h:972
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:1000
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:1032
const CameraState::Temperature::General & get() const
Definition: CameraState.h:1008
Temperature & set(const PCB &value)
Set PCB
Definition: CameraState.h:991
const General & general() const
Get General
Definition: CameraState.h:922
bool operator!=(const Temperature &other) const
Inequality operator
const LED & led() const
Get LED
Definition: CameraState.h:941
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:1069
Temperature(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:816
friend std::ostream & operator<<(std::ostream &stream, const Temperature &value)
Operator to send the value as string to a stream
Definition: CameraState.h:1099
std::tuple< CameraState::Temperature::DMD, CameraState::Temperature::General, CameraState::Temperature::LED, CameraState::Temperature::Lens, CameraState::Temperature::PCB > Descendants
Definition: CameraState.h:785
Temperature & set(const LED &value)
Set LED
Definition: CameraState.h:953
std::string toString() const
Get the value as string
LED & led()
Get LED
Definition: CameraState.h:947
bool operator==(const Temperature &other) const
Equality operator
const Lens & lens() const
Get Lens
Definition: CameraState.h:960
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:883
General & general()
Get General
Definition: CameraState.h:928
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:847
const DMD & dmd() const
Get DMD
Definition: CameraState.h:903
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:1080
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:1016
Lens & lens()
Get Lens
Definition: CameraState.h:966
Temperature()
Default constructor
Temperature & set(const DMD &value)
Set DMD
Definition: CameraState.h:915
PCB & pcb()
Get PCB
Definition: CameraState.h:985
Information about camera connection state, temperatures, etc.
Definition: CameraState.h:123
const Temperature & temperature() const
Get Temperature
Definition: CameraState.h:1294
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:1237
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:1392
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:1306
const CameraState::Connected & get() const
Definition: CameraState.h:1354
Temperature & temperature()
Get Temperature
Definition: CameraState.h:1300
const CameraState::Temperature::General & get() const
Definition: CameraState.h:1376
std::string toString() const
Get the value as string
const CameraState::Available & get() const
Definition: CameraState.h:1348
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:1128
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:1434
void save(const std::string &fileName) const
Save to the given file
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:1400
CameraState & set(const Temperature::PCB &value)
Set Temperature::PCB
Definition: CameraState.h:1341
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:1384
CameraState & set(const Temperature::General &value)
Set Temperature::General
Definition: CameraState.h:1320
friend std::ostream & operator<<(std::ostream &stream, const CameraState &value)
Operator to send the value as string to a stream
Definition: CameraState.h:1451
bool operator!=(const CameraState &other) const
Inequality operator
const Available & isAvailable() const
Get Available
Definition: CameraState.h:1256
Connected & isConnected()
Get Connected
Definition: CameraState.h:1281
CameraState & set(const Temperature::Lens &value)
Set Temperature::Lens
Definition: CameraState.h:1334
CameraState & set(const Available &value)
Set Available
Definition: CameraState.h:1268
CameraState & set(const Temperature::DMD &value)
Set Temperature::DMD
Definition: CameraState.h:1313
bool operator==(const CameraState &other) const
Equality operator
CameraState()
Default constructor
CameraState & set(const Connected &value)
Set Connected
Definition: CameraState.h:1287
CameraState(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:1164
const CameraState::Temperature & get() const
Definition: CameraState.h:1360
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:1425
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:1198
CameraState & set(const Temperature::LED &value)
Set Temperature::LED
Definition: CameraState.h:1327
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:1368
const Connected & isConnected() const
Get Connected
Definition: CameraState.h:1275
Available & isAvailable()
Get Available
Definition: CameraState.h:1262
Class describing a range of values for a given type T
Definition: Range.h:118
NodeType
Definition: NodeType.h:100
The main Zivid namespace. All Zivid code is found here
Definition: Application.h:99