Program Listing for File network.h

Return to documentation for file (include/cpphots/network.h)

#ifndef CPPHOTS_NETWORK_H
#define CPPHOTS_NETWORK_H

#include <cstdint>
#include <vector>
#include <string>
#include <ostream>
#include <istream>
#include <functional>

#include "types.h"
#include "layer.h"
#include "interfaces/streamable.h"


namespace cpphots {

class Network : public interfaces::Streamable {

public:

    Network();

    void createLayer(interfaces::TimeSurfacePoolCalculator* tspool = nullptr,
                   interfaces::Clusterer* clusterer = nullptr,
                   interfaces::EventRemapper* remapper = nullptr,
                   interfaces::SuperCell* supercell = nullptr);

    void addLayer(const Layer& layer);

    event process(uint64_t t, uint16_t x, uint16_t y, uint16_t p, bool skip_check = false);

    event process(const event& ev, bool skip_check = false);

    size_t getNumLayers() const;

    Layer& getLayer(size_t pos);

    const Layer& getLayer(size_t pos) const;

    Layer& operator[](size_t pos);

    const Layer& operator[](size_t pos) const;

    Layer& back();

    const Layer& back() const;

    Network getSubnetwork(int start, int stop = 0) const;

    void reset();

    void toStream(std::ostream& out) const override;

    void fromStream(std::istream& in) override;

    using iterator = std::vector<Layer>::iterator;

    using const_iterator = std::vector<Layer>::const_iterator;

    iterator begin() noexcept;

    const_iterator begin() const noexcept;

    const_iterator cbegin() const noexcept;

    iterator end() noexcept;

    const_iterator end() const noexcept;

    const_iterator cend() const noexcept;

private:
    std::vector<Layer> layers;

};

Network operator+(const Network& n1, const Network& n2);

}

#endif