|
ACTS
Experiment-independent tracking
|
JSON-specific dispatcher that routes decoder functions based on a string kind tag found in the encoded payload. More...
#include <ActsPlugins/Json/JsonKindDispatcher.hpp>
Public Types | |
| using | decoder_pointer_type = return_t (*)(args_t...) |
| Decoder callable pointer type. | |
| using | decoder_signature = return_t(const nlohmann::json&, args_t...) |
| Function signature type. | |
| using | decoder_type = std::function<decoder_signature> |
| Decoder callable type. | |
| using | self_type = JsonKindDispatcher<return_t, args_t...> |
| Type of the dispatcher specialization. | |
Public Member Functions | |
| JsonKindDispatcher (std::string kindKey="kind", std::string context="JSON payload") | |
| Explicit constructor of the dispatcher. | |
| void | clear () |
| Clear the registered decoders list. | |
| bool | hasKind (std::string_view kind) const |
| Check if a certain kind is registered. | |
| template<typename... func_args_t> requires std::invocable<decoder_pointer_type, func_args_t...> | |
| return_t | operator() (const nlohmann::json &encoded, func_args_t &&... args) const |
| Decode the registered kind from a json file. | |
| self_type & | registerKind (std::string kind, decoder_type decoder) |
| Register a kind and the corresponding decoder. | |
| std::size_t | size () const |
| Get the number of registered decoders. | |
JSON-specific dispatcher that routes decoder functions based on a string kind tag found in the encoded payload.
|
explicit |
Explicit constructor of the dispatcher.
| kindKey | the key containing the type kind in json |
| context | context string for error signaling |
| bool Acts::JsonKindDispatcher< return_t, args_t >::hasKind | ( | std::string_view | kind | ) | const |
Check if a certain kind is registered.
| kind | the kind to check for registration |
| return_t Acts::JsonKindDispatcher< return_t, args_t >::operator() | ( | const nlohmann::json & | encoded, |
| func_args_t &&... | args ) const |
Decode the registered kind from a json file.
| encoded | json file to decode |
| args | forwarding reference to the decoder arguments |
| self_type & Acts::JsonKindDispatcher< return_t, args_t >::registerKind | ( | std::string | kind, |
| decoder_type | decoder ) |
Register a kind and the corresponding decoder.
| kind | kind to register |
| decoder | corresponding decoder |
| std::size_t Acts::JsonKindDispatcher< return_t, args_t >::size | ( | ) | const |
Get the number of registered decoders.