// Copyright (c) 2012-2021 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 c#.
///
class SettingsBase
{
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
SettingsBase(const SettingsBase&) = delete;
SettingsBase& operator=(const SettingsBase&) = delete;
protected:
SettingsBase()
{
Containers.Add(this);
}
public:
virtual ~SettingsBase() = 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 c#.
///
template
class Settings : public SettingsBase, public Singleton
{
protected:
Settings()
{
}
};