ARTS  2.2.66
workspace_ng.h
Go to the documentation of this file.
1 /* Copyright (C) 2004-2012 Oliver Lemke <olemke@core-dump.info>
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 
19 // File description
21 
32 #ifndef WORKSPACE_NG_INCLUDED
33 #define WORKSPACE_NG_INCLUDED
34 
35 #include <stack>
36 #include <map>
37 
38 class Workspace;
39 
40 #include "array.h"
41 #include "wsv_aux.h"
42 
44 
47 class Workspace {
48 private:
49  struct WsvStruct {
50  void *wsv;
53  };
54 
57 
58 public:
59 #ifndef NDEBUG
62 #endif
63 
65 
67  static map<String, Index> WsvMap;
68 
69  Workspace ();
70  Workspace (const Workspace& workspace);
71  virtual ~Workspace ();
72 
73  static void define_wsv_data();
74  static void define_wsv_map();
75  static Index add_wsv (const WsvRecord& wsv);
76 
77  void del (Index i);
78 
79  void duplicate (Index i);
80 
81  void initialize ();
82 
84  bool is_initialized (Index i) {
85  return ((ws[i].size () != 0)
86  && (ws[i].top()->initialized == true)); }
87 
88  void *pop (Index i);
89 
90  void pop_free (Index i);
91 
92  void push (Index i, void *wsv);
93 
94  void push_uninitialized (Index i, void *wsv);
95 
96  Index nelem () {return ws.nelem ();}
97 
98  void *operator[](Index i);
99 };
100 
101 
103 
109 template <typename OutputStream> void
110 PrintWsvName (OutputStream& outstream, Index i)
111 {
112  outstream << Workspace::wsv_data[i].Name () << "(" << i << ") ";
113 }
114 
115 
117 
124 template <typename OutputStream, typename Container> void
125 PrintWsvNames (OutputStream& outstream, const Container& container)
126 {
127  for (typename Container::const_iterator it = container.begin ();
128  it != container.end (); it++ )
129  {
130  PrintWsvName (outstream, *it);
131  }
132 
133 }
134 
135 
136 #endif /* WORKSPACE_NG_INCLUDED */
137 
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
static Array< WsvRecord > wsv_data
Definition: workspace_ng.h:64
Index nelem() const
Number of elements.
Definition: array.h:176
void initialize()
void duplicate(Index i)
Duplicate WSV.
Definition: workspace_ng.cc:96
void pop_free(Index i)
Pop the topmost wsv from its stack and free its memory.
bool is_initialized(Index i)
Checks existence of the given WSV.
Definition: workspace_ng.h:84
void PrintWsvNames(OutputStream &outstream, const Container &container)
Print list of WSV names to output stream.
Definition: workspace_ng.h:125
This file contains the definition of Array.
String context
Only for debugging.
Definition: workspace_ng.h:61
virtual ~Workspace()
Destruct the workspace.
static void define_wsv_data()
Definition: workspace.cc:50
void * operator[](Index i)
Retrieve pointer to the given WSV.
Index nelem()
Definition: workspace_ng.h:96
void PrintWsvName(OutputStream &outstream, Index i)
Print WSV name to output stream.
Definition: workspace_ng.h:110
void * pop(Index i)
Pop the topmost wsv from its stack.
Workspace()
Construct a new workspace.
Definition: workspace_ng.cc:45
This can be used to make arrays out of anything.
Definition: array.h:40
void push(Index i, void *wsv)
Push a new wsv onto its stack.
static map< String, Index > WsvMap
Definition: workspace_ng.h:67
static Index add_wsv(const WsvRecord &wsv)
Definition: workspace_ng.cc:62
void push_uninitialized(Index i, void *wsv)
Push a new wsv onto its stack but mark it as uninitialized.
Workspace class.
Definition: workspace_ng.h:47
static void define_wsv_map()
Definition: workspace_ng.cc:53
Array< stack< WsvStruct * > > ws
Workspace variable container.
Definition: workspace_ng.h:56
This class contains all static information for one workspace variable.
Definition: wsv_aux.h:54
void del(Index i)
Delete WSV.
Definition: workspace_ng.cc:76
Auxiliary header stuff related to workspace variable groups.