Chi-Tech
doc_EventSystem.h
Go to the documentation of this file.
1/**\defgroup doc_EventSystem I Event System
2
3# ChiTech's event system
4We have some elements in ChiTech that follow the `Publisher/Subscriber` design
5pattern. The basic functionality is captured with the base classes
6`chi::EventPublisher` and `chi::EventSubscriber`, where multiple subscribers are
7assigned to a publisher.
8
9\image html "EventSystem0.drawio.png" width=700px
10
11## Events
12Events are implemented as, a conceptually simple, data class `chi::Event` and
13has the following members:
14- `chi::Event::Name()`
15- `chi::Event::Code()`
16- `chi::Event::Parameters()`
17
18The latter member is a `chi::ParameterBlock` supporting anything from simple
19scalar quantities all the way through to complex hierarchies of data.
20
21## System events
22Systems events are posted via the `chi::SystemWideEventPublisher` singleton
23and serves the purpose of being the central publisher where all events end up,
24although, some publishers can attempt to handle events before this handler.
25Events originating from this publisher are:
26- `"ProgramStart"`
27- `"ProgramExecuted"`
28
29## Physics events
30Physics events are handled via the `chi_physics::PhysicsEventPublisher`
31singleton and has the following basic events (although this list will be
32extended in future):
33- `"SolverPreInitialize"`
34- `"SolverInitialized"`
35- `"SolverPreExecution"`
36- `"SolverExecuted"`
37- `"SolverPreStep"`
38- `"SolverStep"`
39- `"SolverPreAdvance"`
40- `"SolverAdvanced"`
41
42## `PhysicsEventPublisher` interaction with `SystemWideEventPublisher`
43Order of operations and dependencies related to events can be resolved by using
44different publishers. This is because the event publishers always form a
45hierarchy with the `SystemWideEventPublisher` as the base. Any event published
46by a leaf publisher will ultimately get forwarded to the
47`SystemWideEventPublisher`. An example flow of events is shown below:
48
49\image html "EventSystem1.drawio.png" width=700px
50
51
52* */