Shamrock 2025.10.0
Astrophysical Code
Loading...
Searching...
No Matches
Public Member Functions | List of all members
shambase::StorageComponent< T > Class Template Reference

Helper class for Storage Module of any solver. More...

#include <shambase/include/shambase/StorageComponent.hpp>

Public Member Functions

void set (T &&arg, SourceLocation loc=SourceLocation())
 Replace the held object by moving the given argument.
 
T & get (SourceLocation loc=SourceLocation())
 Get the reference to the held object if it was allocated.
 
void reset ()
 Reset the storage component.
 
bool is_empty ()
 Check if the storage component is empty.
 

Detailed Description

template<class T>
class shambase::StorageComponent< T >

Helper class for Storage Module of any solver.

This class provides a simple way to store an object in the storage module of any solver. it will delete the stored object when it goes out of scope.

Template Parameters
TType of the stored object

Definition at line 35 of file StorageComponent.hpp.

Member Function Documentation

◆ get()

template<class T >
T & shambase::StorageComponent< T >::get ( SourceLocation  loc = SourceLocation())
inline

Get the reference to the held object if it was allocated.

This function returns a reference to the object held by this StorageComponent. If the StorageComponent does not hold anything, it throws a std::runtime_error.

Returns
T& the reference held
Exceptions
std::runtime_errorIf the StorageComponent does not hold anything.

Definition at line 73 of file StorageComponent.hpp.

+ Here is the call graph for this function:

◆ is_empty()

template<class T >
bool shambase::StorageComponent< T >::is_empty ( )
inline

Check if the storage component is empty.

This function returns whether the storage component is empty or not.

Returns
true if the storage component does not hold anything, false otherwise.

Definition at line 96 of file StorageComponent.hpp.

+ Here is the call graph for this function:

◆ reset()

template<class T >
void shambase::StorageComponent< T >::reset ( )
inline

Reset the storage component.

Delete the content of the StorageComponent by resetting the unique_ptr holding the stored object.

Definition at line 84 of file StorageComponent.hpp.

+ Here is the call graph for this function:

◆ set()

template<class T >
void shambase::StorageComponent< T >::set ( T &&  arg,
SourceLocation  loc = SourceLocation() 
)
inline

Replace the held object by moving the given argument.

This function replaces the held object by moving the given argument into the StorageComponent. If the StorageComponent already holds an object, this function throws a std::runtime_error.

Parameters
argThe object to be moved into the StorageComponent.
Exceptions
std::runtime_errorIf the StorageComponent already holds an object.

Definition at line 52 of file StorageComponent.hpp.

+ Here is the call graph for this function:

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