CIRCT 22.0.0git
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | List of all members
esi::Type Class Reference

Root class of the ESI type system. More...

#include <Types.h>

Inheritance diagram for esi::Type:
Inheritance graph
[legend]
Collaboration diagram for esi::Type:
Collaboration graph
[legend]

Public Types

using ID = std::string
 

Public Member Functions

 Type (const ID &id)
 
virtual ~Type ()=default
 
ID getID () const
 
virtual std::ptrdiff_t getBitWidth () const
 
virtual MutableBitVector serialize (const std::any &obj) const
 Serialize an object to a MutableBitVector (LSB-first stream).
 
virtual std::any deserialize (BitVector &data) const
 Deserialize from a BitVector stream (LSB-first).
 
std::any deserialize (const MessageData &data) const
 
virtual void ensureValid (const std::any &obj) const
 Ensure that a std::any object is valid for this type.
 
std::optional< std::string > isValid (const std::any &obj) const
 

Protected Attributes

ID id
 

Detailed Description

Root class of the ESI type system.

Definition at line 34 of file Types.h.

Member Typedef Documentation

◆ ID

using esi::Type::ID = std::string

Definition at line 36 of file Types.h.

Constructor & Destructor Documentation

◆ Type()

esi::Type::Type ( const ID id)
inline

Definition at line 37 of file Types.h.

◆ ~Type()

virtual esi::Type::~Type ( )
virtualdefault

Member Function Documentation

◆ deserialize() [1/2]

virtual std::any esi::Type::deserialize ( BitVector data) const
inlinevirtual

Deserialize from a BitVector stream (LSB-first).

Implementations consume bits from 'data' in-place (via logical right shifts) and return the reconstructed value. Remaining bits stay in 'data'.

Reimplemented in esi::ChannelType, esi::VoidType, esi::BitsType, esi::SIntType, esi::UIntType, esi::StructType, esi::ArrayType, esi::ChannelType, esi::VoidType, esi::BitsType, esi::SIntType, esi::UIntType, esi::StructType, and esi::ArrayType.

Definition at line 54 of file Types.h.

Referenced by esi::ChannelType::deserialize(), esi::StructType::deserialize(), esi::ArrayType::deserialize(), and deserialize().

◆ deserialize() [2/2]

std::any esi::Type::deserialize ( const MessageData data) const
inline

Definition at line 61 of file Types.h.

References deserialize().

◆ ensureValid()

virtual void esi::Type::ensureValid ( const std::any &  obj) const
inlinevirtual

Ensure that a std::any object is valid for this type.

Throws std::runtime_error if the object is not valid.

Reimplemented in esi::ChannelType, esi::VoidType, esi::BitsType, esi::SIntType, esi::UIntType, esi::StructType, and esi::ArrayType.

Definition at line 68 of file Types.h.

Referenced by esi::ChannelType::ensureValid(), esi::ArrayType::ensureValid(), and isValid().

◆ getBitWidth()

virtual std::ptrdiff_t esi::Type::getBitWidth ( ) const
inlinevirtual

◆ getID()

ID esi::Type::getID ( ) const
inline

◆ isValid()

std::optional< std::string > esi::Type::isValid ( const std::any &  obj) const
inline

Definition at line 74 of file Types.h.

References ensureValid().

◆ serialize()

virtual MutableBitVector esi::Type::serialize ( const std::any &  obj) const
inlinevirtual

Serialize an object to a MutableBitVector (LSB-first stream).

The object should be passed via std::any. Implementations append fields in the order they are iterated (the first serialized field occupies the least-significant bits of the result).

Reimplemented in esi::ChannelType, esi::VoidType, esi::BitsType, esi::SIntType, esi::UIntType, esi::StructType, and esi::ArrayType.

Definition at line 47 of file Types.h.

Referenced by esi::ChannelType::serialize(), esi::StructType::serialize(), and esi::ArrayType::serialize().

Member Data Documentation

◆ id

ID esi::Type::id
protected

Definition at line 84 of file Types.h.

Referenced by getID().


The documentation for this class was generated from the following file: