Zivid C++ API  1.8.1+6967bc1b-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-2020 (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 Support <support@zivid.com>
42  * Info: http://www.zivid.com
43  ******************************************************************************/
44 
45 #pragma once
46 
47 #include <chrono>
48 #include <ctime>
49 #include <iomanip>
50 #include <memory>
51 #include <sstream>
52 #include <string>
53 #include <tuple>
54 #include <utility>
55 #include <vector>
56 
57 #include "Zivid/APIExport.h"
58 #include "Zivid/Range.h"
59 
60 #ifdef _MSC_VER
61 # pragma warning(push)
62 # pragma warning(disable : 4251) // "X needs to have dll-interface to be used by clients of class Y."
63 #endif
64 
65 namespace Zivid
66 {
68  class ZIVID_API_EXPORT CameraState
69  {
70  public:
71  static constexpr size_t version{ 1 };
72 
73 #ifndef NO_DOC
74  template<size_t>
75  struct Version;
76 
77  using LatestVersion = Zivid::CameraState;
78 #endif
79 
81  ~CameraState();
82 
84  CameraState(const CameraState &other);
85 
87  CameraState &operator=(const CameraState &other);
88 
90  CameraState(CameraState &&other) noexcept;
91 
93  CameraState &operator=(CameraState &&other) noexcept;
94 
96  CameraState() = default;
97 
99  static constexpr bool isContainer{ true };
100 
102  static constexpr const char *path{ "" };
103 
105  static constexpr const char *name{ "CameraState" };
106 
108  static constexpr const char *description{
109  R"description(Information about camera connection state, live mode, temperatures, etc.)description"
110  };
111 
113  void set(const std::string &fullPath, const std::string &value);
114 
116  std::string getString(const std::string &fullPath) const;
117 
119  class ZIVID_API_EXPORT Available
120  {
121  public:
123  using ValueType = bool;
124  static const Available yes;
125  static const Available no;
126 
128  static constexpr bool isContainer{ false };
129 
131  static constexpr const char *path{ "Available" };
132 
134  static constexpr const char *name{ "Available" };
135 
137  static constexpr const char *description{
138  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"
139  };
140 
142  Available() = default;
143 
145  explicit constexpr Available(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
146  : m_value{ value }
147  {}
148 
150  const ValueType &value() const
151  {
152  return m_value;
153  }
154 
156  void setFromString(const std::string &value)
157  {
158  if(value == "yes")
159  {
160  m_value = true;
161  }
162  else if(value == "no")
163  {
164  m_value = false;
165  }
166  else
167  {
168  throw std::invalid_argument("Available{ " + value + " } is not in range [yes, no]");
169  }
170  }
171 
173  std::string toString() const
174  {
175  return m_value ? "yes" : "no";
176  }
177 
179  explicit operator bool() const
180  {
181  return m_value;
182  }
183 
185  bool operator==(const Available &other) const
186  {
187  return m_value == other.m_value;
188  }
189 
191  bool operator!=(const Available &other) const
192  {
193  return m_value != other.m_value;
194  }
195 
197  friend std::ostream &operator<<(std::ostream &stream, const Available &value)
198  {
199  return stream << value.toString();
200  }
201 
203  friend std::istream &operator>>(std::istream &stream, Available &value)
204  {
205  value.setFromString(
206  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
207  return stream;
208  }
209 
210  private:
211  ValueType m_value{ false };
212  };
213 
216  {
217  public:
219  using ValueType = bool;
220  static const Connected yes;
221  static const Connected no;
222 
224  static constexpr bool isContainer{ false };
225 
227  static constexpr const char *path{ "Connected" };
228 
230  static constexpr const char *name{ "Connected" };
231 
233  static constexpr const char *description{
234  R"description(Flag if camera is connected in software)description"
235  };
236 
238  Connected() = default;
239 
241  explicit constexpr Connected(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
242  : m_value{ value }
243  {}
244 
246  const ValueType &value() const
247  {
248  return m_value;
249  }
250 
252  void setFromString(const std::string &value)
253  {
254  if(value == "yes")
255  {
256  m_value = true;
257  }
258  else if(value == "no")
259  {
260  m_value = false;
261  }
262  else
263  {
264  throw std::invalid_argument("Connected{ " + value + " } is not in range [yes, no]");
265  }
266  }
267 
269  std::string toString() const
270  {
271  return m_value ? "yes" : "no";
272  }
273 
275  explicit operator bool() const
276  {
277  return m_value;
278  }
279 
281  bool operator==(const Connected &other) const
282  {
283  return m_value == other.m_value;
284  }
285 
287  bool operator!=(const Connected &other) const
288  {
289  return m_value != other.m_value;
290  }
291 
293  friend std::ostream &operator<<(std::ostream &stream, const Connected &value)
294  {
295  return stream << value.toString();
296  }
297 
299  friend std::istream &operator>>(std::istream &stream, Connected &value)
300  {
301  value.setFromString(
302  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
303  return stream;
304  }
305 
306  private:
307  ValueType m_value{ false };
308  };
309 
311  class ZIVID_API_EXPORT Live
312  {
313  public:
315  using ValueType = bool;
316  static const Live yes;
317  static const Live no;
318 
320  static constexpr bool isContainer{ false };
321 
323  static constexpr const char *path{ "Live" };
324 
326  static constexpr const char *name{ "Live" };
327 
329  static constexpr const char *description{ R"description(Camera live status)description" };
330 
332  Live() = default;
333 
335  explicit constexpr Live(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
336  : m_value{ value }
337  {}
338 
340  const ValueType &value() const
341  {
342  return m_value;
343  }
344 
346  void setFromString(const std::string &value)
347  {
348  if(value == "yes")
349  {
350  m_value = true;
351  }
352  else if(value == "no")
353  {
354  m_value = false;
355  }
356  else
357  {
358  throw std::invalid_argument("Live{ " + value + " } is not in range [yes, no]");
359  }
360  }
361 
363  std::string toString() const
364  {
365  return m_value ? "yes" : "no";
366  }
367 
369  explicit operator bool() const
370  {
371  return m_value;
372  }
373 
375  bool operator==(const Live &other) const
376  {
377  return m_value == other.m_value;
378  }
379 
381  bool operator!=(const Live &other) const
382  {
383  return m_value != other.m_value;
384  }
385 
387  friend std::ostream &operator<<(std::ostream &stream, const Live &value)
388  {
389  return stream << value.toString();
390  }
391 
393  friend std::istream &operator>>(std::istream &stream, Live &value)
394  {
396  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
397  return stream;
398  }
399 
400  private:
401  ValueType m_value{ false };
402  };
403 
406  {
407  public:
409  Temperature() = default;
410 
412  static constexpr bool isContainer{ true };
413 
415  static constexpr const char *path{ "Temperature" };
416 
418  static constexpr const char *name{ "Temperature" };
419 
421  static constexpr const char *description{ R"description(Current temperature(s))description" };
422 
424  void set(const std::string &fullPath, const std::string &value);
425 
427  std::string getString(const std::string &fullPath) const;
428 
430  class ZIVID_API_EXPORT DMD
431  {
432  public:
434  using ValueType = double;
435 
437  static constexpr bool isContainer{ false };
438 
440  static constexpr const char *path{ "Temperature/DMD" };
441 
443  static constexpr const char *name{ "DMD" };
444 
446  static constexpr const char *description{ R"description(DMD temperature)description" };
447 
449  DMD() = default;
450 
452  explicit constexpr DMD(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
453  : m_value{ value }
454  {}
455 
457  const ValueType &value() const
458  {
459  return m_value;
460  }
461 
463  Range<ValueType> range() const
464  {
465  return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
466  }
467 
469  void setFromString(const std::string &value)
470  {
471  m_value = std::stod(value);
472  }
473 
475  std::string toString() const
476  {
477  return std::to_string(m_value);
478  }
479 
481  bool operator==(const DMD &other) const
482  {
483  return m_value == other.m_value;
484  }
485 
487  bool operator!=(const DMD &other) const
488  {
489  return m_value != other.m_value;
490  }
491 
493  bool operator<(const DMD &other) const
494  {
495  return m_value < other.m_value;
496  }
497 
499  bool operator>(const DMD &other) const
500  {
501  return m_value > other.m_value;
502  }
503 
505  friend std::ostream &operator<<(std::ostream &stream, const DMD &value)
506  {
507  return stream << value.toString();
508  }
509 
511  friend std::istream &operator>>(std::istream &stream, DMD &value)
512  {
514  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
515  return stream;
516  }
517 
518  private:
519  ValueType m_value{ 0.0 };
520  };
521 
523  class ZIVID_API_EXPORT General
524  {
525  public:
527  using ValueType = double;
528 
530  static constexpr bool isContainer{ false };
531 
533  static constexpr const char *path{ "Temperature/General" };
534 
536  static constexpr const char *name{ "General" };
537 
539  static constexpr const char *description{ R"description(General temperature)description" };
540 
542  General() = default;
543 
545  explicit constexpr General(ValueType value) noexcept(
546  std::is_nothrow_copy_constructible<ValueType>::value)
547  : m_value{ value }
548  {}
549 
551  const ValueType &value() const
552  {
553  return m_value;
554  }
555 
557  Range<ValueType> range() const
558  {
559  return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
560  }
561 
563  void setFromString(const std::string &value)
564  {
565  m_value = std::stod(value);
566  }
567 
569  std::string toString() const
570  {
571  return std::to_string(m_value);
572  }
573 
575  bool operator==(const General &other) const
576  {
577  return m_value == other.m_value;
578  }
579 
581  bool operator!=(const General &other) const
582  {
583  return m_value != other.m_value;
584  }
585 
587  bool operator<(const General &other) const
588  {
589  return m_value < other.m_value;
590  }
591 
593  bool operator>(const General &other) const
594  {
595  return m_value > other.m_value;
596  }
597 
599  friend std::ostream &operator<<(std::ostream &stream, const General &value)
600  {
601  return stream << value.toString();
602  }
603 
605  friend std::istream &operator>>(std::istream &stream, General &value)
606  {
607  value.setFromString(
608  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
609  return stream;
610  }
611 
612  private:
613  ValueType m_value{ 0.0 };
614  };
615 
617  class ZIVID_API_EXPORT LED
618  {
619  public:
621  using ValueType = double;
622 
624  static constexpr bool isContainer{ false };
625 
627  static constexpr const char *path{ "Temperature/LED" };
628 
630  static constexpr const char *name{ "LED" };
631 
633  static constexpr const char *description{ R"description(LED temperature)description" };
634 
636  LED() = default;
637 
639  explicit constexpr LED(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
640  : m_value{ value }
641  {}
642 
644  const ValueType &value() const
645  {
646  return m_value;
647  }
648 
650  Range<ValueType> range() const
651  {
652  return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
653  }
654 
656  void setFromString(const std::string &value)
657  {
658  m_value = std::stod(value);
659  }
660 
662  std::string toString() const
663  {
664  return std::to_string(m_value);
665  }
666 
668  bool operator==(const LED &other) const
669  {
670  return m_value == other.m_value;
671  }
672 
674  bool operator!=(const LED &other) const
675  {
676  return m_value != other.m_value;
677  }
678 
680  bool operator<(const LED &other) const
681  {
682  return m_value < other.m_value;
683  }
684 
686  bool operator>(const LED &other) const
687  {
688  return m_value > other.m_value;
689  }
690 
692  friend std::ostream &operator<<(std::ostream &stream, const LED &value)
693  {
694  return stream << value.toString();
695  }
696 
698  friend std::istream &operator>>(std::istream &stream, LED &value)
699  {
701  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
702  return stream;
703  }
704 
705  private:
706  ValueType m_value{ 0.0 };
707  };
708 
710  class ZIVID_API_EXPORT Lens
711  {
712  public:
714  using ValueType = double;
715 
717  static constexpr bool isContainer{ false };
718 
720  static constexpr const char *path{ "Temperature/Lens" };
721 
723  static constexpr const char *name{ "Lens" };
724 
726  static constexpr const char *description{ R"description(Lens temperature)description" };
727 
729  Lens() = default;
730 
732  explicit constexpr Lens(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
733  : m_value{ value }
734  {}
735 
737  const ValueType &value() const
738  {
739  return m_value;
740  }
741 
743  Range<ValueType> range() const
744  {
745  return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
746  }
747 
749  void setFromString(const std::string &value)
750  {
751  m_value = std::stod(value);
752  }
753 
755  std::string toString() const
756  {
757  return std::to_string(m_value);
758  }
759 
761  bool operator==(const Lens &other) const
762  {
763  return m_value == other.m_value;
764  }
765 
767  bool operator!=(const Lens &other) const
768  {
769  return m_value != other.m_value;
770  }
771 
773  bool operator<(const Lens &other) const
774  {
775  return m_value < other.m_value;
776  }
777 
779  bool operator>(const Lens &other) const
780  {
781  return m_value > other.m_value;
782  }
783 
785  friend std::ostream &operator<<(std::ostream &stream, const Lens &value)
786  {
787  return stream << value.toString();
788  }
789 
791  friend std::istream &operator>>(std::istream &stream, Lens &value)
792  {
794  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
795  return stream;
796  }
797 
798  private:
799  ValueType m_value{ 0.0 };
800  };
801 
803  class ZIVID_API_EXPORT PCB
804  {
805  public:
807  using ValueType = double;
808 
810  static constexpr bool isContainer{ false };
811 
813  static constexpr const char *path{ "Temperature/PCB" };
814 
816  static constexpr const char *name{ "PCB" };
817 
819  static constexpr const char *description{ R"description(PCB temperature)description" };
820 
822  PCB() = default;
823 
825  explicit constexpr PCB(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
826  : m_value{ value }
827  {}
828 
830  const ValueType &value() const
831  {
832  return m_value;
833  }
834 
836  Range<ValueType> range() const
837  {
838  return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
839  }
840 
842  void setFromString(const std::string &value)
843  {
844  m_value = std::stod(value);
845  }
846 
848  std::string toString() const
849  {
850  return std::to_string(m_value);
851  }
852 
854  bool operator==(const PCB &other) const
855  {
856  return m_value == other.m_value;
857  }
858 
860  bool operator!=(const PCB &other) const
861  {
862  return m_value != other.m_value;
863  }
864 
866  bool operator<(const PCB &other) const
867  {
868  return m_value < other.m_value;
869  }
870 
872  bool operator>(const PCB &other) const
873  {
874  return m_value > other.m_value;
875  }
876 
878  friend std::ostream &operator<<(std::ostream &stream, const PCB &value)
879  {
880  return stream << value.toString();
881  }
882 
884  friend std::istream &operator>>(std::istream &stream, PCB &value)
885  {
887  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
888  return stream;
889  }
890 
891  private:
892  ValueType m_value{ 0.0 };
893  };
894 
895  template<typename T,
896  typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
897  const CameraState::Temperature::DMD &get() const
898  {
899  return m_dmd;
900  }
901 
902  template<typename T,
903  typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
905  {
906  return m_general;
907  }
908 
909  template<typename T,
910  typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
911  const CameraState::Temperature::LED &get() const
912  {
913  return m_led;
914  }
915 
916  template<typename T,
917  typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
918  const CameraState::Temperature::Lens &get() const
919  {
920  return m_lens;
921  }
922 
923  template<typename T,
924  typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
925  const CameraState::Temperature::PCB &get() const
926  {
927  return m_pcb;
928  }
929 
930  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
931  const CameraState::Temperature::DMD &get() const
932  {
933  return m_dmd;
934  }
935 
936  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
937  const CameraState::Temperature::General &get() const
938  {
939  return m_general;
940  }
941 
942  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
943  const CameraState::Temperature::LED &get() const
944  {
945  return m_led;
946  }
947 
948  template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
949  const CameraState::Temperature::Lens &get() const
950  {
951  return m_lens;
952  }
953 
954  template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
955  const CameraState::Temperature::PCB &get() const
956  {
957  return m_pcb;
958  }
959 
961  explicit Temperature(const DMD &dmd,
962  const General &general,
963  const LED &led,
964  const Lens &lens,
965  const PCB &pcb);
966 
967  private:
968  DMD m_dmd{};
969 
970  public:
972  Temperature &set(const DMD &value)
973  {
974  if(value.value() < value.range().min() || value.value() > value.range().max())
975  {
976  throw std::out_of_range("DMD{ " + std::to_string(value.value()) + " } is not in range ["
977  + std::to_string(value.range().min()) + ", "
978  + std::to_string(value.range().max()) + "]");
979  }
980 
981  m_dmd = value;
982  return *this;
983  }
985  const DMD &dmd() const
986  {
987  return m_dmd;
988  }
989 
990  private:
991  General m_general{};
992 
993  public:
995  Temperature &set(const General &value)
996  {
997  if(value.value() < value.range().min() || value.value() > value.range().max())
998  {
999  throw std::out_of_range("General{ " + std::to_string(value.value()) + " } is not in range ["
1000  + std::to_string(value.range().min()) + ", "
1001  + std::to_string(value.range().max()) + "]");
1002  }
1003 
1004  m_general = value;
1005  return *this;
1006  }
1008  const General &general() const
1009  {
1010  return m_general;
1011  }
1012 
1013  private:
1014  LED m_led{};
1015 
1016  public:
1018  Temperature &set(const LED &value)
1019  {
1020  if(value.value() < value.range().min() || value.value() > value.range().max())
1021  {
1022  throw std::out_of_range("LED{ " + std::to_string(value.value()) + " } is not in range ["
1023  + std::to_string(value.range().min()) + ", "
1024  + std::to_string(value.range().max()) + "]");
1025  }
1026 
1027  m_led = value;
1028  return *this;
1029  }
1031  const LED &led() const
1032  {
1033  return m_led;
1034  }
1035 
1036  private:
1037  Lens m_lens{};
1038 
1039  public:
1041  Temperature &set(const Lens &value)
1042  {
1043  if(value.value() < value.range().min() || value.value() > value.range().max())
1044  {
1045  throw std::out_of_range("Lens{ " + std::to_string(value.value()) + " } is not in range ["
1046  + std::to_string(value.range().min()) + ", "
1047  + std::to_string(value.range().max()) + "]");
1048  }
1049 
1050  m_lens = value;
1051  return *this;
1052  }
1054  const Lens &lens() const
1055  {
1056  return m_lens;
1057  }
1058 
1059  private:
1060  PCB m_pcb{};
1061 
1062  public:
1064  Temperature &set(const PCB &value)
1065  {
1066  if(value.value() < value.range().min() || value.value() > value.range().max())
1067  {
1068  throw std::out_of_range("PCB{ " + std::to_string(value.value()) + " } is not in range ["
1069  + std::to_string(value.range().min()) + ", "
1070  + std::to_string(value.range().max()) + "]");
1071  }
1072 
1073  m_pcb = value;
1074  return *this;
1075  }
1077  const PCB &pcb() const
1078  {
1079  return m_pcb;
1080  }
1081 
1083  template<typename F>
1084  void forEach(const F &f) const
1085  {
1086  f(m_dmd);
1087  f(m_general);
1088  f(m_led);
1089  f(m_lens);
1090  f(m_pcb);
1091  }
1092 
1094  template<typename F>
1095  void forEach(const F &f)
1096  {
1097  f(m_dmd);
1098  f(m_general);
1099  f(m_led);
1100  f(m_lens);
1101  f(m_pcb);
1102  }
1103 
1105  template<typename F>
1106  void traverseValues(const F &f) const
1107  {
1108  f(m_dmd);
1109  f(m_general);
1110  f(m_led);
1111  f(m_lens);
1112  f(m_pcb);
1113  }
1114 
1116  template<typename F>
1117  void traverseValues(const F &f)
1118  {
1119  f(m_dmd);
1120  f(m_general);
1121  f(m_led);
1122  f(m_lens);
1123  f(m_pcb);
1124  }
1125 
1127  std::string toString() const;
1128 
1130  friend std::ostream &operator<<(std::ostream &stream, const Temperature &value)
1131  {
1132  return stream << value.toString();
1133  }
1134 
1136  void setFromString(const std::string &value);
1137 
1139  friend std::istream &operator>>(std::istream &stream, Temperature &value)
1140  {
1141  value.setFromString(
1142  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
1143  return stream;
1144  }
1145 
1147  bool operator==(const Temperature &other) const;
1148 
1150  bool operator!=(const Temperature &other) const;
1151  };
1152 
1153  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Available>::value, int>::type = 0>
1154  const CameraState::Available &get() const
1155  {
1156  return m_available;
1157  }
1158 
1159  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Connected>::value, int>::type = 0>
1160  const CameraState::Connected &get() const
1161  {
1162  return m_connected;
1163  }
1164 
1165  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Live>::value, int>::type = 0>
1166  const CameraState::Live &get() const
1167  {
1168  return m_live;
1169  }
1170 
1171  template<typename T, typename std::enable_if<std::is_same<T, CameraState::Temperature>::value, int>::type = 0>
1172  const CameraState::Temperature &get() const
1173  {
1174  return m_temperature;
1175  }
1176 
1177  template<typename T,
1178  typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value, int>::type = 0>
1179  const CameraState::Temperature::DMD &get() const
1180  {
1181  return m_temperature.get<CameraState::Temperature::DMD>();
1182  }
1183 
1184  template<typename T,
1185  typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value, int>::type = 0>
1186  const CameraState::Temperature::General &get() const
1187  {
1188  return m_temperature.get<CameraState::Temperature::General>();
1189  }
1190 
1191  template<typename T,
1192  typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value, int>::type = 0>
1193  const CameraState::Temperature::LED &get() const
1194  {
1195  return m_temperature.get<CameraState::Temperature::LED>();
1196  }
1197 
1198  template<typename T,
1199  typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value, int>::type = 0>
1200  const CameraState::Temperature::Lens &get() const
1201  {
1202  return m_temperature.get<CameraState::Temperature::Lens>();
1203  }
1204 
1205  template<typename T,
1206  typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value, int>::type = 0>
1207  const CameraState::Temperature::PCB &get() const
1208  {
1209  return m_temperature.get<CameraState::Temperature::PCB>();
1210  }
1211 
1212  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1213  const CameraState::Available &get() const
1214  {
1215  return m_available;
1216  }
1217 
1218  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1219  const CameraState::Connected &get() const
1220  {
1221  return m_connected;
1222  }
1223 
1224  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1225  const CameraState::Live &get() const
1226  {
1227  return m_live;
1228  }
1229 
1230  template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1231  const CameraState::Temperature &get() const
1232  {
1233  return m_temperature;
1234  }
1235 
1237  explicit CameraState(const Available &available,
1238  const Connected &connected,
1239  const Live &live,
1240  const Temperature &temperature);
1241 
1242  private:
1243  Available m_available{};
1244 
1245  public:
1247  CameraState &set(const Available &value)
1248  {
1249  m_available = value;
1250  return *this;
1251  }
1253  const Available &isAvailable() const
1254  {
1255  return m_available;
1256  }
1257 
1258  private:
1259  Connected m_connected{};
1260 
1261  public:
1263  CameraState &set(const Connected &value)
1264  {
1265  m_connected = value;
1266  return *this;
1267  }
1269  const Connected &isConnected() const
1270  {
1271  return m_connected;
1272  }
1273 
1274  private:
1275  Live m_live{};
1276 
1277  public:
1279  CameraState &set(const Live &value)
1280  {
1281  m_live = value;
1282  return *this;
1283  }
1285  const Live &live() const
1286  {
1287  return m_live;
1288  }
1289 
1290  private:
1291  Temperature m_temperature{};
1293  public:
1295  CameraState &set(const Temperature &value)
1296  {
1297  m_temperature = value;
1298  return *this;
1299  }
1301  const Temperature &temperature() const
1302  {
1303  return m_temperature;
1304  }
1305 
1307  CameraState &set(const Temperature::DMD &value)
1308  {
1309  m_temperature.set(value);
1310  return *this;
1311  }
1312 
1314  CameraState &set(const Temperature::General &value)
1315  {
1316  m_temperature.set(value);
1317  return *this;
1318  }
1319 
1321  CameraState &set(const Temperature::LED &value)
1322  {
1323  m_temperature.set(value);
1324  return *this;
1325  }
1328  CameraState &set(const Temperature::Lens &value)
1329  {
1330  m_temperature.set(value);
1331  return *this;
1332  }
1333 
1335  CameraState &set(const Temperature::PCB &value)
1336  {
1337  m_temperature.set(value);
1338  return *this;
1339  }
1340 
1342  template<typename F>
1343  void forEach(const F &f) const
1344  {
1345  f(m_available);
1346  f(m_connected);
1347  f(m_live);
1348  f(m_temperature);
1349  }
1350 
1352  template<typename F>
1353  void forEach(const F &f)
1354  {
1355  f(m_available);
1356  f(m_connected);
1357  f(m_live);
1358  f(m_temperature);
1359  }
1360 
1362  template<typename F>
1363  void traverseValues(const F &f) const
1364  {
1365  f(m_available);
1366  f(m_connected);
1367  f(m_live);
1368  m_temperature.traverseValues(f);
1369  }
1370 
1372  template<typename F>
1373  void traverseValues(const F &f)
1374  {
1375  f(m_available);
1376  f(m_connected);
1377  f(m_live);
1378  m_temperature.traverseValues(f);
1379  }
1382  std::string toString() const;
1383 
1385  friend std::ostream &operator<<(std::ostream &stream, const CameraState &value)
1386  {
1387  return stream << value.toString();
1388  }
1389 
1391  void setFromString(const std::string &value);
1392 
1394  friend std::istream &operator>>(std::istream &stream, CameraState &value)
1395  {
1396  value.setFromString(
1397  std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
1398  return stream;
1399  }
1402  bool operator==(const CameraState &other) const;
1403 
1405  bool operator!=(const CameraState &other) const;
1406 
1408  explicit CameraState(const std::string &fileName);
1409 
1411  void save(const std::string &fileName) const;
1412 
1414  void load(const std::string &fileName);
1415  };
1416 
1417 #ifndef NO_DOC
1418  template<>
1419  struct CameraState::Version<1>
1420  {
1421  using Type = CameraState;
1422  };
1423 #endif
1424 
1425 } // namespace Zivid
1426 
1427 #ifdef _MSC_VER
1428 # pragma warning(pop)
1429 #endif
1430 
1431 #ifndef NO_DOC
1432 # if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1433 namespace std // NOLINT
1434 {
1435  template<>
1436  struct tuple_size<Zivid::CameraState::Temperature> : integral_constant<size_t, 5>
1437  {};
1438 
1439  template<size_t i>
1440  struct tuple_element<i, Zivid::CameraState::Temperature>
1441  {
1442  using type // NOLINT
1443  = decltype(declval<Zivid::CameraState::Temperature>().get<i>());
1444  };
1445 
1446  template<>
1447  struct tuple_size<Zivid::CameraState> : integral_constant<size_t, 4>
1448  {};
1449 
1450  template<size_t i>
1451  struct tuple_element<i, Zivid::CameraState>
1452  {
1453  using type // NOLINT
1454  = decltype(declval<Zivid::CameraState>().get<i>());
1455  };
1456 
1457 } // namespace std
1458 # endif
1459 #endif
Zivid::toString
ZIVID_API_EXPORT std::string toString(const std::exception &exception)
Get string representation of the exception
Zivid::CameraState::toString
std::string toString() const
Get the value as string
Zivid::CameraState::Connected::ValueType
bool ValueType
The type of the underlying value
Definition: CameraState.h:298
Zivid::CameraState::Live::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:425
Zivid::CameraState::Temperature::PCB::range
Range< ValueType > range() const
The range of valid values
Definition: CameraState.h:915
Zivid::CameraState::Temperature::Lens::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:828
Zivid::CameraState::Temperature::PCB::ValueType
double ValueType
The type of the underlying value
Definition: CameraState.h:886
Zivid::CameraState::Live::ValueType
bool ValueType
The type of the underlying value
Definition: CameraState.h:394
Zivid::CameraState::Temperature::PCB::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:921
Zivid::CameraState::Temperature::DMD::ValueType
double ValueType
The type of the underlying value
Definition: CameraState.h:513
Zivid::CameraState::Live
Camera live status
Definition: CameraState.h:390
Zivid::CameraState::Temperature::Lens::toString
std::string toString() const
Get the value as string
Definition: CameraState.h:834
Zivid::CameraState::Temperature::PCB::value
const ValueType & value() const
Get the value
Definition: CameraState.h:909
Zivid::CameraState::Temperature::LED::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:735
Zivid::CameraState::Available
Flag if camera is physically connected to the computer, but not connected in software....
Definition: CameraState.h:198
Zivid::CameraState::Temperature::DMD::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:548
Zivid::CameraState::Temperature::DMD::range
Range< ValueType > range() const
The range of valid values
Definition: CameraState.h:542
Zivid::CameraState::Connected
Flag if camera is connected in software
Definition: CameraState.h:294
Zivid::CameraState::Temperature::LED
LED temperature
Definition: CameraState.h:696
Zivid::CameraState::Temperature::LED::ValueType
double ValueType
The type of the underlying value
Definition: CameraState.h:700
Zivid::CameraState::setFromString
void setFromString(const std::string &value)
Set from the given string
Zivid::CameraState::CameraState
CameraState()=default
Default constructor
Zivid::CameraState::Temperature::DMD::value
const ValueType & value() const
Get the value
Definition: CameraState.h:536
Zivid::CameraState::Temperature
Current temperature(s)
Definition: CameraState.h:484
Range.h
Zivid::CameraState::set
void set(const std::string &fullPath, const std::string &value)
Set a value from string by specifying the path
Zivid::CameraState
Information about camera connection state, live mode, temperatures, etc.
Definition: CameraState.h:107
Zivid::CameraState::Available::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:235
Zivid::CameraState::Temperature::LED::range
Range< ValueType > range() const
The range of valid values
Definition: CameraState.h:729
APIExport.h
Zivid::CameraState::Temperature::LED::value
const ValueType & value() const
Get the value
Definition: CameraState.h:723
Zivid::CameraState::Temperature::General
General temperature
Definition: CameraState.h:602
Zivid::CameraState::Temperature::Lens::ValueType
double ValueType
The type of the underlying value
Definition: CameraState.h:793
Zivid::CameraState::Temperature::DMD
DMD temperature
Definition: CameraState.h:509
Zivid::CameraState::Temperature::PCB
PCB temperature
Definition: CameraState.h:882
Zivid::CameraState::Temperature::General::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:642
Zivid
The main Zivid namespace. All Zivid code is found here
Definition: Application.h:52
Zivid::CameraState::Temperature::setFromString
void setFromString(const std::string &value)
Set from the given string
Zivid::CameraState::Temperature::General::ValueType
double ValueType
The type of the underlying value
Definition: CameraState.h:606
Zivid::CameraState::Temperature::toString
std::string toString() const
Get the value as string
ZIVID_API_EXPORT
#define ZIVID_API_EXPORT
Definition: APIExport.h:56
Zivid::CameraState::Temperature::Lens
Lens temperature
Definition: CameraState.h:789
Zivid::CameraState::Temperature::LED::toString
std::string toString() const
Get the value as string
Definition: CameraState.h:741
Zivid::CameraState::Available::ValueType
bool ValueType
The type of the underlying value
Definition: CameraState.h:202
Zivid::operator<<
ZIVID_API_EXPORT std::ostream & operator<<(std::ostream &stream, const Camera &camera)
Serialize the value to a stream
Zivid::CameraState::Temperature::PCB::toString
std::string toString() const
Get the value as string
Definition: CameraState.h:927
Zivid::CameraState::Connected::setFromString
void setFromString(const std::string &value)
Set the value from string
Definition: CameraState.h:331
Zivid::Range
Class describing a range of values for a given type T The range boudaries for both minimum and maximu...
Definition: Range.h:95