38 std::optional<uint32_t>
idx;
40 AppID(
const std::string &
name, std::optional<uint32_t>
idx = std::nullopt)
51 return name +
"[" + std::to_string(
idx.value()) +
"]";
55bool operator<(
const AppID &a,
const AppID &b);
59 using std::vector<
AppID>::vector;
63 std::string
toStr()
const;
70 std::optional<const Type *>
type;
74 std::optional<std::string>
name;
77 std::optional<std::string>
repo;
80 std::map<std::string, std::any>
extra;
182 virtual std::unique_ptr<services::HostMemRegion>
take(
size_t segIdx);
215 operator const std::vector<uint8_t> &()
const {
return data; }
216 operator std::span<const uint8_t>()
const {
return data; }
231 template <
typename T>
232 const T *
as()
const {
233 if (
data.size() !=
sizeof(T))
234 throw std::runtime_error(
"Data size does not match type size. Size is " +
235 std::to_string(
data.size()) +
", expected " +
236 std::to_string(
sizeof(T)) +
".");
237 return reinterpret_cast<const T *
>(
data.data());
241 template <
typename T>
243 return MessageData(
reinterpret_cast<const uint8_t *
>(&t),
sizeof(T));
247 std::string
toHex()
const;
252 throw std::out_of_range(
"MessageData only has one segment");
278 std::span<const uint8_t>
remaining()
const;
305std::string
toHex(
void *val);
306std::string
toHex(uint64_t val);
std::string toStr() const
friend std::ostream & operator<<(std::ostream &os, const AppIDPath &path)
AppIDPath operator+(const AppIDPath &b) const
A concrete flat message backed by a single vector of bytes.
const std::vector< uint8_t > & getData() const
Get the data as a vector of bytes.
const uint8_t * getBytes() const
std::string toHex() const
Convert the data to a hex string.
const T * as() const
Cast to a type.
std::vector< uint8_t > takeData()
Move the data out of this object.
size_t numSegments() const override
Number of segments in the message.
Segment segment(size_t idx) const override
Get a segment by index. Throws if the segment has been take()n.
size_t getSize() const
Get the size of the data in bytes.
MessageData()=default
Adopts the data vector buffer.
MessageData(const uint8_t *data, size_t size)
MessageData(std::vector< uint8_t > &data)
MessageData toMessageData() const override
Flatten all segments into a standard MessageData.
MessageData(std::span< const uint8_t > data)
bool empty() const
Returns true if this message contains no data.
static MessageData from(T &t)
Cast from a type to its raw bytes.
std::vector< uint8_t > data
MessageData(std::vector< uint8_t > &&data)
Segment remainingSegment() const
The unconsumed part of the current segment, with its region.
const SegmentedMessageData & msg
void advance(size_t n)
Advance by n bytes, crossing segment boundaries as needed.
bool done() const
True when all segments have been consumed.
std::span< const uint8_t > remaining() const
Contiguous span from current position to end of current segment.
SegmentedMessageDataCursor(const SegmentedMessageData &msg)
Abstract multi-segment message.
virtual Segment segment(size_t idx) const =0
Get a segment by index. Throws if the segment has been take()n.
virtual ~SegmentedMessageData()=default
virtual MessageData toMessageData() const
Flatten all segments into a standard MessageData.
bool empty() const
True if totalSize() == 0.
virtual std::unique_ptr< services::HostMemRegion > take(size_t segIdx)
Optionally called by a backend once it has transmitted segment segIdx, to obtain ownership of the Hos...
size_t totalSize() const
Total size across all segments.
virtual size_t numSegments() const =0
Number of segments in the message.
Root class of the ESI type system.
std::ostream & operator<<(std::ostream &, const esi::ModuleInfo &)
std::string toHex(void *val)
std::vector< HWClientDetail > HWClientDetails
std::map< std::string, std::any > ServiceImplDetails
std::map< std::string, ChannelAssignment > ChannelAssignments
bool operator<(const AppID &a, const AppID &b)
bool operator!=(const AppID &other) const
std::string toString() const
bool operator==(const AppID &other) const
friend std::ostream & operator<<(std::ostream &os, const AppID &id)
std::optional< uint32_t > idx
AppID(const std::string &name, std::optional< uint32_t > idx=std::nullopt)
Details about how to connect to a particular channel.
std::map< std::string, std::any > implOptions
Implementation-specific options.
std::string type
The name of the type of connection.
std::optional< const Type * > type
A description of a hardware client.
std::map< std::string, std::any > implOptions
ChannelAssignments channelAssignments
std::optional< std::string > version
std::optional< std::string > name
std::map< std::string, Constant > constants
std::optional< std::string > commitHash
std::optional< std::string > repo
std::map< std::string, std::any > extra
std::optional< std::string > summary
A contiguous, non-owning view of bytes within a SegmentedMessageData.
std::span< const uint8_t > span() const
std::optional< uint64_t > getDeviceAddress() const
Device address of this segment's bytes, if region is set and contains them; std::nullopt otherwise.
services::HostMemRegion * region
The HostMem region (from services::HostMem::allocate()) which holds [data, data + size),...
A description of a service port.
RAII memory region for host memory in accelerator-accessible address space.