// Copyright (c) 2012-2020 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Singleton.h" #include "Engine/Core/Collections/Array.h" #include "Engine/Serialization/ISerializable.h" /// /// Base class for all global settings containers for the engine. Helps to apply, store and expose properties to engine/game. /// class FLAXENGINE_API Settings { public: /// /// The settings containers. /// static Array Containers; /// /// Restores the default settings for all the registered containers. /// static void RestoreDefaultAll() { for (int32 i = 0; i < Containers.Count(); i++) Containers[i]->RestoreDefault(); } private: // Disable copy/move Settings(const Settings&) = delete; Settings& operator=(const Settings&) = delete; protected: Settings() { Containers.Add(this); } public: virtual ~Settings() = default; public: typedef ISerializable::DeserializeStream DeserializeStream; /// /// Applies the settings to the target services. /// virtual void Apply() { } /// /// Restores the default settings. /// virtual void RestoreDefault() = 0; /// /// Deserializes the settings container. /// /// The input data stream. /// The deserialization modifier object. Always valid. virtual void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) = 0; }; /// /// Base class for all global settings containers for the engine. Helps to apply, store and expose properties to engine/game. /// template class SettingsBase : public Settings, public Singleton { protected: SettingsBase() { } };