Holds a type-erased reference to an arbitray collector.
A collector is any class that implements
on(NodeID, SimTime, Event)
for all events emitted by a Peer.
This class is used to type-erase the actual collector used by each peer in the simulation. The idea is to compose complicated and typed collectors using the helpers in collectors.h, then only type erase at the higher-most level when adding to the simulation.
The example code below demonstrates the reason for storing the collector as a reference. The collector's lifetime will generally be be longer than the simulation; perhaps several simulations are run for a single collector instance. The collector potentially stores lots of data as well, so the simulation needs to point to the single instance, rather than requiring collectors to manage copying that data efficiently in their design.
SomeFancyCollector collector{"out.file"};
Sim sim(trustgraph, topology, collector);
sim.run(100);
collector.report();
- Note
- If a new event type is added, it needs to be added to the interfaces below.
Definition at line 68 of file CollectorRef.h.