21template<
typename PropertyType>
22void call_callback(
const ant::IProperty& oProperty,
const std::function<
void(
const char*, PropertyType)>& fnCallback)
24 oProperty.GetName(cStringRedirect(
25 [&](
const IString& strName)
27 fnCallback(strName.Get(), adtf::base::get_property_value<std::decay_t<PropertyType>>(*oProperty.GetValue()));
32template<
typename PropertyType>
33tResult get_property_value_from_property(
const IProperty& oProperty, PropertyType& oFoundValue)
35 if (
const auto oResult = adtf::base::get_property_value(*oProperty.GetValue(), oFoundValue);
IS_FAILED(oResult))
37 std::string strPropertyName;
41 LOG_WARNING(
"%s", oExtendedResult.GetDescription());
43 return oExtendedResult;
67using tPropertyVisitorCallback = std::function<void(
const ant::IProperty& oProperty)>;
82template<
typename SubPropertyType>
84 const std::function<
void(
const char*, SubPropertyType)>& fnCallback)
86 visit_properties(oProperties, std::bind(detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
102template<
typename SubPropertyType>
104 const std::function<
void(
const char*, SubPropertyType)>& fnCallback)
107 std::bind(detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
117 const char* strPropertyName,
118 const tPropertyVisitorCallback& fnCallback);
127template<
typename SubPropertyType>
129 const char* strPropertyName,
130 const std::function<
void(
const char*, SubPropertyType)>& fnCallback)
133 std::bind(detail::call_callback<SubPropertyType>, std::placeholders::_1, fnCallback));
136tResult visit_property(
const ant::IProperties& oProperties,
137 const char* strPropertyName,
138 const std::function<
tResult(
const IProperty& oProperty)>& fnCallback);
140tResult visit_property_by_path(
const ant::IProperties& oProperties,
141 const char* strPropertyPathAndName,
142 const std::function<
tResult(
const IProperty& oProperty)>& fnCallback);
157template<
typename VALUETYPE>
197 const auto oResult = visit_property(oProperties, strNameOfValue, [&](
const IProperty& oProperty) ->
tResult
198 {
return detail::get_property_value_from_property(oProperty, oFoundValue); });
201 return oDefaultValue;
218template<
typename VALUETYPE>
224template<
typename VALUETYPE>
225tResult set_property_by_path(ant::IProperties& oProperties,
const char* strPathAndName, VALUETYPE oValue)
227 util::cString strHelper(strPathAndName);
228 size_t nLastSlashPosition = strHelper.RFind(
'/');
229 if (nLastSlashPosition == util::cString::InvalidPos)
234 util::cString strParent = strHelper.Mid(0, nLastSlashPosition);
235 return oProperties.SetPropertyByPath(strParent, property<VALUETYPE>(strHelper.Mid(nLastSlashPosition + 1), oValue));
239T get_property_by_path(
const ant::IProperties& oProperties,
const char* strPathAndName,
const T& oDefaultValue)
244 visit_property_by_path(oProperties, strPathAndName, [&](
const IProperty& oProperty) ->
tResult
245 {
return detail::get_property_value_from_property(oProperty, oFoundValue); });
248 return oDefaultValue;
254template<
typename VALUETYPE>
255VALUETYPE get_property_by_path(
const ant::IProperties& oProperties,
const char* strPathAndName)
257 return get_property_by_path(oProperties, strPathAndName, VALUETYPE());
268 const char* strPropertyPathAndName,
283 bool Exists(
const char* )
const override
293 tResult SetPropertyByPath(
const char* ,
const IProperty& )
override
298 tResult Set(
const IProperties& )
override
303 tResult Get(IProperties& )
const override
308 size_t GetSize()
const override
313 tResult RemoveProperty(
const char* )
override
318 tResult RegisterPropertyObserver(
const char* , IPropertyObserver& )
override
323 tResult UnregisterPropertyObserver(IPropertyObserver& )
override
#define LOG_WARNING(...)
Logs a warning message.
Definition log.h:465
#define IS_FAILED(s)
Check if result is failed.
Definition result.h:20
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:775
#define ADTF_UTIL_COMPOSED_RESULT(_result,...)
for internal use
Definition result.h:68
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
Definition result.h:29
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
Definition result.h:42
Definition property_intf.h:213
Definition property_intf.h:119
Definition property_helper.h:275
tResult SetProperty(const IProperty &)=0
Definition property.h:337
Namespace for the ADTF Base SDK.
Definition adtf_base_type_traits.h:13
tResult get_property_object_by_path(const ant::IProperties &oProperties, const char *strPropertyPathAndName, ant::IProperty &oProperty)
std::pair< std::string, std::string > split_parents_and_leaf(const char *strPropertyPathAndName)
tResult create_property_tree(ant::IProperties &oProperties, const char *strPath)
tResult set_property(ant::IProperties &oProperties, const char *strNameOfValue, VALUETYPE oValue)
Definition property_helper.h:158
void visit_properties(const ant::IProperties &oProperties, const tPropertyVisitorCallback &fnCallback)
void visit_sub_properties(const ant::IProperty &oProperty, const tPropertyVisitorCallback &fnCallback)
T get_property(const ant::IProperties &oProperties, const char *strNameOfValue, const T &oDefaultValue)
Definition property_helper.h:193
Namespace for all functionality provided by ADTF and its SDKs.
Definition adtf_client_connector.h:14
#define adtf_string_intf(__string__)
Definition string_intf.h:465