29#include "ipc/transport/struc/schema/detail/structured_msg.capnp.h"
30#include <boost/endian.hpp>
49template<
typename Struct_builder_config>
51 private Msg_out<schema::detail::StructuredMessage, typename Struct_builder_config::Builder>
97 size_t n_serialization_segments_or_none);
142template<
typename Struct_builder_config>
145 msg_id_t originating_msg_id_or_none,
msg_id_t id_or_none,
size_t n_serialization_segments_or_none) :
147 Base(struct_builder_config)
149 using boost::endian::native_to_little;
164 auto capnp_uuid = msg_root->initAuthHeader().initSessionToken();
165 static_assert(std::remove_reference_t<
decltype(session_token)>::static_size() == 2 *
sizeof(uint64_t),
166 "World is broken: UUIDs expected to be 16 bytes!");
167 auto& first8 = *(
reinterpret_cast<const uint64_t*
>(session_token.data));
168 auto& last8 = *(
reinterpret_cast<const uint64_t*
>(session_token.data +
sizeof(uint64_t)));
169 capnp_uuid.setFirst8(native_to_little(first8));
170 capnp_uuid.setLast8(native_to_little(last8));
172 msg_root->setId(id_or_none);
174 if (originating_msg_id_or_none != 0)
176 msg_root->initOriginatingMessageOrNull().setId(originating_msg_id_or_none);
181 msg_root->initInternalMessageBody();
185 assert((n_serialization_segments_or_none != 0)
186 &&
"If serializing a user message, you have to have some segs for it.");
187 msg_root->setNumBodySerializationSegments(n_serialization_segments_or_none);
191template<
typename Struct_builder_config>
195 return Base::body_root()->getInternalMessageBody();
198template<
typename Struct_builder_config>
202 return Base::body_root();
205template<
typename Struct_builder_config>
210 Base::emit_serialization(&target_blobs, session, err_code);
212 assert((!target_blobs.empty()) &&
"That is just weird.");
213 assert((target_blobs.size() == 1) &&
"As described in our contract we should have ensured this internal-use "
214 "structure shall fit in one segment no matter the builder. Bug?");
216 return target_blobs.front();
Internally used (data-free) addendum on-top of Msg_out; really an alias to Msg_out<schema::detail::St...
Msg_mdt_out(const Builder_config &struct_builder_config, const Session_token &session_token, msg_id_t originating_msg_id_or_none, msg_id_t id_or_none, size_t n_serialization_segments_or_none)
Constructs out-metadata-message describing a user-created message (not an internal message); or else ...
Internal_msg_body_builder internal_msg_body_root()
Returns a builder for the internal-message root; to be called only if id_or_none == 0 in ctor.
flow::util::Blob * emit_serialization(const typename Base::Builder::Session &session, Error_code *err_code) const
Returns the serialization in the form of a sequence of 1 Blob.
typename Base::Body_builder Body_builder
Short-hand for capnp-generated mutating Builder nested class of Body. See body_root().
const Body_builder * body_root() const
Forwards to Msg_out::body_root() (const overload).
Struct_builder_config Builder_config
Short-hand for user-specified builder engine.
typename Base::Body::InternalMessageBody::Builder Internal_msg_body_builder
In the event *this describes an internally-created message – for internal purposes,...
A structured out-message suitable to be sent via struc::Channel::send() (et al).
typename Body::Builder Body_builder
Short-hand for capnp-generated mutating Builder nested class of Body. See body_root().
Body_builder * body_root()
The Body root capnp-generated mutator object.
Builder< ipc::shm::classic::Pool_arena > Builder
Convenience alias: transport::struc::shm::Builder that works with boost.ipc.shm pools from ipc::shm::...
Sub-module of Flow-IPC module ipc::transport providing transmission of structured messages specifical...
boost::uuids::uuid Session_token
A type used by struc::Channel for internal safety/security/auth needs.
std::vector< flow::util::Blob * > Segment_ptrs
Sequence of 1+ Blob pointers to blobs which must stay alive while these pointers may be dereferenced,...
uint64_t msg_id_t
Message ID uniquely identifying outgoing message (Msg_out, among all other Msg_outs),...
flow::Error_code Error_code
Short-hand for flow::Error_code which is very common.