61 # pragma warning(push)
62 # pragma warning(disable : 4251) // "X needs to have dll-interface to be used by clients of class Y."
71 static constexpr
size_t version{ 1 };
84 CameraState(
const CameraState &other);
87 CameraState &operator=(
const CameraState &other);
90 CameraState(CameraState &&other) noexcept;
93 CameraState &operator=(CameraState &&other) noexcept;
96 CameraState() =
default;
99 static constexpr
bool isContainer{
true };
102 static constexpr
const char *path{
"" };
105 static constexpr
const char *name{
"CameraState" };
108 static constexpr
const char *description{
109 R
"description(Information about camera connection state, live mode, temperatures, etc.)description"
113 void set(
const std::string &fullPath,
const std::string &value);
116 std::string getString(
const std::string &fullPath)
const;
123 using ValueType = bool;
124 static const Available yes;
125 static const Available no;
128 static constexpr
bool isContainer{
false };
131 static constexpr
const char *path{
"Available" };
134 static constexpr
const char *name{
"Available" };
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"
142 Available() = default;
145 explicit constexpr Available(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
150 const ValueType &value()
const
156 void setFromString(
const std::string &value)
162 else if(value ==
"no")
168 throw std::invalid_argument(
"Available{ " + value +
" } is not in range [yes, no]");
175 return m_value ?
"yes" :
"no";
179 explicit operator bool()
const
185 bool operator==(
const Available &other)
const
187 return m_value == other.m_value;
191 bool operator!=(
const Available &other)
const
193 return m_value != other.m_value;
197 friend std::ostream &
operator<<(std::ostream &stream,
const Available &value)
199 return stream << value.toString();
203 friend std::istream &operator>>(std::istream &stream,
Available &value)
206 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
224 static constexpr
bool isContainer{
false };
227 static constexpr
const char *path{
"Connected" };
230 static constexpr
const char *name{
"Connected" };
233 static constexpr
const char *description{
234 R
"description(Flag if camera is connected in software)description"
241 explicit constexpr
Connected(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
246 const ValueType &value()
const
252 void setFromString(
const std::string &value)
258 else if(value ==
"no")
264 throw std::invalid_argument(
"Connected{ " + value +
" } is not in range [yes, no]");
271 return m_value ?
"yes" :
"no";
275 explicit operator bool()
const
281 bool operator==(
const Connected &other)
const
283 return m_value == other.m_value;
287 bool operator!=(
const Connected &other)
const
289 return m_value != other.m_value;
293 friend std::ostream &
operator<<(std::ostream &stream,
const Connected &value)
295 return stream << value.toString();
299 friend std::istream &operator>>(std::istream &stream,
Connected &value)
302 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
316 static const Live yes;
317 static const Live no;
320 static constexpr
bool isContainer{
false };
323 static constexpr
const char *path{
"Live" };
326 static constexpr
const char *name{
"Live" };
329 static constexpr
const char *description{ R
"description(Camera live status)description" };
335 explicit constexpr Live(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
340 const ValueType &value()
const
346 void setFromString(
const std::string &value)
352 else if(value ==
"no")
358 throw std::invalid_argument(
"Live{ " + value +
" } is not in range [yes, no]");
365 return m_value ?
"yes" :
"no";
369 explicit operator bool()
const
375 bool operator==(
const Live &other)
const
377 return m_value == other.m_value;
381 bool operator!=(
const Live &other)
const
383 return m_value != other.m_value;
387 friend std::ostream &
operator<<(std::ostream &stream,
const Live &value)
389 return stream << value.toString();
393 friend std::istream &operator>>(std::istream &stream,
Live &value)
396 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
412 static constexpr
bool isContainer{
true };
415 static constexpr
const char *path{
"Temperature" };
418 static constexpr
const char *name{
"Temperature" };
421 static constexpr
const char *description{ R
"description(Current temperature(s))description" };
424 void set(
const std::string &fullPath,
const std::string &value);
427 std::string getString(
const std::string &fullPath)
const;
437 static constexpr
bool isContainer{
false };
440 static constexpr
const char *path{
"Temperature/DMD" };
443 static constexpr
const char *name{
"DMD" };
446 static constexpr
const char *description{ R
"description(DMD temperature)description" };
452 explicit constexpr DMD(ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
457 const ValueType &value()
const
465 return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
469 void setFromString(
const std::string &value)
471 m_value = std::stod(value);
477 return std::to_string(m_value);
481 bool operator==(
const DMD &other)
const
483 return m_value == other.m_value;
487 bool operator!=(
const DMD &other)
const
489 return m_value != other.m_value;
493 bool operator<(
const DMD &other)
const
495 return m_value < other.m_value;
499 bool operator>(
const DMD &other)
const
501 return m_value > other.m_value;
505 friend std::ostream &
operator<<(std::ostream &stream,
const DMD &value)
507 return stream << value.toString();
511 friend std::istream &operator>>(std::istream &stream,
DMD &value)
514 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
530 static constexpr
bool isContainer{
false };
533 static constexpr
const char *path{
"Temperature/General" };
536 static constexpr
const char *name{
"General" };
539 static constexpr
const char *description{ R
"description(General temperature)description" };
546 std::is_nothrow_copy_constructible<ValueType>::value)
551 const ValueType &value()
const
559 return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
563 void setFromString(
const std::string &value)
565 m_value = std::stod(value);
571 return std::to_string(m_value);
575 bool operator==(
const General &other)
const
577 return m_value == other.m_value;
581 bool operator!=(
const General &other)
const
583 return m_value != other.m_value;
587 bool operator<(
const General &other)
const
589 return m_value < other.m_value;
593 bool operator>(
const General &other)
const
595 return m_value > other.m_value;
599 friend std::ostream &
operator<<(std::ostream &stream,
const General &value)
601 return stream << value.toString();
605 friend std::istream &operator>>(std::istream &stream,
General &value)
608 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
624 static constexpr
bool isContainer{
false };
627 static constexpr
const char *path{
"Temperature/LED" };
630 static constexpr
const char *name{
"LED" };
633 static constexpr
const char *description{ R
"description(LED temperature)description" };
639 explicit constexpr
LED(
ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
652 return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
656 void setFromString(
const std::string &value)
658 m_value = std::stod(value);
664 return std::to_string(m_value);
668 bool operator==(
const LED &other)
const
670 return m_value == other.m_value;
674 bool operator!=(
const LED &other)
const
676 return m_value != other.m_value;
680 bool operator<(
const LED &other)
const
682 return m_value < other.m_value;
686 bool operator>(
const LED &other)
const
688 return m_value > other.m_value;
692 friend std::ostream &
operator<<(std::ostream &stream,
const LED &value)
698 friend std::istream &operator>>(std::istream &stream,
LED &value)
701 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
717 static constexpr
bool isContainer{
false };
720 static constexpr
const char *path{
"Temperature/Lens" };
723 static constexpr
const char *name{
"Lens" };
726 static constexpr
const char *description{ R
"description(Lens temperature)description" };
732 explicit constexpr
Lens(
ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
745 return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
749 void setFromString(
const std::string &value)
751 m_value = std::stod(value);
757 return std::to_string(m_value);
761 bool operator==(
const Lens &other)
const
763 return m_value == other.m_value;
767 bool operator!=(
const Lens &other)
const
769 return m_value != other.m_value;
773 bool operator<(
const Lens &other)
const
775 return m_value < other.m_value;
779 bool operator>(
const Lens &other)
const
781 return m_value > other.m_value;
785 friend std::ostream &
operator<<(std::ostream &stream,
const Lens &value)
791 friend std::istream &operator>>(std::istream &stream,
Lens &value)
794 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
810 static constexpr
bool isContainer{
false };
813 static constexpr
const char *path{
"Temperature/PCB" };
816 static constexpr
const char *name{
"PCB" };
819 static constexpr
const char *description{ R
"description(PCB temperature)description" };
825 explicit constexpr
PCB(
ValueType value) noexcept(std::is_nothrow_copy_constructible<ValueType>::value)
838 return { std::numeric_limits<ValueType>::lowest(), std::numeric_limits<ValueType>::max() };
842 void setFromString(
const std::string &value)
844 m_value = std::stod(value);
850 return std::to_string(m_value);
854 bool operator==(
const PCB &other)
const
856 return m_value == other.m_value;
860 bool operator!=(
const PCB &other)
const
862 return m_value != other.m_value;
866 bool operator<(
const PCB &other)
const
868 return m_value < other.m_value;
872 bool operator>(
const PCB &other)
const
874 return m_value > other.m_value;
878 friend std::ostream &
operator<<(std::ostream &stream,
const PCB &value)
884 friend std::istream &operator>>(std::istream &stream,
PCB &value)
887 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
896 typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value,
int>::type = 0>
903 typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value,
int>::type = 0>
910 typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value,
int>::type = 0>
917 typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value,
int>::type = 0>
924 typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value,
int>::type = 0>
930 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
936 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
942 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
948 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
954 template<size_t i, typename std::enable_if<i == 4, int>::type = 0>
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()) +
"]");
985 const DMD &dmd()
const
997 if(value.value() < value.range().min() || value.value() > value.range().max())
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()) +
"]");
1008 const General &general()
const
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()) +
"]");
1031 const LED &led()
const
1041 Temperature &set(
const Lens &value)
1043 if(value.value() < value.range().min() || value.value() > value.range().max())
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()) +
"]");
1054 const Lens &lens()
const
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()) +
"]");
1077 const PCB &pcb()
const
1083 template<
typename F>
1084 void forEach(
const F &f)
const
1094 template<
typename F>
1095 void forEach(
const F &f)
1105 template<
typename F>
1106 void traverseValues(
const F &f)
const
1116 template<
typename F>
1117 void traverseValues(
const F &f)
1136 void setFromString(
const std::string &value);
1139 friend std::istream &operator>>(std::istream &stream,
Temperature &value)
1142 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
1153 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Available>::value,
int>::type = 0>
1159 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Connected>::value,
int>::type = 0>
1165 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Live>::value,
int>::type = 0>
1171 template<typename T, typename std::enable_if<std::is_same<T, CameraState::Temperature>::value,
int>::type = 0>
1174 return m_temperature;
1177 template<
typename T,
1178 typename std::enable_if<std::is_same<T, CameraState::Temperature::DMD>::value,
int>::type = 0>
1184 template<
typename T,
1185 typename std::enable_if<std::is_same<T, CameraState::Temperature::General>::value,
int>::type = 0>
1191 template<
typename T,
1192 typename std::enable_if<std::is_same<T, CameraState::Temperature::LED>::value,
int>::type = 0>
1198 template<
typename T,
1199 typename std::enable_if<std::is_same<T, CameraState::Temperature::Lens>::value,
int>::type = 0>
1205 template<
typename T,
1206 typename std::enable_if<std::is_same<T, CameraState::Temperature::PCB>::value,
int>::type = 0>
1212 template<size_t i, typename std::enable_if<i == 0, int>::type = 0>
1218 template<size_t i, typename std::enable_if<i == 1, int>::type = 0>
1224 template<size_t i, typename std::enable_if<i == 2, int>::type = 0>
1230 template<size_t i, typename std::enable_if<i == 3, int>::type = 0>
1233 return m_temperature;
1238 const Connected &connected,
1249 m_available = value;
1253 const Available &isAvailable()
const
1265 m_connected = value;
1269 const Connected &isConnected()
const
1285 const Live &live()
const
1291 Temperature m_temperature{};
1297 m_temperature = value;
1301 const Temperature &temperature()
const
1303 return m_temperature;
1309 m_temperature.
set(value);
1314 CameraState &set(
const Temperature::General &value)
1316 m_temperature.
set(value);
1321 CameraState &set(
const Temperature::LED &value)
1323 m_temperature.set(value);
1330 m_temperature.
set(value);
1337 m_temperature.
set(value);
1342 template<
typename F>
1343 void forEach(
const F &f)
const
1352 template<
typename F>
1353 void forEach(
const F &f)
1362 template<
typename F>
1363 void traverseValues(
const F &f)
const
1368 m_temperature.traverseValues(f);
1372 template<
typename F>
1373 void traverseValues(
const F &f)
1378 m_temperature.traverseValues(f);
1391 void setFromString(
const std::string &value);
1394 friend std::istream &operator>>(std::istream &stream,
CameraState &value)
1397 std::string{ std::istreambuf_iterator<char>{ stream }, std::istreambuf_iterator<char>{} });
1408 explicit CameraState(
const std::string &fileName);
1411 void save(
const std::string &fileName)
const;
1414 void load(
const std::string &fileName);
1419 struct CameraState::Version<1>
1428 # pragma warning(pop)
1432 # if !(defined(_MSC_VER) && (_MSC_VER <= 1900))
1443 = decltype(declval<Zivid::CameraState::Temperature>().get<i>());
1451 struct tuple_element<i,
Zivid::CameraState>
1454 = decltype(declval<Zivid::CameraState>().get<i>());