47 cPropertyValue(
const T& xValue)
49 if constexpr (std::is_base_of_v<IPropertyValue, T>)
51 auto oResult = AssignRaw(xValue);
53 if (oResult == ERR_EMPTY)
55 oResult = AssignString(xValue);
66 cPropertyValue(
const char* strValue)
68 m_xValue = std::string(strValue);
71 cPropertyValue(std::string_view strValue)
73 m_xValue = std::string(strValue);
76 cPropertyValue(cPropertyValue&&) =
default;
77 cPropertyValue(
const cPropertyValue&) =
default;
78 cPropertyValue& operator=(cPropertyValue&&) =
default;
79 cPropertyValue& operator=(
const cPropertyValue&) =
default;
87 if constexpr (std::is_base_of_v<IPropertyValue, T>)
106 return std::get<T>(m_xValue);
112 return std::get<T>(m_xValue);
115 tResult Validate(
const IPropertyValue& oTargetValue,
const IProperty& oValidationScope)
const noexcept;
118 tResult AssignType(
const IPropertyValue& oValue);
119 tResult AssignRaw(
const IPropertyValue& oValue);
120 tResult AssignString(
const IPropertyValue& oValue);
141using is_user_defined_property_value =
142 std::integral_constant<bool,
143 !(std::is_same_v<T, bool> || std::is_arithmetic_v<T> || std::is_same_v<T, std::string>)>;
146typename std::enable_if<is_user_defined_property_value<T>::value,
tResult>::type
147 get_property_value(
const cPropertyValue& oValue, T& xValue)
149 const auto& strValue = oValue.Get<cPropertyValue::tUserDefined>().strValue;
150 RETURN_IF_FAILED(property_type_definition<T>::con_type::FromString(adtf::util::cString(strValue.c_str()), xValue));
155typename std::enable_if<!is_user_defined_property_value<T>::value,
tResult>::type
156 get_property_value(
const cPropertyValue& oValue, T& xValue)
158 xValue = oValue.Get<T>();
163 typename std::conditional<is_user_defined_property_value<T>::value, cPropertyValue::tUserDefined, T>::type;
171 RETURN_IF_FAILED(oHelper.Set(oValue));
172 RETURN_IF_FAILED(detail::get_property_value(oHelper, xValue));
188class property_value :
public cPropertyValue
191 property_value(): cPropertyValue(InitValue(T{}))
195 property_value(
const T& oValue): cPropertyValue(InitValue(oValue))
200 const T& GetValue()
const
202 if constexpr (std::is_same_v<T, const char*>)
204 m_oValue = Get<std::string>().c_str();
207 else if constexpr (detail::is_user_defined_property_value<T>::value)
219 static auto InitValue(
const T& oValue)
221 if constexpr (std::is_same_v<T, const char*>)
223 return std::string(oValue ? oValue :
"");
225 else if constexpr (detail::is_user_defined_property_value<T>::value)
227 adtf::util::cString strValue;
239 mutable T m_oValue{};
249 cProperty(
const cProperty& oProp);
250 cProperty(cProperty&& oProp);
269 cProperty(std::string_view strName,
const T& xValue): m_oValue(xValue), m_strName(strName)
274 cProperty(
const char* strName,
const T& xValue):
cProperty(std::string_view(strName), xValue)
279 cProperty(
const T& xValue): m_oValue(xValue)
285 const IPropertyValue* GetValue()
const override;
286 IPropertyValue* GetValue()
override;
287 tResult SetValue(
const IPropertyValue& oValue)
override;
290 tResult SetValue(
const T& xValue)
292 if constexpr (std::is_base_of_v<IPropertyValue, T>)
294 return this->SetValue(
static_cast<const IPropertyValue&
>(xValue));
298 RETURN_IF_FAILED(m_oValue.Set(xValue));
304 tResult GetName(IString&& strName)
const override;
305 tResult SetName(
const IString& strName)
override;
306 tResult Set(
const IProperty& oProp)
override;
307 bool HasProperties()
const override;
308 bool HasAttachedProperties()
const override;
322 void NotifyObservers();
323 void CreateProperties()
const;
326 std::string m_strName;
328 std::vector<IPropertyObserver*> m_oObservers;
329 bool m_bAttached =
false;
335template<
typename T,
typename Enable =
void>
341 RegisterObserver(*
this);
344 property(property&& oProp): cProperty(std::move(oProp))
346 RegisterObserver(*
this);
354 property(std::string_view strName,
const T& oValue):
360 property(
const char* strName,
const T& oValue): property(std::string_view(strName), oValue)
366 UnregisterObserver(*
this);
369 const T& GetValueT()
const
374 bool operator==(
const T& xOther)
const
376 return GetValueT() == xOther;
379 property& operator=(
const T& xValue)
381 ConvertAndSetValue(xValue);
385 property& operator=(property&& oProp)
395 void InitValue(
const T& oValue)
397 ConvertAndSetValue(oValue);
398 RegisterObserver(*
this);
401 void ConvertAndSetValue(
const T& oValue)
403 adtf::util::cString strHelper;
420class property<T, typename std::enable_if<!detail::is_user_defined_property_value<T>::value>::type> :
public cProperty
423 property(): cProperty(T{})
427 using cProperty::cProperty;
429 const T& GetValueT()
const
434 bool operator==(
const T& xOther)
const
436 return GetValueT() == xOther;
439 property& operator=(
const T& xValue)
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:775
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define THROW_IF_FAILED(s)
throws if the expression returns a failed tResult
Definition result.h:88
Definition property_intf.h:213
Definition property_intf.h:190
Definition property_intf.h:61
Definition property_intf.h:119
Definition rawmemory_base.h:23
Definition string_intf.h:29
tResult ToRaw(IRawMemory &&oRawValue) const override
tResult ToString(IString &&strIToString) const override
tResult FromString(const IString &strValueAsString) override
tResult GetType(IString &&strType) const override
tResult FromRaw(const IRawMemory &oRawValue) override
tResult Set(const IPropertyValue &oValue) override
Definition property.h:246
cProperty & operator=(const IProperty &oProp)
tResult AttachProperties(const ucom::ant::iobject_ptr< IProperties > &pProperties) override
tResult GetProperties(ucom::ant::iobject_ptr< IProperties > &pProperties) override
get subproperties for writing access
cProperty & operator=(const cProperty &oProp)
tResult GetAttachedProperties(IProperty &pProperty) const override
tResult DetachProperties() override
cProperty & operator=(cProperty &&oProp)
tResult SetProperties(const IProperties &pProperties) override
will copy given properties
tResult GetProperties(ucom::ant::iobject_ptr< const IProperties > &pProperties) const override
get subproperties for readonly access
Base object pointer to realize binary compatible reference counting in interface methods.
Definition object_ptr_intf.h:112
Definition object_ptr.h:384
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
std::string strValue
Definition property.h:43
std::string strType
Definition property.h:39
Definition property_type_definitions.h:36