#include <Simulation.hpp>
Public Types | |
enum class | UserLevel : int { Basic , Regular , Expert } |
Public Member Functions | |
FilePaths * | filePaths () const |
Log * | log () const |
ParallelFactory * | parallelFactory () const |
Random * | random () const |
void | setupAndRun () |
Units * | units () const |
UserLevel | userLevel () const |
![]() | |
template<class T > | |
T * | find (bool setup=true) const |
template<class T > | |
T * | interface (int levels=-999999, bool setup=true) const |
virtual string | itemName () const |
void | setup () |
string | typeAndName () const |
![]() | |
Item (const Item &)=delete | |
virtual | ~Item () |
void | addChild (Item *child) |
const vector< Item * > & | children () const |
virtual void | clearItemListProperty (const PropertyDef *property) |
void | destroyChild (Item *child) |
virtual bool | getBoolProperty (const PropertyDef *property) const |
virtual vector< double > | getDoubleListProperty (const PropertyDef *property) const |
virtual double | getDoubleProperty (const PropertyDef *property) const |
virtual string | getEnumProperty (const PropertyDef *property) const |
virtual int | getIntProperty (const PropertyDef *property) const |
virtual vector< Item * > | getItemListProperty (const PropertyDef *property) const |
virtual Item * | getItemProperty (const PropertyDef *property) const |
virtual string | getStringProperty (const PropertyDef *property) const |
int | getUtilityProperty (string name) const |
virtual void | insertIntoItemListProperty (const PropertyDef *property, int index, Item *item) |
Item & | operator= (const Item &)=delete |
Item * | parent () const |
virtual void | removeFromItemListProperty (const PropertyDef *property, int index) |
virtual void | setBoolProperty (const PropertyDef *property, bool value) |
virtual void | setDoubleListProperty (const PropertyDef *property, vector< double > value) |
virtual void | setDoubleProperty (const PropertyDef *property, double value) |
virtual void | setEnumProperty (const PropertyDef *property, string value) |
virtual void | setIntProperty (const PropertyDef *property, int value) |
virtual void | setItemProperty (const PropertyDef *property, Item *item) |
virtual void | setStringProperty (const PropertyDef *property, string value) |
void | setUtilityProperty (string name, int value) |
virtual string | type () const |
Protected Member Functions | |
Simulation () | |
virtual void | runSimulation ()=0 |
virtual void | setupSimulation ()=0 |
![]() | |
SimulationItem () | |
virtual bool | offersInterface (const std::type_info &interfaceTypeInfo) const |
virtual void | setupSelfAfter () |
virtual void | setupSelfBefore () |
![]() | |
Item () | |
Private Types | |
using | BaseType = SimulationItem |
using | ItemType = Simulation |
Private Attributes | |
ParallelFactory * | _factory |
Log * | _log |
FilePaths * | _paths |
Random * | _random |
Units * | _units |
UserLevel | _userLevel |
Friends | |
class | ItemRegistry |
Simulation is the abstract base class for a simulation item that represents a complete simulation and sits at the top of a run-time simulation hierarchy (i.e. it has no parent). A Simulation instance holds a number of essential simulation-wide property instances. Some of these (a random number generator and a system of units) are discoverable and hence fully user-configurable. The other properties (a file paths object, a logging mechanism, and a parallel factory) are not discoverable. When a Simulation instance is constructed, a default instance is created for each of these properties. A reference to these property instances can be retrieved through the corresponding getter, and in some cases, the property can be further configured under program control (e.g., to set the input and output file paths for the simulation).
Specifically, when a Simulation instance is constructed, the log property is set to an instance of the ConsoleLog class; the filePaths property is set to an instance of the FilePaths class with default paths and no filename prefix; and the parallelFactory property is set to an instance of the ParallelFactory class with the default maximum number of parallel threads.
|
strong |
The enumeration type indicating the user experience level:
Level 1: Basic
Basic : "Basic: for beginning users (hides many options)" .
Regular : "Regular: for regular users (hides esoteric options)" .
Expert : "Expert: for expert users (hides no options)" .
|
inlineprotected |
Default constructor for abstract Item subclass Simulation : "the simulation" .
FilePaths * Simulation::filePaths | ( | ) | const |
Returns the input/output file paths object for this simulation hierarchy.
Log * Simulation::log | ( | ) | const |
Returns the logging mechanism for this simulation hierarchy.
ParallelFactory * Simulation::parallelFactory | ( | ) | const |
Returns the logging mechanism for this simulation hierarchy.
|
inline |
This function returns the value of the discoverable item property random : "the random number generator" .
The default value for this property is given by the conditional value expression "Random" .
This property is displayed only if the Boolean expression "Level3" evaluates to true after replacing the names by true or false depending on their presence.
|
protectedpure virtual |
This function actually runs the simulation, assuming that setup has been already performed. Its implementation must be provided by a subclass.
Implemented in MonteCarloSimulation.
void Simulation::setupAndRun | ( | ) |
This function performs setup for the complete simulation hierarchy by invoking the setup() function defined in the SimulationItem base class, and then runs the simulation by invoking the run() function which must be defined in a subclass. The complete operation is surrounded by start/finish log messages.
It is highly recommended for the creator/manager of a simulation hierarchy to immediately call setupAndRun() on the Simulation instance rather than first calling the setup() function.
|
protectedpure virtual |
This function actually performs setup for the complete simulation hierarchy. Its implementation must be provided by a subclass.
Implemented in MonteCarloSimulation.
|
inline |
This function returns the value of the discoverable item property units : "the units system" .
The default value for this property is given by the conditional value expression "ExtragalacticUnits" .
|
inline |
This function returns the value of the discoverable UserLevel enumeration property userLevel : "the user experience level" .
The default value for this property is given by the conditional value expression "Regular" .
When a value is entered for this property, the names provided by the conditional value expression "userLevelBasic:Level1;userLevelRegular:Level1,Level2;userLevelExpert:Level1,Level2,Level3" are inserted into the name sets used for evaluating Boolean expressions.