38 using ID = std::string;
54 throw std::runtime_error(
"Serialization not implemented for type " +
id);
61 throw std::runtime_error(
"Deserialization not implemented for type " +
id);
75 throw std::runtime_error(
"Validation not implemented for type " +
id);
80 std::optional<std::string>
isValid(
const std::any &obj)
const {
84 }
catch (
const std::runtime_error &e) {
90 void dump(std::ostream &os,
bool oneLine =
false)
const;
93 std::string
toString(
bool oneLine =
false)
const;
109 std::vector<std::tuple<std::string, Direction, const Type *>>;
117 std::pair<const Type *, Direction>
findChannel(std::string name)
const;
132 void ensureValid(
const std::any &obj)
const override;
150 void ensureValid(
const std::any &obj)
const override;
173 "TypeAliasType must have a non-null inner type");
183 void ensureValid(
const std::any &obj)
const override;
194 while (
auto *alias =
dynamic_cast<const TypeAliasType *
>(type))
195 type = alias->getInnerType();
205 while (
auto *channel =
dynamic_cast<const ChannelType *
>(type))
207 return dynamic_cast<const T *
>(type);
229 void ensureValid(
const std::any &obj)
const override;
244 using IntegerType::IntegerType;
247 void ensureValid(
const std::any &obj)
const override;
255 using IntegerType::IntegerType;
258 void ensureValid(
const std::any &obj)
const override;
266 using FieldVector = std::vector<std::pair<std::string, const Type *>>;
274 std::ptrdiff_t size = 0;
276 std::ptrdiff_t fieldSize = ty->getBitWidth();
284 void ensureValid(
const std::any &obj)
const override;
312 std::ptrdiff_t elementSize =
elementType->getBitWidth();
315 return elementSize *
size;
318 void ensureValid(
const std::any &obj)
const override;
377 using FieldVector = std::vector<std::pair<std::string, const Type *>>;
385 std::ptrdiff_t maxWidth = 0;
387 std::ptrdiff_t fieldWidth = ty->getBitWidth();
390 maxWidth = std::max(maxWidth, fieldWidth);
395 void ensureValid(
const std::any &obj)
const override;
assert(baseType &&"element must be base type")
std::ptrdiff_t getBitWidth() const override
std::ptrdiff_t getBitWidth() const override
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
const Type * getElementType() const
ArrayType(const ID &id, const Type *elementType, uint64_t size, bool reverse=true)
BitVectorType(const ID &id, uint64_t width)
std::ptrdiff_t getBitWidth() const override
uint64_t getWidth() const
A lightweight, non-owning bit vector view backed by a byte array span.
Bits are just an array of bits.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
BitVectorType(const ID &id, uint64_t width)
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
BundleType(const ID &id, const ChannelVector &channels)
std::vector< std::tuple< std::string, Direction, const Type * > > ChannelVector
std::ptrdiff_t getBitWidth() const override
const ChannelVector & getChannels() const
std::pair< const Type *, Direction > findChannel(std::string name) const
Channels are the basic communication primitives.
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
std::ptrdiff_t getBitWidth() const override
ChannelType(const ID &id, const Type *inner)
const Type * getInner() const
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
Integers are bit vectors which may be signed or unsigned and are interpreted as numbers.
BitVectorType(const ID &id, uint64_t width)
ListType(const ID &id, const Type *elementType)
std::ptrdiff_t getBitWidth() const override
const Type * getElementType() const
A concrete flat message backed by a single vector of bytes.
A mutable bit vector that owns its underlying storage.
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::vector< std::pair< std::string, const Type * > > FieldVector
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::ptrdiff_t getBitWidth() const override
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
StructType(const ID &id, const FieldVector &fields, bool reverse=true)
const FieldVector & getFields() const
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
Type aliases provide a named type which forwards to an inner type.
std::ptrdiff_t getBitWidth() const override
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
TypeAliasType(const ID &id, std::string name, const Type *innerType)
const Type * getInnerType() const
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
const std::string & getName() const
Root class of the ESI type system.
virtual void ensureValid(const std::any &obj) const
Ensure that a std::any object is valid for this type.
std::string toString(bool oneLine=false) const
virtual std::ptrdiff_t getBitWidth() const
void setHWBitwidth(std::ptrdiff_t bw)
Set from manifest JSON hwBitwidth.
std::any deserialize(const MessageData &data) const
virtual std::any deserialize(BitVector &data) const
Deserialize from a BitVector stream (LSB-first).
std::optional< std::string > isValid(const std::any &obj) const
virtual MutableBitVector serialize(const std::any &obj) const
Serialize an object to a MutableBitVector (LSB-first stream).
void dump(std::ostream &os, bool oneLine=false) const
std::ptrdiff_t hwBitwidth
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
UnionType(const ID &id, const FieldVector &fields)
std::vector< std::pair< std::string, const Type * > > FieldVector
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
const FieldVector & getFields() const
std::ptrdiff_t getBitWidth() const override
std::any deserialize(BitVector &data) const override
Deserialize from a BitVector stream (LSB-first).
void ensureValid(const std::any &obj) const override
Ensure that a std::any object is valid for this type.
std::ptrdiff_t getBitWidth() const override
MutableBitVector serialize(const std::any &obj) const override
Serialize an object to a MutableBitVector (LSB-first stream).
std::ptrdiff_t getBitWidth() const override
std::vector< Frame > frames
const std::vector< Frame > & getFrames() const
const Type * getLoweredType() const
const std::string & getName() const
const Type * getIntoType() const
WindowType(const ID &id, const std::string &name, const Type *intoType, const Type *loweredType, const std::vector< Frame > &frames)
const T * getUnwrappedAs(const Type *type)
Unwrap aliases and channels, then cast the payload to T.
const Type * unwrapTypeAlias(const Type *type)
Unwrap TypeAliasType (possibly recursively) to get the underlying type.
Field information describing a field within a frame.
Frame information describing which fields are included in a particular frame.
std::vector< Field > fields