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 MessageData serialize (const std::any &obj) const
 Serialize an object to MessageData.
 
virtual std::pair< std::any, std::span< const uint8_t > > deserialize (std::span< const uint8_t > data) const
 Deserialize from a span of bytes to an object.
 
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 33 of file Types.h.

Member Typedef Documentation

◆ ID

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

Definition at line 35 of file Types.h.

Constructor & Destructor Documentation

◆ Type()

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

Definition at line 36 of file Types.h.

◆ ~Type()

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

Member Function Documentation

◆ deserialize()

virtual std::pair< std::any, std::span< const uint8_t > > esi::Type::deserialize ( std::span< const uint8_t >  data) const
inlinevirtual

Deserialize from a span of bytes to an object.

Returns the deserialized object as a std::any and a span to the remaining bytes.

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

Definition at line 52 of file Types.h.

Referenced by esi::ChannelType::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 58 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 64 of file Types.h.

References ensureValid().

◆ serialize()

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

Serialize an object to MessageData.

The object should be passed as a std::any to provide type erasure. Returns a MessageData containing the serialized representation.

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

Definition at line 45 of file Types.h.

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

Member Data Documentation

◆ id

ID esi::Type::id
protected

Definition at line 74 of file Types.h.

Referenced by getID().


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