Platform.Data.Doublets C++
Loading...
Searching...
No Matches
PropertiesOperator.h
Go to the documentation of this file.
2{
3 template <typename...>
5 template <std::integral TLinkAddress>
6 class PropertiesOperator<TLinkAddress> : public LinksOperatorBase<TLinkAddress>,
7 IProperties<TLinkAddress, TLinkAddress, TLinkAddress>
8 {
9 public:
10 PropertiesOperator(ILinks<TLinkAddress>& storage) : base(storage) {}
11
12 public:
14 {
15 auto storage = _links;
16 auto objectProperty = storage.SearchOrDefault(object, property);
17 if (objectProperty == 0)
18 {
19 return 0;
20 }
21 constexpr auto constants = std::remove_cvref_t<decltype(storage)>::Constants;
22 auto any = constants.Any;
23 auto query = Link<TLinkAddress>(any, objectProperty, any);
24 auto valueLink = storage.SingleOrDefault(query);
25 if (valueLink == nullptr)
26 {
27 return 0;
28 }
29 return storage.GetTarget(valueLink[constants.IndexPart]);
30 }
31
32 public:
33 void SetValue(TLinkAddress object, TLinkAddress property, TLinkAddress value)
34 {
35 auto storage = _links;
36 auto objectProperty = storage.GetOrCreate(object, property);
37 storage.DeleteMany(storage.AllIndices(storage.Constants.Any, objectProperty));
38 storage.GetOrCreate(objectProperty, value);
39 }
40 };
41} // namespace Platform::Data::Doublets::PropertyOperators
void SetValue(TLinkAddress object, TLinkAddress property, TLinkAddress value)
Definition PropertiesOperator.h:33
TLinkAddress GetValue(TLinkAddress object, TLinkAddress property)
Definition PropertiesOperator.h:13
PropertiesOperator(ILinks< TLinkAddress > &storage)
Definition PropertiesOperator.h:10
Definition PropertiesOperator.h:2