Zivid C++ API  2.4.2+1a2e8cfb-1
Defining the Future of 3D Machine Vision
CameraInfo.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{ "CameraInfo" };
130 
132  static constexpr const char *description{
133  R"description(Information about camera model, serial number etc.)description"
134  };
135 
136  static constexpr size_t version{ 1 };
137 
138 #ifndef NO_DOC
139  template<size_t>
140  struct Version;
141 
142  using LatestVersion = Zivid::CameraInfo;
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{ 'n', 'f', 'o' };
147 
148 #endif
149 
152  {
153  public:
156 
158  static constexpr const char *path{ "FirmwareVersion" };
159 
161  static constexpr const char *name{ "FirmwareVersion" };
162 
164  static constexpr const char *description{ R"description(The firmware version on the camera)description" };
165 
167  using ValueType = std::string;
168 
171  {
172  return { 0, std::numeric_limits<ValueType::size_type>::max() };
173  }
174 
176  FirmwareVersion() = default;
177 
179  explicit FirmwareVersion(std::string value)
180  : m_value{ std::move(value) }
181  {}
182 
184  const std::string &value() const;
185 
187  std::string toString() const;
188 
190  bool operator==(const FirmwareVersion &other) const
191  {
192  return m_value == other.m_value;
193  }
194 
196  bool operator!=(const FirmwareVersion &other) const
197  {
198  return m_value != other.m_value;
199  }
200 
202  bool operator<(const FirmwareVersion &other) const
203  {
204  return m_value < other.m_value;
205  }
206 
208  bool operator>(const FirmwareVersion &other) const
209  {
210  return m_value > other.m_value;
211  }
212 
214  friend std::ostream &operator<<(std::ostream &stream, const FirmwareVersion &value)
215  {
216  return stream << value.toString();
217  }
218 
219  private:
220  void setFromString(const std::string &value);
221 
222  std::string m_value{};
223 
224  friend struct DataModel::Detail::Befriend<FirmwareVersion>;
225  };
226 
229  {
230  public:
233 
235  static constexpr const char *path{ "ModelName" };
236 
238  static constexpr const char *name{ "ModelName" };
239 
241  static constexpr const char *description{ R"description(The model name of the camera)description" };
242 
244  using ValueType = std::string;
245 
248  {
249  return { 0, std::numeric_limits<ValueType::size_type>::max() };
250  }
251 
253  ModelName() = default;
254 
256  explicit ModelName(std::string value)
257  : m_value{ std::move(value) }
258  {}
259 
261  const std::string &value() const;
262 
264  std::string toString() const;
265 
267  bool operator==(const ModelName &other) const
268  {
269  return m_value == other.m_value;
270  }
271 
273  bool operator!=(const ModelName &other) const
274  {
275  return m_value != other.m_value;
276  }
277 
279  bool operator<(const ModelName &other) const
280  {
281  return m_value < other.m_value;
282  }
283 
285  bool operator>(const ModelName &other) const
286  {
287  return m_value > other.m_value;
288  }
289 
291  friend std::ostream &operator<<(std::ostream &stream, const ModelName &value)
292  {
293  return stream << value.toString();
294  }
295 
296  private:
297  void setFromString(const std::string &value);
298 
299  std::string m_value{};
300 
301  friend struct DataModel::Detail::Befriend<ModelName>;
302  };
303 
306  {
307  public:
309  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
310 
312  static constexpr const char *path{ "Revision" };
313 
315  static constexpr const char *name{ "Revision" };
316 
318  static constexpr const char *description{ R"description(The hardware revision of the camera)description" };
319 
322  {
323  public:
326 
328  static constexpr const char *path{ "Revision/Major" };
329 
331  static constexpr const char *name{ "Major" };
332 
334  static constexpr const char *description{ R"description(Major hardware revision number)description" };
335 
337  using ValueType = uint32_t;
338 
340  static constexpr Range<uint32_t> validRange()
341  {
342  return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
343  }
344 
346  Major() = default;
347 
349  explicit constexpr Major(uint32_t value)
350  : m_value{ value }
351  {}
352 
354  uint32_t value() const;
355 
357  std::string toString() const;
358 
360  bool operator==(const Major &other) const
361  {
362  return m_value == other.m_value;
363  }
364 
366  bool operator!=(const Major &other) const
367  {
368  return m_value != other.m_value;
369  }
370 
372  bool operator<(const Major &other) const
373  {
374  return m_value < other.m_value;
375  }
376 
378  bool operator>(const Major &other) const
379  {
380  return m_value > other.m_value;
381  }
382 
384  friend std::ostream &operator<<(std::ostream &stream, const Major &value)
385  {
386  return stream << value.toString();
387  }
388 
389  private:
390  void setFromString(const std::string &value);
391 
392  uint32_t m_value{ 0 };
393 
394  friend struct DataModel::Detail::Befriend<Major>;
395  };
396 
399  {
400  public:
403 
405  static constexpr const char *path{ "Revision/Minor" };
406 
408  static constexpr const char *name{ "Minor" };
409 
411  static constexpr const char *description{ R"description(Minor hardware revision number)description" };
412 
414  using ValueType = uint32_t;
415 
417  static constexpr Range<uint32_t> validRange()
418  {
419  return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
420  }
421 
423  Minor() = default;
424 
426  explicit constexpr Minor(uint32_t value)
427  : m_value{ value }
428  {}
429 
431  uint32_t value() const;
432 
434  std::string toString() const;
435 
437  bool operator==(const Minor &other) const
438  {
439  return m_value == other.m_value;
440  }
441 
443  bool operator!=(const Minor &other) const
444  {
445  return m_value != other.m_value;
446  }
447 
449  bool operator<(const Minor &other) const
450  {
451  return m_value < other.m_value;
452  }
453 
455  bool operator>(const Minor &other) const
456  {
457  return m_value > other.m_value;
458  }
459 
461  friend std::ostream &operator<<(std::ostream &stream, const Minor &value)
462  {
463  return stream << value.toString();
464  }
465 
466  private:
467  void setFromString(const std::string &value);
468 
469  uint32_t m_value{ 0 };
470 
471  friend struct DataModel::Detail::Befriend<Minor>;
472  };
473 
474  using Descendants = std::tuple<CameraInfo::Revision::Major, CameraInfo::Revision::Minor>;
475 
478 
491 #ifndef NO_DOC
492  template<typename... Args,
493  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
494  typename std::enable_if<
495  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
496  typename std::decay<Args>::type...>::value,
497  int>::type = 0>
498 #else
499  template<typename... Args>
500 #endif
501  explicit Revision(Args &&...args)
502  {
503  using namespace Zivid::Detail::TypeTraits;
504 
505  static_assert(AllArgsDecayedAreUnique<Args...>::value,
506  "Found duplicate types among the arguments passed to Revision(...). "
507  "Types should be listed at most once.");
508 
509  set(std::forward<Args>(args)...);
510  }
511 
523 #ifndef NO_DOC
524  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
525 #else
526  template<typename... Args>
527 #endif
528  void set(Args &&...args)
529  {
530  using namespace Zivid::Detail::TypeTraits;
531 
532  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
533  static_assert(AllArgsAreDescendantNodes::value,
534  "All arguments passed to set(...) must be descendant nodes.");
535 
536  static_assert(AllArgsDecayedAreUnique<Args...>::value,
537  "Found duplicate types among the arguments passed to set(...). "
538  "Types should be listed at most once.");
539 
540  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
541  }
542 
555 #ifndef NO_DOC
556  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
557 #else
558  template<typename... Args>
559 #endif
560  Revision copyWith(Args &&...args) const
561  {
562  using namespace Zivid::Detail::TypeTraits;
563 
564  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
565  static_assert(AllArgsAreDescendantNodes::value,
566  "All arguments passed to copyWith(...) must be descendant nodes.");
567 
568  static_assert(AllArgsDecayedAreUnique<Args...>::value,
569  "Found duplicate types among the arguments passed to copyWith(...). "
570  "Types should be listed at most once.");
571 
572  auto copy{ *this };
573  copy.set(std::forward<Args>(args)...);
574  return copy;
575  }
576 
578  const Major &major() const
579  {
580  return m_major;
581  }
582 
585  {
586  return m_major;
587  }
588 
590  Revision &set(const Major &value)
591  {
592  m_major = value;
593  return *this;
594  }
595 
597  const Minor &minor() const
598  {
599  return m_minor;
600  }
601 
604  {
605  return m_minor;
606  }
607 
609  Revision &set(const Minor &value)
610  {
611  m_minor = value;
612  return *this;
613  }
614 
615  template<typename T,
616  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
618  {
619  return m_major;
620  }
621 
622  template<typename T,
623  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
625  {
626  return m_minor;
627  }
628 
629  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
631  {
632  return m_major;
633  }
634 
635  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
637  {
638  return m_minor;
639  }
640 
642  template<typename F>
643  void forEach(const F &f) const
644  {
645  f(m_major);
646  f(m_minor);
647  }
648 
650  template<typename F>
651  void forEach(const F &f)
652  {
653  f(m_major);
654  f(m_minor);
655  }
656 
658  bool operator==(const Revision &other) const;
659 
661  bool operator!=(const Revision &other) const;
662 
664  std::string toString() const;
665 
667  friend std::ostream &operator<<(std::ostream &stream, const Revision &value)
668  {
669  return stream << value.toString();
670  }
671 
672  private:
673  void setFromString(const std::string &value);
674 
675  void setFromString(const std::string &fullPath, const std::string &value);
676 
677  std::string getString(const std::string &fullPath) const;
678 
679  Major m_major;
680  Minor m_minor;
681 
682  friend struct DataModel::Detail::Befriend<Revision>;
683  };
684 
687  {
688  public:
691 
693  static constexpr const char *path{ "SerialNumber" };
694 
696  static constexpr const char *name{ "SerialNumber" };
697 
699  static constexpr const char *description{ R"description(The serial number of the camera)description" };
700 
702  using ValueType = std::string;
703 
706  {
707  return { 0, std::numeric_limits<ValueType::size_type>::max() };
708  }
709 
711  SerialNumber() = default;
712 
714  explicit SerialNumber(std::string value)
715  : m_value{ std::move(value) }
716  {}
717 
719  const std::string &value() const;
720 
722  std::string toString() const;
723 
725  bool operator==(const SerialNumber &other) const
726  {
727  return m_value == other.m_value;
728  }
729 
731  bool operator!=(const SerialNumber &other) const
732  {
733  return m_value != other.m_value;
734  }
735 
737  bool operator<(const SerialNumber &other) const
738  {
739  return m_value < other.m_value;
740  }
741 
743  bool operator>(const SerialNumber &other) const
744  {
745  return m_value > other.m_value;
746  }
747 
749  friend std::ostream &operator<<(std::ostream &stream, const SerialNumber &value)
750  {
751  return stream << value.toString();
752  }
753 
754  private:
755  void setFromString(const std::string &value);
756 
757  std::string m_value{};
758 
759  friend struct DataModel::Detail::Befriend<SerialNumber>;
760  };
761 
764  {
765  public:
767  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
768 
770  static constexpr const char *path{ "UserData" };
771 
773  static constexpr const char *name{ "UserData" };
774 
776  static constexpr const char *description{
777  R"description(Information about user data capabilities of the camera)description"
778  };
779 
782  {
783  public:
786 
788  static constexpr const char *path{ "UserData/MaxSizeBytes" };
789 
791  static constexpr const char *name{ "MaxSizeBytes" };
792 
794  static constexpr const char *description{
795  R"description(The maximum number of bytes of user data that can be stored in the camera)description"
796  };
797 
799  using ValueType = uint64_t;
800 
802  static constexpr Range<uint64_t> validRange()
803  {
804  return { std::numeric_limits<uint64_t>::lowest(), std::numeric_limits<uint64_t>::max() };
805  }
806 
808  MaxSizeBytes() = default;
809 
811  explicit constexpr MaxSizeBytes(uint64_t value)
812  : m_value{ value }
813  {}
814 
816  uint64_t value() const;
817 
819  std::string toString() const;
820 
822  bool operator==(const MaxSizeBytes &other) const
823  {
824  return m_value == other.m_value;
825  }
826 
828  bool operator!=(const MaxSizeBytes &other) const
829  {
830  return m_value != other.m_value;
831  }
832 
834  bool operator<(const MaxSizeBytes &other) const
835  {
836  return m_value < other.m_value;
837  }
838 
840  bool operator>(const MaxSizeBytes &other) const
841  {
842  return m_value > other.m_value;
843  }
844 
846  friend std::ostream &operator<<(std::ostream &stream, const MaxSizeBytes &value)
847  {
848  return stream << value.toString();
849  }
850 
851  private:
852  void setFromString(const std::string &value);
853 
854  uint64_t m_value{ 0 };
855 
856  friend struct DataModel::Detail::Befriend<MaxSizeBytes>;
857  };
858 
859  using Descendants = std::tuple<CameraInfo::UserData::MaxSizeBytes>;
860 
863 
875 #ifndef NO_DOC
876  template<typename... Args,
877  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
878  typename std::enable_if<
879  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
880  typename std::decay<Args>::type...>::value,
881  int>::type = 0>
882 #else
883  template<typename... Args>
884 #endif
885  explicit UserData(Args &&...args)
886  {
887  using namespace Zivid::Detail::TypeTraits;
888 
889  static_assert(AllArgsDecayedAreUnique<Args...>::value,
890  "Found duplicate types among the arguments passed to UserData(...). "
891  "Types should be listed at most once.");
892 
893  set(std::forward<Args>(args)...);
894  }
895 
906 #ifndef NO_DOC
907  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
908 #else
909  template<typename... Args>
910 #endif
911  void set(Args &&...args)
912  {
913  using namespace Zivid::Detail::TypeTraits;
914 
915  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
916  static_assert(AllArgsAreDescendantNodes::value,
917  "All arguments passed to set(...) must be descendant nodes.");
918 
919  static_assert(AllArgsDecayedAreUnique<Args...>::value,
920  "Found duplicate types among the arguments passed to set(...). "
921  "Types should be listed at most once.");
922 
923  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
924  }
925 
937 #ifndef NO_DOC
938  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
939 #else
940  template<typename... Args>
941 #endif
942  UserData copyWith(Args &&...args) const
943  {
944  using namespace Zivid::Detail::TypeTraits;
945 
946  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
947  static_assert(AllArgsAreDescendantNodes::value,
948  "All arguments passed to copyWith(...) must be descendant nodes.");
949 
950  static_assert(AllArgsDecayedAreUnique<Args...>::value,
951  "Found duplicate types among the arguments passed to copyWith(...). "
952  "Types should be listed at most once.");
953 
954  auto copy{ *this };
955  copy.set(std::forward<Args>(args)...);
956  return copy;
957  }
958 
960  const MaxSizeBytes &maxSizeBytes() const
961  {
962  return m_maxSizeBytes;
963  }
964 
967  {
968  return m_maxSizeBytes;
969  }
970 
972  UserData &set(const MaxSizeBytes &value)
973  {
974  m_maxSizeBytes = value;
975  return *this;
976  }
977 
978  template<typename T,
979  typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
981  {
982  return m_maxSizeBytes;
983  }
984 
985  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
987  {
988  return m_maxSizeBytes;
989  }
990 
992  template<typename F>
993  void forEach(const F &f) const
994  {
995  f(m_maxSizeBytes);
996  }
997 
999  template<typename F>
1000  void forEach(const F &f)
1001  {
1002  f(m_maxSizeBytes);
1003  }
1004 
1006  bool operator==(const UserData &other) const;
1007 
1009  bool operator!=(const UserData &other) const;
1010 
1012  std::string toString() const;
1013 
1015  friend std::ostream &operator<<(std::ostream &stream, const UserData &value)
1016  {
1017  return stream << value.toString();
1018  }
1019 
1020  private:
1021  void setFromString(const std::string &value);
1022 
1023  void setFromString(const std::string &fullPath, const std::string &value);
1024 
1025  std::string getString(const std::string &fullPath) const;
1026 
1027  MaxSizeBytes m_maxSizeBytes;
1028 
1029  friend struct DataModel::Detail::Befriend<UserData>;
1030  };
1031 
1040 
1043 
1045  explicit CameraInfo(const std::string &fileName);
1046 
1065 #ifndef NO_DOC
1066  template<
1067  typename... Args,
1068  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1069  typename std::enable_if<
1070  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1071  int>::type = 0>
1072 #else
1073  template<typename... Args>
1074 #endif
1075  explicit CameraInfo(Args &&...args)
1076  {
1077  using namespace Zivid::Detail::TypeTraits;
1078 
1079  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1080  "Found duplicate types among the arguments passed to CameraInfo(...). "
1081  "Types should be listed at most once.");
1082 
1083  set(std::forward<Args>(args)...);
1084  }
1085 
1103 #ifndef NO_DOC
1104  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1105 #else
1106  template<typename... Args>
1107 #endif
1108  void set(Args &&...args)
1109  {
1110  using namespace Zivid::Detail::TypeTraits;
1111 
1112  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1113  static_assert(AllArgsAreDescendantNodes::value,
1114  "All arguments passed to set(...) must be descendant nodes.");
1115 
1116  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1117  "Found duplicate types among the arguments passed to set(...). "
1118  "Types should be listed at most once.");
1119 
1120  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1121  }
1122 
1141 #ifndef NO_DOC
1142  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1143 #else
1144  template<typename... Args>
1145 #endif
1146  CameraInfo copyWith(Args &&...args) const
1147  {
1148  using namespace Zivid::Detail::TypeTraits;
1149 
1150  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1151  static_assert(AllArgsAreDescendantNodes::value,
1152  "All arguments passed to copyWith(...) must be descendant nodes.");
1153 
1154  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1155  "Found duplicate types among the arguments passed to copyWith(...). "
1156  "Types should be listed at most once.");
1157 
1158  auto copy{ *this };
1159  copy.set(std::forward<Args>(args)...);
1160  return copy;
1161  }
1162 
1165  {
1166  return m_firmwareVersion;
1167  }
1168 
1171  {
1172  return m_firmwareVersion;
1173  }
1174 
1177  {
1178  m_firmwareVersion = value;
1179  return *this;
1180  }
1181 
1183  const ModelName &modelName() const
1184  {
1185  return m_modelName;
1186  }
1187 
1190  {
1191  return m_modelName;
1192  }
1193 
1195  CameraInfo &set(const ModelName &value)
1196  {
1197  m_modelName = value;
1198  return *this;
1199  }
1200 
1202  const Revision &revision() const
1203  {
1204  return m_revision;
1205  }
1206 
1209  {
1210  return m_revision;
1211  }
1212 
1214  CameraInfo &set(const Revision &value)
1215  {
1216  m_revision = value;
1217  return *this;
1218  }
1219 
1222  {
1223  m_revision.set(value);
1224  return *this;
1225  }
1226 
1229  {
1230  m_revision.set(value);
1231  return *this;
1232  }
1233 
1236  {
1237  return m_serialNumber;
1238  }
1239 
1242  {
1243  return m_serialNumber;
1244  }
1245 
1247  CameraInfo &set(const SerialNumber &value)
1248  {
1249  m_serialNumber = value;
1250  return *this;
1251  }
1252 
1254  const UserData &userData() const
1255  {
1256  return m_userData;
1257  }
1258 
1261  {
1262  return m_userData;
1263  }
1264 
1266  CameraInfo &set(const UserData &value)
1267  {
1268  m_userData = value;
1269  return *this;
1270  }
1271 
1274  {
1275  m_userData.set(value);
1276  return *this;
1277  }
1278 
1279  template<typename T,
1280  typename std::enable_if<std::is_same<T, CameraInfo::FirmwareVersion>::value, int>::type = 0>
1282  {
1283  return m_firmwareVersion;
1284  }
1285 
1286  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::ModelName>::value, int>::type = 0>
1288  {
1289  return m_modelName;
1290  }
1291 
1292  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Revision>::value, int>::type = 0>
1293  const CameraInfo::Revision &get() const
1294  {
1295  return m_revision;
1296  }
1297 
1298  template<typename T,
1299  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
1301  {
1302  return m_revision.get<CameraInfo::Revision::Major>();
1303  }
1304 
1305  template<typename T,
1306  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
1308  {
1309  return m_revision.get<CameraInfo::Revision::Minor>();
1310  }
1311 
1312  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::SerialNumber>::value, int>::type = 0>
1314  {
1315  return m_serialNumber;
1316  }
1317 
1318  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::UserData>::value, int>::type = 0>
1319  const CameraInfo::UserData &get() const
1320  {
1321  return m_userData;
1322  }
1323 
1324  template<typename T,
1325  typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1327  {
1328  return m_userData.get<CameraInfo::UserData::MaxSizeBytes>();
1329  }
1330 
1331  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1333  {
1334  return m_firmwareVersion;
1335  }
1336 
1337  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1339  {
1340  return m_modelName;
1341  }
1342 
1343  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1344  const CameraInfo::Revision &get() const
1345  {
1346  return m_revision;
1347  }
1348 
1349  template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1351  {
1352  return m_serialNumber;
1353  }
1354 
1355  template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
1356  const CameraInfo::UserData &get() const
1357  {
1358  return m_userData;
1359  }
1360 
1362  template<typename F>
1363  void forEach(const F &f) const
1364  {
1365  f(m_firmwareVersion);
1366  f(m_modelName);
1367  f(m_revision);
1368  f(m_serialNumber);
1369  f(m_userData);
1370  }
1371 
1373  template<typename F>
1374  void forEach(const F &f)
1375  {
1376  f(m_firmwareVersion);
1377  f(m_modelName);
1378  f(m_revision);
1379  f(m_serialNumber);
1380  f(m_userData);
1381  }
1382 
1384  bool operator==(const CameraInfo &other) const;
1385 
1387  bool operator!=(const CameraInfo &other) const;
1388 
1390  std::string toString() const;
1391 
1393  friend std::ostream &operator<<(std::ostream &stream, const CameraInfo &value)
1394  {
1395  return stream << value.toString();
1396  }
1397 
1399  void save(const std::string &fileName) const;
1400 
1402  void load(const std::string &fileName);
1403 
1404  private:
1405  void setFromString(const std::string &value);
1406 
1407  void setFromString(const std::string &fullPath, const std::string &value);
1408 
1409  std::string getString(const std::string &fullPath) const;
1410 
1411  FirmwareVersion m_firmwareVersion;
1412  ModelName m_modelName;
1413  Revision m_revision;
1414  SerialNumber m_serialNumber;
1415  UserData m_userData;
1416 
1417  friend struct DataModel::Detail::Befriend<CameraInfo>;
1418  };
1419 
1420 #ifndef NO_DOC
1421  template<>
1422  struct CameraInfo::Version<1>
1423  {
1424  using Type = CameraInfo;
1425  };
1426 #endif
1427 
1428 } // namespace Zivid
1429 
1430 #ifdef _MSC_VER
1431 # pragma warning(pop)
1432 #endif
1433 
1434 #ifndef NO_DOC
1435 # if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1436 namespace std // NOLINT
1437 {
1438  template<>
1439  struct tuple_size<Zivid::CameraInfo::Revision> : integral_constant<size_t, 2>
1440  {};
1441 
1442  template<size_t i>
1443  struct tuple_element<i, Zivid::CameraInfo::Revision>
1444  {
1445  static_assert(i < tuple_size<Zivid::CameraInfo::Revision>::value, "Index must be less than 2");
1446 
1447  using type // NOLINT
1448  = decltype(declval<Zivid::CameraInfo::Revision>().get<i>());
1449  };
1450 
1451  template<>
1452  struct tuple_size<Zivid::CameraInfo::UserData> : integral_constant<size_t, 1>
1453  {};
1454 
1455  template<size_t i>
1456  struct tuple_element<i, Zivid::CameraInfo::UserData>
1457  {
1458  static_assert(i < tuple_size<Zivid::CameraInfo::UserData>::value, "Index must be less than 1");
1459 
1460  using type // NOLINT
1461  = decltype(declval<Zivid::CameraInfo::UserData>().get<i>());
1462  };
1463 
1464  template<>
1465  struct tuple_size<Zivid::CameraInfo> : integral_constant<size_t, 5>
1466  {};
1467 
1468  template<size_t i>
1469  struct tuple_element<i, Zivid::CameraInfo>
1470  {
1471  static_assert(i < tuple_size<Zivid::CameraInfo>::value, "Index must be less than 5");
1472 
1473  using type // NOLINT
1474  = decltype(declval<Zivid::CameraInfo>().get<i>());
1475  };
1476 
1477 } // namespace std
1478 # endif
1479 #endif
#define ZIVID_CORE_EXPORT
Definition: CoreExport.h:101
The firmware version on the camera
Definition: CameraInfo.h:152
std::string toString() const
Get the value as string
bool operator==(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:190
FirmwareVersion(std::string value)
Constructor
Definition: CameraInfo.h:179
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for FirmwareVersion
Definition: CameraInfo.h:170
const std::string & value() const
Get the value
bool operator<(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:202
friend std::ostream & operator<<(std::ostream &stream, const FirmwareVersion &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:214
bool operator>(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:208
bool operator!=(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:196
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:167
FirmwareVersion()=default
Default constructor
The model name of the camera
Definition: CameraInfo.h:229
bool operator==(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:267
ModelName()=default
Default constructor
const std::string & value() const
Get the value
std::string toString() const
Get the value as string
ModelName(std::string value)
Constructor
Definition: CameraInfo.h:256
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:244
bool operator<(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:279
bool operator>(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:285
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for ModelName
Definition: CameraInfo.h:247
bool operator!=(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:273
friend std::ostream & operator<<(std::ostream &stream, const ModelName &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:291
Major hardware revision number
Definition: CameraInfo.h:322
std::string toString() const
Get the value as string
bool operator!=(const Major &other) const
Comparison operator
Definition: CameraInfo.h:366
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:337
static constexpr Range< uint32_t > validRange()
The range of valid values for Major
Definition: CameraInfo.h:340
bool operator>(const Major &other) const
Comparison operator
Definition: CameraInfo.h:378
uint32_t value() const
Get the value
friend std::ostream & operator<<(std::ostream &stream, const Major &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:384
constexpr Major(uint32_t value)
Constructor
Definition: CameraInfo.h:349
bool operator<(const Major &other) const
Comparison operator
Definition: CameraInfo.h:372
Major()=default
Default constructor
bool operator==(const Major &other) const
Comparison operator
Definition: CameraInfo.h:360
Minor hardware revision number
Definition: CameraInfo.h:399
bool operator>(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:455
bool operator!=(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:443
constexpr Minor(uint32_t value)
Constructor
Definition: CameraInfo.h:426
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:414
friend std::ostream & operator<<(std::ostream &stream, const Minor &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:461
bool operator==(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:437
std::string toString() const
Get the value as string
static constexpr Range< uint32_t > validRange()
The range of valid values for Minor
Definition: CameraInfo.h:417
Minor()=default
Default constructor
bool operator<(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:449
uint32_t value() const
Get the value
The hardware revision of the camera
Definition: CameraInfo.h:306
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:624
Revision copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraInfo.h:560
friend std::ostream & operator<<(std::ostream &stream, const Revision &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:667
Revision & set(const Minor &value)
Set Minor
Definition: CameraInfo.h:609
std::tuple< CameraInfo::Revision::Major, CameraInfo::Revision::Minor > Descendants
Definition: CameraInfo.h:474
bool operator==(const Revision &other) const
Equality operator
std::string toString() const
Get the value as string
Revision & set(const Major &value)
Set Major
Definition: CameraInfo.h:590
Minor & minor()
Get Minor
Definition: CameraInfo.h:603
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:651
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:617
Revision()
Default constructor
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:643
Revision(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:501
Major & major()
Get Major
Definition: CameraInfo.h:584
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:528
const Minor & minor() const
Get Minor
Definition: CameraInfo.h:597
bool operator!=(const Revision &other) const
Inequality operator
const Major & major() const
Get Major
Definition: CameraInfo.h:578
The serial number of the camera
Definition: CameraInfo.h:687
SerialNumber(std::string value)
Constructor
Definition: CameraInfo.h:714
friend std::ostream & operator<<(std::ostream &stream, const SerialNumber &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:749
bool operator==(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:725
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:702
const std::string & value() const
Get the value
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for SerialNumber
Definition: CameraInfo.h:705
SerialNumber()=default
Default constructor
std::string toString() const
Get the value as string
bool operator>(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:743
bool operator<(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:737
bool operator!=(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:731
The maximum number of bytes of user data that can be stored in the camera
Definition: CameraInfo.h:782
friend std::ostream & operator<<(std::ostream &stream, const MaxSizeBytes &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:846
bool operator!=(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:828
bool operator>(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:840
MaxSizeBytes()=default
Default constructor
constexpr MaxSizeBytes(uint64_t value)
Constructor
Definition: CameraInfo.h:811
uint64_t value() const
Get the value
bool operator<(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:834
bool operator==(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:822
std::string toString() const
Get the value as string
static constexpr Range< uint64_t > validRange()
The range of valid values for MaxSizeBytes
Definition: CameraInfo.h:802
uint64_t ValueType
The type of the underlying value
Definition: CameraInfo.h:799
Information about user data capabilities of the camera
Definition: CameraInfo.h:764
bool operator==(const UserData &other) const
Equality operator
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1000
UserData copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraInfo.h:942
UserData & set(const MaxSizeBytes &value)
Set MaxSizeBytes
Definition: CameraInfo.h:972
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:980
std::string toString() const
Get the value as string
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:993
std::tuple< CameraInfo::UserData::MaxSizeBytes > Descendants
Definition: CameraInfo.h:859
bool operator!=(const UserData &other) const
Inequality operator
MaxSizeBytes & maxSizeBytes()
Get MaxSizeBytes
Definition: CameraInfo.h:966
const MaxSizeBytes & maxSizeBytes() const
Get MaxSizeBytes
Definition: CameraInfo.h:960
UserData()
Default constructor
UserData(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:885
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:911
friend std::ostream & operator<<(std::ostream &stream, const UserData &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1015
Information about camera model, serial number etc.
Definition: CameraInfo.h:120
CameraInfo & set(const UserData &value)
Set UserData
Definition: CameraInfo.h:1266
bool operator==(const CameraInfo &other) const
Equality operator
const ModelName & modelName() const
Get ModelName
Definition: CameraInfo.h:1183
const CameraInfo::FirmwareVersion & get() const
Definition: CameraInfo.h:1281
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1374
const CameraInfo::SerialNumber & get() const
Definition: CameraInfo.h:1313
CameraInfo & set(const SerialNumber &value)
Set SerialNumber
Definition: CameraInfo.h:1247
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:1307
bool operator!=(const CameraInfo &other) const
Inequality operator
CameraInfo & set(const UserData::MaxSizeBytes &value)
Set UserData::MaxSizeBytes
Definition: CameraInfo.h:1273
FirmwareVersion & firmwareVersion()
Get FirmwareVersion
Definition: CameraInfo.h:1170
UserData & userData()
Get UserData
Definition: CameraInfo.h:1260
CameraInfo(const std::string &fileName)
Construct CameraInfo by loading from file
CameraInfo copyWith(Args &&...args) const
Returns a copy of this object with the given argument(s) set to the new value(s)
Definition: CameraInfo.h:1146
void forEach(const F &f) const
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1363
CameraInfo & set(const FirmwareVersion &value)
Set FirmwareVersion
Definition: CameraInfo.h:1176
CameraInfo(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:1075
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:1300
const FirmwareVersion & firmwareVersion() const
Get FirmwareVersion
Definition: CameraInfo.h:1164
const UserData & userData() const
Get UserData
Definition: CameraInfo.h:1254
CameraInfo & set(const Revision::Major &value)
Set Revision::Major
Definition: CameraInfo.h:1221
CameraInfo & set(const Revision::Minor &value)
Set Revision::Minor
Definition: CameraInfo.h:1228
CameraInfo & set(const ModelName &value)
Set ModelName
Definition: CameraInfo.h:1195
void load(const std::string &fileName)
Load from the given file
friend std::ostream & operator<<(std::ostream &stream, const CameraInfo &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:1393
Revision & revision()
Get Revision
Definition: CameraInfo.h:1208
const Revision & revision() const
Get Revision
Definition: CameraInfo.h:1202
const CameraInfo::Revision & get() const
Definition: CameraInfo.h:1293
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1108
const CameraInfo::ModelName & get() const
Definition: CameraInfo.h:1287
CameraInfo & set(const Revision &value)
Set Revision
Definition: CameraInfo.h:1214
ModelName & modelName()
Get ModelName
Definition: CameraInfo.h:1189
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1326
std::tuple< CameraInfo::FirmwareVersion, CameraInfo::ModelName, CameraInfo::Revision, CameraInfo::Revision::Major, CameraInfo::Revision::Minor, CameraInfo::SerialNumber, CameraInfo::UserData, CameraInfo::UserData::MaxSizeBytes > Descendants
Definition: CameraInfo.h:1039
std::string toString() const
Get the value as string
const SerialNumber & serialNumber() const
Get SerialNumber
Definition: CameraInfo.h:1235
CameraInfo()
Default constructor
const CameraInfo::UserData & get() const
Definition: CameraInfo.h:1319
void save(const std::string &fileName) const
Save to the given file
SerialNumber & serialNumber()
Get SerialNumber
Definition: CameraInfo.h:1241
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