dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
DataMessage.hpp
1// SPDX-FileCopyrightText: 2025-2026 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 friend class details::Unpacker;
45
46public:
49 std::vector<uint8_t> const & data() const noexcept { return _data; }
50
56 std::vector<uint8_t> takeData() noexcept { return std::move(_data); }
57
58public:
60 Kind kind() const override { return Kind::Data; }
61
67 MessagePtr clone() const override;
68
69protected:
74 void cloneFromBase(Message const & base) override;
75
76protected:
78 explicit DataMessage() noexcept = default;
79
81 explicit DataMessage(blank_construct_t) noexcept : Message(blank_construct) {}
82
88 explicit DataMessage(std::vector<uint8_t> data, Message const * parent = nullptr);
89
95 explicit DataMessage(std::vector<uint8_t> data, MimeType mimeType, Message const * parent = nullptr);
96
97private:
98 std::vector<uint8_t> _data;
99};
100} // !namespace dfx::Core
void cloneFromBase(Message const &base) override
Copy base and derived state from base into this instance.
DataMessage() noexcept=default
Default constructor with an empty payload.
std::vector< uint8_t > const & data() const noexcept
Access the payload buffer.
Definition DataMessage.hpp:49
DataMessage(std::vector< uint8_t > data, MimeType mimeType, Message const *parent=nullptr)
Construct a data message with payload and explicit MIME type.
std::vector< uint8_t > takeData() noexcept
Move the payload buffer out of the message.
Definition DataMessage.hpp:56
DataMessage(std::vector< uint8_t > data, Message const *parent=nullptr)
Construct a data message with a payload, optionally inheriting from a parent.
Kind kind() const override
This message belongs to the data-plane connectivity domain.
Definition DataMessage.hpp:60
MessagePtr clone() const override
Clone this message (deep copy).
MimeType mimeType() const noexcept
Get the message MIME type. If no explicit MIME type is set, returns dfx::Core::MimeType::OctetStream.
Definition Message.hpp:138
MIME type value object.
Definition MimeType.hpp:44
Definition Unpacker.hpp:20
Definition Channel.hpp:25
std::unique_ptr< Message > MessagePtr
Unique ownership handle for messages.
Definition Message.hpp:27
constexpr blank_construct_t blank_construct
Tag used in constructor to indicate that the object should be as brut as possible.
Definition Message.hpp:41
Kind
Port kind (connection domain).
Definition Kind.hpp:29
@ Data
Data-plane ports.
Definition Kind.hpp:34
Struct used when you explicitely want an object to be as bare as possible.
Definition Message.hpp:39