Zivid C++ API  2.3.1+1a22cbf1-1
Defining the Future of 3D Machine Vision
CameraState.h
Go to the documentation of this file.
1 
2 /*******************************************************************************
3  * This file is part of the Zivid 3D Camera API
4  *
5  * Copyright 2015-2022 (C) Zivid AS
6  * All rights reserved.
7  *
8  * Zivid Software License, v1.0
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * 3. Neither the name of Zivid AS nor the names of its contributors may be used
21  * to endorse or promote products derived from this software without specific
22  * prior written permission.
23  *
24  * 4. This software, with or without modification, must not be used with any
25  * other 3D camera than from Zivid AS.
26  *
27  * 5. Any software provided in binary form under this license must not be
28  * reverse engineered, decompiled, modified and/or disassembled.
29  *
30  * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
31  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32  * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
33  * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
34  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
42  * Info: http://www.zivid.com
43  ******************************************************************************/
44 
45 #pragma once
46 
47 #include <array>
48 #include <chrono>
49 #include <cmath>
50 #include <ctime>
51 #include <iomanip>
52 #include <memory>
53 #include <set>
54 #include <sstream>
55 #include <string>
56 #include <tuple>
57 #include <utility>
58 #include <vector>
59 
62 #include "Zivid/DataModel/Traits.h"
65 #include "Zivid/Range.h"
66 
67 #ifdef _MSC_VER
68 # pragma warning(push)
69 # pragma warning(disable : 4251) // "X needs to have dll-interface to be used by clients of class Y."
70 #endif
71 
72 namespace Zivid
73 {
76  {
77  public:
79  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
80 
82  static constexpr const char *path{ "" };
83 
85  static constexpr const char *name{ "CameraState" };
86 
88  static constexpr const char *description{
89  R"description(Information about camera connection state, temperatures, etc.)description"
90  };
91 
92  static constexpr size_t version{ 2 };
93 
94 #ifndef NO_DOC
95  template<size_t>
96  struct Version;
97 
98  using LatestVersion = Zivid::CameraState;
99 
100  // Short identifier. This value is not guaranteed to be universally unique
101  // Todo(ZIVID-2808): Move this to internal DataModelExt header
102  static constexpr std::array<uint8_t, 3> binaryId{ 'c', 's', 't' };
103 
104 #endif
105 
108  {
109  public:
112 
114  static constexpr const char *path{ "Available" };
115 
117  static constexpr const char *name{ "Available" };
118 
120  static constexpr const char *description{
121  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"
122  };
123 
125  using ValueType = bool;
126  static const Available yes;
127  static const Available no;
128 
130  static std::set<bool> validValues()
131  {
132  return { false, true };
133  }
134 
136  Available() = default;
137 
139  explicit constexpr Available(bool value)
140  : m_value{ value }
141  {}
142 
144  bool value() const;
145 
147  std::string toString() const;
148 
150  explicit operator bool() const
151  {
152  return m_value;
153  }
154 
156  bool operator==(const Available &other) const
157  {
158  return m_value == other.m_value;
159  }
160 
162  bool operator!=(const Available &other) const
163  {
164  return m_value != other.m_value;
165  }
166 
168  friend std::ostream &operator<<(std::ostream &stream, const Available &value)
169  {
170  return stream << value.toString();
171  }
172 
173  private:
174  void setFromString(const std::string &value);
175 
176  bool m_value{ false };
177 
178  friend struct DataModel::Detail::Befriend<Available>;
179  };
180 
183  {
184  public:
187 
189  static constexpr const char *path{ "Connected" };
190 
192  static constexpr const char *name{ "Connected" };
193 
195  static constexpr const char *description{
196  R"description(Flag if camera is connected in software)description"
197  };
198 
200  using ValueType = bool;
201  static const Connected yes;
202  static const Connected no;
203 
205  static std::set<bool> validValues()
206  {
207  return { false, true };
208  }
209 
211  Connected() = default;
212 
214  explicit constexpr Connected(bool value)
215  : m_value{ value }
216  {}
217 
219  bool value() const;
220 
222  std::string toString() const;
223 
225  explicit operator bool() const
226  {
227  return m_value;
228  }
229 
231  bool operator==(const Connected &other) const
232  {
233  return m_value == other.m_value;
234  }
235 
237  bool operator!=(const Connected &other) const
238  {
239  return m_value != other.m_value;
240  }
241 
243  friend std::ostream &operator<<(std::ostream &stream, const Connected &value)
244  {
245  return stream << value.toString();
246  }
247 
248  private:
249  void setFromString(const std::string &value);
250 
251  bool m_value{ false };
252 
253  friend struct DataModel::Detail::Befriend<Connected>;
254  };
255 
258  {
259  public:
261  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
262 
264  static constexpr const char *path{ "Temperature" };
265 
267  static constexpr const char *name{ "Temperature" };
268 
270  static constexpr const char *description{ R"description(Current temperature(s))description" };
271 
274  {
275  public:
278 
280  static constexpr const char *path{ "Temperature/DMD" };
281 
283  static constexpr const char *name{ "DMD" };
284 
286  static constexpr const char *description{ R"description(DMD temperature)description" };
287 
289  using ValueType = double;
290 
292  static constexpr Range<double> validRange()
293  {
294  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
295  }
296 
298  DMD() = default;
299 
301  explicit constexpr DMD(double value)
302  : m_value{ value }
303  {}
304 
306  double value() const;
307 
309  std::string toString() const;
310 
312  bool operator==(const DMD &other) const
313  {
314  return m_value == other.m_value;
315  }
316 
318  bool operator!=(const DMD &other) const
319  {
320  return m_value != other.m_value;
321  }
322 
324  bool operator<(const DMD &other) const
325  {
326  return m_value < other.m_value;
327  }
328 
330  bool operator>(const DMD &other) const
331  {
332  return m_value > other.m_value;
333  }
334 
336  friend std::ostream &operator<<(std::ostream &stream, const DMD &value)
337  {
338  return stream << value.toString();
339  }
340 
341  private:
342  void setFromString(const std::string &value);
343 
344  double m_value{ 0.0 };
345 
346  friend struct DataModel::Detail::Befriend<DMD>;
347  };
348 
351  {
352  public:
355 
357  static constexpr const char *path{ "Temperature/General" };
358 
360  static constexpr const char *name{ "General" };
361 
363  static constexpr const char *description{ R"description(General temperature)description" };
364 
366  using ValueType = double;
367 
369  static constexpr Range<double> validRange()
370  {
371  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
372  }
373 
375  General() = default;
376 
378  explicit constexpr General(double value)
379  : m_value{ value }
380  {}
381 
383  double value() const;
384 
386  std::string toString() const;
387 
389  bool operator==(const General &other) const
390  {
391  return m_value == other.m_value;
392  }
393 
395  bool operator!=(const General &other) const
396  {
397  return m_value != other.m_value;
398  }
399 
401  bool operator<(const General &other) const
402  {
403  return m_value < other.m_value;
404  }
405 
407  bool operator>(const General &other) const
408  {
409  return m_value > other.m_value;
410  }
411 
413  friend std::ostream &operator<<(std::ostream &stream, const General &value)
414  {
415  return stream << value.toString();
416  }
417 
418  private:
419  void setFromString(const std::string &value);
420 
421  double m_value{ 0.0 };
422 
423  friend struct DataModel::Detail::Befriend<General>;
424  };
425 
428  {
429  public:
432 
434  static constexpr const char *path{ "Temperature/LED" };
435 
437  static constexpr const char *name{ "LED" };
438 
440  static constexpr const char *description{ R"description(LED temperature)description" };
441 
443  using ValueType = double;
444 
446  static constexpr Range<double> validRange()
447  {
448  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
449  }
450 
452  LED() = default;
453 
455  explicit constexpr LED(double value)
456  : m_value{ value }
457  {}
458 
460  double value() const;
461 
463  std::string toString() const;
464 
466  bool operator==(const LED &other) const
467  {
468  return m_value == other.m_value;
469  }
470 
472  bool operator!=(const LED &other) const
473  {
474  return m_value != other.m_value;
475  }
476 
478  bool operator<(const LED &other) const
479  {
480  return m_value < other.m_value;
481  }
482 
484  bool operator>(const LED &other) const
485  {
486  return m_value > other.m_value;
487  }
488 
490  friend std::ostream &operator<<(std::ostream &stream, const LED &value)
491  {
492  return stream << value.toString();
493  }
494 
495  private:
496  void setFromString(const std::string &value);
497 
498  double m_value{ 0.0 };
499 
500  friend struct DataModel::Detail::Befriend<LED>;
501  };
502 
505  {
506  public:
509 
511  static constexpr const char *path{ "Temperature/Lens" };
512 
514  static constexpr const char *name{ "Lens" };
515 
517  static constexpr const char *description{ R"description(Lens temperature)description" };
518 
520  using ValueType = double;
521 
523  static constexpr Range<double> validRange()
524  {
525  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
526  }
527 
529  Lens() = default;
530 
532  explicit constexpr Lens(double value)
533  : m_value{ value }
534  {}
535 
537  double value() const;
538 
540  std::string toString() const;
541 
543  bool operator==(const Lens &other) const
544  {
545  return m_value == other.m_value;
546  }
547 
549  bool operator!=(const Lens &other) const
550  {
551  return m_value != other.m_value;
552  }
553 
555  bool operator<(const Lens &other) const
556  {
557  return m_value < other.m_value;
558  }
559 
561  bool operator>(const Lens &other) const
562  {
563  return m_value > other.m_value;
564  }
565 
567  friend std::ostream &operator<<(std::ostream &stream, const Lens &value)
568  {
569  return stream << value.toString();
570  }
571 
572  private:
573  void setFromString(const std::string &value);
574 
575  double m_value{ 0.0 };
576 
577  friend struct DataModel::Detail::Befriend<Lens>;
578  };
579 
582  {
583  public:
586 
588  static constexpr const char *path{ "Temperature/PCB" };
589 
591  static constexpr const char *name{ "PCB" };
592 
594  static constexpr const char *description{ R"description(PCB temperature)description" };
595 
597  using ValueType = double;
598 
600  static constexpr Range<double> validRange()
601  {
602  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
603  }
604 
606  PCB() = default;
607 
609  explicit constexpr PCB(double value)
610  : m_value{ value }
611  {}
612 
614  double value() const;
615 
617  std::string toString() const;
618 
620  bool operator==(const PCB &other) const
621  {
622  return m_value == other.m_value;
623  }
624 
626  bool operator!=(const PCB &other) const
627  {
628  return m_value != other.m_value;
629  }
630 
632  bool operator<(const PCB &other) const
633  {
634  return m_value < other.m_value;
635  }
636 
638  bool operator>(const PCB &other) const
639  {
640  return m_value > other.m_value;
641  }
642 
644  friend std::ostream &operator<<(std::ostream &stream, const PCB &value)
645  {
646  return stream << value.toString();
647  }
648 
649  private:
650  void setFromString(const std::string &value);
651 
652  double m_value{ 0.0 };
653 
654  friend struct DataModel::Detail::Befriend<PCB>;
655  };
656 
662 
665 
681 #ifndef NO_DOC
682  template<typename... Args,
683  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
684  typename std::enable_if<
685  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
686  typename std::decay<Args>::type...>::value,
687  int>::type = 0>
688 #else
689  template<typename... Args>
690 #endif
691  explicit Temperature(Args &&...args)
692  {
693  using namespace Zivid::Detail::TypeTraits;
694 
695  static_assert(AllArgsDecayedAreUnique<Args...>::value,
696  "Found duplicate types among the arguments passed to Temperature(...). "
697  "Types should be listed at most once.");
698 
699  set(std::forward<Args>(args)...);
700  }
701 
716 #ifndef NO_DOC
717  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
718 #else
719  template<typename... Args>
720 #endif
721  void set(Args &&...args)
722  {
723  using namespace Zivid::Detail::TypeTraits;
724 
725  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
726  static_assert(AllArgsAreDescendantNodes::value,
727  "All arguments passed to set(...) must be descendant nodes.");
728 
729  static_assert(AllArgsDecayedAreUnique<Args...>::value,
730  "Found duplicate types among the arguments passed to set(...). "
731  "Types should be listed at most once.");
732 
733  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
734  }
735 
751 #ifndef NO_DOC
752  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
753 #else
754  template<typename... Args>
755 #endif
756  Temperature copyWith(Args &&...args) const
757  {
758  using namespace Zivid::Detail::TypeTraits;
759 
760  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
761  static_assert(AllArgsAreDescendantNodes::value,
762  "All arguments passed to copyWith(...) must be descendant nodes.");
763 
764  static_assert(AllArgsDecayedAreUnique<Args...>::value,
765  "Found duplicate types among the arguments passed to copyWith(...). "
766  "Types should be listed at most once.");
767 
768  auto copy{ *this };
769  copy.set(std::forward<Args>(args)...);
770  return copy;
771  }
772 
774  const DMD &dmd() const
775  {
776  return m_dmd;
777  }
778 
780  DMD &dmd()
781  {
782  return m_dmd;
783  }
784 
786  Temperature &set(const DMD &value)
787  {
788  m_dmd = value;
789  return *this;
790  }
791 
793  const General &general() const
794  {
795  return m_general;
796  }
797 
800  {
801  return m_general;
802  }
803 
805  Temperature &set(const General &value)
806  {
807  m_general = value;
808  return *this;
809  }
810 
812  const LED &led() const
813  {
814  return m_led;
815  }
816 
818  LED &led()
819  {
820  return m_led;
821  }
822 
824  Temperature &set(const LED &value)
825  {
826  m_led = value;
827  return *this;
828  }
829 
831  const Lens &lens() const
832  {
833  return m_lens;
834  }
835 
838  {
839  return m_lens;
840  }
841 
843  Temperature &set(const Lens &value)
844  {
845  m_lens = value;
846  return *this;
847  }
848 
850  const PCB &pcb() const
851  {
852  return m_pcb;
853  }
854 
856  PCB &pcb()
857  {
858  return m_pcb;
859  }
860 
862  Temperature &set(const PCB &value)
863  {
864  m_pcb = value;
865  return *this;
866  }
867 
868  template<typename T,
869  typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
871  {
872  return m_dmd;
873  }
874 
875  template<typename T,
876  typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
878  {
879  return m_general;
880  }
881 
882  template<typename T,
883  typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
885  {
886  return m_led;
887  }
888 
889  template<typename T,
890  typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
892  {
893  return m_lens;
894  }
895 
896  template<typename T,
897  typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
899  {
900  return m_pcb;
901  }
902 
903  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
905  {
906  return m_dmd;
907  }
908 
909  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
911  {
912  return m_general;
913  }
914 
915  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
917  {
918  return m_led;
919  }
920 
921  template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
923  {
924  return m_lens;
925  }
926 
927  template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
929  {
930  return m_pcb;
931  }
932 
934  template<typename F>
935  void forEach(const F &f) const
936  {
937  f(m_dmd);
938  f(m_general);
939  f(m_led);
940  f(m_lens);
941  f(m_pcb);
942  }
943 
945  template<typename F>
946  void forEach(const F &f)
947  {
948  f(m_dmd);
949  f(m_general);
950  f(m_led);
951  f(m_lens);
952  f(m_pcb);
953  }
954 
956  bool operator==(const Temperature &other) const;
957 
959  bool operator!=(const Temperature &other) const;
960 
962  std::string toString() const;
963 
965  friend std::ostream &operator<<(std::ostream &stream, const Temperature &value)
966  {
967  return stream << value.toString();
968  }
969 
970  private:
971  void setFromString(const std::string &value);
972 
973  void setFromString(const std::string &fullPath, const std::string &value);
974 
975  std::string getString(const std::string &fullPath) const;
976 
977  DMD m_dmd;
978  General m_general;
979  LED m_led;
980  Lens m_lens;
981  PCB m_pcb;
982 
983  friend struct DataModel::Detail::Befriend<Temperature>;
984  };
985 
994 
997 
999  explicit CameraState(const std::string &fileName);
1000 
1019 #ifndef NO_DOC
1020  template<
1021  typename... Args,
1022  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1023  typename std::enable_if<
1024  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1025  int>::type = 0>
1026 #else
1027  template<typename... Args>
1028 #endif
1029  explicit CameraState(Args &&...args)
1030  {
1031  using namespace Zivid::Detail::TypeTraits;
1032 
1033  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1034  "Found duplicate types among the arguments passed to CameraState(...). "
1035  "Types should be listed at most once.");
1036 
1037  set(std::forward<Args>(args)...);
1038  }
1039 
1057 #ifndef NO_DOC
1058  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1059 #else
1060  template<typename... Args>
1061 #endif
1062  void set(Args &&...args)
1063  {
1064  using namespace Zivid::Detail::TypeTraits;
1065 
1066  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1067  static_assert(AllArgsAreDescendantNodes::value,
1068  "All arguments passed to set(...) must be descendant nodes.");
1069 
1070  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1071  "Found duplicate types among the arguments passed to set(...). "
1072  "Types should be listed at most once.");
1073 
1074  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1075  }
1076 
1095 #ifndef NO_DOC
1096  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1097 #else
1098  template<typename... Args>
1099 #endif
1100  CameraState copyWith(Args &&...args) const
1101  {
1102  using namespace Zivid::Detail::TypeTraits;
1103 
1104  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1105  static_assert(AllArgsAreDescendantNodes::value,
1106  "All arguments passed to copyWith(...) must be descendant nodes.");
1107 
1108  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1109  "Found duplicate types among the arguments passed to copyWith(...). "
1110  "Types should be listed at most once.");
1111 
1112  auto copy{ *this };
1113  copy.set(std::forward<Args>(args)...);
1114  return copy;
1115  }
1116 
1118  const Available &isAvailable() const
1119  {
1120  return m_available;
1121  }
1122 
1125  {
1126  return m_available;
1127  }
1128 
1130  CameraState &set(const Available &value)
1131  {
1132  m_available = value;
1133  return *this;
1134  }
1135 
1137  const Connected &isConnected() const
1138  {
1139  return m_connected;
1140  }
1141 
1144  {
1145  return m_connected;
1146  }
1147 
1149  CameraState &set(const Connected &value)
1150  {
1151  m_connected = value;
1152  return *this;
1153  }
1154 
1156  const Temperature &temperature() const
1157  {
1158  return m_temperature;
1159  }
1160 
1163  {
1164  return m_temperature;
1165  }
1166 
1168  CameraState &set(const Temperature &value)
1169  {
1170  m_temperature = value;
1171  return *this;
1172  }
1173 
1176  {
1177  m_temperature.set(value);
1178  return *this;
1179  }
1180 
1183  {
1184  m_temperature.set(value);
1185  return *this;
1186  }
1187 
1190  {
1191  m_temperature.set(value);
1192  return *this;
1193  }
1194 
1197  {
1198  m_temperature.set(value);
1199  return *this;
1200  }
1201 
1204  {
1205  m_temperature.set(value);
1206  return *this;
1207  }
1208 
1209  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Available>::value, int>::type = 0>
1211  {
1212  return m_available;
1213  }
1214 
1215  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Connected>::value, int>::type = 0>
1217  {
1218  return m_connected;
1219  }
1220 
1221  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Temperature>::value, int>::type = 0>
1223  {
1224  return m_temperature;
1225  }
1226 
1227  template<typename T,
1228  typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
1230  {
1231  return m_temperature.get<CameraState::Temperature::DMD>();
1232  }
1233 
1234  template<typename T,
1235  typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
1237  {
1238  return m_temperature.get<CameraState::Temperature::General>();
1239  }
1240 
1241  template<typename T,
1242  typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
1244  {
1245  return m_temperature.get<CameraState::Temperature::LED>();
1246  }
1247 
1248  template<typename T,
1249  typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
1251  {
1252  return m_temperature.get<CameraState::Temperature::Lens>();
1253  }
1254 
1255  template<typename T,
1256  typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
1258  {
1259  return m_temperature.get<CameraState::Temperature::PCB>();
1260  }
1261 
1262  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1264  {
1265  return m_available;
1266  }
1267 
1268  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1270  {
1271  return m_connected;
1272  }
1273 
1274  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1276  {
1277  return m_temperature;
1278  }
1279 
1281  template<typename F>
1282  void forEach(const F &f) const
1283  {
1284  f(m_available);
1285  f(m_connected);
1286  f(m_temperature);
1287  }
1288 
1290  template<typename F>
1291  void forEach(const F &f)
1292  {
1293  f(m_available);
1294  f(m_connected);
1295  f(m_temperature);
1296  }
1297 
1299  bool operator==(const CameraState &other) const;
1300 
1302  bool operator!=(const CameraState &other) const;
1303 
1305  std::string toString() const;
1306 
1308  friend std::ostream &operator<<(std::ostream &stream, const CameraState &value)
1309  {
1310  return stream << value.toString();
1311  }
1312 
1314  void save(const std::string &fileName) const;
1315 
1317  void load(const std::string &fileName);
1318 
1319  private:
1320  void setFromString(const std::string &value);
1321 
1322  void setFromString(const std::string &fullPath, const std::string &value);
1323 
1324  std::string getString(const std::string &fullPath) const;
1325 
1326  Available m_available;
1327  Connected m_connected;
1328  Temperature m_temperature;
1329 
1330  friend struct DataModel::Detail::Befriend<CameraState>;
1331  };
1332 
1333 #ifndef NO_DOC
1334  template<>
1335  struct CameraState::Version<2>
1336  {
1337  using Type = CameraState;
1338  };
1339 #endif
1340 
1341 } // namespace Zivid
1342 
1343 #ifdef _MSC_VER
1344 # pragma warning(pop)
1345 #endif
1346 
1347 #ifndef NO_DOC
1348 # if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1349 namespace std // NOLINT
1350 {
1351  template<>
1352  struct tuple_size<Zivid::CameraState::Temperature> : integral_constant<size_t, 5>
1353  {};
1354 
1355  template<size_t i>
1356  struct tuple_element<i, Zivid::CameraState::Temperature>
1357  {
1358  static_assert(i < tuple_size<Zivid::CameraState::Temperature>::value, "Index must be less than 5");
1359 
1360  using type // NOLINT
1361  = decltype(declval<Zivid::CameraState::Temperature>().get<i>());
1362  };
1363 
1364  template<>
1365  struct tuple_size<Zivid::CameraState> : integral_constant<size_t, 3>
1366  {};
1367 
1368  template<size_t i>
1369  struct tuple_element<i, Zivid::CameraState>
1370  {
1371  static_assert(i < tuple_size<Zivid::CameraState>::value, "Index must be less than 3");
1372 
1373  using type // NOLINT
1374  = decltype(declval<Zivid::CameraState>().get<i>());
1375  };
1376 
1377 } // namespace std
1378 # endif
1379 #endif
#define ZIVID_CORE_EXPORT
Definition: CoreExport.h:57
Flag if camera is physically connected to the computer, but not connected in software....
Definition: CameraState.h:108
static const Available no
Off/disabled.
Definition: CameraState.h:127
bool operator==(const Available &other) const
Comparison operator
Definition: CameraState.h:156
std::string toString() const
Get the value as string
friend std::ostream & operator<<(std::ostream &stream, const Available &value)
Operator to serialize the value to a stream
Definition: CameraState.h:168
bool ValueType
The type of the underlying value
Definition: CameraState.h:125
static const Available yes
On/enabled.
Definition: CameraState.h:126
bool operator!=(const Available &other) const
Comparison operator
Definition: CameraState.h:162
constexpr Available(bool value)
Constructor
Definition: CameraState.h:139
bool value() const
Get the value
static std::set< bool > validValues()
All valid values of Available
Definition: CameraState.h:130
Available()=default
Default constructor
Flag if camera is connected in software
Definition: CameraState.h:183
Connected()=default
Default constructor
static const Connected yes
On/enabled.
Definition: CameraState.h:201
static std::set< bool > validValues()
All valid values of Connected
Definition: CameraState.h:205
static const Connected no
Off/disabled.
Definition: CameraState.h:202
bool operator!=(const Connected &other) const
Comparison operator
Definition: CameraState.h:237
friend std::ostream & operator<<(std::ostream &stream, const Connected &value)
Operator to serialize the value to a stream
Definition: CameraState.h:243
constexpr Connected(bool value)
Constructor
Definition: CameraState.h:214
bool value() const
Get the value
std::string toString() const
Get the value as string
bool operator==(const Connected &other) const
Comparison operator
Definition: CameraState.h:231
bool ValueType
The type of the underlying value
Definition: CameraState.h:200
DMD temperature
Definition: CameraState.h:274
bool operator>(const DMD &other) const
Comparison operator
Definition: CameraState.h:330
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:318
bool operator<(const DMD &other) const
Comparison operator
Definition: CameraState.h:324
friend std::ostream & operator<<(std::ostream &stream, const DMD &value)
Operator to serialize the value to a stream
Definition: CameraState.h:336
double ValueType
The type of the underlying value
Definition: CameraState.h:289
static constexpr Range< double > validRange()
The range of valid values for DMD
Definition: CameraState.h:292
constexpr DMD(double value)
Constructor
Definition: CameraState.h:301
bool operator==(const DMD &other) const
Comparison operator
Definition: CameraState.h:312
DMD()=default
Default constructor
General temperature
Definition: CameraState.h:351
static constexpr Range< double > validRange()
The range of valid values for General
Definition: CameraState.h:369
double ValueType
The type of the underlying value
Definition: CameraState.h:366
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:401
constexpr General(double value)
Constructor
Definition: CameraState.h:378
bool operator==(const General &other) const
Comparison operator
Definition: CameraState.h:389
General()=default
Default constructor
bool operator!=(const General &other) const
Comparison operator
Definition: CameraState.h:395
bool operator>(const General &other) const
Comparison operator
Definition: CameraState.h:407
friend std::ostream & operator<<(std::ostream &stream, const General &value)
Operator to serialize the value to a stream
Definition: CameraState.h:413
LED temperature
Definition: CameraState.h:428
std::string toString() const
Get the value as string
bool operator<(const LED &other) const
Comparison operator
Definition: CameraState.h:478
double value() const
Get the value
LED()=default
Default constructor
constexpr LED(double value)
Constructor
Definition: CameraState.h:455
bool operator!=(const LED &other) const
Comparison operator
Definition: CameraState.h:472
bool operator==(const LED &other) const
Comparison operator
Definition: CameraState.h:466
bool operator>(const LED &other) const
Comparison operator
Definition: CameraState.h:484
friend std::ostream & operator<<(std::ostream &stream, const LED &value)
Operator to serialize the value to a stream
Definition: CameraState.h:490
double ValueType
The type of the underlying value
Definition: CameraState.h:443
static constexpr Range< double > validRange()
The range of valid values for LED
Definition: CameraState.h:446
Lens temperature
Definition: CameraState.h:505
double ValueType
The type of the underlying value
Definition: CameraState.h:520
bool operator==(const Lens &other) const
Comparison operator
Definition: CameraState.h:543
Lens()=default
Default constructor
double value() const
Get the value
bool operator>(const Lens &other) const
Comparison operator
Definition: CameraState.h:561
bool operator!=(const Lens &other) const
Comparison operator
Definition: CameraState.h:549
friend std::ostream & operator<<(std::ostream &stream, const Lens &value)
Operator to serialize the value to a stream
Definition: CameraState.h:567
std::string toString() const
Get the value as string
constexpr Lens(double value)
Constructor
Definition: CameraState.h:532
static constexpr Range< double > validRange()
The range of valid values for Lens
Definition: CameraState.h:523
bool operator<(const Lens &other) const
Comparison operator
Definition: CameraState.h:555
PCB temperature
Definition: CameraState.h:582
bool operator!=(const PCB &other) const
Comparison operator
Definition: CameraState.h:626
constexpr PCB(double value)
Constructor
Definition: CameraState.h:609
PCB()=default
Default constructor
bool operator==(const PCB &other) const
Comparison operator
Definition: CameraState.h:620
friend std::ostream & operator<<(std::ostream &stream, const PCB &value)
Operator to serialize the value to a stream
Definition: CameraState.h:644
static constexpr Range< double > validRange()
The range of valid values for PCB
Definition: CameraState.h:600
double value() const
Get the value
bool operator>(const PCB &other) const
Comparison operator
Definition: CameraState.h:638
double ValueType
The type of the underlying value
Definition: CameraState.h:597
std::string toString() const
Get the value as string
bool operator<(const PCB &other) const
Comparison operator
Definition: CameraState.h:632
Current temperature(s)
Definition: CameraState.h:258
DMD & dmd()
Get DMD
Definition: CameraState.h:780
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:891
LED & led()
Get LED
Definition: CameraState.h:818
const DMD & dmd() const
Get DMD
Definition: CameraState.h:774
const PCB & pcb() const
Get PCB
Definition: CameraState.h:850
const CameraState::Temperature::General & get() const
Definition: CameraState.h:877
bool operator!=(const Temperature &other) const
Inequality operator
Temperature & set(const General &value)
Set General
Definition: CameraState.h:805
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:935
Temperature(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:691
std::string toString() const
Get the value as string
bool operator==(const Temperature &other) const
Equality operator
Temperature & set(const LED &value)
Set LED
Definition: CameraState.h:824
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:756
General & general()
Get General
Definition: CameraState.h:799
const LED & led() const
Get LED
Definition: CameraState.h:812
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:721
const General & general() const
Get General
Definition: CameraState.h:793
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:898
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:946
Temperature & set(const Lens &value)
Set Lens
Definition: CameraState.h:843
Temperature & set(const DMD &value)
Set DMD
Definition: CameraState.h:786
const Lens & lens() const
Get Lens
Definition: CameraState.h:831
Temperature & set(const PCB &value)
Set PCB
Definition: CameraState.h:862
Temperature()
Default constructor
Lens & lens()
Get Lens
Definition: CameraState.h:837
friend std::ostream & operator<<(std::ostream &stream, const Temperature &value)
Operator to send the value as string to a stream
Definition: CameraState.h:965
PCB & pcb()
Get PCB
Definition: CameraState.h:856
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:870
std::tuple< CameraState::Temperature::DMD, CameraState::Temperature::General, CameraState::Temperature::LED, CameraState::Temperature::Lens, CameraState::Temperature::PCB > Descendants
Definition: CameraState.h:661
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:884
Information about camera connection state, temperatures, etc.
Definition: CameraState.h:76
Available & isAvailable()
Get Available
Definition: CameraState.h:1124
const CameraState::Connected & get() const
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:1100
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 Available &value)
Set Available
Definition: CameraState.h:1130
std::string toString() const
Get the value as string
CameraState & set(const Temperature::LED &value)
Set Temperature::LED
Definition: CameraState.h:1189
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:1257
friend std::ostream & operator<<(std::ostream &stream, const CameraState &value)
Operator to send the value as string to a stream
Definition: CameraState.h:1308
const CameraState::Temperature & get() const
Definition: CameraState.h:1222
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:1291
void save(const std::string &fileName) const
Save to the given file
const CameraState::Temperature::General & get() const
Definition: CameraState.h:1236
const Connected & isConnected() const
Get Connected
Definition: CameraState.h:1137
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:1250
const Temperature & temperature() const
Get Temperature
Definition: CameraState.h:1156
CameraState & set(const Temperature::DMD &value)
Set Temperature::DMD
Definition: CameraState.h:1175
CameraState & set(const Temperature::Lens &value)
Set Temperature::Lens
Definition: CameraState.h:1196
bool operator!=(const CameraState &other) const
Inequality operator
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:1229
CameraState & set(const Connected &value)
Set Connected
Definition: CameraState.h:1149
Connected & isConnected()
Get Connected
Definition: CameraState.h:1143
CameraState & set(const Temperature::General &value)
Set Temperature::General
Definition: CameraState.h:1182
bool operator==(const CameraState &other) const
Equality operator
CameraState()
Default constructor
Temperature & temperature()
Get Temperature
Definition: CameraState.h:1162
CameraState & set(const Temperature &value)
Set Temperature
Definition: CameraState.h:1168
CameraState(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:1029
CameraState & set(const Temperature::PCB &value)
Set Temperature::PCB
Definition: CameraState.h:1203
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:1282
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:1062
const CameraState::Available & get() const
Definition: CameraState.h:1210
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:1243
const Available & isAvailable() const
Get Available
Definition: CameraState.h:1118
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:993
Class describing a range of values for a given type T
Definition: Range.h:58
NodeType
Definition: NodeType.h:56
The main Zivid namespace. All Zivid code is found here
Definition: Application.h:55