Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
shamalgs::ImplVariantParams< Alt > Struct Template Reference

Customization point controlling how an alternative's fields (if any) are serialized to / parsed from the "parameters" json value carried alongside its name. More...

#include <shamalgs/include/shamalgs/ImplVariant.hpp>

Static Public Member Functions

static nlohmann::json to_json (const Alt &)
 Serialize the alternative's fields (default: no fields, empty object).
static Alt from_json (const nlohmann::json &)
 Parse the alternative's fields back (default: no fields, ignored).

Detailed Description

template<class Alt>
struct shamalgs::ImplVariantParams< Alt >

Customization point controlling how an alternative's fields (if any) are serialized to / parsed from the "parameters" json value carried alongside its name.

The default (used by empty/tag alternatives, i.e. most of them) serializes to an empty json object. Alternatives with tunable fields (e.g. a group size) specialize this trait, for example:

struct GpuTeamFetching {
static constexpr std::string_view variant_type_name = "gpu_team_fetching";
u32 group_size = 128;
};
template<>
struct shamalgs::ImplVariantParams<GpuTeamFetching> {
static nlohmann::json to_json(const GpuTeamFetching &p) {
return {{"group_size", p.group_size}};
}
static GpuTeamFetching from_json(const nlohmann::json &j) {
GpuTeamFetching p{};
if (j.contains("group_size")) {
p.group_size = j.at("group_size").get<u32>();
}
return p;
}
};
std::uint32_t u32
32 bit unsigned integer
Customization point controlling how an alternative's fields (if any) are serialized to / parsed from ...
static Alt from_json(const nlohmann::json &)
Parse the alternative's fields back (default: no fields, ignored).
static nlohmann::json to_json(const Alt &)
Serialize the alternative's fields (default: no fields, empty object).

Definition at line 84 of file ImplVariant.hpp.

Member Function Documentation

◆ from_json()

template<class Alt>
Alt shamalgs::ImplVariantParams< Alt >::from_json ( const nlohmann::json & )
inlinestatic

Parse the alternative's fields back (default: no fields, ignored).

Definition at line 88 of file ImplVariant.hpp.

◆ to_json()

template<class Alt>
nlohmann::json shamalgs::ImplVariantParams< Alt >::to_json ( const Alt & )
inlinestatic

Serialize the alternative's fields (default: no fields, empty object).

Definition at line 86 of file ImplVariant.hpp.


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