Class Network
Defined in File network.h
Inheritance Relationships
Base Type
public cpphots::interfaces::Streamable(Class Streamable)
Class Documentation
-
class cpphots::Network : public cpphots::interfaces::Streamable
A multi-layered HOTS network.
This class can process events through a sequence of layers.
A Network owns no layers, only references to them.
Public Types
Public Functions
-
Network()
Construct a new Network object.
The network has no layers and they must be added via the Network::addLayer method.
-
void createLayer(interfaces::TimeSurfacePoolCalculator *tspool = nullptr, interfaces::Clusterer *clusterer = nullptr, interfaces::EventRemapper *remapper = nullptr, interfaces::SuperCell *supercell = nullptr)
Create a new layer and append it to the network.
Creates a new Layer with the specified components.
- Parameters
tspool – time surface pool calculator
clusterer – clusterer
remapper – event remapper
supercell – supercell modifier
-
void addLayer(const Layer &layer)
Append a layer to the network.
- Parameters
layer – the layer to be added
-
event process(uint64_t t, uint16_t x, uint16_t y, uint16_t p, bool skip_check = false)
Process an event.
Process the event through all the layers of the network, emitting the event resulting from the last layer. If the input event produces a non valid surface in any layer, the output event is invalid.
- Parameters
t – time of the event
x – horizontal coordinate of the event
y – vertical coordinate of the event
p – polarity of the event
skip_check – if true consider the event as valid
- Returns
the new emitted events, possibly empty
-
event process(const event &ev, bool skip_check = false)
Process an event.
Process the event through all the layers of the network, emitting events from the last layer. If the input event produces a non valid surface in any layer, the output event is invalid
- Parameters
ev – the event
skip_check – if true consider the event as valid
- Returns
the new emitted events, possibly empty
-
size_t getNumLayers() const
Get the number of layers in the network.
- Returns
the number of layers in the network
-
Layer &getLayer(size_t pos)
Access a layer.
- Parameters
pos – index of the layer to access
- Returns
reference to the layer
-
const Layer &getLayer(size_t pos) const
Access a layer.
- Parameters
pos – index of the layer to access
- Returns
reference to the layer
-
Layer &operator[](size_t pos)
Access a layer.
- Parameters
pos – index of the layer to access
- Returns
reference to the layer
-
const Layer &operator[](size_t pos) const
Access a layer.
- Parameters
pos – index of the layer to access
- Returns
reference to the layer
-
Network getSubnetwork(int start, int stop = 0) const
Create a subnetwork of the current Network.
Returns a new network that shares layers [start:end) with this network. Indexes can be negative (python-like) and end=0 means up to the end.
- Parameters
start – start of interval
stop – end of interval (not included)
- Returns
the subnetwork
-
void reset()
Reset the network.
Call reset on every layer.
-
virtual void toStream(std::ostream &out) const override
Insert to stream.
Save all layers to the stream.
- Parameters
out – stream where to insert to
-
virtual void fromStream(std::istream &in) override
Extract from stream.
Parameters/current state is expected to be overwritten or invalidated.
Load all layers to the stream.
- Parameters
in – stream where to extract from
-
const_iterator begin() const noexcept
Returns an iterator to the first layer.
- Returns
iterator
-
const_iterator cbegin() const noexcept
Returns an iterator to the first layer.
- Returns
iterator
-
iterator end() noexcept
Returns an iterator to the layer following the last layer.
- Returns
iterator
-
const_iterator end() const noexcept
Returns an iterator to the layer following the last layer.
- Returns
iterator
-
const_iterator cend() const noexcept
Returns an iterator to the layer following the last layer.
- Returns
iterator
-
Network()