diff --git a/docs/class_diagram_cpp.puml b/docs/class_diagram_cpp.puml new file mode 100644 index 00000000..f6a57a2e --- /dev/null +++ b/docs/class_diagram_cpp.puml @@ -0,0 +1,137 @@ +@startuml ScorePersistencyKvsDesign + +skinparam class { + BackgroundColor<> LightYellow + BorderColor<> DarkGoldenRod + BackgroundColor<> LightBlue + BorderColor<> DodgerBlue + BackgroundColor<> LightPink + BorderColor<> IndianRed +} + +class KvsBuilder <> { + - instance_id : InstanceId + - defaults : optional + - kvs_load : optional + - backend : optional + - {static} kvs_pool : map> + __ + + KvsBuilder(instance_id : InstanceId) + + Defaults(defaults : KvsDefaults) : KvsBuilder& + + KvsLoad(kvs_load : KvsLoad) : KvsBuilder& + + Backend(backend : IKvsBackend) : KvsBuilder& + + Build() : ptr +} + +interface IKvsBackend <> { + + LoadKvs(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + LoadDefaults(instance_id : InstanceId) : Result + + Flush(instance_id : InstanceId, kvs : KvsMap) : ResultBlank + + SnapshotCount(instance_id : InstanceId) : Result + + SnapshotRestore(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + SnapshotMaxCount() : size_t +} + +interface IKvs <> { + + Reset() : ResultBlank + + ResetKey(key : string) : ResultBlank + + GetAllKeys() : Result> + + KeyExists(key : string) : Result + + GetValue(key : string) : Result + + GetDefaultValue(key : string) : Result + + IsValueDefault(key : string) : Result + + SetValue(key : string, value : KvsValue) : ResultBlank + + RemoveKey(key : string) : ResultBlank + + Flush() : ResultBlank + + SnapshotCount() : Result + + SnapshotMaxCount() : size_t + + SnapshotRestore(snapshot_id : SnapshotId) : ResultBlank +} + +IKvsBackend -[hidden]right- IKvs +MockBackend -[hidden]right- JsonBackend +JsonBackend -[hidden]right- KvsMock +KvsMock -[hidden]right- Kvs + +class MockBackend <> { + + LoadKvs(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + LoadDefaults(instance_id : InstanceId) : Result + + Flush(instance_id : InstanceId, kvs : KvsMap) : ResultBlank + + SnapshotCount(instance_id : InstanceId) : Result + + SnapshotRestore(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + SnapshotMaxCount() : size_t +} + +class JsonBackend <> { + - instance_id : InstanceId + - filename_prefix : path + - filesystem : score::filesystem + - parser : ptr + - writer : ptr + - directory : string + - max_snapshot_count : size_t + __ + + JsonBackend(instance_id : InstanceId, filename_prefix : path, filesystem : score::filesystem, directory : string, max_snapshot_count : size_t) + + LoadKvs(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + LoadDefaults(instance_id : InstanceId) : Result + + Flush(instance_id : InstanceId, kvs : KvsMap) : ResultBlank + + SnapshotCount(instance_id : InstanceId) : Result + + SnapshotRestore(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + SnapshotMaxCount() : size_t + + KvsFileName(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + KvsFilePath(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + HashFileName(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + HashFilePath(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + DefaultsFileName(instance_id : InstanceId, snapshot_id : SnapshotId) : Result + + DefaultsFilePath(instance_id : InstanceId, snapshot_id : SnapshotId) : Result +} + +class KvsMock <> { + + Reset() : ResultBlank + + ResetKey(key : string) : ResultBlank + + GetAllKeys() : Result> + + KeyExists(key : string) : Result + + GetValue(key : string) : Result + + GetDefaultValue(key : string) : Result + + IsValueDefault(key : string) : Result + + SetValue(key : string, value : KvsValue) : ResultBlank + + RemoveKey(key : string) : ResultBlank + + Flush() : ResultBlank + + SnapshotCount() : Result + + SnapshotMaxCount() : size_t + + SnapshotRestore(snapshot_id : SnapshotId) : ResultBlank +} + +class Kvs <> { + - kvs : KvsMap + - default_kvs : KvsMap + - logger : ptr + - backend : IKvsBackend + __ + + Reset() : ResultBlank + + ResetKey(key : string) : ResultBlank + + GetAllKeys() : Result> + + KeyExists(key : string) : Result + + GetValue(key : string) : Result + + GetDefaultValue(key : string) : Result + + IsValueDefault(key : string) : Result + + SetValue(key : string, value : KvsValue) : ResultBlank + + RemoveKey(key : string) : ResultBlank + + Flush() : ResultBlank + + SnapshotCount() : Result + + SnapshotMaxCount() : size_t + + SnapshotRestore(snapshot_id : SnapshotId) : ResultBlank +} + +' Relationships +MockBackend -up-|> IKvsBackend : implements +JsonBackend -up-|> IKvsBackend : implements +KvsMock -up-|> IKvs : implements +Kvs -up-|> IKvs : implements + +' Dependencies +KvsBuilder ..> IKvsBackend : uses +KvsBuilder ..> IKvs : uses +IKvsBackend *-- IKvs : Composes + +@enduml