Celeritas
0.5.0-56+6b053cd
|
Adapter class for writing a JSON-serializable data to output. More...
#include <OutputInterfaceAdapter.hh>
Public Types | |
Type aliases | |
using | SPConstT = std::shared_ptr< T const > |
using | SPThis = std::shared_ptr< OutputInterfaceAdapter< T > > |
Public Types inherited from celeritas::OutputInterface | |
enum class | Category { input , result , system , internal , size_ } |
Output category (TODO: could replace with string/cstring?) | |
Public Member Functions | |
OutputInterfaceAdapter (Category cat, std::string label, SPConstT obj) | |
Construct from category, label, and shared pointer. | |
Category | category () const final |
Category of data to write. | |
std::string_view | label () const final |
Label of the entry inside the category. | |
void | output (JsonPimpl *jp) const final |
Write output to the given JSON object. | |
Static Public Member Functions | |
static SPThis | from_const_ref (Category cat, std::string label, T const &obj) |
Construct from a long-lived const reference. More... | |
static SPThis | from_rvalue_ref (Category cat, std::string label, T &&obj) |
Construct by capturing an object. | |
Adapter class for writing a JSON-serializable data to output.
This class is to be used only when JSON is available and when a to_json
free function has been defined for T
.
|
inlinestatic |
Construct from a long-lived const reference.
This is a dangerous but sometimes necessary way to make an interface adapter. The object's lifespan must be guaranteed to exceed that of the OutputManager
.
Example: