Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::SettingsRegistryImpl Class Referencefinal

Inherits AZ::SettingsRegistryInterface.

Public Member Functions

 AZ_CLASS_ALLOCATOR (SettingsRegistryImpl, AZ::OSAllocator)
 
 AZ_RTTI (AZ::SettingsRegistryImpl, "{E9C34190-F888-48CA-83C9-9F24B4E21D72}", AZ::SettingsRegistryInterface)
 
 SettingsRegistryImpl (bool useFileIo)
 
 AZ_DISABLE_COPY_MOVE (SettingsRegistryImpl)
 
void SetContext (SerializeContext *context)
 
void SetContext (JsonRegistrationContext *context)
 
SettingsType GetType (AZStd::string_view path) const override
 Returns the type of an entry in the Settings Registry or Type::None if there's no value or the path is invalid.
 
bool Visit (Visitor &visitor, AZStd::string_view path) const override
 
bool Visit (const VisitorCallback &callback, AZStd::string_view path) const override
 
NotifyEventHandler RegisterNotifier (NotifyCallback callback) override
 
void RegisterNotifier (NotifyEventHandler &hanlder) override
 
void ClearNotifiers ()
 
PreMergeEventHandler RegisterPreMergeEvent (PreMergeEventCallback callback) override
 
void RegisterPreMergeEvent (PreMergeEventHandler &handler) override
 
PostMergeEventHandler RegisterPostMergeEvent (PostMergeEventCallback callback) override
 
void RegisterPostMergeEvent (PostMergeEventHandler &handler) override
 
void ClearMergeEvents ()
 
bool Get (bool &result, AZStd::string_view path) const override
 
bool Get (s64 &result, AZStd::string_view path) const override
 
bool Get (u64 &result, AZStd::string_view path) const override
 
bool Get (double &result, AZStd::string_view path) const override
 
bool Get (AZStd::string &result, AZStd::string_view path) const override
 
bool Get (SettingsRegistryInterface::FixedValueString &result, AZStd::string_view path) const override
 
bool GetObject (void *result, AZ::Uuid resultTypeID, AZStd::string_view path) const override
 
bool Set (AZStd::string_view path, bool value) override
 
bool Set (AZStd::string_view path, s64 value) override
 
bool Set (AZStd::string_view path, u64 value) override
 
bool Set (AZStd::string_view path, double value) override
 
bool Set (AZStd::string_view path, AZStd::string_view value) override
 
bool Set (AZStd::string_view path, const char *value) override
 
bool SetObject (AZStd::string_view path, const void *value, AZ::Uuid valueTypeID) override
 
bool Remove (AZStd::string_view path) override
 
bool MergeCommandLineArgument (AZStd::string_view argument, AZStd::string_view anchorKey, const CommandLineArgumentSettings &commandLineSettings) override
 
MergeSettingsResult MergeSettings (AZStd::string_view data, Format format, AZStd::string_view anchorKey="") override
 
MergeSettingsResult MergeSettingsFile (AZStd::string_view path, Format format, AZStd::string_view anchorKey="", AZStd::vector< char > *scratchBuffer=nullptr) override
 
MergeSettingsResult MergeSettingsFolder (AZStd::string_view path, const Specializations &specializations, AZStd::string_view platform, AZStd::string_view anchorKey="", AZStd::vector< char > *scratchBuffer=nullptr) override
 
void SetNotifyForMergeOperations (bool notify) override
 
bool GetNotifyForMergeOperations () const override
 
void SetUseFileIO (bool useFileIo) override
 
- Public Member Functions inherited from AZ::SettingsRegistryInterface
 AZ_RTTI (AZ::SettingsRegistryInterface, "{D62619D8-0C0B-4D9F-9FE8-F8EBC330DC55}")
 
 AZ_DISABLE_COPY_MOVE (SettingsRegistryInterface)
 
virtual SettingsType GetType (AZStd::string_view path) const =0
 Returns the type of an entry in the Settings Registry or Type::None if there's no value or the path is invalid.
 
virtual bool Visit (Visitor &visitor, AZStd::string_view path) const =0
 
virtual bool Visit (const VisitorCallback &callback, AZStd::string_view path) const =0
 
virtual NotifyEventHandler RegisterNotifier (NotifyCallback callback)=0
 
virtual void RegisterNotifier (NotifyEventHandler &handler)=0
 
virtual PreMergeEventHandler RegisterPreMergeEvent (PreMergeEventCallback callback)=0
 
virtual void RegisterPreMergeEvent (PreMergeEventHandler &handler)=0
 
virtual PostMergeEventHandler RegisterPostMergeEvent (PostMergeEventCallback callback)=0
 
