Platform.Data.Doublets C++
Toggle main menu visibility
Loading...
Searching...
No Matches
UInt32Links.h
Go to the documentation of this file.
1
2
3
using
TLinkAddress
= std::uint32_t;
4
5
namespace
Platform::Data::Doublets::Decorators
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
TLinkAddress
std::uint32_t TLinkAddress
Definition
UInt32Links.h:3
Platform::Data::Doublets::Decorators::LinksDisposableDecoratorBase< TLinkAddress >::LinksDisposableDecoratorBase
LinksDisposableDecoratorBase(ILinks< TLinkAddress > &storage)
Definition
LinksDisposableDecoratorBase.h:24
Platform::Data::Doublets::Decorators::UInt32Links::Update
TLinkAddress Update(const LinkType &restriction, const LinkType &substitution)
Definition
UInt32Links.h:19
Platform::Data::Doublets::Decorators::UInt32Links::UInt32Links
UInt32Links(ILinks< TLinkAddress > &storage)
Definition
UInt32Links.h:10
Platform::Data::Doublets::Decorators::UInt32Links::Delete
void Delete(const LinkType &restriction)
Definition
UInt32Links.h:52
Platform::Data::Doublets::Decorators::UInt32Links::Create
TLinkAddress Create(const LinkType &restriction)
Definition
UInt32Links.h:13
Platform::Data::Doublets::Decorators
Definition
Decorators.h:4
cpp
Platform.Data.Doublets
Decorators
UInt32Links.h
Generated by
1.18.0