Falcon
Loading...
Searching...
No Matches
fileserializer.hpp
1// ---------------------------------------------------------------------
2// This file is part of falcon-core.
3//
4// Copyright (C) 2015, 2016, 2017 Neuro-Electronics Research Flanders
5//
6// Falcon-server is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Falcon-server is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with falcon-core. If not, see <http://www.gnu.org/licenses/>.
18// ---------------------------------------------------------------------
19
20#pragma once
21#include <memory>
22#include <vector>
23
24#include "iprocessor.hpp"
25#include "options/options.hpp"
26#include "serializer.hpp"
27
28class FileSerializer : public IProcessor {
29 // CONSTRUCTOR and OVERLOADED METHODS
30 public:
31 FileSerializer();
32 void CreatePorts() override;
33 void Configure(const GlobalContext& context) override;
34 void Preprocess(ProcessingContext& context) override;
35 void Process(ProcessingContext& context) override;
36 void Postprocess(ProcessingContext& context) override;
37
38 // METHODS
39 protected:
40 /* Add YAML preamble to file (note: there is one file by slot in the input
41 * port)
42 *
43 * @input out file stream to emit the preamble node
44 * @input slot the slot number corresponding to the file
45 */
46 void create_preamble(std::ostream& out, int slot);
47
48 // DATA PORTS
49 protected:
50 PortIn<AnyType>* data_port_;
51
52 // VARIABLES
53 protected:
54 std::unique_ptr<Serialization::Serializer> serializer_;
55 std::vector<std::unique_ptr<std::ostream>> streams_;
56 std::vector<uint64_t> packetid_;
57 std::vector<unsigned int> upstream_buffer_size_;
58 double throttle_level_;
59 std::vector<uint64_t> nskipped_;
60
61 // OPTIONS
62 protected:
63 options::String path_{"run://"};
64 options::Value<Serialization::Encoding, false> encoding_{Serialization::Encoding::BINARY};
65 options::Value<Serialization::Format, false> format_{Serialization::Format::FULL};
66 options::Bool overwrite_{false};
67 options::Bool throttle_{false};
68 options::Double throttle_threshold_{0.3, options::inrange<double>(0., 1.)};
69 options::Double throttle_smooth_{0.5, options::inrange<double>(0., 1.)};
70 options::Bool preamble_{true};
71};
Definition context.hpp:54
Definition streamports.hpp:256
Definition runinfo.hpp:248