Zivid C++ API  2.4.2+1a2e8cfb-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-2021 (C) Zivid AS
10 
11  * All rights reserved.
12 
13  *
14 
15  * Zivid Software License, v1.0
16 
17  *
18 
19  * Redistribution and use in source and binary forms, with or without
20 
21  * modification, are permitted provided that the following conditions are met:
22 
23  *
24 
25  * 1. Redistributions of source code must retain the above copyright notice,
26 
27  * this list of conditions and the following disclaimer.
28 
29  *
30 
31  * 2. Redistributions in binary form must reproduce the above copyright notice,
32 
33  * this list of conditions and the following disclaimer in the documentation
34 
35  * and/or other materials provided with the distribution.
36 
37  *
38 
39  * 3. Neither the name of Zivid AS nor the names of its contributors may be used
40 
41  * to endorse or promote products derived from this software without specific
42 
43  * prior written permission.
44 
45  *
46 
47  * 4. This software, with or without modification, must not be used with any
48 
49  * other 3D camera than from Zivid AS.
50 
51  *
52 
53  * 5. Any software provided in binary form under this license must not be
54 
55  * reverse engineered, decompiled, modified and/or disassembled.
56 
57  *
58 
59  * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
60 
61  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
62 
63  * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
64 
65  * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
66 
67  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
68 
69  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
70 
71  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
72 
73  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
74 
75  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
76 
77  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
78 
79  *
80 
81  * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
82 
83  * Info: http://www.zivid.com
84 
85  ******************************************************************************/
86 
87 
88 
89 #pragma once
90 
91 #include <array>
92 #include <chrono>
93 #include <cmath>
94 #include <ctime>
95 #include <iomanip>
96 #include <memory>
97 #include <set>
98 #include <sstream>
99 #include <string>
100 #include <tuple>
101 #include <utility>
102 #include <vector>
103 
106 #include "Zivid/DataModel/Traits.h"
107 #include "Zivid/Detail/CoreExport.h"
108 #include "Zivid/Detail/TypeTraits.h"
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 
116 namespace Zivid
117 {
120  {
121  public:
123  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
124 
126  static constexpr const char *path{ "" };
127 
129  static constexpr const char *name{ "CameraState" };
130 
132  static constexpr const char *description{
133  R"description(Information about camera connection state, temperatures, etc.)description"
134  };
135 
136  static constexpr size_t version{ 2 };
137 
138 #ifndef NO_DOC
139  template<size_t>
140  struct Version;
141 
142  using LatestVersion = Zivid::CameraState;
143 
144  // Short identifier. This value is not guaranteed to be universally unique
145  // Todo(ZIVID-2808): Move this to internal DataModelExt header
146  static constexpr std::array<uint8_t, 3> binaryId{ 'c', 's', 't' };
147 
148 #endif
149 
152  {
153  public:
156 
158  static constexpr const char *path{ "Available" };
159 
161  static constexpr const char *name{ "Available" };
162 
164  static constexpr const char *description{
165  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"
166  };
167 
169  using ValueType = bool;
170  static const Available yes;
171  static const Available no;
172 
174  static std::set<bool> validValues()
175  {
176  return { false, true };
177  }
178 
180  Available() = default;
181 
183  explicit constexpr Available(bool value)
184  : m_value{ value }
185  {}
186 
188  bool value() const;
189 
191  std::string toString() const;
192 
194  explicit operator bool() const
195  {
196  return m_value;
197  }
198 
200  bool operator==(const Available &other) const
201  {
202  return m_value == other.m_value;
203  }
204 
206  bool operator!=(const Available &other) const
207  {
208  return m_value != other.m_value;
209  }
210 
212  friend std::ostream &operator<<(std::ostream &stream, const Available &value)
213  {
214  return stream << value.toString();
215  }
216 
217  private:
218  void setFromString(const std::string &value);
219 
220  bool m_value{ false };
221 
222  friend struct DataModel::Detail::Befriend<Available>;
223  };
224 
227  {
228  public:
231 
233  static constexpr const char *path{ "Connected" };
234 
236  static constexpr const char *name{ "Connected" };
237 
239  static constexpr const char *description{
240  R"description(Flag if camera is connected in software)description"
241  };
242 
244  using ValueType = bool;
245  static const Connected yes;
246  static const Connected no;
247 
249  static std::set<bool> validValues()
250  {
251  return { false, true };
252  }
253 
255  Connected() = default;
256 
258  explicit constexpr Connected(bool value)
259  : m_value{ value }
260  {}
261 
263  bool value() const;
264 
266  std::string toString() const;
267 
269  explicit operator bool() const
270  {
271  return m_value;
272  }
273 
275  bool operator==(const Connected &other) const
276  {
277  return m_value == other.m_value;
278  }
279 
281  bool operator!=(const Connected &other) const
282  {
283  return m_value != other.m_value;
284  }
285 
287  friend std::ostream &operator<<(std::ostream &stream, const Connected &value)
288  {
289  return stream << value.toString();
290  }
291 
292  private:
293  void setFromString(const std::string &value);
294 
295  bool m_value{ false };
296 
297  friend struct DataModel::Detail::Befriend<Connected>;
298  };
299 
302  {
303  public:
305  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
306 
308  static constexpr const char *path{ "Temperature" };
309 
311  static constexpr const char *name{ "Temperature" };
312 
314  static constexpr const char *description{ R"description(Current temperature(s))description" };
315 
318  {
319  public:
322 
324  static constexpr const char *path{ "Temperature/DMD" };
325 
327  static constexpr const char *name{ "DMD" };
328 
330  static constexpr const char *description{ R"description(DMD temperature)description" };
331 
333  using ValueType = double;
334 
336  static constexpr Range<double> validRange()
337  {
338  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
339  }
340 
342  DMD() = default;
343 
345  explicit constexpr DMD(double value)
346  : m_value{ value }
347  {}
348 
350  double value() const;
351 
353  std::string toString() const;
354 
356  bool operator==(const DMD &other) const
357  {
358  return m_value == other.m_value;
359  }
360 
362  bool operator!=(const DMD &other) const
363  {
364  return m_value != other.m_value;
365  }
366 
368  bool operator<(const DMD &other) const
369  {
370  return m_value < other.m_value;
371  }
372 
374  bool operator>(const DMD &other) const
375  {
376  return m_value > other.m_value;
377  }
378 
380  friend std::ostream &operator<<(std::ostream &stream, const DMD &value)
381  {
382  return stream << value.toString();
383  }
384 
385  private:
386  void setFromString(const std::string &value);
387 
388  double m_value{ 0.0 };
389 
390  friend struct DataModel::Detail::Befriend<DMD>;
391  };
392 
395  {
396  public:
399 
401  static constexpr const char *path{ "Temperature/General" };
402 
404  static constexpr const char *name{ "General" };
405 
407  static constexpr const char *description{ R"description(General temperature)description" };
408 
410  using ValueType = double;
411 
413  static constexpr Range<double> validRange()
414  {
415  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
416  }
417 
419  General() = default;
420 
422  explicit constexpr General(double value)
423  : m_value{ value }
424  {}
425 
427  double value() const;
428 
430  std::string toString() const;
431 
433  bool operator==(const General &other) const
434  {
435  return m_value == other.m_value;
436  }
437 
439  bool operator!=(const General &other) const
440  {
441  return m_value != other.m_value;
442  }
443 
445  bool operator<(const General &other) const
446  {
447  return m_value < other.m_value;
448  }
449 
451  bool operator>(const General &other) const
452  {
453  return m_value > other.m_value;
454  }
455 
457  friend std::ostream &operator<<(std::ostream &stream, const General &value)
458  {
459  return stream << value.toString();
460  }
461 
462  private:
463  void setFromString(const std::string &value);
464 
465  double m_value{ 0.0 };
466 
467  friend struct DataModel::Detail::Befriend<General>;
468  };
469 
472  {
473  public:
476 
478  static constexpr const char *path{ "Temperature/LED" };
479 
481  static constexpr const char *name{ "LED" };
482 
484  static constexpr const char *description{ R"description(LED temperature)description" };
485 
487  using ValueType = double;
488 
490  static constexpr Range<double> validRange()
491  {
492  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
493  }
494 
496  LED() = default;
497 
499  explicit constexpr LED(double value)
500  : m_value{ value }
501  {}
502 
504  double value() const;
505 
507  std::string toString() const;
508 
510  bool operator==(const LED &other) const
511  {
512  return m_value == other.m_value;
513  }
514 
516  bool operator!=(const LED &other) const
517  {
518  return m_value != other.m_value;
519  }
520 
522  bool operator<(const LED &other) const
523  {
524  return m_value < other.m_value;
525  }
526 
528  bool operator>(const LED &other) const
529  {
530  return m_value > other.m_value;
531  }
532 
534  friend std::ostream &operator<<(std::ostream &stream, const LED &value)
535  {
536  return stream << value.toString();
537  }
538 
539  private:
540  void setFromString(const std::string &value);
541 
542  double m_value{ 0.0 };
543 
544  friend struct DataModel::Detail::Befriend<LED>;
545  };
546 
549  {
550  public:
553 
555  static constexpr const char *path{ "Temperature/Lens" };
556 
558  static constexpr const char *name{ "Lens" };
559 
561  static constexpr const char *description{ R"description(Lens temperature)description" };
562 
564  using ValueType = double;
565 
567  static constexpr Range<double> validRange()
568  {
569  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
570  }
571 
573  Lens() = default;
574 
576  explicit constexpr Lens(double value)
577  : m_value{ value }
578  {}
579 
581  double value() const;
582 
584  std::string toString() const;
585 
587  bool operator==(const Lens &other) const
588  {
589  return m_value == other.m_value;
590  }
591 
593  bool operator!=(const Lens &other) const
594  {
595  return m_value != other.m_value;
596  }
597 
599  bool operator<(const Lens &other) const
600  {
601  return m_value < other.m_value;
602  }
603 
605  bool operator>(const Lens &other) const
606  {
607  return m_value > other.m_value;
608  }
609 
611  friend std::ostream &operator<<(std::ostream &stream, const Lens &value)
612  {
613  return stream << value.toString();
614  }
615 
616  private:
617  void setFromString(const std::string &value);
618 
619  double m_value{ 0.0 };
620 
621  friend struct DataModel::Detail::Befriend<Lens>;
622  };
623 
626  {
627  public:
630 
632  static constexpr const char *path{ "Temperature/PCB" };
633 
635  static constexpr const char *name{ "PCB" };
636 
638  static constexpr const char *description{ R"description(PCB temperature)description" };
639 
641  using ValueType = double;
642 
644  static constexpr Range<double> validRange()
645  {
646  return { std::numeric_limits<double>::lowest(), std::numeric_limits<double>::max() };
647  }
648 
650  PCB() = default;
651 
653  explicit constexpr PCB(double value)
654  : m_value{ value }
655  {}
656 
658  double value() const;
659 
661  std::string toString() const;
662 
664  bool operator==(const PCB &other) const
665  {
666  return m_value == other.m_value;
667  }
668 
670  bool operator!=(const PCB &other) const
671  {
672  return m_value != other.m_value;
673  }
674 
676  bool operator<(const PCB &other) const
677  {
678  return m_value < other.m_value;
679  }
680 
682  bool operator>(const PCB &other) const
683  {
684  return m_value > other.m_value;
685  }
686 
688  friend std::ostream &operator<<(std::ostream &stream, const PCB &value)
689  {
690  return stream << value.toString();
691  }
692 
693  private:
694  void setFromString(const std::string &value);
695 
696  double m_value{ 0.0 };
697 
698  friend struct DataModel::Detail::Befriend<PCB>;
699  };
700 
706 
709 
725 #ifndef NO_DOC
726  template<typename... Args,
727  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
728  typename std::enable_if<
729  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
730  typename std::decay<Args>::type...>::value,
731  int>::type = 0>
732 #else
733  template<typename... Args>
734 #endif
735  explicit Temperature(Args &&...args)
736  {
737  using namespace Zivid::Detail::TypeTraits;
738 
739  static_assert(AllArgsDecayedAreUnique<Args...>::value,
740  "Found duplicate types among the arguments passed to Temperature(...). "
741  "Types should be listed at most once.");
742 
743  set(std::forward<Args>(args)...);
744  }
745 
760 #ifndef NO_DOC
761  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
762 #else
763  template<typename... Args>
764 #endif
765  void set(Args &&...args)
766  {
767  using namespace Zivid::Detail::TypeTraits;
768 
769  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
770  static_assert(AllArgsAreDescendantNodes::value,
771  "All arguments passed to set(...) must be descendant nodes.");
772 
773  static_assert(AllArgsDecayedAreUnique<Args...>::value,
774  "Found duplicate types among the arguments passed to set(...). "
775  "Types should be listed at most once.");
776 
777  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
778  }
779 
795 #ifndef NO_DOC
796  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
797 #else
798  template<typename... Args>
799 #endif
800  Temperature copyWith(Args &&...args) const
801  {
802  using namespace Zivid::Detail::TypeTraits;
803 
804  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
805  static_assert(AllArgsAreDescendantNodes::value,
806  "All arguments passed to copyWith(...) must be descendant nodes.");
807 
808  static_assert(AllArgsDecayedAreUnique<Args...>::value,
809  "Found duplicate types among the arguments passed to copyWith(...). "
810  "Types should be listed at most once.");
811 
812  auto copy{ *this };
813  copy.set(std::forward<Args>(args)...);
814  return copy;
815  }
816 
818  const DMD &dmd() const
819  {
820  return m_dmd;
821  }
822 
824  DMD &dmd()
825  {
826  return m_dmd;
827  }
828 
830  Temperature &set(const DMD &value)
831  {
832  m_dmd = value;
833  return *this;
834  }
835 
837  const General &general() const
838  {
839  return m_general;
840  }
841 
844  {
845  return m_general;
846  }
847 
849  Temperature &set(const General &value)
850  {
851  m_general = value;
852  return *this;
853  }
854 
856  const LED &led() const
857  {
858  return m_led;
859  }
860 
862  LED &led()
863  {
864  return m_led;
865  }
866 
868  Temperature &set(const LED &value)
869  {
870  m_led = value;
871  return *this;
872  }
873 
875  const Lens &lens() const
876  {
877  return m_lens;
878  }
879 
882  {
883  return m_lens;
884  }
885 
887  Temperature &set(const Lens &value)
888  {
889  m_lens = value;
890  return *this;
891  }
892 
894  const PCB &pcb() const
895  {
896  return m_pcb;
897  }
898 
900  PCB &pcb()
901  {
902  return m_pcb;
903  }
904 
906  Temperature &set(const PCB &value)
907  {
908  m_pcb = value;
909  return *this;
910  }
911 
912  template<typename T,
913  typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
915  {
916  return m_dmd;
917  }
918 
919  template<typename T,
920  typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
922  {
923  return m_general;
924  }
925 
926  template<typename T,
927  typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
929  {
930  return m_led;
931  }
932 
933  template<typename T,
934  typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
936  {
937  return m_lens;
938  }
939 
940  template<typename T,
941  typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
943  {
944  return m_pcb;
945  }
946 
947  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
949  {
950  return m_dmd;
951  }
952 
953  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
955  {
956  return m_general;
957  }
958 
959  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
961  {
962  return m_led;
963  }
964 
965  template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
967  {
968  return m_lens;
969  }
970 
971  template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
973  {
974  return m_pcb;
975  }
976 
978  template<typename F>
979  void forEach(const F &f) const
980  {
981  f(m_dmd);
982  f(m_general);
983  f(m_led);
984  f(m_lens);
985  f(m_pcb);
986  }
987 
989  template<typename F>
990  void forEach(const F &f)
991  {
992  f(m_dmd);
993  f(m_general);
994  f(m_led);
995  f(m_lens);
996  f(m_pcb);
997  }
998 
1000  bool operator==(const Temperature &other) const;
1001 
1003  bool operator!=(const Temperature &other) const;
1004 
1006  std::string toString() const;
1007 
1009  friend std::ostream &operator<<(std::ostream &stream, const Temperature &value)
1010  {
1011  return stream << value.toString();
1012  }
1013 
1014  private:
1015  void setFromString(const std::string &value);
1016 
1017  void setFromString(const std::string &fullPath, const std::string &value);
1018 
1019  std::string getString(const std::string &fullPath) const;
1020 
1021  DMD m_dmd;
1022  General m_general;
1023  LED m_led;
1024  Lens m_lens;
1025  PCB m_pcb;
1026 
1027  friend struct DataModel::Detail::Befriend<Temperature>;
1028  };
1029 
1038 
1041 
1043  explicit CameraState(const std::string &fileName);
1044 
1063 #ifndef NO_DOC
1064  template<
1065  typename... Args,
1066  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1067  typename std::enable_if<
1068  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1069  int>::type = 0>
1070 #else
1071  template<typename... Args>
1072 #endif
1073  explicit CameraState(Args &&...args)
1074  {
1075  using namespace Zivid::Detail::TypeTraits;
1076 
1077  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1078  "Found duplicate types among the arguments passed to CameraState(...). "
1079  "Types should be listed at most once.");
1080 
1081  set(std::forward<Args>(args)...);
1082  }
1083 
1101 #ifndef NO_DOC
1102  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1103 #else
1104  template<typename... Args>
1105 #endif
1106  void set(Args &&...args)
1107  {
1108  using namespace Zivid::Detail::TypeTraits;
1109 
1110  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1111  static_assert(AllArgsAreDescendantNodes::value,
1112  "All arguments passed to set(...) must be descendant nodes.");
1113 
1114  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1115  "Found duplicate types among the arguments passed to set(...). "
1116  "Types should be listed at most once.");
1117 
1118  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1119  }
1120 
1139 #ifndef NO_DOC
1140  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1141 #else
1142  template<typename... Args>
1143 #endif
1144  CameraState copyWith(Args &&...args) const
1145  {
1146  using namespace Zivid::Detail::TypeTraits;
1147 
1148  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1149  static_assert(AllArgsAreDescendantNodes::value,
1150  "All arguments passed to copyWith(...) must be descendant nodes.");
1151 
1152  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1153  "Found duplicate types among the arguments passed to copyWith(...). "
1154  "Types should be listed at most once.");
1155 
1156  auto copy{ *this };
1157  copy.set(std::forward<Args>(args)...);
1158  return copy;
1159  }
1160 
1162  const Available &isAvailable() const
1163  {
1164  return m_available;
1165  }
1166 
1169  {
1170  return m_available;
1171  }
1172 
1174  CameraState &set(const Available &value)
1175  {
1176  m_available = value;
1177  return *this;
1178  }
1179 
1181  const Connected &isConnected() const
1182  {
1183  return m_connected;
1184  }
1185 
1188  {
1189  return m_connected;
1190  }
1191 
1193  CameraState &set(const Connected &value)
1194  {
1195  m_connected = value;
1196  return *this;
1197  }
1198 
1200  const Temperature &temperature() const
1201  {
1202  return m_temperature;
1203  }
1204 
1207  {
1208  return m_temperature;
1209  }
1210 
1212  CameraState &set(const Temperature &value)
1213  {
1214  m_temperature = value;
1215  return *this;
1216  }
1217 
1220  {
1221  m_temperature.set(value);
1222  return *this;
1223  }
1224 
1227  {
1228  m_temperature.set(value);
1229  return *this;
1230  }
1231 
1234  {
1235  m_temperature.set(value);
1236  return *this;
1237  }
1238 
1241  {
1242  m_temperature.set(value);
1243  return *this;
1244  }
1245 
1248  {
1249  m_temperature.set(value);
1250  return *this;
1251  }
1252 
1253  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Available>::value, int>::type = 0>
1255  {
1256  return m_available;
1257  }
1258 
1259  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Connected>::value, int>::type = 0>
1261  {
1262  return m_connected;
1263  }
1264 
1265  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Temperature>::value, int>::type = 0>
1267  {
1268  return m_temperature;
1269  }
1270 
1271  template<typename T,
1272  typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
1274  {
1275  return m_temperature.get<CameraState::Temperature::DMD>();
1276  }
1277 
1278  template<typename T,
1279  typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
1281  {
1282  return m_temperature.get<CameraState::Temperature::General>();
1283  }
1284 
1285  template<typename T,
1286  typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
1288  {
1289  return m_temperature.get<CameraState::Temperature::LED>();
1290  }
1291 
1292  template<typename T,
1293  typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
1295  {
1296  return m_temperature.get<CameraState::Temperature::Lens>();
1297  }
1298 
1299  template<typename T,
1300  typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
1302  {
1303  return m_temperature.get<CameraState::Temperature::PCB>();
1304  }
1305 
1306  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1308  {
1309  return m_available;
1310  }
1311 
1312  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1314  {
1315  return m_connected;
1316  }
1317 
1318  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1320  {
1321  return m_temperature;
1322  }
1323 
1325  template<typename F>
1326  void forEach(const F &f) const
1327  {
1328  f(m_available);
1329  f(m_connected);
1330  f(m_temperature);
1331  }
1332 
1334  template<typename F>
1335  void forEach(const F &f)
1336  {
1337  f(m_available);
1338  f(m_connected);
1339  f(m_temperature);
1340  }
1341 
1343  bool operator==(const CameraState &other) const;
1344 
1346  bool operator!=(const CameraState &other) const;
1347 
1349  std::string toString() const;
1350 
1352  friend std::ostream &operator<<(std::ostream &stream, const CameraState &value)
1353  {
1354  return stream << value.toString();
1355  }
1356 
1358  void save(const std::string &fileName) const;
1359 
1361  void load(const std::string &fileName);
1362 
1363  private:
1364  void setFromString(const std::string &value);
1365 
1366  void setFromString(const std::string &fullPath, const std::string &value);
1367 
1368  std::string getString(const std::string &fullPath) const;
1369 
1370  Available m_available;
1371  Connected m_connected;
1372  Temperature m_temperature;
1373 
1374  friend struct DataModel::Detail::Befriend<CameraState>;
1375  };
1376 
1377 #ifndef NO_DOC
1378  template<>
1379  struct CameraState::Version<2>
1380  {
1381  using Type = CameraState;
1382  };
1383 #endif
1384 
1385 } // namespace Zivid
1386 
1387 #ifdef _MSC_VER
1388 # pragma warning(pop)
1389 #endif
1390 
1391 #ifndef NO_DOC
1392 # if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1393 namespace std // NOLINT
1394 {
1395  template<>
1396  struct tuple_size<Zivid::CameraState::Temperature> : integral_constant<size_t, 5>
1397  {};
1398 
1399  template<size_t i>
1400  struct tuple_element<i, Zivid::CameraState::Temperature>
1401  {
1402  static_assert(i < tuple_size<Zivid::CameraState::Temperature>::value, "Index must be less than 5");
1403 
1404  using type // NOLINT
1405  = decltype(declval<Zivid::CameraState::Temperature>().get<i>());
1406  };
1407 
1408  template<>
1409  struct tuple_size<Zivid::CameraState> : integral_constant<size_t, 3>
1410  {};
1411 
1412  template<size_t i>
1413  struct tuple_element<i, Zivid::CameraState>
1414  {
1415  static_assert(i < tuple_size<Zivid::CameraState>::value, "Index must be less than 3");
1416 
1417  using type // NOLINT
1418  = decltype(declval<Zivid::CameraState>().get<i>());
1419  };
1420 
1421 } // namespace std
1422 # endif
1423 #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:152
static const Available no
Off/disabled.
Definition: CameraState.h:171
bool operator==(const Available &other) const
Comparison operator
Definition: CameraState.h:200
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:212
bool ValueType
The type of the underlying value
Definition: CameraState.h:169
static const Available yes
On/enabled.
Definition: CameraState.h:170
bool operator!=(const Available &other) const
Comparison operator
Definition: CameraState.h:206
constexpr Available(bool value)
Constructor
Definition: CameraState.h:183
bool value() const
Get the value
static std::set< bool > validValues()
All valid values of Available
Definition: CameraState.h:174
Available()=default
Default constructor
Flag if camera is connected in software
Definition: CameraState.h:227
Connected()=default
Default constructor
static const Connected yes
On/enabled.
Definition: CameraState.h:245
static std::set< bool > validValues()
All valid values of Connected
Definition: CameraState.h:249
static const Connected no
Off/disabled.
Definition: CameraState.h:246
bool operator!=(const Connected &other) const
Comparison operator
Definition: CameraState.h:281
friend std::ostream & operator<<(std::ostream &stream, const Connected &value)
Operator to serialize the value to a stream
Definition: CameraState.h:287
constexpr Connected(bool value)
Constructor
Definition: CameraState.h:258
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:275
bool ValueType
The type of the underlying value
Definition: CameraState.h:244
DMD temperature
Definition: CameraState.h:318
bool operator>(const DMD &other) const
Comparison operator
Definition: CameraState.h:374
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:362
bool operator<(const DMD &other) const
Comparison operator
Definition: CameraState.h:368
friend std::ostream & operator<<(std::ostream &stream, const DMD &value)
Operator to serialize the value to a stream
Definition: CameraState.h:380
double ValueType
The type of the underlying value
Definition: CameraState.h:333
static constexpr Range< double > validRange()
The range of valid values for DMD
Definition: CameraState.h:336
constexpr DMD(double value)
Constructor
Definition: CameraState.h:345
bool operator==(const DMD &other) const
Comparison operator
Definition: CameraState.h:356
DMD()=default
Default constructor
General temperature
Definition: CameraState.h:395
static constexpr Range< double > validRange()
The range of valid values for General
Definition: CameraState.h:413
double ValueType
The type of the underlying value
Definition: CameraState.h:410
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:445
constexpr General(double value)
Constructor
Definition: CameraState.h:422
bool operator==(const General &other) const
Comparison operator
Definition: CameraState.h:433
General()=default
Default constructor
bool operator!=(const General &other) const
Comparison operator
Definition: CameraState.h:439
bool operator>(const General &other) const
Comparison operator
Definition: CameraState.h:451
friend std::ostream & operator<<(std::ostream &stream, const General &value)
Operator to serialize the value to a stream
Definition: CameraState.h:457
LED temperature
Definition: CameraState.h:472
std::string toString() const
Get the value as string
bool operator<(const LED &other) const
Comparison operator
Definition: CameraState.h:522
double value() const
Get the value
LED()=default
Default constructor
constexpr LED(double value)
Constructor
Definition: CameraState.h:499
bool operator!=(const LED &other) const
Comparison operator
Definition: CameraState.h:516
bool operator==(const LED &other) const
Comparison operator
Definition: CameraState.h:510
bool operator>(const LED &other) const
Comparison operator
Definition: CameraState.h:528
friend std::ostream & operator<<(std::ostream &stream, const LED &value)
Operator to serialize the value to a stream
Definition: CameraState.h:534
double ValueType
The type of the underlying value
Definition: CameraState.h:487
static constexpr Range< double > validRange()
The range of valid values for LED
Definition: CameraState.h:490
Lens temperature
Definition: CameraState.h:549
double ValueType
The type of the underlying value
Definition: CameraState.h:564
bool operator==(const Lens &other) const
Comparison operator
Definition: CameraState.h:587
Lens()=default
Default constructor
double value() const
Get the value
bool operator>(const Lens &other) const
Comparison operator
Definition: CameraState.h:605
bool operator!=(const Lens &other) const
Comparison operator
Definition: CameraState.h:593
friend std::ostream & operator<<(std::ostream &stream, const Lens &value)
Operator to serialize the value to a stream
Definition: CameraState.h:611
std::string toString() const
Get the value as string
constexpr Lens(double value)
Constructor
Definition: CameraState.h:576
static constexpr Range< double > validRange()
The range of valid values for Lens
Definition: CameraState.h:567
bool operator<(const Lens &other) const
Comparison operator
Definition: CameraState.h:599
PCB temperature
Definition: CameraState.h:626
bool operator!=(const PCB &other) const
Comparison operator
Definition: CameraState.h:670
constexpr PCB(double value)
Constructor
Definition: CameraState.h:653
PCB()=default
Default constructor
bool operator==(const PCB &other) const
Comparison operator
Definition: CameraState.h:664
friend std::ostream & operator<<(std::ostream &stream, const PCB &value)
Operator to serialize the value to a stream
Definition: CameraState.h:688
static constexpr Range< double > validRange()
The range of valid values for PCB
Definition: CameraState.h:644
double value() const
Get the value
bool operator>(const PCB &other) const
Comparison operator
Definition: CameraState.h:682
double ValueType
The type of the underlying value
Definition: CameraState.h:641
std::string toString() const
Get the value as string
bool operator<(const PCB &other) const
Comparison operator
Definition: CameraState.h:676
Current temperature(s)
Definition: CameraState.h:302
DMD & dmd()
Get DMD
Definition: CameraState.h:824
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:935
LED & led()
Get LED
Definition: CameraState.h:862
const DMD & dmd() const
Get DMD
Definition: CameraState.h:818
const PCB & pcb() const
Get PCB
Definition: CameraState.h:894
const CameraState::Temperature::General & get() const
Definition: CameraState.h:921
bool operator!=(const Temperature &other) const
Inequality operator
Temperature & set(const General &value)
Set General
Definition: CameraState.h:849
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:979
Temperature(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:735
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:868
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:800
General & general()
Get General
Definition: CameraState.h:843
const LED & led() const
Get LED
Definition: CameraState.h:856
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:765
const General & general() const
Get General
Definition: CameraState.h:837
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:942
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:990
Temperature & set(const Lens &value)
Set Lens
Definition: CameraState.h:887
Temperature & set(const DMD &value)
Set DMD
Definition: CameraState.h:830
const Lens & lens() const
Get Lens
Definition: CameraState.h:875
Temperature & set(const PCB &value)
Set PCB
Definition: CameraState.h:906
Temperature()
Default constructor
Lens & lens()
Get Lens
Definition: CameraState.h:881
friend std::ostream & operator<<(std::ostream &stream, const Temperature &value)
Operator to send the value as string to a stream
Definition: CameraState.h:1009
PCB & pcb()
Get PCB
Definition: CameraState.h:900
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:914
std::tuple< CameraState::Temperature::DMD, CameraState::Temperature::General, CameraState::Temperature::LED, CameraState::Temperature::Lens, CameraState::Temperature::PCB > Descendants
Definition: CameraState.h:705
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:928
Information about camera connection state, temperatures, etc.
Definition: CameraState.h:120
Available & isAvailable()
Get Available
Definition: CameraState.h:1168
const CameraState::Connected & get() const
Definition: CameraState.h:1260
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:1144
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:1174
std::string toString() const
Get the value as string
CameraState & set(const Temperature::LED &value)
Set Temperature::LED
Definition: CameraState.h:1233
const CameraState::Temperature::PCB & get() const
Definition: CameraState.h:1301
friend std::ostream & operator<<(std::ostream &stream, const CameraState &value)
Operator to send the value as string to a stream
Definition: CameraState.h:1352
const CameraState::Temperature & get() const
Definition: CameraState.h:1266
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraState.h:1335
void save(const std::string &fileName) const
Save to the given file
const CameraState::Temperature::General & get() const
Definition: CameraState.h:1280
const Connected & isConnected() const
Get Connected
Definition: CameraState.h:1181
const CameraState::Temperature::Lens & get() const
Definition: CameraState.h:1294
const Temperature & temperature() const
Get Temperature
Definition: CameraState.h:1200
CameraState & set(const Temperature::DMD &value)
Set Temperature::DMD
Definition: CameraState.h:1219
CameraState & set(const Temperature::Lens &value)
Set Temperature::Lens
Definition: CameraState.h:1240
bool operator!=(const CameraState &other) const
Inequality operator
const CameraState::Temperature::DMD & get() const
Definition: CameraState.h:1273
CameraState & set(const Connected &value)
Set Connected
Definition: CameraState.h:1193
Connected & isConnected()
Get Connected
Definition: CameraState.h:1187
CameraState & set(const Temperature::General &value)
Set Temperature::General
Definition: CameraState.h:1226
bool operator==(const CameraState &other) const
Equality operator
CameraState()
Default constructor
Temperature & temperature()
Get Temperature
Definition: CameraState.h:1206
CameraState & set(const Temperature &value)
Set Temperature
Definition: CameraState.h:1212
CameraState(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraState.h:1073
CameraState & set(const Temperature::PCB &value)
Set Temperature::PCB
Definition: CameraState.h:1247
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:1326
void set(Args &&...args)
Set multiple arguments
Definition: CameraState.h:1106
const CameraState::Available & get() const
Definition: CameraState.h:1254
const CameraState::Temperature::LED & get() const
Definition: CameraState.h:1287
const Available & isAvailable() const
Get Available
Definition: CameraState.h:1162
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:1037
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