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

Arrays have a compile time specified (static) size and an element type. More...

#include <Types.h>

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

Public Member Functions

 ArrayType (const ID &id, const Type *elementType, uint64_t size)
 
const TypegetElementType () const
 
uint64_t getSize () const
 
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.
 
MessageData serialize (const std::any &obj) const override
 Serialize an object to MessageData.
 
std::pair< std::any, std::span< const uint8_t > > deserialize (std::span< const uint8_t > data) const override
 Deserialize from a span of bytes to an object.
 
- Public Member Functions inherited from esi::Type
 Type (const ID &id)
 
virtual ~Type ()=default
 
ID getID () const
 
std::optional< std::string > isValid (const std::any &obj) const
 

Private Attributes

const TypeelementType
 
uint64_t size
 

Additional Inherited Members

- Public Types inherited from esi::Type
using ID = std::string
 
- Protected Attributes inherited from esi::Type
ID id
 

Detailed Description

Arrays have a compile time specified (static) size and an element type.

Definition at line 231 of file Types.h.

Constructor & Destructor Documentation

◆ ArrayType()

esi::ArrayType::ArrayType ( const ID id,
const Type elementType,
uint64_t  size 
)
inline

Definition at line 233 of file Types.h.

Member Function Documentation

◆ deserialize()

std::pair< std::any, std::span< const uint8_t > > esi::ArrayType::deserialize ( std::span< const uint8_t >  data) const
overridevirtual

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 from esi::Type.

◆ ensureValid()

void esi::ArrayType::ensureValid ( const std::any &  obj) const
overridevirtual

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

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

Reimplemented from esi::Type.

Definition at line 359 of file Types.cpp.

References elementType, esi::Type::ensureValid(), and size.

Referenced by serialize().

◆ getBitWidth()

std::ptrdiff_t esi::ArrayType::getBitWidth ( ) const
inlineoverridevirtual

Reimplemented from esi::Type.

Definition at line 238 of file Types.h.

References elementType, esi::Type::getBitWidth(), and size.

Referenced by serialize().

◆ getElementType()

const Type * esi::ArrayType::getElementType ( ) const
inline

Definition at line 236 of file Types.h.

References elementType.

◆ getSize()

uint64_t esi::ArrayType::getSize ( ) const
inline

Definition at line 237 of file Types.h.

References size.

◆ serialize()

MessageData esi::ArrayType::serialize ( const std::any &  obj) const
overridevirtual

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 from esi::Type.

Definition at line 381 of file Types.cpp.

References elementType, ensureValid(), getBitWidth(), esi::MessageData::getData(), and esi::Type::serialize().

Member Data Documentation

◆ elementType

const Type* esi::ArrayType::elementType
private

Definition at line 251 of file Types.h.

Referenced by ensureValid(), getBitWidth(), getElementType(), and serialize().

◆ size

uint64_t esi::ArrayType::size
private

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