49 cPropertyValue(
const T& xValue)
51 if constexpr (std::is_base_of_v<ant::IPropertyValue, T>)
53 auto oResult = AssignRaw(xValue);
55 if (oResult == ERR_EMPTY)
57 oResult = AssignString(xValue);
70 m_xValue = std::string(strValue);
75 m_xValue = std::string(strValue);
78 cPropertyValue(cPropertyValue&&) =
default;
79 cPropertyValue(
const cPropertyValue&) =
default;
80 cPropertyValue& operator=(cPropertyValue&&) =
default;
81 cPropertyValue& operator=(
const cPropertyValue&) =
default;
89 if constexpr (std::is_base_of_v<ant::IPropertyValue, T>)
108 return std::get<T>(m_xValue);
114 return std::get<T>(m_xValue);
142using is_user_defined_property_value =
143 std::integral_constant<bool,
144 !(std::is_same_v<T, bool> || std::is_arithmetic_v<T> || std::is_same_v<T, std::string>)>;
147typename std::enable_if<is_user_defined_property_value<T>::value,
tResult>::type
150 const auto& strValue = oValue.Get<cPropertyValue::tUserDefined>().strValue;
152 ant::property_type_definition<T>::con_type::FromString(adtf::util::cString(strValue.c_str()), xValue));
157typename std::enable_if<!is_user_defined_property_value<T>::value,
tResult>::type
160 xValue = oValue.Get<T>();
165 typename std::conditional<is_user_defined_property_value<T>::value, cPropertyValue::tUserDefined, T>::type;
170tResult get_property_value(
const IPropertyValue& oValue, T& xValue)
173 RETURN_IF_FAILED(oHelper.Set(oValue));
174 RETURN_IF_FAILED(detail::get_property_value(oHelper, xValue));
179T get_property_value(
const IPropertyValue& oValue)
195 cProperty(
const cProperty& oProp);
196 cProperty(cProperty&& oProp);
215 cProperty(std::string_view strName,
const T& xValue): m_oValue(xValue), m_strName(strName)
220 cProperty(
const char* strName,
const T& xValue):
cProperty(std::string_view(strName), xValue)
225 cProperty(
const T& xValue): m_oValue(xValue)
231 const IPropertyValue* GetValue()
const override;
232 IPropertyValue* GetValue()
override;
233 tResult SetValue(
const IPropertyValue& oValue)
override;
236 tResult SetValue(
const T& xValue)
238 if constexpr (std::is_base_of_v<ant::IPropertyValue, T>)
240 return this->SetValue(
static_cast<const IPropertyValue&
>(xValue));
244 RETURN_IF_FAILED(m_oValue.
Set(xValue));
250 tResult GetName(IString&& strName)
const override;
251 tResult SetName(
const IString& strName)
override;
252 tResult Set(
const IProperty& oProp)
override;
253 bool HasProperties()
const override;
254 bool HasAttachedProperties()
const override;
268 void NotifyObservers();
269 void CreateProperties()
const;
272 std::string m_strName;
274 std::vector<IPropertyObserver*> m_oObservers;
275 bool m_bAttached =
false;
281template<
typename T,
typename Enable =
void>
287 RegisterObserver(*
this);
290 property(property&& oProp): cProperty(std::move(oProp))
292 RegisterObserver(*
this);
300 property(std::string_view strName,
const T& oValue):
306 property(
const char* strName,
const T& oValue): property(std::string_view(strName), oValue)
312 UnregisterObserver(*
this);
315 const T& GetValueT()
const
320 bool operator==(
const T& xOther)
const
322 return GetValueT() == xOther;
325 property& operator=(
const T& xValue)
327 ConvertAndSetValue(xValue);
331 property& operator=(property&& oProp)
341 void InitValue(
const T& oValue)
343 ConvertAndSetValue(oValue);
344 RegisterObserver(*
this);
347 void ConvertAndSetValue(
const T& oValue)
349 adtf::util::cString strHelper;
367class property<T, typename std::enable_if<!detail::is_user_defined_property_value<T>::value>::type> :
public cProperty
370 property(): cProperty(T{})
374 using cProperty::cProperty;
376 const T& GetValueT()
const
381 bool operator==(
const T& xOther)
const
383 return GetValueT() == xOther;
386 property& operator=(
const T& xValue)
399 cProperties() =
default;
401 bool Exists(
const char* strName)
const override;
404 size_t GetSize()
const override;
405 tResult GetProperty(
const char* strName,
IProperty& pProperty)
const override;
409 cProperties& CreateProperty(std::string_view strName,
const T& xValue)
411 const auto emplaced = m_oProperties.emplace(std::piecewise_construct, std::forward_as_tuple(strName),
412 std::forward_as_tuple(strName, xValue));
413 if (!emplaced.second)
415 emplaced.first->second.SetValue(xValue);
418 return static_cast<cProperties&
>(emplaced.first->second.GetProperties());
421 tResult SetPropertyByPath(
const char* strParentPath,
const IProperty& pProperty)
override;
422 tResult RemoveProperty(
const char* strName)
override;
428 std::map<std::string, cProperty, std::less<>> m_oProperties;
433using spider::cProperties;
434using spider::cProperty;
435using spider::cPropertyValue;
436using spider::property;
437using spider::get_property_value;
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:736
#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
Definition properties_v2.h:31
Definition properties_v2.h:192
Definition properties_v2.h:397
Definition properties_v2.h:31
tResult ToString(IString &&strIToString) const override
tResult Set(const IPropertyValue &oValue) override
tResult FromRaw(const IRawMemory &oRawValue) override
tResult GetType(IString &&strType) const override
tResult ToRaw(IRawMemory &&oRawValue) const override
tResult FromString(const IString &strValueAsString) override
Definition properties_v2.h:192
tResult DetachProperties() override
cProperty & operator=(cProperty &&oProp)
cProperty & operator=(const ant::IProperty &oProp)
tResult GetProperties(ucom::ant::iobject_ptr< const IProperties > &pProperties) const override
get subproperties for readonly access
tResult AttachProperties(const ucom::ant::iobject_ptr< IProperties > &pProperties) override
tResult GetAttachedProperties(IProperty &pProperty) const override
tResult GetProperties(ucom::ant::iobject_ptr< IProperties > &pProperties) override
get subproperties for writing access
cProperty & operator=(const cProperty &oProp)
tResult SetProperties(const IProperties &pProperties) override
will copy given properties
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 all functionality of the ADTF Base SDK provided since v3.18.
Definition properties_v2.h:24
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
Definition property_type_definitions.h:38
Definition properties_v2.h:37
std::string strValue
Definition properties_v2.h:45
std::string strType
Definition properties_v2.h:41