-2
void myAPP::initialize(int stage) {
    ....
}

I am trying to understand what calls? I have done the tictoc tutorial but the initialize method in there does not have int stage as a parameter. Can someone shine some light?

LionsFan
  • 159
  • 10

1 Answers1

2

Multi-stage initialization (i.e. initialize with stage parameter) is used by the simulation environment if a module contains redefined numInitStages() method.

Example 1:
No redefinition numInitStages() in the class.
The simulation environment calls method:

  • initialize()

Example 2:
The class contains:

int numInitStages() const { return 3; }
void initialize(int stage);

The simulation environment calls methods:

  • initialize(0)

  • initialize(1)

  • initialize(2)

TicToc examples don't have numInitStages() so initialize() without parameters is called.

Jerzy D.
  • 5,417
  • 2
  • 12
  • 16
  • Thank you for your reply. and in the latter case, where's initialize(0) --(2) is invoked? – LionsFan Sep 23 '17 at 21:36
  • In the second example a class contains `initialize(int stage)` method. During preparing of a network the simulation environment will call `initialize(0)`, then `initialize (1)` and so on. Of course inside `initialize (int stage)` the current stage should be recognized. – Jerzy D. Sep 23 '17 at 22:44
  • Multi-stage initialization is used to resolve any dependencies between modules. You can initialize parts of a module in different stages to make sure parts of other modules which the current part in your module depends on are already created/initiliazed. – Julian Heinovski Sep 25 '17 at 08:25