Quote:Original post by NairouQuote:Original post by stonemetal
Maybe you should split your settings up. after all why does the renderer need the physics settings or ai settings?
Very true, but what is the alternative? Having every class open it's own settings? Depending on how settings are stored, that might mean reprocessing the same file multiple times or maintaining multiple copies of settings in memory.
The details of how settings are kept in persistent storage shouldn't be the concern of the sub systems, that concern should belong to a SettingsParser which accepts a stream and reads in the system settings.
It might work like this:
// Settings are distributed into appropriate classes and// instances of these classes are what get returned by the SettingsParser.class LoggerSettings;class VideoSettings;class PhysicsSettings;// ...// Some higher level system constructorvoid Engine::Engine(){ // Load in settings std::ifstream settingsFile( SETTINGS_PATH ); SettingsParser settings( settingsFile ); // Initialise sub-systems this->logger = new Logger( settings.getLoggerSettings() ); this->renderer = new Renderer( settings.getVideoSettings(), this->logger ); this->physicsController = new PhysicsController( settings.getPhysicsSettings(), this->logger ); // ...}