Empirical
Classes | Namespaces
config.h File Reference

Maintains a set of configuration options. More...

#include <map>
#include <ostream>
#include <fstream>
#include <functional>
#include <string>
#include <sstream>
#include <unordered_set>
#include "../base/errors.h"
#include "../base/vector.h"
#include "../tools/functions.h"
#include "../tools/string_utils.h"
#include "ConfigManager.h"

Go to the source code of this file.

Classes

class  emp::ConfigEntry
 Base class for all configuration settings. More...
 
class  emp::Config
 Master configuration class that manages all of the settings. More...
 
class  emp::Config::tConfigEntry< VAR_TYPE >
 Type-specific versions of ConfigEntry class to manage settings. More...
 
class  emp::Config::tConfigConstEntry< VAR_TYPE >
 Type-specific and CONST versions of ConfigEntry class to manage fixed settings. More...
 
class  emp::Config::ConfigLiveEntry
 Special settings entry for settings created during the run (only accissibly dynamically) More...
 
class  emp::Config::ConfigGroup
 Information about a sub-group of settings. More...
 

Namespaces

 emp
 If we are in emscripten, make sure to include the header.
 

Detailed Description

Maintains a set of configuration options.

Note
This file is part of Empirical, https://github.com/devosoft/Empirical
Date
2016-2018

This file defines a master configuration option Config, whose values can be loaded at runtime or else set as constant values throughout the code.

Assuming you have an emp::Config object called config, you can:

access a setting value: config.SETTING_NAME() adjust a setting value: config.SETTING_NAME(new_value) determine if a setting is locked: config.SETTING_NAME_is_const() lookup a setting dynamically: config("SETTING_NAME") adjust a setting dynamically: config("SETTING_NAME", "new_value")

load settings from a stream: config.Read(stream); load settings from a file: config.Read(filename); save settings to a stream: config.Write(stream); save settings to a file: config.Write(filename);

write settings macros to a stream: config.WriteMacros(stream); write settings macros to a file: config.WriteMacros(filename);

The configuration files generated can use the following keywords in order to configure this object: include OTHER_FILENAME – Load in all data from another file. set SETTING_NAME VALUE – Set a basic configuration setting. new OBJECT_TYPE OBJECT_NAME – Create a new config object of a managed class. use OBJECT_TYPE OBJECT_NAME – Use a previouly create configuration object.