![]() |
Shamrock 2025.10.0
Astrophysical Code
|
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. | |
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.
| T | Type of the stored object |
Definition at line 35 of file StorageComponent.hpp.
|
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.
| std::runtime_error | If the StorageComponent does not hold anything. |
Definition at line 73 of file StorageComponent.hpp.
Here is the call graph for this function:
|
inline |
Check if the storage component is empty.
This function returns whether the storage component is empty or not.
Definition at line 96 of file StorageComponent.hpp.
Here is the call graph for this function:
|
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:
|
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.
| arg | The object to be moved into the StorageComponent. |
| std::runtime_error | If the StorageComponent already holds an object. |
Definition at line 52 of file StorageComponent.hpp.
Here is the call graph for this function: