Let's start with Example 1. This simple example allows outputting a table that looks like this:
| Results_Example1 | Iteration 1 | Iteration 2 | Iteration 3 |
|---|---|---|---|
| Nb de Fissions | 36 | 0 | 85 |
| Nb de Collisions | 29 | 84 | 21 |
We have two rows and three columns here. The numbers present are generated randomly.
Let's look at the start-init entry point:
SimpleTableOutputExample1Module.cc
In this example, we are in singleton mode. The .axl file for this example therefore does not contain options.
However, the .config configuration file references the singleton.
csv.config <time-loop name="example1">
Let's go back to the .cc file. We only retrieve the pointer to the singleton and initialize it with a table name (Results_Example1) and a subdirectory name (example1) (and we print the empty table).
Let's look at the compute-loop entry point:
SimpleTableOutputExample1Module.cc
Here, we have a simple example of the typical usage imagined initially for this service.
We create a column named Iteration X (meaning a new column for each iteration), then we add the desired values to rows.
Do the rows not exist because they were not created during init? The service takes care of creating them before adding the value.
In this example, the rows will therefore be created during the first iteration, and afterwards, the service will simply fill them.
Exporting values from code, for example during a debugging session, is therefore something that is very simple with this service.
Finally, let's look at the exit entry point:
SimpleTableOutputExample1Module.cc
In this part, we simply request the writing of the CSV file whose location and name were defined during init. If this had not been done, there are the methods ISimpleTableOutput::setOutputDirectory() and ISimpleTableOutput::setTableName() to correct it (otherwise, the service defines default values).