ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::SurfaceMaterialJsonConverter Class Reference

Static class performing the JSON conversion of surface material. More...

#include <ActsPlugins/Json/SurfaceMaterialJsonConverter.hpp>

Classes

struct  Config
 Configuration struct. More...

Public Types

using DecodeContext = detail::MaterialJsonDecodeContext
 Context carrying the slab stores of the document being read.
using Decoder
 Decoder type for the surface material.
using EncodeContext = detail::MaterialJsonEncodeContext
 Context collecting the slab stores of the document being written.
using Encoder
 Encoder type for the surface material.

Public Member Functions

 SurfaceMaterialJsonConverter ()=delete
 Delete the default constructor as the class is purely static.

Static Public Member Functions

static std::unique_ptr< const ISurfaceMaterialfromJson (const nlohmann::json &jMaterial, const Config &config=Config::defaultConfig(), const DecodeContext *context=nullptr)
 Convert a json payload back into surface material.
static nlohmann::json toJson (const ISurfaceMaterial &material, const Config &config=Config::defaultConfig(), EncodeContext *context=nullptr)
 Convert surface material into its json payload.

Detailed Description

Static class performing the JSON conversion of surface material.

The encoding side is a TypeDispatcher registered on the concrete (or, for the grid family, the abstract templated) material types, the decoding side a JsonKindDispatcher keyed on the payload type tag.

Member Typedef Documentation

◆ Decoder

Initial value:
const DecodeContext&>
JSON-specific dispatcher that routes decoder functions based on a string kind tag found in the encode...
Definition JsonKindDispatcher.hpp:27
detail::MaterialJsonDecodeContext DecodeContext
Context carrying the slab stores of the document being read.
Definition SurfaceMaterialJsonConverter.hpp:42

Decoder type for the surface material.

◆ Encoder

Initial value:
Base class of all surface-based material description.
Definition ISurfaceMaterial.hpp:39
detail::MaterialJsonEncodeContext EncodeContext
Context collecting the slab stores of the document being written.
Definition SurfaceMaterialJsonConverter.hpp:39
Template class for type-based function dispatch.
Definition TypeDispatcher.hpp:38

Encoder type for the surface material.

Member Function Documentation

◆ fromJson()

std::unique_ptr< const ISurfaceMaterial > Acts::SurfaceMaterialJsonConverter::fromJson ( const nlohmann::json & jMaterial,
const Config & config = Config::defaultConfig(),
const DecodeContext * context = nullptr )
static

Convert a json payload back into surface material.

Parameters
jMaterialthe json payload of the material
configthe converter configuration
contextthe document context holding the slab stores, or a nullptr if the payload is expected to be self-contained
Returns
the decoded material, or a nullptr if the payload is flagged as not participating in the material mapping

◆ toJson()

nlohmann::json Acts::SurfaceMaterialJsonConverter::toJson ( const ISurfaceMaterial & material,
const Config & config = Config::defaultConfig(),
EncodeContext * context = nullptr )
static

Convert surface material into its json payload.

Parameters
materialthe material to be converted
configthe converter configuration
contextthe document context collecting the slab stores, or a nullptr to inline any slab store and keep the payload self-contained
Returns
the json payload of the material, i.e. the value that goes under the material key of a surface