Adaptyst
A comprehensive and architecture-agnostic performance analysis tool
Loading...
Searching...
No Matches
adaptyst::ObjectWithMetadata Class Referenceabstract

#include <output.hpp>

Inheritance diagram for adaptyst::ObjectWithMetadata:
adaptyst::File adaptyst::Path adaptyst::Array< T >

Public Member Functions

 ObjectWithMetadata ()
 
template<class T>
void set_metadata (std::string key, T value, bool save=true)
 
template<class T>
get_metadata (std::string key, T default_value)
 
template<class T>
get_metadata (std::string key)
 
virtual void save_metadata ()=0
 

Protected Attributes

nlohmann::json metadata
 

Detailed Description

This abstract class describes an arbitrary object with attached metadata in form of key-value pairs, where the value type is templatised.

Constructor & Destructor Documentation

◆ ObjectWithMetadata()

adaptyst::ObjectWithMetadata::ObjectWithMetadata ( )
inline

Member Function Documentation

◆ get_metadata() [1/2]

template<class T>
T adaptyst::ObjectWithMetadata::get_metadata ( std::string key)
inline

Gets a value from the metadata based on a given key, throwing an exception if the key is not found.

Parameters
keyKey to look for.
Returns
Value corresponding to the key.

◆ get_metadata() [2/2]

template<class T>
T adaptyst::ObjectWithMetadata::get_metadata ( std::string key,
T default_value )
inline

Gets a value from the metadata based on a given key, with the default value provided if the key is not found.

Parameters
keyKey to look for.
default_valueValue to return if the key is not found.
Returns
Value corresponding to the key or the default value if the key is not found.

◆ save_metadata()

virtual void adaptyst::ObjectWithMetadata::save_metadata ( )
pure virtual

Saves metadata in a way dependent on the implementation, e.g. to disk.

Implemented in adaptyst::File, and adaptyst::Path.

◆ set_metadata()

template<class T>
void adaptyst::ObjectWithMetadata::set_metadata ( std::string key,
T value,
bool save = true )
inline

Sets a key-value pair in the metadata.

Parameters
keyKey in the key-value pair.
valueValue in the key-value pair.
saveWhether all metadata should be saved to disk or elsewhere after setting the pair.

Member Data Documentation

◆ metadata

nlohmann::json adaptyst::ObjectWithMetadata::metadata
protected

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