Skip to content

Commit 8797bea

Browse files
authored
Merge pull request #172 from Ahmed-Elsaka-JC/afe_new_uml_model
KVS new Design
2 parents b9420a2 + c02d41a commit 8797bea

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed

docs/class_diagram_cpp.puml

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
@startuml ScorePersistencyKvsDesign
2+
3+
skinparam class {
4+
BackgroundColor<<interface>> LightYellow
5+
BorderColor<<interface>> DarkGoldenRod
6+
BackgroundColor<<implementation>> LightBlue
7+
BorderColor<<implementation>> DodgerBlue
8+
BackgroundColor<<mock>> LightPink
9+
BorderColor<<mock>> IndianRed
10+
}
11+
12+
class KvsBuilder <<implementation>> {
13+
- instance_id : InstanceId
14+
- defaults : optional<KvsDefaults>
15+
- kvs_load : optional<KvsLoad>
16+
- backend : optional<IKvsBackend>
17+
- {static} kvs_pool : map<InstanceId, ptr<Kvs>>
18+
__
19+
+ KvsBuilder(instance_id : InstanceId)
20+
+ Defaults(defaults : KvsDefaults) : KvsBuilder&
21+
+ KvsLoad(kvs_load : KvsLoad) : KvsBuilder&
22+
+ Backend(backend : IKvsBackend) : KvsBuilder&
23+
+ Build() : ptr<Kvs>
24+
}
25+
26+
interface IKvsBackend <<interface>> {
27+
+ LoadKvs(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<KvsMap>
28+
+ LoadDefaults(instance_id : InstanceId) : Result<KvsMap>
29+
+ Flush(instance_id : InstanceId, kvs : KvsMap) : ResultBlank
30+
+ SnapshotCount(instance_id : InstanceId) : Result<size_t>
31+
+ SnapshotRestore(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<KvsMap>
32+
+ SnapshotMaxCount() : size_t
33+
}
34+
35+
interface IKvs <<interface>> {
36+
+ Reset() : ResultBlank
37+
+ ResetKey(key : string) : ResultBlank
38+
+ GetAllKeys() : Result<vector<string>>
39+
+ KeyExists(key : string) : Result<bool>
40+
+ GetValue(key : string) : Result<KvsValue>
41+
+ GetDefaultValue(key : string) : Result<KvsValue>
42+
+ IsValueDefault(key : string) : Result<bool>
43+
+ SetValue(key : string, value : KvsValue) : ResultBlank
44+
+ RemoveKey(key : string) : ResultBlank
45+
+ Flush() : ResultBlank
46+
+ SnapshotCount() : Result<size_t>
47+
+ SnapshotMaxCount() : size_t
48+
+ SnapshotRestore(snapshot_id : SnapshotId) : ResultBlank
49+
}
50+
51+
IKvsBackend -[hidden]right- IKvs
52+
MockBackend -[hidden]right- JsonBackend
53+
JsonBackend -[hidden]right- KvsMock
54+
KvsMock -[hidden]right- Kvs
55+
56+
class MockBackend <<mock>> {
57+
+ LoadKvs(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<KvsMap>
58+
+ LoadDefaults(instance_id : InstanceId) : Result<KvsMap>
59+
+ Flush(instance_id : InstanceId, kvs : KvsMap) : ResultBlank
60+
+ SnapshotCount(instance_id : InstanceId) : Result<size_t>
61+
+ SnapshotRestore(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<KvsMap>
62+
+ SnapshotMaxCount() : size_t
63+
}
64+
65+
class JsonBackend <<implementation>> {
66+
- instance_id : InstanceId
67+
- filename_prefix : path
68+
- filesystem : score::filesystem
69+
- parser : ptr<IJsonParser>
70+
- writer : ptr<IJsonWriter>
71+
- directory : string
72+
- max_snapshot_count : size_t
73+
__
74+
+ JsonBackend(instance_id : InstanceId, filename_prefix : path, filesystem : score::filesystem, directory : string, max_snapshot_count : size_t)
75+
+ LoadKvs(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<KvsMap>
76+
+ LoadDefaults(instance_id : InstanceId) : Result<KvsMap>
77+
+ Flush(instance_id : InstanceId, kvs : KvsMap) : ResultBlank
78+
+ SnapshotCount(instance_id : InstanceId) : Result<size_t>
79+
+ SnapshotRestore(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<KvsMap>
80+
+ SnapshotMaxCount() : size_t
81+
+ KvsFileName(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<string>
82+
+ KvsFilePath(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<path>
83+
+ HashFileName(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<string>
84+
+ HashFilePath(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<path>
85+
+ DefaultsFileName(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<string>
86+
+ DefaultsFilePath(instance_id : InstanceId, snapshot_id : SnapshotId) : Result<path>
87+
}
88+
89+
class KvsMock <<mock>> {
90+
+ Reset() : ResultBlank
91+
+ ResetKey(key : string) : ResultBlank
92+
+ GetAllKeys() : Result<vector<string>>
93+
+ KeyExists(key : string) : Result<bool>
94+
+ GetValue(key : string) : Result<KvsValue>
95+
+ GetDefaultValue(key : string) : Result<KvsValue>
96+
+ IsValueDefault(key : string) : Result<bool>
97+
+ SetValue(key : string, value : KvsValue) : ResultBlank
98+
+ RemoveKey(key : string) : ResultBlank
99+
+ Flush() : ResultBlank
100+
+ SnapshotCount() : Result<size_t>
101+
+ SnapshotMaxCount() : size_t
102+
+ SnapshotRestore(snapshot_id : SnapshotId) : ResultBlank
103+
}
104+
105+
class Kvs <<implementation>> {
106+
- kvs : KvsMap
107+
- default_kvs : KvsMap
108+
- logger : ptr<mw::log::Logger>
109+
- backend : IKvsBackend
110+
__
111+
+ Reset() : ResultBlank
112+
+ ResetKey(key : string) : ResultBlank
113+
+ GetAllKeys() : Result<vector<string>>
114+
+ KeyExists(key : string) : Result<bool>
115+
+ GetValue(key : string) : Result<KvsValue>
116+
+ GetDefaultValue(key : string) : Result<KvsValue>
117+
+ IsValueDefault(key : string) : Result<bool>
118+
+ SetValue(key : string, value : KvsValue) : ResultBlank
119+
+ RemoveKey(key : string) : ResultBlank
120+
+ Flush() : ResultBlank
121+
+ SnapshotCount() : Result<size_t>
122+
+ SnapshotMaxCount() : size_t
123+
+ SnapshotRestore(snapshot_id : SnapshotId) : ResultBlank
124+
}
125+
126+
' Relationships
127+
MockBackend -up-|> IKvsBackend : implements
128+
JsonBackend -up-|> IKvsBackend : implements
129+
KvsMock -up-|> IKvs : implements
130+
Kvs -up-|> IKvs : implements
131+
132+
' Dependencies
133+
KvsBuilder ..> IKvsBackend : uses
134+
KvsBuilder ..> IKvs : uses
135+
IKvsBackend *-- IKvs : Composes
136+
137+
@enduml

0 commit comments

Comments
 (0)