Zivid C++ API  2.3.1+1a22cbf1-1
Defining the Future of 3D Machine Vision
CameraInfo.h
Go to the documentation of this file.
1 
2 /*******************************************************************************
3  * This file is part of the Zivid 3D Camera API
4  *
5  * Copyright 2015-2022 (C) Zivid AS
6  * All rights reserved.
7  *
8  * Zivid Software License, v1.0
9  *
10  * Redistribution and use in source and binary forms, with or without
11  * modification, are permitted provided that the following conditions are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright notice,
17  * this list of conditions and the following disclaimer in the documentation
18  * and/or other materials provided with the distribution.
19  *
20  * 3. Neither the name of Zivid AS nor the names of its contributors may be used
21  * to endorse or promote products derived from this software without specific
22  * prior written permission.
23  *
24  * 4. This software, with or without modification, must not be used with any
25  * other 3D camera than from Zivid AS.
26  *
27  * 5. Any software provided in binary form under this license must not be
28  * reverse engineered, decompiled, modified and/or disassembled.
29  *
30  * THIS SOFTWARE IS PROVIDED BY ZIVID AS "AS IS" AND ANY EXPRESS OR IMPLIED
31  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
32  * MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
33  * DISCLAIMED. IN NO EVENT SHALL ZIVID AS OR CONTRIBUTORS BE LIABLE FOR ANY
34  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * Contact: Zivid Customer Success Team <customersuccess@zivid.com>
42  * Info: http://www.zivid.com
43  ******************************************************************************/
44 
45 #pragma once
46 
47 #include <array>
48 #include <chrono>
49 #include <cmath>
50 #include <ctime>
51 #include <iomanip>
52 #include <memory>
53 #include <set>
54 #include <sstream>
55 #include <string>
56 #include <tuple>
57 #include <utility>
58 #include <vector>
59 
62 #include "Zivid/DataModel/Traits.h"
65 #include "Zivid/Range.h"
66 
67 #ifdef _MSC_VER
68 # pragma warning(push)
69 # pragma warning(disable : 4251) // "X needs to have dll-interface to be used by clients of class Y."
70 #endif
71 
72 namespace Zivid
73 {
76  {
77  public:
79  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
80 
82  static constexpr const char *path{ "" };
83 
85  static constexpr const char *name{ "CameraInfo" };
86 
88  static constexpr const char *description{
89  R"description(Information about camera model, serial number etc.)description"
90  };
91 
92  static constexpr size_t version{ 1 };
93 
94 #ifndef NO_DOC
95  template<size_t>
96  struct Version;
97 
98  using LatestVersion = Zivid::CameraInfo;
99 
100  // Short identifier. This value is not guaranteed to be universally unique
101  // Todo(ZIVID-2808): Move this to internal DataModelExt header
102  static constexpr std::array<uint8_t, 3> binaryId{ 'n', 'f', 'o' };
103 
104 #endif
105 
108  {
109  public:
112 
114  static constexpr const char *path{ "FirmwareVersion" };
115 
117  static constexpr const char *name{ "FirmwareVersion" };
118 
120  static constexpr const char *description{ R"description(The firmware version on the camera)description" };
121 
123  using ValueType = std::string;
124 
127  {
128  return { 0, std::numeric_limits<ValueType::size_type>::max() };
129  }
130 
132  FirmwareVersion() = default;
133 
135  explicit FirmwareVersion(std::string value)
136  : m_value{ std::move(value) }
137  {}
138 
140  const std::string &value() const;
141 
143  std::string toString() const;
144 
146  bool operator==(const FirmwareVersion &other) const
147  {
148  return m_value == other.m_value;
149  }
150 
152  bool operator!=(const FirmwareVersion &other) const
153  {
154  return m_value != other.m_value;
155  }
156 
158  bool operator<(const FirmwareVersion &other) const
159  {
160  return m_value < other.m_value;
161  }
162 
164  bool operator>(const FirmwareVersion &other) const
165  {
166  return m_value > other.m_value;
167  }
168 
170  friend std::ostream &operator<<(std::ostream &stream, const FirmwareVersion &value)
171  {
172  return stream << value.toString();
173  }
174 
175  private:
176  void setFromString(const std::string &value);
177 
178  std::string m_value{};
179 
180  friend struct DataModel::Detail::Befriend<FirmwareVersion>;
181  };
182 
185  {
186  public:
189 
191  static constexpr const char *path{ "ModelName" };
192 
194  static constexpr const char *name{ "ModelName" };
195 
197  static constexpr const char *description{ R"description(The model name of the camera)description" };
198 
200  using ValueType = std::string;
201 
204  {
205  return { 0, std::numeric_limits<ValueType::size_type>::max() };
206  }
207 
209  ModelName() = default;
210 
212  explicit ModelName(std::string value)
213  : m_value{ std::move(value) }
214  {}
215 
217  const std::string &value() const;
218 
220  std::string toString() const;
221 
223  bool operator==(const ModelName &other) const
224  {
225  return m_value == other.m_value;
226  }
227 
229  bool operator!=(const ModelName &other) const
230  {
231  return m_value != other.m_value;
232  }
233 
235  bool operator<(const ModelName &other) const
236  {
237  return m_value < other.m_value;
238  }
239 
241  bool operator>(const ModelName &other) const
242  {
243  return m_value > other.m_value;
244  }
245 
247  friend std::ostream &operator<<(std::ostream &stream, const ModelName &value)
248  {
249  return stream << value.toString();
250  }
251 
252  private:
253  void setFromString(const std::string &value);
254 
255  std::string m_value{};
256 
257  friend struct DataModel::Detail::Befriend<ModelName>;
258  };
259 
262  {
263  public:
265  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
266 
268  static constexpr const char *path{ "Revision" };
269 
271  static constexpr const char *name{ "Revision" };
272 
274  static constexpr const char *description{ R"description(The hardware revision of the camera)description" };
275 
278  {
279  public:
282 
284  static constexpr const char *path{ "Revision/Major" };
285 
287  static constexpr const char *name{ "Major" };
288 
290  static constexpr const char *description{ R"description(Major hardware revision number)description" };
291 
293  using ValueType = uint32_t;
294 
296  static constexpr Range<uint32_t> validRange()
297  {
298  return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
299  }
300 
302  Major() = default;
303 
305  explicit constexpr Major(uint32_t value)
306  : m_value{ value }
307  {}
308 
310  uint32_t value() const;
311 
313  std::string toString() const;
314 
316  bool operator==(const Major &other) const
317  {
318  return m_value == other.m_value;
319  }
320 
322  bool operator!=(const Major &other) const
323  {
324  return m_value != other.m_value;
325  }
326 
328  bool operator<(const Major &other) const
329  {
330  return m_value < other.m_value;
331  }
332 
334  bool operator>(const Major &other) const
335  {
336  return m_value > other.m_value;
337  }
338 
340  friend std::ostream &operator<<(std::ostream &stream, const Major &value)
341  {
342  return stream << value.toString();
343  }
344 
345  private:
346  void setFromString(const std::string &value);
347 
348  uint32_t m_value{ 0 };
349 
350  friend struct DataModel::Detail::Befriend<Major>;
351  };
352 
355  {
356  public:
359 
361  static constexpr const char *path{ "Revision/Minor" };
362 
364  static constexpr const char *name{ "Minor" };
365 
367  static constexpr const char *description{ R"description(Minor hardware revision number)description" };
368 
370  using ValueType = uint32_t;
371 
373  static constexpr Range<uint32_t> validRange()
374  {
375  return { std::numeric_limits<uint32_t>::lowest(), std::numeric_limits<uint32_t>::max() };
376  }
377 
379  Minor() = default;
380 
382  explicit constexpr Minor(uint32_t value)
383  : m_value{ value }
384  {}
385 
387  uint32_t value() const;
388 
390  std::string toString() const;
391 
393  bool operator==(const Minor &other) const
394  {
395  return m_value == other.m_value;
396  }
397 
399  bool operator!=(const Minor &other) const
400  {
401  return m_value != other.m_value;
402  }
403 
405  bool operator<(const Minor &other) const
406  {
407  return m_value < other.m_value;
408  }
409 
411  bool operator>(const Minor &other) const
412  {
413  return m_value > other.m_value;
414  }
415 
417  friend std::ostream &operator<<(std::ostream &stream, const Minor &value)
418  {
419  return stream << value.toString();
420  }
421 
422  private:
423  void setFromString(const std::string &value);
424 
425  uint32_t m_value{ 0 };
426 
427  friend struct DataModel::Detail::Befriend<Minor>;
428  };
429 
430  using Descendants = std::tuple<CameraInfo::Revision::Major, CameraInfo::Revision::Minor>;
431 
434 
447 #ifndef NO_DOC
448  template<typename... Args,
449  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
450  typename std::enable_if<
451  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
452  typename std::decay<Args>::type...>::value,
453  int>::type = 0>
454 #else
455  template<typename... Args>
456 #endif
457  explicit Revision(Args &&...args)
458  {
459  using namespace Zivid::Detail::TypeTraits;
460 
461  static_assert(AllArgsDecayedAreUnique<Args...>::value,
462  "Found duplicate types among the arguments passed to Revision(...). "
463  "Types should be listed at most once.");
464 
465  set(std::forward<Args>(args)...);
466  }
467 
479 #ifndef NO_DOC
480  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
481 #else
482  template<typename... Args>
483 #endif
484  void set(Args &&...args)
485  {
486  using namespace Zivid::Detail::TypeTraits;
487 
488  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
489  static_assert(AllArgsAreDescendantNodes::value,
490  "All arguments passed to set(...) must be descendant nodes.");
491 
492  static_assert(AllArgsDecayedAreUnique<Args...>::value,
493  "Found duplicate types among the arguments passed to set(...). "
494  "Types should be listed at most once.");
495 
496  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
497  }
498 
511 #ifndef NO_DOC
512  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
513 #else
514  template<typename... Args>
515 #endif
516  Revision copyWith(Args &&...args) const
517  {
518  using namespace Zivid::Detail::TypeTraits;
519 
520  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
521  static_assert(AllArgsAreDescendantNodes::value,
522  "All arguments passed to copyWith(...) must be descendant nodes.");
523 
524  static_assert(AllArgsDecayedAreUnique<Args...>::value,
525  "Found duplicate types among the arguments passed to copyWith(...). "
526  "Types should be listed at most once.");
527 
528  auto copy{ *this };
529  copy.set(std::forward<Args>(args)...);
530  return copy;
531  }
532 
534  const Major &major() const
535  {
536  return m_major;
537  }
538 
541  {
542  return m_major;
543  }
544 
546  Revision &set(const Major &value)
547  {
548  m_major = value;
549  return *this;
550  }
551 
553  const Minor &minor() const
554  {
555  return m_minor;
556  }
557 
560  {
561  return m_minor;
562  }
563 
565  Revision &set(const Minor &value)
566  {
567  m_minor = value;
568  return *this;
569  }
570 
571  template<typename T,
572  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
574  {
575  return m_major;
576  }
577 
578  template<typename T,
579  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
581  {
582  return m_minor;
583  }
584 
585  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
587  {
588  return m_major;
589  }
590 
591  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
593  {
594  return m_minor;
595  }
596 
598  template<typename F>
599  void forEach(const F &f) const
600  {
601  f(m_major);
602  f(m_minor);
603  }
604 
606  template<typename F>
607  void forEach(const F &f)
608  {
609  f(m_major);
610  f(m_minor);
611  }
612 
614  bool operator==(const Revision &other) const;
615 
617  bool operator!=(const Revision &other) const;
618 
620  std::string toString() const;
621 
623  friend std::ostream &operator<<(std::ostream &stream, const Revision &value)
624  {
625  return stream << value.toString();
626  }
627 
628  private:
629  void setFromString(const std::string &value);
630 
631  void setFromString(const std::string &fullPath, const std::string &value);
632 
633  std::string getString(const std::string &fullPath) const;
634 
635  Major m_major;
636  Minor m_minor;
637 
638  friend struct DataModel::Detail::Befriend<Revision>;
639  };
640 
643  {
644  public:
647 
649  static constexpr const char *path{ "SerialNumber" };
650 
652  static constexpr const char *name{ "SerialNumber" };
653 
655  static constexpr const char *description{ R"description(The serial number of the camera)description" };
656 
658  using ValueType = std::string;
659 
662  {
663  return { 0, std::numeric_limits<ValueType::size_type>::max() };
664  }
665 
667  SerialNumber() = default;
668 
670  explicit SerialNumber(std::string value)
671  : m_value{ std::move(value) }
672  {}
673 
675  const std::string &value() const;
676 
678  std::string toString() const;
679 
681  bool operator==(const SerialNumber &other) const
682  {
683  return m_value == other.m_value;
684  }
685 
687  bool operator!=(const SerialNumber &other) const
688  {
689  return m_value != other.m_value;
690  }
691 
693  bool operator<(const SerialNumber &other) const
694  {
695  return m_value < other.m_value;
696  }
697 
699  bool operator>(const SerialNumber &other) const
700  {
701  return m_value > other.m_value;
702  }
703 
705  friend std::ostream &operator<<(std::ostream &stream, const SerialNumber &value)
706  {
707  return stream << value.toString();
708  }
709 
710  private:
711  void setFromString(const std::string &value);
712 
713  std::string m_value{};
714 
715  friend struct DataModel::Detail::Befriend<SerialNumber>;
716  };
717 
720  {
721  public:
723  static constexpr DataModel::NodeType nodeType = DataModel::NodeType::group;
724 
726  static constexpr const char *path{ "UserData" };
727 
729  static constexpr const char *name{ "UserData" };
730 
732  static constexpr const char *description{
733  R"description(Information about user data capabilities of the camera)description"
734  };
735 
738  {
739  public:
742 
744  static constexpr const char *path{ "UserData/MaxSizeBytes" };
745 
747  static constexpr const char *name{ "MaxSizeBytes" };
748 
750  static constexpr const char *description{
751  R"description(The maximum number of bytes of user data that can be stored in the camera)description"
752  };
753 
755  using ValueType = uint64_t;
756 
758  static constexpr Range<uint64_t> validRange()
759  {
760  return { std::numeric_limits<uint64_t>::lowest(), std::numeric_limits<uint64_t>::max() };
761  }
762 
764  MaxSizeBytes() = default;
765 
767  explicit constexpr MaxSizeBytes(uint64_t value)
768  : m_value{ value }
769  {}
770 
772  uint64_t value() const;
773 
775  std::string toString() const;
776 
778  bool operator==(const MaxSizeBytes &other) const
779  {
780  return m_value == other.m_value;
781  }
782 
784  bool operator!=(const MaxSizeBytes &other) const
785  {
786  return m_value != other.m_value;
787  }
788 
790  bool operator<(const MaxSizeBytes &other) const
791  {
792  return m_value < other.m_value;
793  }
794 
796  bool operator>(const MaxSizeBytes &other) const
797  {
798  return m_value > other.m_value;
799  }
800 
802  friend std::ostream &operator<<(std::ostream &stream, const MaxSizeBytes &value)
803  {
804  return stream << value.toString();
805  }
806 
807  private:
808  void setFromString(const std::string &value);
809 
810  uint64_t m_value{ 0 };
811 
812  friend struct DataModel::Detail::Befriend<MaxSizeBytes>;
813  };
814 
815  using Descendants = std::tuple<CameraInfo::UserData::MaxSizeBytes>;
816 
819 
831 #ifndef NO_DOC
832  template<typename... Args,
833  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
834  typename std::enable_if<
835  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants,
836  typename std::decay<Args>::type...>::value,
837  int>::type = 0>
838 #else
839  template<typename... Args>
840 #endif
841  explicit UserData(Args &&...args)
842  {
843  using namespace Zivid::Detail::TypeTraits;
844 
845  static_assert(AllArgsDecayedAreUnique<Args...>::value,
846  "Found duplicate types among the arguments passed to UserData(...). "
847  "Types should be listed at most once.");
848 
849  set(std::forward<Args>(args)...);
850  }
851 
862 #ifndef NO_DOC
863  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
864 #else
865  template<typename... Args>
866 #endif
867  void set(Args &&...args)
868  {
869  using namespace Zivid::Detail::TypeTraits;
870 
871  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
872  static_assert(AllArgsAreDescendantNodes::value,
873  "All arguments passed to set(...) must be descendant nodes.");
874 
875  static_assert(AllArgsDecayedAreUnique<Args...>::value,
876  "Found duplicate types among the arguments passed to set(...). "
877  "Types should be listed at most once.");
878 
879  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
880  }
881 
893 #ifndef NO_DOC
894  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
895 #else
896  template<typename... Args>
897 #endif
898  UserData copyWith(Args &&...args) const
899  {
900  using namespace Zivid::Detail::TypeTraits;
901 
902  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
903  static_assert(AllArgsAreDescendantNodes::value,
904  "All arguments passed to copyWith(...) must be descendant nodes.");
905 
906  static_assert(AllArgsDecayedAreUnique<Args...>::value,
907  "Found duplicate types among the arguments passed to copyWith(...). "
908  "Types should be listed at most once.");
909 
910  auto copy{ *this };
911  copy.set(std::forward<Args>(args)...);
912  return copy;
913  }
914 
916  const MaxSizeBytes &maxSizeBytes() const
917  {
918  return m_maxSizeBytes;
919  }
920 
923  {
924  return m_maxSizeBytes;
925  }
926 
928  UserData &set(const MaxSizeBytes &value)
929  {
930  m_maxSizeBytes = value;
931  return *this;
932  }
933 
934  template<typename T,
935  typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
937  {
938  return m_maxSizeBytes;
939  }
940 
941  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
943  {
944  return m_maxSizeBytes;
945  }
946 
948  template<typename F>
949  void forEach(const F &f) const
950  {
951  f(m_maxSizeBytes);
952  }
953 
955  template<typename F>
956  void forEach(const F &f)
957  {
958  f(m_maxSizeBytes);
959  }
960 
962  bool operator==(const UserData &other) const;
963 
965  bool operator!=(const UserData &other) const;
966 
968  std::string toString() const;
969 
971  friend std::ostream &operator<<(std::ostream &stream, const UserData &value)
972  {
973  return stream << value.toString();
974  }
975 
976  private:
977  void setFromString(const std::string &value);
978 
979  void setFromString(const std::string &fullPath, const std::string &value);
980 
981  std::string getString(const std::string &fullPath) const;
982 
983  MaxSizeBytes m_maxSizeBytes;
984 
985  friend struct DataModel::Detail::Befriend<UserData>;
986  };
987 
996 
999 
1001  explicit CameraInfo(const std::string &fileName);
1002 
1021 #ifndef NO_DOC
1022  template<
1023  typename... Args,
1024  typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0,
1025  typename std::enable_if<
1026  Zivid::Detail::TypeTraits::AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>::value,
1027  int>::type = 0>
1028 #else
1029  template<typename... Args>
1030 #endif
1031  explicit CameraInfo(Args &&...args)
1032  {
1033  using namespace Zivid::Detail::TypeTraits;
1034 
1035  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1036  "Found duplicate types among the arguments passed to CameraInfo(...). "
1037  "Types should be listed at most once.");
1038 
1039  set(std::forward<Args>(args)...);
1040  }
1041 
1059 #ifndef NO_DOC
1060  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 2, int>::type = 0>
1061 #else
1062  template<typename... Args>
1063 #endif
1064  void set(Args &&...args)
1065  {
1066  using namespace Zivid::Detail::TypeTraits;
1067 
1068  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1069  static_assert(AllArgsAreDescendantNodes::value,
1070  "All arguments passed to set(...) must be descendant nodes.");
1071 
1072  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1073  "Found duplicate types among the arguments passed to set(...). "
1074  "Types should be listed at most once.");
1075 
1076  Zivid::DataModel::Detail::invokeSetWithEachArgument(*this, std::forward<Args>(args)...);
1077  }
1078 
1097 #ifndef NO_DOC
1098  template<typename... Args, typename std::enable_if<sizeof...(Args) >= 1, int>::type = 0>
1099 #else
1100  template<typename... Args>
1101 #endif
1102  CameraInfo copyWith(Args &&...args) const
1103  {
1104  using namespace Zivid::Detail::TypeTraits;
1105 
1106  using AllArgsAreDescendantNodes = AllArgsAreInTuple<Descendants, typename std::decay<Args>::type...>;
1107  static_assert(AllArgsAreDescendantNodes::value,
1108  "All arguments passed to copyWith(...) must be descendant nodes.");
1109 
1110  static_assert(AllArgsDecayedAreUnique<Args...>::value,
1111  "Found duplicate types among the arguments passed to copyWith(...). "
1112  "Types should be listed at most once.");
1113 
1114  auto copy{ *this };
1115  copy.set(std::forward<Args>(args)...);
1116  return copy;
1117  }
1118 
1121  {
1122  return m_firmwareVersion;
1123  }
1124 
1127  {
1128  return m_firmwareVersion;
1129  }
1130 
1133  {
1134  m_firmwareVersion = value;
1135  return *this;
1136  }
1137 
1139  const ModelName &modelName() const
1140  {
1141  return m_modelName;
1142  }
1143 
1146  {
1147  return m_modelName;
1148  }
1149 
1151  CameraInfo &set(const ModelName &value)
1152  {
1153  m_modelName = value;
1154  return *this;
1155  }
1156 
1158  const Revision &revision() const
1159  {
1160  return m_revision;
1161  }
1162 
1165  {
1166  return m_revision;
1167  }
1168 
1170  CameraInfo &set(const Revision &value)
1171  {
1172  m_revision = value;
1173  return *this;
1174  }
1175 
1178  {
1179  m_revision.set(value);
1180  return *this;
1181  }
1182 
1185  {
1186  m_revision.set(value);
1187  return *this;
1188  }
1189 
1192  {
1193  return m_serialNumber;
1194  }
1195 
1198  {
1199  return m_serialNumber;
1200  }
1201 
1203  CameraInfo &set(const SerialNumber &value)
1204  {
1205  m_serialNumber = value;
1206  return *this;
1207  }
1208 
1210  const UserData &userData() const
1211  {
1212  return m_userData;
1213  }
1214 
1217  {
1218  return m_userData;
1219  }
1220 
1222  CameraInfo &set(const UserData &value)
1223  {
1224  m_userData = value;
1225  return *this;
1226  }
1227 
1230  {
1231  m_userData.set(value);
1232  return *this;
1233  }
1234 
1235  template<typename T,
1236  typename std::enable_if<std::is_same<T, CameraInfo::FirmwareVersion>::value, int>::type = 0>
1238  {
1239  return m_firmwareVersion;
1240  }
1241 
1242  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::ModelName>::value, int>::type = 0>
1244  {
1245  return m_modelName;
1246  }
1247 
1248  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::Revision>::value, int>::type = 0>
1249  const CameraInfo::Revision &get() const
1250  {
1251  return m_revision;
1252  }
1253 
1254  template<typename T,
1255  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Major>::value, int>::type = 0>
1257  {
1258  return m_revision.get<CameraInfo::Revision::Major>();
1259  }
1260 
1261  template<typename T,
1262  typename std::enable_if<std::is_same<T, CameraInfo::Revision::Minor>::value, int>::type = 0>
1264  {
1265  return m_revision.get<CameraInfo::Revision::Minor>();
1266  }
1267 
1268  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::SerialNumber>::value, int>::type = 0>
1270  {
1271  return m_serialNumber;
1272  }
1273 
1274  template<typename T, typename std::enable_if<std::is_same<T, CameraInfo::UserData>::value, int>::type = 0>
1275  const CameraInfo::UserData &get() const
1276  {
1277  return m_userData;
1278  }
1279 
1280  template<typename T,
1281  typename std::enable_if<std::is_same<T, CameraInfo::UserData::MaxSizeBytes>::value, int>::type = 0>
1283  {
1284  return m_userData.get<CameraInfo::UserData::MaxSizeBytes>();
1285  }
1286 
1287  template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1289  {
1290  return m_firmwareVersion;
1291  }
1292 
1293  template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1295  {
1296  return m_modelName;
1297  }
1298 
1299  template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1300  const CameraInfo::Revision &get() const
1301  {
1302  return m_revision;
1303  }
1304 
1305  template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1307  {
1308  return m_serialNumber;
1309  }
1310 
1311  template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
1312  const CameraInfo::UserData &get() const
1313  {
1314  return m_userData;
1315  }
1316 
1318  template<typename F>
1319  void forEach(const F &f) const
1320  {
1321  f(m_firmwareVersion);
1322  f(m_modelName);
1323  f(m_revision);
1324  f(m_serialNumber);
1325  f(m_userData);
1326  }
1327 
1329  template<typename F>
1330  void forEach(const F &f)
1331  {
1332  f(m_firmwareVersion);
1333  f(m_modelName);
1334  f(m_revision);
1335  f(m_serialNumber);
1336  f(m_userData);
1337  }
1338 
1340  bool operator==(const CameraInfo &other) const;
1341 
1343  bool operator!=(const CameraInfo &other) const;
1344 
1346  std::string toString() const;
1347 
1349  friend std::ostream &operator<<(std::ostream &stream, const CameraInfo &value)
1350  {
1351  return stream << value.toString();
1352  }
1353 
1355  void save(const std::string &fileName) const;
1356 
1358  void load(const std::string &fileName);
1359 
1360  private:
1361  void setFromString(const std::string &value);
1362 
1363  void setFromString(const std::string &fullPath, const std::string &value);
1364 
1365  std::string getString(const std::string &fullPath) const;
1366 
1367  FirmwareVersion m_firmwareVersion;
1368  ModelName m_modelName;
1369  Revision m_revision;
1370  SerialNumber m_serialNumber;
1371  UserData m_userData;
1372 
1373  friend struct DataModel::Detail::Befriend<CameraInfo>;
1374  };
1375 
1376 #ifndef NO_DOC
1377  template<>
1378  struct CameraInfo::Version<1>
1379  {
1380  using Type = CameraInfo;
1381  };
1382 #endif
1383 
1384 } // namespace Zivid
1385 
1386 #ifdef _MSC_VER
1387 # pragma warning(pop)
1388 #endif
1389 
1390 #ifndef NO_DOC
1391 # if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1392 namespace std // NOLINT
1393 {
1394  template<>
1395  struct tuple_size<Zivid::CameraInfo::Revision> : integral_constant<size_t, 2>
1396  {};
1397 
1398  template<size_t i>
1399  struct tuple_element<i, Zivid::CameraInfo::Revision>
1400  {
1401  static_assert(i < tuple_size<Zivid::CameraInfo::Revision>::value, "Index must be less than 2");
1402 
1403  using type // NOLINT
1404  = decltype(declval<Zivid::CameraInfo::Revision>().get<i>());
1405  };
1406 
1407  template<>
1408  struct tuple_size<Zivid::CameraInfo::UserData> : integral_constant<size_t, 1>
1409  {};
1410 
1411  template<size_t i>
1412  struct tuple_element<i, Zivid::CameraInfo::UserData>
1413  {
1414  static_assert(i < tuple_size<Zivid::CameraInfo::UserData>::value, "Index must be less than 1");
1415 
1416  using type // NOLINT
1417  = decltype(declval<Zivid::CameraInfo::UserData>().get<i>());
1418  };
1419 
1420  template<>
1421  struct tuple_size<Zivid::CameraInfo> : integral_constant<size_t, 5>
1422  {};
1423 
1424  template<size_t i>
1425  struct tuple_element<i, Zivid::CameraInfo>
1426  {
1427  static_assert(i < tuple_size<Zivid::CameraInfo>::value, "Index must be less than 5");
1428 
1429  using type // NOLINT
1430  = decltype(declval<Zivid::CameraInfo>().get<i>());
1431  };
1432 
1433 } // namespace std
1434 # endif
1435 #endif
#define ZIVID_CORE_EXPORT
Definition: CoreExport.h:57
The firmware version on the camera
Definition: CameraInfo.h:108
std::string toString() const
Get the value as string
bool operator==(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:146
FirmwareVersion(std::string value)
Constructor
Definition: CameraInfo.h:135
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for FirmwareVersion
Definition: CameraInfo.h:126
const std::string & value() const
Get the value
bool operator<(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:158
friend std::ostream & operator<<(std::ostream &stream, const FirmwareVersion &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:170
bool operator>(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:164
bool operator!=(const FirmwareVersion &other) const
Comparison operator
Definition: CameraInfo.h:152
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:123
FirmwareVersion()=default
Default constructor
The model name of the camera
Definition: CameraInfo.h:185
bool operator==(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:223
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:212
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:200
bool operator<(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:235
bool operator>(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:241
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for ModelName
Definition: CameraInfo.h:203
bool operator!=(const ModelName &other) const
Comparison operator
Definition: CameraInfo.h:229
friend std::ostream & operator<<(std::ostream &stream, const ModelName &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:247
Major hardware revision number
Definition: CameraInfo.h:278
std::string toString() const
Get the value as string
bool operator!=(const Major &other) const
Comparison operator
Definition: CameraInfo.h:322
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:293
static constexpr Range< uint32_t > validRange()
The range of valid values for Major
Definition: CameraInfo.h:296
bool operator>(const Major &other) const
Comparison operator
Definition: CameraInfo.h:334
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:340
constexpr Major(uint32_t value)
Constructor
Definition: CameraInfo.h:305
bool operator<(const Major &other) const
Comparison operator
Definition: CameraInfo.h:328
Major()=default
Default constructor
bool operator==(const Major &other) const
Comparison operator
Definition: CameraInfo.h:316
Minor hardware revision number
Definition: CameraInfo.h:355
bool operator>(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:411
bool operator!=(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:399
constexpr Minor(uint32_t value)
Constructor
Definition: CameraInfo.h:382
uint32_t ValueType
The type of the underlying value
Definition: CameraInfo.h:370
friend std::ostream & operator<<(std::ostream &stream, const Minor &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:417
bool operator==(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:393
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:373
Minor()=default
Default constructor
bool operator<(const Minor &other) const
Comparison operator
Definition: CameraInfo.h:405
uint32_t value() const
Get the value
The hardware revision of the camera
Definition: CameraInfo.h:262
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:580
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:516
friend std::ostream & operator<<(std::ostream &stream, const Revision &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:623
Revision & set(const Minor &value)
Set Minor
Definition: CameraInfo.h:565
std::tuple< CameraInfo::Revision::Major, CameraInfo::Revision::Minor > Descendants
Definition: CameraInfo.h:430
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:546
Minor & minor()
Get Minor
Definition: CameraInfo.h:559
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:607
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:573
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:599
Revision(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:457
Major & major()
Get Major
Definition: CameraInfo.h:540
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:484
const Minor & minor() const
Get Minor
Definition: CameraInfo.h:553
bool operator!=(const Revision &other) const
Inequality operator
const Major & major() const
Get Major
Definition: CameraInfo.h:534
The serial number of the camera
Definition: CameraInfo.h:643
SerialNumber(std::string value)
Constructor
Definition: CameraInfo.h:670
friend std::ostream & operator<<(std::ostream &stream, const SerialNumber &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:705
bool operator==(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:681
std::string ValueType
The type of the underlying value
Definition: CameraInfo.h:658
const std::string & value() const
Get the value
static constexpr Range< ValueType::size_type > validSize()
The valid sizes for SerialNumber
Definition: CameraInfo.h:661
SerialNumber()=default
Default constructor
std::string toString() const
Get the value as string
bool operator>(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:699
bool operator<(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:693
bool operator!=(const SerialNumber &other) const
Comparison operator
Definition: CameraInfo.h:687
The maximum number of bytes of user data that can be stored in the camera
Definition: CameraInfo.h:738
friend std::ostream & operator<<(std::ostream &stream, const MaxSizeBytes &value)
Operator to serialize the value to a stream
Definition: CameraInfo.h:802
bool operator!=(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:784
bool operator>(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:796
MaxSizeBytes()=default
Default constructor
constexpr MaxSizeBytes(uint64_t value)
Constructor
Definition: CameraInfo.h:767
uint64_t value() const
Get the value
bool operator<(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:790
bool operator==(const MaxSizeBytes &other) const
Comparison operator
Definition: CameraInfo.h:778
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:758
uint64_t ValueType
The type of the underlying value
Definition: CameraInfo.h:755
Information about user data capabilities of the camera
Definition: CameraInfo.h:720
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:956
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:898
UserData & set(const MaxSizeBytes &value)
Set MaxSizeBytes
Definition: CameraInfo.h:928
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:936
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:949
std::tuple< CameraInfo::UserData::MaxSizeBytes > Descendants
Definition: CameraInfo.h:815
bool operator!=(const UserData &other) const
Inequality operator
MaxSizeBytes & maxSizeBytes()
Get MaxSizeBytes
Definition: CameraInfo.h:922
const MaxSizeBytes & maxSizeBytes() const
Get MaxSizeBytes
Definition: CameraInfo.h:916
UserData()
Default constructor
UserData(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:841
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:867
friend std::ostream & operator<<(std::ostream &stream, const UserData &value)
Operator to send the value as string to a stream
Definition: CameraInfo.h:971
Information about camera model, serial number etc.
Definition: CameraInfo.h:76
CameraInfo & set(const UserData &value)
Set UserData
Definition: CameraInfo.h:1222
bool operator==(const CameraInfo &other) const
Equality operator
const ModelName & modelName() const
Get ModelName
Definition: CameraInfo.h:1139
const CameraInfo::FirmwareVersion & get() const
Definition: CameraInfo.h:1237
void forEach(const F &f)
Run the given function on each direct member with the value of the member as parameter
Definition: CameraInfo.h:1330
const CameraInfo::SerialNumber & get() const
Definition: CameraInfo.h:1269
CameraInfo & set(const SerialNumber &value)
Set SerialNumber
Definition: CameraInfo.h:1203
const CameraInfo::Revision::Minor & get() const
Definition: CameraInfo.h:1263
bool operator!=(const CameraInfo &other) const
Inequality operator
CameraInfo & set(const UserData::MaxSizeBytes &value)
Set UserData::MaxSizeBytes
Definition: CameraInfo.h:1229
FirmwareVersion & firmwareVersion()
Get FirmwareVersion
Definition: CameraInfo.h:1126
UserData & userData()
Get UserData
Definition: CameraInfo.h:1216
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:1102
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:1319
CameraInfo & set(const FirmwareVersion &value)
Set FirmwareVersion
Definition: CameraInfo.h:1132
CameraInfo(Args &&...args)
Constructor taking variadic number of arguments
Definition: CameraInfo.h:1031
const CameraInfo::Revision::Major & get() const
Definition: CameraInfo.h:1256
const FirmwareVersion & firmwareVersion() const
Get FirmwareVersion
Definition: CameraInfo.h:1120
const UserData & userData() const
Get UserData
Definition: CameraInfo.h:1210
CameraInfo & set(const Revision::Major &value)
Set Revision::Major
Definition: CameraInfo.h:1177
CameraInfo & set(const Revision::Minor &value)
Set Revision::Minor
Definition: CameraInfo.h:1184
CameraInfo & set(const ModelName &value)
Set ModelName
Definition: CameraInfo.h:1151
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:1349
Revision & revision()
Get Revision
Definition: CameraInfo.h:1164
const Revision & revision() const
Get Revision
Definition: CameraInfo.h:1158
const CameraInfo::Revision & get() const
Definition: CameraInfo.h:1249
void set(Args &&...args)
Set multiple arguments
Definition: CameraInfo.h:1064
const CameraInfo::ModelName & get() const
Definition: CameraInfo.h:1243
CameraInfo & set(const Revision &value)
Set Revision
Definition: CameraInfo.h:1170
ModelName & modelName()
Get ModelName
Definition: CameraInfo.h:1145
const CameraInfo::UserData::MaxSizeBytes & get() const
Definition: CameraInfo.h:1282
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:995
std::string toString() const
Get the value as string
const SerialNumber & serialNumber() const
Get SerialNumber
Definition: CameraInfo.h:1191
CameraInfo()
Default constructor
const CameraInfo::UserData & get() const
Definition: CameraInfo.h:1275
void save(const std::string &fileName) const
Save to the given file
SerialNumber & serialNumber()
Get SerialNumber
Definition: CameraInfo.h:1197
Class describing a range of values for a given type T
Definition: Range.h:58
NodeType
Definition: NodeType.h:56
The main Zivid namespace. All Zivid code is found here
Definition: Application.h:55