dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
DataMessage.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// Project includes
12#include "Message.hpp"
13
14namespace dfx::Core
15{
41class DataMessage : public Message
42{
43 friend class Message;
44
45public:
48 std::vector<uint8_t> const & data() const noexcept { return _data; }
49
55 std::vector<uint8_t> takeData() noexcept { return std::move(_data); }
56
57public:
59 Kind kind() const override { return Kind::Data; }
60
66 MessagePtr clone() const override;
67
68protected:
73 void cloneFromBase(Message const & base) override;
74
75protected:
76 using Message::Message;
77
83 DataMessage(std::vector<uint8_t> data, MessagePtr const & parent = nullptr);
84
90 DataMessage(std::vector<uint8_t> data, MimeType mimeType, MessagePtr const & parent = nullptr);
91
92private:
93 std::vector<uint8_t> _data;
94};
95} // !namespace dfx::Core
DataMessage(std::vector< uint8_t > data, MessagePtr const &parent=nullptr)
Construct a data message with a payload, optionally inheriting from a parent.
void cloneFromBase(Message const &base) override
Copy base and derived state from base into this instance.
std::vector< uint8_t > const & data() const noexcept
Access the payload buffer.
Definition DataMessage.hpp:48
std::vector< uint8_t > takeData() noexcept
Move the payload buffer out of the message.
Definition DataMessage.hpp:55
Kind kind() const override
This message belongs to the data-plane connectivity domain.
Definition DataMessage.hpp:59
MessagePtr clone() const override
Clone this message (deep copy).
DataMessage(std::vector< uint8_t > data, MimeType mimeType, MessagePtr const &parent=nullptr)
Construct a data message with payload and explicit MIME type.
Message(MessagePtr const &parent=nullptr)
Construct a message, optionally inheriting state from a parent message.
MimeType mimeType() const noexcept
Get the message MIME type. If no explicit MIME type is set, returns dfx::Core::MimeType::OctetStream.
Definition Message.hpp:126
MIME type value object.
Definition MimeType.hpp:44
Definition Channel.hpp:22
std::unique_ptr< Message > MessagePtr
Unique ownership handle for messages.
Definition Message.hpp:27
Kind
Port kind (connection domain).
Definition Kind.hpp:29
@ Data
Data-plane ports.
Definition Kind.hpp:34