Celeritas  0.5.0-86+4a8eea4
Public Member Functions | Static Public Member Functions | List of all members
celeritas::OutputInterfaceAdapter< T > Class Template Referencefinal

Adapter class for writing a JSON-serializable data to output. More...

#include <OutputInterfaceAdapter.hh>

Inheritance diagram for celeritas::OutputInterfaceAdapter< T >:
Inheritance graph
[legend]

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.
 

Detailed Description

template<class T>
class celeritas::OutputInterfaceAdapter< T >

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.

Member Function Documentation

◆ from_const_ref()

template<class T >
auto celeritas::OutputInterfaceAdapter< T >::from_const_ref ( Category  cat,
std::string  label,
T const &  obj 
)
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:

OutputInterface::Category::system,
"device",
celeritas::device()));
static SPThis from_const_ref(Category cat, std::string label, T const &obj)
Construct from a long-lived const reference.
Definition: OutputInterfaceAdapter.hh:84

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