virtual void RegisterPostMergeEvent (PostMergeEventHandler &handler)=0
 
virtual bool Get (bool &result, AZStd::string_view path) const =0
 
virtual bool Get (s64 &result, AZStd::string_view path) const =0
 
virtual bool Get (u64 &result, AZStd::string_view path) const =0
 
virtual bool Get (double &result, AZStd::string_view path) const =0
 
virtual bool Get (AZStd::string &result, AZStd::string_view path) const =0
 
virtual bool Get (FixedValueString &result, AZStd::string_view path) const =0
 
virtual bool GetObject (void *result, AZ::Uuid resultTypeId, AZStd::string_view path) const =0
 
template<typename T >
bool GetObject (T &result, AZStd::string_view path) const
 
virtual bool Set (AZStd::string_view path, bool value)=0
 
virtual bool Set (AZStd::string_view path, s64 value)=0
 
virtual bool Set (AZStd::string_view path, u64 value)=0
 
virtual bool Set (AZStd::string_view path, double value)=0
 
virtual bool Set (AZStd::string_view path, AZStd::string_view value)=0
 
virtual bool Set (AZStd::string_view path, const char *value)=0
 
virtual bool SetObject (AZStd::string_view path, const void *value, AZ::Uuid valueTypeId)=0
 
template<typename T >
bool SetObject (AZStd::string_view path, const T &value)
 
virtual bool Remove (AZStd::string_view path)=0
 
virtual bool MergeCommandLineArgument (AZStd::string_view argument, AZStd::string_view anchorKey="", const CommandLineArgumentSettings &commandLineSettings={})=0
 
virtual MergeSettingsResult MergeSettings (AZStd::string_view data, Format format, AZStd::string_view anchorKey="")=0
 
virtual MergeSettingsResult MergeSettingsFile (AZStd::string_view path, Format format, AZStd::string_view anchorKey="", AZStd::vector< char > *scratchBuffer=nullptr)=0
 
virtual MergeSettingsResult MergeSettingsFolder (AZStd::string_view path, const Specializations &specializations, AZStd::string_view platform={}, AZStd::string_view anchorKey="", AZStd::vector< char > *scratchBuffer=nullptr)=0
 
virtual void SetNotifyForMergeOperations (bool notify)=0
 
virtual bool GetNotifyForMergeOperations () const =0
 
virtual void SetUseFileIO (bool useFileIo)=0
 

Static Public Attributes

static constexpr size_t MaxRegistryFolderEntries = 128
 
- Static Public Attributes inherited from AZ::SettingsRegistryInterface
static constexpr char Extension [] = "setreg"
 
static constexpr char PatchExtension [] = "setregpatch"
 
static constexpr char RegistryFolder [] = "Registry"
 
static constexpr char DevUserRegistryFolder [] = "user" AZ_CORRECT_FILESYSTEM_SEPARATOR_STRING "Registry"
 
static constexpr char PlatformFolder [] = "Platform"
 

Additional Inherited Members

- Public Types inherited from AZ::SettingsRegistryInterface
enum class  Type {
  NoType , Null , Boolean , Integer ,
  FloatingPoint , String , Array , Object
}
 Type of the store value, or None if there's no value stored.
 
enum class  Signedness { None , Signed , Unsigned }
 Type of an integer.
 
enum class  VisitResponse { Continue , Skip , Done }
 The response to let the visit call know what to do next. More...
 
enum class  VisitAction { Begin , Value , End }
 The action the visit call is taken. More...
 
enum class  Format { JsonPatch , JsonMergePatch }
 File formats supported to load settings from. More...
 
enum class  MergeSettingsReturnCode { Unset = 0 , Success = 1 , PartialSuccess , Failure = -1 }
 
using FixedValueString = AZ::StringFunc::Path::FixedString
 
using FilenameTags = Specializations
 
using NotifyCallback = AZStd::function< void(const NotifyEventArgs &notifierArgs)>
 
using NotifyEvent = AZ::Event< const NotifyEventArgs & >
 
using NotifyEventHandler = typename NotifyEvent::Handler
 
using PreMergeEventCallback = AZStd::function< void(const MergeEventArgs &)>
 
using PostMergeEventCallback = AZStd::function< void(const MergeEventArgs &)>
 
using PreMergeEvent = AZ::Event< const MergeEventArgs & >
 
using PostMergeEvent = AZ::Event< const MergeEventArgs & >
 
using PreMergeEventHandler = typename PreMergeEvent::Handler
 
using PostMergeEventHandler = typename PostMergeEvent::Handler
 
using VisitorCallback = AZStd::function< VisitResponse(const VisitArgs &, VisitAction action)>
 

Constructor & Destructor Documentation

◆ SettingsRegistryImpl()

AZ::SettingsRegistryImpl::SettingsRegistryImpl ( bool  useFileIo)
explicit
Parameters
useFileIo- If true attempt to redirect file read operations through the FileIOBase instance first before falling back to SystemFile otherwise always use SystemFile

Member Function Documentation

◆ Get() [1/6]

bool AZ::SettingsRegistryImpl::Get ( AZStd::string result,
AZStd::string_view  path 
) const
overridevirtual

Gets the string value at the provided path.

Parameters
resultThe target to write the result to.
pathThe path to the value.
Returns
Whether or not the value was retrieved. An invalid path or type-mismatch will return false;

Implements AZ::SettingsRegistryInterface.

◆ Get() [2/6]

bool AZ::SettingsRegistryImpl::Get ( bool &  result,
AZStd::string_view  path 
) const
overridevirtual

Gets the boolean value at the provided path.

Parameters
resultThe target to write the result to.
pathThe path to the value.
Returns
Whether or not the value was retrieved. An invalid path or type-mismatch will return false;

Implements AZ::SettingsRegistryInterface.

◆ Get() [3/6]

bool AZ::SettingsRegistryImpl::Get ( double &  result,
AZStd::string_view  path 
) const
overridevirtual

Gets the floating point value at the provided path.

Parameters
resultThe target to write the result to.
pathThe path to the value.
Returns
Whether or not the value was retrieved. An invalid path or type-mismatch will return false;

Implements AZ::SettingsRegistryInterface.

◆ Get() [4/6]

bool AZ::SettingsRegistryImpl::Get ( s64 &  result,
AZStd::string_view  path 
) const
overridevirtual

Gets the integer value at the provided path.

Parameters
resultThe target to write the result to.
pathThe path to the value.
Returns
Whether or not the value was retrieved. An invalid path or type-mismatch will return false;

Implements AZ::SettingsRegistryInterface.

◆ Get() [5/6]

bool AZ::SettingsRegistryImpl::Get ( SettingsRegistryInterface::FixedValueString result,
AZStd::string_view  path 
) const
overridevirtual

◆ Get() [6/6]

bool AZ::SettingsRegistryImpl::Get ( u64 &  result,
AZStd::string_view  path 
) const
overridevirtual

◆ GetNotifyForMergeOperations()

bool AZ::SettingsRegistryImpl::GetNotifyForMergeOperations ( ) const
overridevirtual
Returns
returns true if merge operations signals the notification events

Implements AZ::SettingsRegistryInterface.

◆ GetObject()

bool AZ::SettingsRegistryImpl::GetObject ( void *  result,
AZ::Uuid  resultTypeId,
AZStd::string_view  path 
) const
overridevirtual

Gets the object value at the provided path serialized to the target struct/class. Classes retrieved through this call needs to be registered with the Serialize Context. Prefer to use GetObject(T& result, AZStd::string_view path) over this one.

Parameters
resultThe target to write the result to.
resultTypeIdThe type id of the target that's being written to.
pathThe path to the value.
Returns
Whether or not the value was stored. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ GetType()

SettingsType AZ::SettingsRegistryImpl::GetType ( AZStd::string_view  path) const
overridevirtual

Returns the type of an entry in the Settings Registry or Type::None if there's no value or the path is invalid.

Implements AZ::SettingsRegistryInterface.

◆ MergeCommandLineArgument()

bool AZ::SettingsRegistryImpl::MergeCommandLineArgument ( AZStd::string_view  argument,
AZStd::string_view  anchorKey,
const CommandLineArgumentSettings commandLineSettings 
)
overridevirtual

Merges a single command line argument into the settings registry. Command line arguments take the form of <path>=

for instance: "/My/Path=My string value" Values are interpreted as follows:

  • "true" (case sensitive) -> boolean with true value
  • "false" (case sensitive) -> boolean with false value
  • all digits -> number
  • all digits and dot -> floating point number
  • Everything else is considered a string.
    Parameters
    argumentThe command line argument.
    anchorKeyThe key where the merged command line argument will be anchored under
    commandLineSettingsstructure which contains functors which determine what characters are delimiters
    Returns
    True if the command line argument could be parsed, otherwise false.

Implements AZ::SettingsRegistryInterface.

◆ MergeSettings()

MergeSettingsResult AZ::SettingsRegistryImpl::MergeSettings ( AZStd::string_view  data,
Format  format,
AZStd::string_view  anchorKey = "" 
)
overridevirtual

Merges the json data provided into the settings registry.

Parameters
dataThe json data stored in a string.
formatThe format of the provided data.
anchorKeyThe key where the merged json content will be anchored under.
Returns
MergeSettingsResult value that is convertible to bool(true) if the data was successfully merged. If the json string was not merged successfully, the MergeSettingsResult::GetMessages() function contains messages around why the operation has failed.

Implements AZ::SettingsRegistryInterface.

◆ MergeSettingsFile()

MergeSettingsResult AZ::SettingsRegistryImpl::MergeSettingsFile ( AZStd::string_view  path,
Format  format,
AZStd::string_view  anchorKey = "",
AZStd::vector< char > *  scratchBuffer = nullptr 
)
overridevirtual

Loads a settings file and merges it into the registry.

Parameters
pathThe path to the registry file.
formatThe format of the text data in the file at the provided path.
anchorKeyThe key where the content of the settings file will be anchored.
scratchBufferAn optional buffer that's used to load the file into. Use this when loading multiple patches to reduce the number of intermediate memory allocations.
Returns
MergeSettingsResult value that is convertible to bool(true) if the registry file was successfully merged. If the file is is not merged successfully the MergeSettingsResult messages structure will be populated with error messages of why the operation failed

Implements AZ::SettingsRegistryInterface.

◆ MergeSettingsFolder()

MergeSettingsResult AZ::SettingsRegistryImpl::MergeSettingsFolder ( AZStd::string_view  path,
const Specializations specializations,
AZStd::string_view  platform,
AZStd::string_view  anchorKey = "",
AZStd::vector< char > *  scratchBuffer = nullptr 
)
overridevirtual

Loads all settings files in a folder and merges them into the registry. With the specializations "a" and "b" and platform "c" the files would be loaded in the order:

  • file1.setreg
  • Platform/c/file1.setreg
  • file1.a.setreg
  • Platform/c/file.b.setreg
  • file1.a.b.setreg
  • file2.setreg
    Parameters
    pathThe path to the registry folder.
    specializationsThe specializations that will be used filter out registry files.
    platformAn optional name of a platform. Platform overloads are located at <path>/Platform/<platform>/ Files in a platform are applied in the same order as for the main folder but always after the same file in the main folder.
    anchorKeyThe registry path location where the settings will be anchored
    scratchBufferAn optional buffer that's used to load the file into. Use this when loading multiple patches to reduce the number of intermediate memory allocations.
    Returns
    MergeSettingsResult value that is convertible to bool(true) if the registry folder was successfully merged.

Implements AZ::SettingsRegistryInterface.

◆ RegisterNotifier() [1/2]

NotifyEventHandler AZ::SettingsRegistryImpl::RegisterNotifier ( NotifyCallback  callback)
overridevirtual

Register a callback that will be called whenever an entry gets a new/updated value.

@callback The function to call when an entry gets a new/updated value.

Returns
NotifyEventHandler instance which must persist to receive event signal

Implements AZ::SettingsRegistryInterface.

◆ RegisterNotifier() [2/2]

void AZ::SettingsRegistryImpl::RegisterNotifier ( NotifyEventHandler &  handler)
overridevirtual

Register a notify event handler with the NotifyEvent. The handler will be called whenever an entry gets a new/updated value.

Parameters
handlerThe handler to register with the NotifyEvent.

Implements AZ::SettingsRegistryInterface.

◆ RegisterPostMergeEvent() [1/2]

PostMergeEventHandler AZ::SettingsRegistryImpl::RegisterPostMergeEvent ( PostMergeEventCallback  callback)
overridevirtual

Register a function that will be called after a file is merged.

Parameters
callbackThe function to call after a file is merged.
Returns
PostMergeEventHandler instance which must persist to receive event signal

Implements AZ::SettingsRegistryInterface.

◆ RegisterPostMergeEvent() [2/2]

void AZ::SettingsRegistryImpl::RegisterPostMergeEvent ( PostMergeEventHandler &  handler)
overridevirtual

Register a post-merge hahndler with the PostMergeEvent. The handler will be called after a file is merged.

Parameters
handlerThe handler to register with the PostmergeEVent.

Implements AZ::SettingsRegistryInterface.

◆ RegisterPreMergeEvent() [1/2]

PreMergeEventHandler AZ::SettingsRegistryImpl::RegisterPreMergeEvent ( PreMergeEventCallback  callback)
overridevirtual

Register a function that will be called before a file is merged.

Parameters
callbackThe function to call before a file is merged.
Returns
PreMergeEventHandler instance which must persist to receive event signal

Implements AZ::SettingsRegistryInterface.

◆ RegisterPreMergeEvent() [2/2]

void AZ::SettingsRegistryImpl::RegisterPreMergeEvent ( PreMergeEventHandler &  handler)
overridevirtual

Register a pre-merge handler with the PreMergeEvent. The handler will be called before a file is merged.

Parameters
handlerThe hanlder to register with the PreMergeEvent.

Implements AZ::SettingsRegistryInterface.

◆ Remove()

bool AZ::SettingsRegistryImpl::Remove ( AZStd::string_view  path)
overridevirtual

Remove the value at the provided path

Parameters
pathThe path to a value that should be removed
Returns
Whether or not the path was found and removed. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ Set() [1/6]

bool AZ::SettingsRegistryImpl::Set ( AZStd::string_view  path,
AZStd::string_view  value 
)
overridevirtual

Sets or replaces the string value at the provided path.

Parameters
pathThe path to the value.
valueThe new value to store.
Returns
Whether or not the value was stored. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ Set() [2/6]

bool AZ::SettingsRegistryImpl::Set ( AZStd::string_view  path,
bool  value 
)
overridevirtual

Sets or replaces the boolean value at the provided path.

Parameters
pathThe path to the value.
valueThe new value to store.
Returns
Whether or not the value was stored. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ Set() [3/6]

bool AZ::SettingsRegistryImpl::Set ( AZStd::string_view  path,
const char *  value 
)
overridevirtual

Sets or replaces the string value at the provided path. Note that this overload was added as the compiler considers boolean a more closer match than string_view.

Parameters
pathThe path to the value.
valueThe new value to store.
Returns
Whether or not the value was stored. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ Set() [4/6]

bool AZ::SettingsRegistryImpl::Set ( AZStd::string_view  path,
double  value 
)
overridevirtual

Sets or replaces the floating point value at the provided path.

Parameters
pathThe path to the value.
valueThe new value to store.
Returns
Whether or not the value was stored. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ Set() [5/6]

bool AZ::SettingsRegistryImpl::Set ( AZStd::string_view  path,
s64  value 
)
overridevirtual

Sets or replaces the integer value at the provided path.

Parameters
pathThe path to the value.
valueThe new value to store.
Returns
Whether or not the value was stored. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ Set() [6/6]

bool AZ::SettingsRegistryImpl::Set ( AZStd::string_view  path,
u64  value 
)
overridevirtual

◆ SetNotifyForMergeOperations()

void AZ::SettingsRegistryImpl::SetNotifyForMergeOperations ( bool  notify)
overridevirtual

Indicates whether the Merge functions should send notification events for individual operations using JSON Patch or JSON Merge Patch.

Parameters
notifyIf true, the patching operations are forwarded through the NotifyEvent

Implements AZ::SettingsRegistryInterface.

◆ SetObject()

bool AZ::SettingsRegistryImpl::SetObject ( AZStd::string_view  path,
const void *  value,
AZ::Uuid  valueTypeId 
)
overridevirtual

Sets the value at the provided path to the serialized version of the provided struct/class. Classes used for this call need to be registered with the Serialize Context. Prefer to use SetObject(AZStd::string_view path, const T& result) over this one.

Parameters
pathThe path to the value.
valueThe new value to store.
valueTypeIdThe type id of the target that's being stored.
Returns
Whether or not the value was stored. An invalid path will return false;

Implements AZ::SettingsRegistryInterface.

◆ SetUseFileIO()

void AZ::SettingsRegistryImpl::SetUseFileIO ( bool  useFileIo)
overridevirtual

Stores option to indicate whether the FileIOBase instance should be used for file operations

Parameters
useFileIoIf true the FileIOBase instance will attempted to be used for FileIOBase operations before falling back to use SystemFile

Implements AZ::SettingsRegistryInterface.

◆ Visit() [1/2]

bool AZ::SettingsRegistryImpl::Visit ( const VisitorCallback callback,
AZStd::string_view  path 
) const
overridevirtual

Traverses over the entries in the Settings Registry. Use this version if only the names and/or types are needed.

Parameters
callbackA callback function that will repeatedly be called as entries are encountered.
pathAn offset at which traversal should start.
Returns
Whether or not entries could be visited.

Implements AZ::SettingsRegistryInterface.

◆ Visit() [2/2]

bool AZ::SettingsRegistryImpl::Visit ( Visitor visitor,
AZStd::string_view  path 
) const
overridevirtual

Traverses over the entries in the Settings Registry. Use this version to retrieve the values of entries as well.

Parameters
visitorAn instance of a class derived from Visitor that will repeatedly be called as entries are encountered.
pathAn offset at which traversal should start.
Returns
Whether or not entries could be visited.

Implements AZ::SettingsRegistryInterface.


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