Platform.Data.Doublets C++
Loading...
Searching...
No Matches
UInt32Links.h
Go to the documentation of this file.
1
2
3using TLinkAddress = std::uint32_t;
4
6{
7 class UInt32Links : public LinksDisposableDecoratorBase<TLinkAddress>
8 {
9 public:
10 UInt32Links(ILinks<TLinkAddress>& storage) : base(storage) {}
11
12 public:
13 TLinkAddress Create(const LinkType& restriction)
14 {
15 return this->decorated().TDecorated::CreatePoint();
16 }
17
18 public:
19 TLinkAddress Update(const LinkType& restriction, const LinkType& substitution)
20 {
21 auto constants = _constants;
22 auto indexPartConstant = constants.IndexPart;
23 auto sourcePartConstant = constants.SourcePart;
24 auto targetPartConstant = constants.TargetPart;
25 auto nullConstant = constants.Null;
26 auto itselfConstant = constants.Itself;
27 auto existedLink = nullConstant;
28 auto updatedLink = restriction[indexPartConstant];
29 auto newSource = substitution[sourcePartConstant];
30 auto newTarget = substitution[targetPartConstant];
31 if (newSource != itselfConstant && newTarget != itselfConstant)
32 {
33 existedLink = storage.SearchOrDefault(newSource, newTarget);
34 }
35 if (existedLink == nullConstant)
36 {
37 auto before = storage.GetLink(updatedLink);
38 if (before[sourcePartConstant] != newSource || before[targetPartConstant] != newTarget)
39 {
40 storage.Update(updatedLink, newSource == itselfConstant ? updatedLink : newSource,
41 newTarget == itselfConstant ? updatedLink : newTarget);
42 }
43 return updatedLink;
44 }
45 else
46 {
47 return this->facade().TFacade::MergeAndDelete(updatedLink, existedLink);
48 }
49 }
50
51 public:
52 void Delete(const LinkType& restriction)
53 {
54 auto linkIndex = restriction[_constants.IndexPart];
55 storage.EnforceResetValues(linkIndex);
56 this->facade().TFacade::DeleteAllUsages(linkIndex);
57 storage.Delete(linkIndex);
58 }
59 };
60} // namespace Platform::Data::Doublets::Decorators
Definition Decorators.h:4