dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
Sink.hpp
1// SPDX-FileCopyrightText: 2025 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Standard includes
12#include <cstdint>
13#include <memory>
14#include <vector>
15
16// Project includes
17#include <dfx-fdwatch/Poller.hpp>
19
20namespace dfx::Pcapng
21{
59class Sink
60{
61public:
66 Sink() noexcept = default;
67
70
72 virtual ~Sink() = default;
73
87 virtual void init(std::vector<uint8_t> initialHeader) = 0;
88
95 void setPoller(FdWatch::Poller * poller) { _poller = poller; }
96
111 virtual void write(std::vector<uint8_t> data) = 0;
112
113protected:
119};
120
122using SinkPtr = std::unique_ptr<Sink>;
123} // !namespace dfx::Pcapng
Convenience macros to explicitly control copy and move semantics.
Abstract interface for FD-based event polling.
Definition Poller.hpp:37
Sink() noexcept=default
Construct a sink.
virtual void init(std::vector< uint8_t > initialHeader)=0
Initialize the sink and write the initial PCAPNG header.
FdWatch::Poller * _poller
Borrowed poller pointer for event-driven sink implementations.
Definition Sink.hpp:118
void setPoller(FdWatch::Poller *poller)
Provide a poller that the sink may use for event-driven I/O.
Definition Sink.hpp:95
DISABLE_COPY_AND_MOVE(Sink)
Sinks are not copyable and not movable.
virtual void write(std::vector< uint8_t > data)=0
Write serialized PCAPNG bytes to the sink.
Definition SocketClient.hpp:23
Definition Capture.hpp:27
std::unique_ptr< Sink > SinkPtr
Owning pointer type for sinks.
Definition Sink.hpp:122
STL namespace.