Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 143 additions & 0 deletions docs/Design/class_diagram_cpp.puml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*.puml files itself will never be rendered. You need to reference it in any other .rst file as

.. uml:: class_diagram_cpp.puml


Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
@startuml ScorePersistencyKvsDesign

' Define color schemes matching original design
skinparam class {
BackgroundColor<<interface>> LightYellow
BorderColor<<interface>> DarkGoldenRod
BackgroundColor<<implementation>> LightBlue
BorderColor<<implementation>> DodgerBlue
BackgroundColor<<mock>> LightPink
BorderColor<<mock>> IndianRed
}

class KvsBuilder <<implementation>> {
- instance_id: InstanceId
- need_defaults : KvsDefaults
- need_kvs : KvsLoad
- backend: IStorageBackend
- {static} Kvs_pool : std::unordered_map<instanceId, std::shared_ptr<kvs> >
__
+ KvsBuilder(instance_id:InstanceId)
+ NeedDefaultsFlag(flag:bool) : KvsBuilder&
+ NeedKvsFlag(flag:bool) : KvsBuilder&
+ Backend(backend:IStorageBackend) : KvsBuilder&
+ Build() : std::shared_ptr<Kvs>
}



interface IStorageBackend <<interface>> {
+ LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs
+ LoadDefault(instance_id:InstanceId):IKvs
+ Flush(instance_id:InstanceId, kvs:unordered_map<string,kvs>):ResultBlank
+ SnapshotCount(instance_id:InstanceId):Result<size_t>
+ SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs
+ SnapshotMaxCount():Result<size_t>
}

interface IKvs <<interface>> {
+ Reset():ResultBlank
+ ResetKey(key:string):ResultBlank
+ GetAllKeys():Result<vector<string>>
+ KeyExists(key:string):Result<bool>
+ GetValue(key:string):Result<KvsValue>
+ GetDefaultValue(key:string):Result<KvsValue>
+ IsDefaultValue(key:string):Result<KvsValue>
+ SetValue(key:string, value:KvsValue):ResultBlank
+ RemoveKey(key:string):ResultBlank
+ Flush():ResultBlank
+ SnapshotCount():Result<size_t>
+ SnapshotMaxCount():Result<size_t>
+ SnapshotRestore(snapshot_id:SnapshotId):ResultBlank
+ GetHashFilename(snapshot_id:SnapshotId):Result<filesystem::path>
}


IStorageBackend -[hidden]right- IKvs
IStorageBackend_Mock -[hidden]right- JsonBackend
JsonBackend -[hidden]right- IKvs_mock
IKvs_mock -[hidden]right- Kvs


class IStorageBackend_Mock <<mock>> {
+ LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs
+ LoadDefault(instance_id:InstanceId):IKvs
+ Flush(instance_id:InstanceId, kvs:unordered_map<string,kvs>):ResultBlank
+ SnapshotCount(instance_id:InstanceId):Result<size_t>
+ SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs
+ SnapshotMaxCount():Result<size_t>
}

class JsonBackend <<implementation>> {
- Instance_id: InstanceId
- filename_prefix : score::filesystem::path
- filesystem : score::filesystem
- parser : unique_ptr<IjsonParser> parser
- writer : unique_ptr<IjsonWriter> writer
- directory : string
- max_snapshot_count : size_t
__
+ JsonBackend(instance_id:InstanceId, filename_prefix:score::filesystem::path, filesystem:score::filesystem, directory:string, max_snapshot_count:size_t)
+ LoadKvs(instance_id:InstanceId, snapshot_id:SnapshotId):IKvs
+ LoadDefault(instance_id:InstanceId):IKvs
+ Flush(instance_id:InstanceId, kvs:unordered_map<string,kvs>):ResultBlank
+ SnapshotCount(instance_id:InstanceId):Result<size_t>
+ SnapshotRestore(instance_id:InstanceId, snapshot_id:SnapshotId):Kvs
+ GetHashFilename(snapshot_id:SnapshotId):Result<filesystem::path>
+ Dir(dir_path:string):ResultBlank
+ SnapshotMaxCount():Result<size_t>

}

class IKvs_mock <<mock>> {
+ Reset():ResultBlank
+ ResetKey(key:string):ResultBlank
+ GetAllKeys():Result<vector<string>>
+ KeyExists(key:string):Result<bool>
+ GetValue(key:string):Result<KvsValue>
+ GetDefaultValue(key:string):Result<KvsValue>
+ IsDefaultValue(key:string):Result<bool>
+ SetValue(key:string, value:KvsValue):ResultBlank
+ RemoveKey(key:string):ResultBlank
+ Flush():ResultBlank
+ SnapshotCount():Result<size_t>
+ SnapshotMaxCount():Result<size_t>
+ SnapshotRestore(snapshot_id:SnapshotId):ResultBlank
+ GetHashFilename(snapshot_id:SnapshotId):Result<filesystem::path>
}

class Kvs <<implementation>> {
+ kvs : unordered_map<string, KvsValue>
+ default_kvs : unordered_map<string, KvsValue>
+ logger : unique_ptr<mw::log::logger> logger
+ Storage_backend : IStorageBackend
__
+ Reset():ResultBlank
+ ResetKey(key:string):Result<bool>
+ GetAllKeys():Result<vector<string>>
+ KeyExists(key:string):Result<bool>
+ GetValue(key:string):Result<KvsValue>
+ GetDefaultValue(key:string):Result<KvsValue>
+ IsDefaultValue(key:string):Result<bool>
+ SetValue(key:string, value:KvsValue):ResultBlank
+ RemoveKey(key:string):ResultBlank
+ Flush():ResultBlank
+ SnapshotCount():Result<size_t>
+ SnapshotMaxCount():Result<size_t>
+ SnapshotRestore(snapshot_id:SnapshotId):ResultBlank
+ GetHashFilename(snapshot_id:SnapshotId):Result<filesystem::path>
}

' Relationships
IStorageBackend_Mock -up-|> IStorageBackend : implements
JsonBackend -up-|> IStorageBackend : implements
IKvs_mock -up-|> IKvs : implements
Kvs -up-|> IKvs : implements

' Dependencies
KvsBuilder ..> IStorageBackend : uses
KvsBuilder ..> IKvs : uses
IStorageBackend *-- IKvs : Composes


@enduml
Loading