ARTS  2.4.0(git:4fb77825)
workspace_memory_handler.h
Go to the documentation of this file.
1 /* Copyright (C) 2020 Simon Pfreundschuh <simon.pfreundschuh@chalmers.se>
2 
3  This program is free software; you can redistribute it and/or
4  modify it under the terms of the GNU General Public License as
5  published by the Free Software Foundation; either version 2 of the
6  License, or (at your option) any later version.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
16  USA. */
17 
24 #ifndef __ARTS_WORKSPACE_MEMORY_HANDLER__
25 #define __ARTS_WORKSPACE_MEMORY_HANDLER__
26 #include "arts.h"
27 #include <vector>
28 
37  public:
39 
44  void *allocate(Index group_index) { return allocation_ptrs_[group_index](); }
45 
53  void deallocate(Index group_index, void *ptr) {
54  deallocation_ptrs_[group_index](ptr);
55  }
56 
62  void *duplicate(Index group_index, void *ptr) {
63  return duplication_ptrs_[group_index](ptr);
64  }
65 
66  void initialize();
67 
68  private:
69  std::vector<void *(*)()> allocation_ptrs_;
70  std::vector<void (*)(void *)> deallocation_ptrs_;
71  std::vector<void *(*)(void *)> duplication_ptrs_;
72 };
73 #endif
WorkspaceMemoryHandler
Handling of workspace memory.
Definition: workspace_memory_handler.h:36
WorkspaceMemoryHandler::initialize
void initialize()
Initialization dispatch functions.
Definition: workspace_memory_handler.cc:838
WorkspaceMemoryHandler::deallocation_ptrs_
std::vector< void(*)(void *)> deallocation_ptrs_
Definition: workspace_memory_handler.h:70
WorkspaceMemoryHandler::duplicate
void * duplicate(Index group_index, void *ptr)
Duplicate workspace variable of given group.
Definition: workspace_memory_handler.h:62
WorkspaceMemoryHandler::deallocate
void deallocate(Index group_index, void *ptr)
Getaway function to call the deallocation function for the WSV group with the given Index.
Definition: workspace_memory_handler.h:53
WorkspaceMemoryHandler::WorkspaceMemoryHandler
WorkspaceMemoryHandler()
Definition: workspace_memory_handler.h:38
WorkspaceMemoryHandler::allocate
void * allocate(Index group_index)
Allocate workspace WSV of given group.
Definition: workspace_memory_handler.h:44
WorkspaceMemoryHandler::duplication_ptrs_
std::vector< void *(*)(void *)> duplication_ptrs_
Definition: workspace_memory_handler.h:71
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
WorkspaceMemoryHandler::allocation_ptrs_
std::vector< void *(*)()> allocation_ptrs_
Definition: workspace_memory_handler.h:69
arts.h
The global header file for ARTS.