3#include "irsol/logging.hpp"
4#include "irsol/macros.hpp"
15 std::is_integral_v<T> || std::is_floating_point_v<T> || std::is_same_v<std::string, T>,
18Interface::getParam(const std::string& param) const
20 using U = std::decay_t<T>;
21 IRSOL_LOG_DEBUG("Getting parameter '{}'", param);
23 std::scoped_lock<std::mutex> lock(m_camMutex);
24 NeoAPI::NeoString neoParam(param.c_str());
25 auto feature = m_cam.GetFeature(neoParam);
27 if constexpr(std::is_same_v<U, std::string>) {
28 return std::string(feature.GetString());
29 } else if constexpr(std::is_same_v<U, bool>) {
30 return feature.GetBool();
31 } else if constexpr(std::is_integral_v<U>) {
32 return static_cast<T>(feature.GetInt());
33 } else if constexpr(std::is_floating_point_v<U>) {
34 return static_cast<T>(feature.GetDouble());
36 IRSOL_MISSING_TEMPLATE_SPECIALIZATION(T, "Interface::getParam()");
38 } catch(const std::exception& e) {
39 IRSOL_LOG_ERROR("Failed to get parameter '{}': {}", param, e.what());
40 if constexpr(std::is_same_v<U, std::string>) {
51 std::is_integral_v<std::decay_t<T>> || std::is_floating_point_v<std::decay_t<T>> ||
52 std::is_same_v<std::decay_t<T>, std::string>,
55Interface::setParam(const std::string& param, T value)
57 IRSOL_LOG_DEBUG("Setting parameter '{}' to value '{}'", param, value);
59 std::scoped_lock<std::mutex> lock(m_camMutex);
60 setParamNonThreadSafe(param, value);
62 return getParam<std::decay_t<T>>(param);
65template<typename T, std::enable_if_t<std::is_same_v<std::decay_t<T>, const char*>, int> = 0>
67Interface::setParam(const std::string& param, T value)
69 return setParam<std::string>(param, std::string(value));
75 std::is_integral_v<std::decay_t<T>> || std::is_floating_point_v<std::decay_t<T>> ||
76 std::is_same_v<std::decay_t<T>, std::string> || std::is_same_v<std::decay_t<T>, const char*>,
79Interface::setParamNonThreadSafe(const std::string& param, T value)
81 using U = std::decay_t<T>;
83 NeoAPI::NeoString neoParam(param.c_str());
84 auto feature = m_cam.GetFeature(neoParam);
86 // Make sure the feature is writable
87 if(!feature.IsWritable()) {
88 IRSOL_LOG_ERROR("Feature '{}' is not writable", param);
89 throw std::runtime_error(std::string("Feature '") + param + "' is not writable");
92 if constexpr(std::is_same_v<U, std::string>)
93 feature.SetString(NeoAPI::NeoString(value.c_str()));
94 else if constexpr(std::is_same_v<U, const char*>) {
95 feature.SetString(NeoAPI::NeoString(value));
96 } else if constexpr(std::is_same_v<U, bool>) {
97 feature.SetBool(value);
98 } else if constexpr(std::is_integral_v<U>) {
99 feature.SetInt(value);
100 } else if constexpr(std::is_floating_point_v<U>) {
101 feature.SetDouble(value);
103 IRSOL_MISSING_TEMPLATE_SPECIALIZATION(T, "Interface::setParamNonThreadSafe()");
106 } catch(const std::exception& e) {
107 IRSOL_LOG_ERROR("Failed to set parameter '{}': {}", param, e.what());