Open 3D Engine SaveData Gem API Reference  24.09
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
SaveData::SaveDataRequests Class Referenceabstract

EBus interface used to make queries/requests related to saving/loading persistent user data. More...

#include <SaveDataRequestBus.h>

Inherits AZ::EBusTraits.

Classes

struct  LoadDataBufferParams
 The parameters used to send a load data buffer request. More...
 
struct  SaveDataBufferParams
 The parameters used to send a save data buffer request. More...
 
struct  SaveOrLoadObjectParams
 

Public Types

using OnDataBufferSaved = AZStd::function< void(const SaveDataNotifications::DataBufferSavedParams &)>
 
using OnDataBufferLoaded = AZStd::function< void(const SaveDataNotifications::DataBufferLoadedParams &)>
 

Public Member Functions

virtual void SaveDataBuffer (const SaveDataBufferParams &saveDataBufferParams)=0
 
virtual void LoadDataBuffer (const LoadDataBufferParams &loadDataBufferParams)=0
 
virtual void SetSaveDataDirectoryPath (const char *saveDataDirectoryPath)=0
 

Static Public Member Functions

template<typename SerializableType >
static void SaveObject (const SaveOrLoadObjectParams< SerializableType > &saveObjectParams)
 
template<typename SerializableType >
static void LoadObject (const SaveOrLoadObjectParams< SerializableType > &loadObjectParams)
 

Static Public Attributes

static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single
 
static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single
 
using DataBufferDeleter = void(*)(void *)
 
using DataBuffer = AZStd::unique_ptr< void, DataBufferDeleter >
 
static void DataBufferDeleterNone (void *)
 
static void DataBufferDeleterAzFree (void *ptr)
 

Detailed Description

EBus interface used to make queries/requests related to saving/loading persistent user data.

Member Typedef Documentation

◆ DataBufferDeleter

DataBuffer is an alias for the unique_ptr to void saved using a SaveDataBuffer requst. DataBuffers being saved must have a custom deleter that conforms to DataBufferDeleter.

DataBufferDeleterAzFree means the buffer will be de-allocated using azfree once it goes out of scope, meaning it MUST have been allocated in the first place using azmalloc.

DataBufferDeleterNone means the calling code must delete the data buffer, in which case it is also responsibile for ensuring it remains valid until the save or load completes.

If you need to allocate the buffer through some other mechanism but still want it to be deleted after saved, you can provide a custom deleter conforming to DataBufferDeleter.

◆ OnDataBufferSaved

Alias for verbose callback function type

Member Function Documentation

◆ LoadDataBuffer()

virtual void SaveData::SaveDataRequests::LoadDataBuffer ( const LoadDataBufferParams loadDataBufferParams)
pure virtual

Load a data buffer from persistent storage.

Parameters
[in]loadDataBufferParamsThe load data buffer request parameters.

◆ LoadObject()

template<class SerializableType >
void SaveData::SaveDataRequests::LoadObject ( const SaveOrLoadObjectParams< SerializableType > &  loadObjectParams)
inlinestatic

Load a serializable object from persistent storage.

Template Parameters
SerializableTypeThe type of serializable object to load.
Parameters
[in]loadObjectParamsThe load object request parameters.

◆ SaveDataBuffer()

virtual void SaveData::SaveDataRequests::SaveDataBuffer ( const SaveDataBufferParams saveDataBufferParams)
pure virtual

Save a data buffer to persistent storage.

Parameters
[in]saveDataBufferRequestParamsThe save data buffer request parameters.

◆ SaveObject()

template<class SerializableType >
void SaveData::SaveDataRequests::SaveObject ( const SaveOrLoadObjectParams< SerializableType > &  saveObjectParams)
inlinestatic

Save a serializable object to persistent storage.

Template Parameters
SerializableTypeThe type of serializable object to save.
Parameters
[in]saveObjectParamsThe save object request parameters.

◆ SetSaveDataDirectoryPath()

virtual void SaveData::SaveDataRequests::SetSaveDataDirectoryPath ( const char *  saveDataDirectoryPath)
pure virtual

Set the path to the application's save data dircetory. If the supplied path is absolute, it will be used directy, otherwise if it's relative it will be appended to the location deemed most appropriate by the host OS for storing application specific user save data.

If this is never called, save data will be saved in and loaded from a directory with the same name as the executable, relative to the default location for storing user save data.

One some systems (ie. consoles), the location of save data is fixed and/or inaccessible using the standard file-system, in which case calling this function will have no effect.

But on systems where we are able to override the default save data directory path, care should be taken that it is only done once at startup before any attempt to load or save.

Parameters
[in]saveDataDirectoryPathThe new path to the application's save data dircetory.

Member Data Documentation

◆ HandlerPolicy

const AZ::EBusHandlerPolicy SaveData::SaveDataRequests::HandlerPolicy = AZ::EBusHandlerPolicy::Single
static

EBus Trait: requests can only be sent to and addressed by a single instance (singleton)


The documentation for this class was generated from the following file: