parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
Loading...
Searching...
No Matches
parcel::BaseCellTypeDescriptor< T > Class Template Reference

CRTP base that fills in the boilerplate of every cell-type descriptor. More...

#include <descriptor.h>

Inheritance diagram for parcel::BaseCellTypeDescriptor< T >:
Collaboration diagram for parcel::BaseCellTypeDescriptor< T >:

Public Member Functions

 BaseCellTypeDescriptor (DisplayInfo info)
 Construct with the given display info.
 
std::string_view kind () const override
 Wire-stable kind identifier.
 
DisplayInfo display_info () const override
 Display info for this cell type.
 
std::type_index storage_type () const override
 std::type_index of the cell's storage type.
 
json_t to_json () const override
 Serialize the descriptor itself (kind + display info + category + extras).
 
- Public Member Functions inherited from parcel::ICellTypeDescriptor
virtual descriptor::CellCategory category () const =0
 Coarse classification (primitive, list, struct, …).
 
virtual cell_t cell_from_json (const json_t &j, ParcelRegistry const &reg) const =0
 Construct a cell from JSON, dispatching to the concrete from_json.
 

Static Public Attributes

static constexpr std::string_view kind_id = T::kind_id
 Wire-stable kind id, lifted from T::kind_id.
 

Protected Member Functions

json_t base_to_json () const
 Common JSON skeleton (kind, display_info, category) reused by overrides.
 

Protected Attributes

DisplayInfo display_info_
 Stored display info.
 

Detailed Description

template<CellLike T>
class parcel::BaseCellTypeDescriptor< T >

CRTP base that fills in the boilerplate of every cell-type descriptor.

Concrete descriptors inherit BaseCellTypeDescriptor<T> and provide the category() plus, when relevant, cell_from_json and to_json overrides.

Template Parameters
TA CellLike cell type whose descriptor this is.

Constructor & Destructor Documentation

◆ BaseCellTypeDescriptor()

template<CellLike T>
parcel::BaseCellTypeDescriptor< T >::BaseCellTypeDescriptor ( DisplayInfo  info)
inlineexplicit

Construct with the given display info.

Parameters
infoDisplay info.

Member Function Documentation

◆ base_to_json()

template<CellLike T>
json_t parcel::BaseCellTypeDescriptor< T >::base_to_json ( ) const
inlineprotected

Common JSON skeleton (kind, display_info, category) reused by overrides.

Returns
Base JSON object that derived to_json overrides extend.

◆ to_json()

template<CellLike T>
json_t parcel::BaseCellTypeDescriptor< T >::to_json ( ) const
inlineoverridevirtual

Serialize the descriptor itself (kind + display info + category + extras).

Returns
JSON object describing this cell type.

Implements parcel::ICellTypeDescriptor.

Reimplemented in parcel::TypedListCellTypeDescriptor< T >, parcel::TypedMapCellTypeDescriptor< T >, parcel::StructCellTypeDescriptor< Derived, Payload >, and parcel::UnionCellTypeDescriptor< Ts >.


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