Module |
|
Header |
/Engine/Plugins/Developer/Concert/ConcertSync/ConcertSyncCore/Source/ConcertSyncCore/Public/ConcertDataStore.h |
Include |
#include "ConcertDataStore.h" |
class FConcertDataStore
Maintains a type-safe key/value map where the values are USTRUCT() structs serialized into a FConcertDataStore_StoreValue. Each key/value pair has a version, starting at 1 which incremented every times the value change.
The implementation is not thread safe. It is left to the user to synchronize access to the store.How to set up a value in the store.template<typenameT>voidMyClass::Store(constFName&Key,constT&Value){//WrapsTintoitscorrespondingUSTRUCT()ifthisisnotalreadyaUSTRUCT()consttypenameTConcertDataStoreType<T>::StructType&StructWrappedValue=TConcertDataStoreType<T>::AsStructType(Value);//Serializethevalue.FConcertSessionSerializedPayloadSerializedValue;SerializedValue.SetPayload(TConcertDataStoreType<T>::StructType::StaticStruct(),&StructWrappedValue);//Storethevalueatversion1.DataStore.Store(Key,TConcertDataStoreType::GetFName(),SerializedValue);}
How to read a value from the store.template<typenameT>TOptional<T>MyClass::Fetch(constFName&Key){FConcertDataStoreResultResult=DataStore.Fetch(Key,TConcertDataStoreType<T>::GetFName());if(Result.Code==EConcertDataStoreResultCode::Fetched){returnResult.Value->DeserializeUnchecked<T>();}returnTOptional<T>();}
Name | Description | |
---|---|---|
|
FConcertDataStore ( |
Construct the store. |
Name | Description | ||
---|---|---|---|
|
FConcertData... |
Fetch |
Looks up the specified key, if found and types match, fetches the corresponding value. |
|
FConcertData... |
FetchOrAdd ( |
Searches the store for the specified key, if not found, adds a new key/value pair, otherwise, if the stored value type matches the initial value type, fetches the stored value. |
|
GetSize() |
Returns the number of key/value pairs currently stored. |
|
|
GetVersion ( |
Returns the version of the specified key if found. |
|
|
FConcertData... |
Store ( |
Looks up the specified key, if it doesn't exist yet, adds new key/value pair, else, if the stored value type matches the specified value type, updates the value. |
|
Visit ( |
Visits all the key/value currently stored. |
Name |
Description |
|
---|---|---|
|
EUpdatePolicy |
Defines how the store updates an existing value. |