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