parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
Loading...
Searching...
No Matches
parcel::OriginCell Class Reference

Cell wrapping comms::OriginPtr (a std::unique_ptr<comms::IOrigin>). More...

#include <commons.h>

Inheritance diagram for parcel::OriginCell:
Collaboration diagram for parcel::OriginCell:

Public Member Functions

std::string_view kind () const override
 Wire-stable kind identifier for this cell.
 
std::optional< DisplayInfo > const & overridden_display_info () const override
 Read-only access to this cell's optional display info.
 
std::string to_string () const override
 Render the cell's value as a compact human-readable string.
 
json_t to_json () const override
 Serialize this cell to its canonical JSON representation.
 
cell_t clone () const override
 Deep-copy this cell.
 
std::partial_ordering compare (ICell const &other) const override
 Three-way compare against another cell.
 
- Public Member Functions inherited from parcel::ICell
virtual std::string to_formatted_string () const
 Render the cell as a multi-line, indented string.
 
virtual std::size_t hash_value () const noexcept
 Equality-consistent hash that mirrors compare's display-info-insensitivity.
 
cell_t with_display_info (DisplayInfo m) const
 Return a deep copy with the entire display info block replaced.
 
cell_t with_name (std::string v) const
 Return a deep copy with name set to v.
 
cell_t with_description (std::string v) const
 Return a deep copy with description set to v.
 
cell_t with_icon (comms::Icon icon) const
 Return a deep copy with icon set to the typed icon.
 
cell_t with_icon (std::string const &v) const
 Return a deep copy with icon parsed from an Iconify set:name string (e.g.
 
cell_t with_color (comms::Color color) const
 Return a deep copy with color set to the typed color.
 
cell_t with_color (std::string const &v) const
 Return a deep copy with color parsed from a color string (hex like "#ffcc00", a CSS-functional form, or a CSS color name).
 

Static Public Member Functions

static cell_t of (comms::OriginPtr v)
 Construct a shared_ptr<OriginCell> owning v.
 

Public Attributes

comms::OriginPtr value
 Held origin (may be null).
 

Protected Member Functions

void set_display_info (std::optional< DisplayInfo > m) override
 Replace this cell's display info in place.
 

Additional Inherited Members

- Static Public Attributes inherited from parcel::ICell
static constexpr std::string_view KEY_KIND = "k"
 JSON key for the kind id ("k").
 
static constexpr std::string_view KEY_VALUE = "v"
 JSON key for the value payload ("v").
 
static constexpr std::string_view KEY_DESCRIPTION = "d"
 JSON key for the optional display info block ("d").
 

Detailed Description

Cell wrapping comms::OriginPtr (a std::unique_ptr<comms::IOrigin>).

Wire kind "origin"; value is a {"kind", …fields} object.

OriginPtr is move-only, so this cell derives directly from ICell rather than BaseCell (whose clone() copies the storage). The held origin serializes through commons' nlohmann::adl_serializer<comms::OriginPtr>; decoding resolves the "kind" discriminator against comms::GlobalOriginRegistry, throwing on an unknown kind.

Member Function Documentation

◆ clone()

cell_t parcel::OriginCell::clone ( ) const
inlineoverridevirtual

Deep-copy this cell.

Returns
A new cell_t whose state is independent of the original.

Implements parcel::ICell.

◆ compare()

std::partial_ordering parcel::OriginCell::compare ( ICell const &  other) const
inlineoverridevirtual

Three-way compare against another cell.

Compares by kind id first (lexicographic on the string view); within the same kind, compares the held value. Display info is intentionally ignored — two cells with the same kind/value but different DisplayInfo are equivalent under this relation.

Parameters
otherCell to compare with.
Returns
std::partial_orderingunordered whenever the storage type only supports equality (or contains incomparable values such as floating-point NaN).

Implements parcel::ICell.

◆ kind()

std::string_view parcel::OriginCell::kind ( ) const
inlineoverridevirtual

Wire-stable kind identifier for this cell.

Returns
The same value as the static kind_id on the concrete type.

Implements parcel::ICell.

◆ overridden_display_info()

std::optional< DisplayInfo > const & parcel::OriginCell::overridden_display_info ( ) const
inlineoverridevirtual

Read-only access to this cell's optional display info.

Returns
Reference to the held optional; empty when no display info is set.

Implements parcel::ICell.

◆ set_display_info()

void parcel::OriginCell::set_display_info ( std::optional< DisplayInfo m)
inlineoverrideprotectedvirtual

Replace this cell's display info in place.

Used by with_* builders on freshly cloned receivers and by JSON deserializers; no other public path mutates display info.

Parameters
mNew display info value (may be empty to clear).

Implements parcel::ICell.

◆ to_json()

json_t parcel::OriginCell::to_json ( ) const
inlineoverridevirtual

Serialize this cell to its canonical JSON representation.

Returns
JSON object of shape {"k", "v", optional "d"}.

Implements parcel::ICell.

◆ to_string()

std::string parcel::OriginCell::to_string ( ) const
inlineoverridevirtual

Render the cell's value as a compact human-readable string.

Returns
String form — implementation-defined per cell type.

Implements parcel::ICell.


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