ADTF
Loading...
Searching...
No Matches
properties.h
Go to the documentation of this file.
1
7#pragma once
8
10#include <adtfbase/property.h>
11
13
14#include <string>
15#include <string_view>
16
17namespace adtf
18{
19namespace base
20{
24class cProperties : public ucom::catwo::object<IProperties>
25{
26public:
27 cProperties() = default;
28 cProperties(const IProperties& oProperties);
29 bool Exists(const char* strName) const override;
30 tResult Get(IProperties& pProperties) const override;
31 tResult Set(const IProperties& pProperties) override;
32 size_t GetSize() const override;
33 tResult GetProperty(const char* strName, IProperty& pProperty) const override;
34 tResult SetProperty(const IProperty& oProperty) override;
35
36 template<typename T>
37 cProperties& CreateProperty(std::string_view strName, const T& xValue)
38 {
39 const auto emplaced = m_oProperties.emplace(std::piecewise_construct, std::forward_as_tuple(strName),
40 std::forward_as_tuple(strName, xValue));
41 if (!emplaced.second)
42 {
43 emplaced.first->second.SetValue(xValue);
44 }
45
46 return static_cast<cProperties&>(emplaced.first->second.GetProperties());
47 }
48
49 tResult SetPropertyByPath(const char* strParentPath, const IProperty& pProperty) override;
50 tResult RemoveProperty(const char* strName) override;
51 tResult RegisterPropertyObserver(const char* strPropertyName, IPropertyObserver& oObserver) override;
52 tResult UnregisterPropertyObserver(IPropertyObserver& oObserver) override;
53
54private:
55 // TODO Switch to std::unordered_map when we have C++20 with is_transparent support in unordered containers.
56 std::map<std::string, cProperty, std::less<>> m_oProperties;
57};
58
59} // namespace base
60} // namespace adtf
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
Definition result.h:775
Definition property_intf.h:213
Definition property_intf.h:190
Definition property_intf.h:119
Definition object.h:397
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