25#ifndef WORKSPACE_NG_INCLUDED
26#define WORKSPACE_NG_INCLUDED
38 std::shared_ptr<void>
wsv;
42using WorkspaceVariable = stack<WorkspaceVariableStruct, std::vector<WorkspaceVariableStruct>>;
53class Workspace final :
public std::enable_shared_from_this<Workspace> {
84 [[nodiscard]]
static std::shared_ptr<Workspace>
create();
87 [[nodiscard]] std::shared_ptr<Workspace>
shallowcopy()
const;
136 template <typename T>
138 using U = std::remove_cv_t<T>;
139 std::shared_ptr<U> wsv_ptr(
const_cast<U *
>(&wsv), [](U *) {});
141 wsvs.initialized =
true;
154 template <
typename T>
156 using U = std::remove_cv_t<T>;
157 std::shared_ptr<U> wsv_ptr(
const_cast<U *
>(&wsv), [](U *) {});
159 wsvs.initialized =
false;
172 template <
typename T>
175 wsvs.initialized =
true;
176 wsvs.wsv = std::forward<std::shared_ptr<T>>(wsv_ptr);
177 ws[i].push(std::move(
wsvs));
191 T*
get(
const char *name) {
193 return static_cast<T*
>(
ws[pos].top().wsv.get());
209 template <
typename OutputStream>
211 outstream << (*wsv_data_ptr)[i].Name() <<
"(" << i <<
") ";
215 std::shared_ptr<Workspace>
deepcopy();
234 else { T mout{x};
return std::make_shared<T>(std::move(mout)); }
This file contains the definition of Array.
int arts_omp_get_max_threads()
Wrapper for omp_get_max_threads.
bool arts_omp_in_parallel()
Wrapper for omp_in_parallel.
Header file for helper functions for OpenMP.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
OmpParallelCopyGuard(T &ws, bool do_copy_manually)
std::shared_ptr< T > copy
OmpParallelCopyGuard(T &ws)
OmpParallelCopyGuard(const OmpParallelCopyGuard &cp)
std::shared_ptr< wsv_data_type > wsv_data_ptr
void swap(Workspace &other) noexcept
Swap with another workspace.
Index add_wsv(const WsvRecord &wsv)
Add a new variable to this workspace.
static std::shared_ptr< Workspace > create()
Creates a new Workspace, it has to be created as a shared pointer.
WorkspaceBorrowGuard borrow_uninitialized(Index i, T &wsv)
Put a new WSV onto its stack.
void PrintWsvName(OutputStream &outstream, Index i) const
Print WSV name to output stream.
std::shared_ptr< Workspace > shallowcopy() const
Shallow copy of a Workspace, it has to be created as a shared pointer.
void pop(Index i)
Remove the topmost WSV from its stack.
void claim_agenda_ownership()
T * get(const char *name)
Retrieve a value ptr if it exist (FIXME: C++20 allows const char* as template argument)
bool is_initialized(Index i) const
Checks existence of the given WSV.
Workspace(Workspace &&) noexcept=default
Allow move construction of this object in public.
map< String, Index > WsvMap_type
wsv_data_type wsvs(const ArrayOfIndex &) const
Workspace * original_workspace
void duplicate(Index i)
Duplicate WSV.
Index nelem() const
Get the number of workspace variables.
Array< WorkspaceVariable > ws
Workspace variable container.
Workspace()
Construct a new workspace.
std::shared_ptr< Workspace > deepcopy()
Gets a full copy that owns all the data (only gets the top of the stack)
std::shared_ptr< WsvMap_type > WsvMap_ptr
Array< WsvRecord > wsv_data_type
Index depth(Index i) const
Return scoping level of the given WSV.
void set_empty(Index i)
Delete WSV.
std::shared_ptr< void > operator[](Index i)
Retrieve a pointer to the given WSV.
WorkspaceBorrowGuard borrow(Index i, T &wsv)
Push a new WSV onto its stack.
void push_move(Index i, std::shared_ptr< T > &&wsv_ptr)
Move a WSV onto its stack.
This class contains all static information for one workspace variable.
INDEX Index
The type to use for all integer numbers and indices.
~WorkspaceBorrowGuard() noexcept
std::shared_ptr< void > wsv
std::shared_ptr< T > get_shallow_copy(const T &x)
stack< WorkspaceVariableStruct, std::vector< WorkspaceVariableStruct > > WorkspaceVariable
Auxiliary header stuff related to workspace variable groups.