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;
148 void ensureValid(
const std::any &obj)
const override;
171 "TypeAliasType must have a non-null inner type");
181 void ensureValid(
const std::any &obj)
const override;
209 void ensureValid(
const std::any &obj)
const override;
224 using IntegerType::IntegerType;
227 void ensureValid(
const std::any &obj)
const override;
235 using IntegerType::IntegerType;
238 void ensureValid(
const std::any &obj)
const override;
246 using FieldVector = std::vector<std::pair<std::string, const Type *>>;
254 std::ptrdiff_t size = 0;
256 std::ptrdiff_t fieldSize = ty->getBitWidth();
264 void ensureValid(
const std::any &obj)
const override;
295 return elementSize *
size;
298 void ensureValid(
const std::any &obj)
const override;
356 using FieldVector = std::vector<std::pair<std::string, const Type *>>;
364 std::ptrdiff_t maxWidth = 0;
366 std::ptrdiff_t fieldWidth = ty->getBitWidth();
369 maxWidth = std::max(maxWidth, fieldWidth);
374 void ensureValid(
const std::any &obj)
const override;
assert(baseType &&"element must be base type")
The "any" type is a special type which can be used to represent any type, as identified by the type i...
std::ptrdiff_t getBitWidth() const override
Arrays have a compile time specified (static) size and an element type.
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)
Bit vectors include signed, unsigned, and signless integers.
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.
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).
Bundles represent a collection of channels.
BundleType(const ID &id, const ChannelVector &channels)
std::ptrdiff_t getBitWidth() const override
const ChannelVector & getChannels() const
std::vector< std::tuple< std::string, Direction, const Type * > > ChannelVector
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.
Lists represent variable-length sequences of elements of a single type.
ListType(const ID &id, const Type *elementType)
std::ptrdiff_t getBitWidth() const override
const Type * getElementType() const
A logical chunk of data representing serialized data.
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.
Structs are an ordered collection of fields, each with a name and a type.
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
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.
Unions are a tagged collection of fields where only one field is active at a time.
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
The "void" type is a special type which can be used to represent no type.
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).
Windows represent a fixed-size sliding window over a stream of data.
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)
Field information describing a field within a frame.
Frame information describing which fields are included in a particular frame.
std::vector< Field > fields