CellModules
Scenario Class Reference

Manages the simulation scenario. More...

#include <Scenario.hpp>

Public Member Functions

WorldgetWorld ()
 Gets the world of the scenario. More...
 
void addCell (Cell *c)
 Adds a cell to the world. More...
 
double getDt () const
 Gets the time step of the world. More...
 
void setDt (double dt)
 Sets the time step of the world. More...
 
void setUpdateBehaviorPeriod (int n)
 Sets the update behavior period of the world. More...
 
CellcreateCell (MecaCell::Vec pos, Type t)
 Creates a cell at a specific position and type, adds it to the world, and initializes it. More...
 
CellcreateCell (MecaCell::Vec pos)
 Creates a cell at a specific position, adds it to the world, and initializes it. More...
 
CellcreateCell (Type t)
 Creates a cell of a specific type, adds it to the world, and initializes it. More...
 
CellcreateCell ()
 Creates a cell. More...
 
void init (nlohmann::json config)
 Initializes the scenario with a configuration. More...
 
void loop ()
 Runs the main loop of the scenario. More...
 
bool stop ()
 Checks if the scenario should stop. More...
 

Public Attributes

double dt = 360.
 
int maxStep = 999999
 

Private Attributes

World world
 
Model m
 

Detailed Description

Manages the simulation scenario.

Definition at line 24 of file Scenario.hpp.

Member Function Documentation

◆ addCell()

void Scenario::addCell ( Cell c)
inline

Adds a cell to the world.

Parameters
cPointer to the cell to add.

Definition at line 60 of file Scenario.hpp.

◆ createCell() [1/4]

Cell * Scenario::createCell ( )
inline

Creates a cell.

Returns
Pointer to the newly created cell.

Creates a new Cell, adds it to the world, and initializes it.

This function dynamically allocates a new Cell object, adds it to the world, and then calls the init() method on the newly created Cell.

Returns
A pointer to the newly created and initialized Cell.

Definition at line 147 of file Scenario.hpp.

◆ createCell() [2/4]

Cell * Scenario::createCell ( MecaCell::Vec  pos)
inline

Creates a cell at a specific position, adds it to the world, and initializes it.

This function dynamically allocates a new Cell object, adds it to the world, and then calls the init() method on the newly created Cell.

Parameters
posThe position vector.
Returns
A pointer to the newly created and initialized Cell.

Definition at line 110 of file Scenario.hpp.

◆ createCell() [3/4]

Cell * Scenario::createCell ( MecaCell::Vec  pos,
Type  t 
)
inline

Creates a cell at a specific position and type, adds it to the world, and initializes it.

This function dynamically allocates a new Cell object, adds it to the world, and then calls the init() method on the newly created Cell.

Parameters
posThe position vector.
tThe type of the cell.
Returns
A pointer to the newly created and initialized Cell.

Definition at line 93 of file Scenario.hpp.

◆ createCell() [4/4]

Cell * Scenario::createCell ( Type  t)
inline

Creates a cell of a specific type, adds it to the world, and initializes it.

This function dynamically allocates a new Cell object, adds it to the world, and then calls the init() method on the newly created Cell.

Parameters
tThe type of the cell.
Returns
A pointer to the newly created and initialized Cell.

Definition at line 126 of file Scenario.hpp.

◆ getDt()

double Scenario::getDt ( ) const
inline

Gets the time step of the world.

Returns
The time step.

Definition at line 67 of file Scenario.hpp.

◆ getWorld()

World & Scenario::getWorld ( )
inline

Gets the world of the scenario.

Returns
Reference to the world.

Definition at line 51 of file Scenario.hpp.

◆ init()

void Scenario::init ( nlohmann::json  config)
inline

Initializes the scenario with a configuration.

Parameters
configThe configuration in JSON format.

Definition at line 159 of file Scenario.hpp.

◆ loop()

void Scenario::loop ( )
inline

Runs the main loop of the scenario.

Definition at line 173 of file Scenario.hpp.

◆ setDt()

void Scenario::setDt ( double  dt)
inline

Sets the time step of the world.

Parameters
dtThe time step to set.

Definition at line 74 of file Scenario.hpp.

◆ setUpdateBehaviorPeriod()

void Scenario::setUpdateBehaviorPeriod ( int  n)
inline

Sets the update behavior period of the world.

Parameters
nThe update behavior period.

Definition at line 81 of file Scenario.hpp.

◆ stop()

bool Scenario::stop ( )
inline

Checks if the scenario should stop.

Returns
True if the scenario should stop, false otherwise.

Definition at line 185 of file Scenario.hpp.

Member Data Documentation

◆ dt

double Scenario::dt = 360.

Definition at line 33 of file Scenario.hpp.

◆ m

Model Scenario::m
private

Definition at line 28 of file Scenario.hpp.

◆ maxStep

int Scenario::maxStep = 999999

Definition at line 34 of file Scenario.hpp.

◆ world

World Scenario::world
private

Definition at line 27 of file Scenario.hpp.


The documentation for this class was generated from the following file: