ARTS  2.0.49
groups.cc
Go to the documentation of this file.
1 /* Copyright (C) 2000-2008
2  Stefan Buehler <sbuehler@ltu.se>
3  Patrick Eriksson <patrick.eriksson@chalmers.se>
4 
5  This program is free software; you can redistribute it and/or modify it
6  under the terms of the GNU General Public License as published by the
7  Free Software Foundation; either version 2, or (at your option) any
8  later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18  USA. */
19 
31 #include <map>
32 #include "arts.h"
33 #include "array.h"
34 #include "mystring.h"
35 #include "wsv_aux.h"
36 
37 
41 map<String, Index> WsvGroupMap;
42 
45 
46 
48 {
49  valid_keyword_groups.resize(0);
50  valid_keyword_groups.push_back(get_wsv_group_id("String"));
51  valid_keyword_groups.push_back(get_wsv_group_id("Index"));
52  valid_keyword_groups.push_back(get_wsv_group_id("Numeric"));
53  valid_keyword_groups.push_back(get_wsv_group_id("ArrayOfString"));
54  valid_keyword_groups.push_back(get_wsv_group_id("ArrayOfIndex"));
55  valid_keyword_groups.push_back(get_wsv_group_id("Vector"));
56 }
57 
58 
60 {
61  for ( Index i=0 ; i<wsv_group_names.nelem() ; ++i )
62  {
64  }
65 }
66 
67 
69 
81 {
82 
83  //--------------------< Build the group names array >--------------------
84  // Initialize to empty, just in case.
85  wsv_group_names.resize(0);
86 
87  wsv_group_names.push_back("Any");
88  wsv_group_names.push_back("Index");
89  wsv_group_names.push_back("Numeric");
90  wsv_group_names.push_back("String");
91  wsv_group_names.push_back("Vector");
92  wsv_group_names.push_back("Matrix");
93  wsv_group_names.push_back("Sparse");
94  wsv_group_names.push_back("Tensor3");
95  wsv_group_names.push_back("Tensor4");
96  wsv_group_names.push_back("Tensor5");
97  wsv_group_names.push_back("Tensor6");
98  wsv_group_names.push_back("Tensor7");
99  wsv_group_names.push_back("Timer");
100  wsv_group_names.push_back("Verbosity");
101  wsv_group_names.push_back("ArrayOfIndex");
102  wsv_group_names.push_back("ArrayOfArrayOfIndex");
103  wsv_group_names.push_back("ArrayOfString");
104  wsv_group_names.push_back("ArrayOfVector");
105  wsv_group_names.push_back("ArrayOfMatrix");
106  wsv_group_names.push_back("ArrayOfArrayOfMatrix");
107  wsv_group_names.push_back("ArrayOfSparse");
108  wsv_group_names.push_back("ArrayOfTensor3");
109  wsv_group_names.push_back("ArrayOfArrayOfTensor3");
110  wsv_group_names.push_back("ArrayOfTensor4");
111  wsv_group_names.push_back("ArrayOfTensor6");
112  wsv_group_names.push_back("ArrayOfTensor7");
113  wsv_group_names.push_back("ArrayOfArrayOfTensor6");
114  wsv_group_names.push_back("ArrayOfLineRecord");
115  wsv_group_names.push_back("ArrayOfArrayOfLineRecord");
116  wsv_group_names.push_back("ArrayOfLineshapeSpec");
117  wsv_group_names.push_back("ArrayOfArrayOfSpeciesTag");
118  wsv_group_names.push_back("Ppath");
119  wsv_group_names.push_back("Agenda");
120  wsv_group_names.push_back("GridPos");
121  wsv_group_names.push_back("GasAbsLookup");
122  wsv_group_names.push_back("SingleScatteringData");
123  wsv_group_names.push_back("ArrayOfSingleScatteringData");
124  wsv_group_names.push_back("ScatteringMetaData");
125  wsv_group_names.push_back("ArrayOfScatteringMetaData");
126  wsv_group_names.push_back("GriddedField1");
127  wsv_group_names.push_back("GriddedField2");
128  wsv_group_names.push_back("GriddedField3");
129  wsv_group_names.push_back("GriddedField4");
130  wsv_group_names.push_back("ArrayOfGriddedField1");
131  wsv_group_names.push_back("ArrayOfGriddedField2");
132  wsv_group_names.push_back("ArrayOfGriddedField3");
133  wsv_group_names.push_back("ArrayOfGriddedField4");
134  wsv_group_names.push_back("ArrayOfArrayOfGriddedField1");
135  wsv_group_names.push_back("ArrayOfArrayOfGriddedField3");
136  wsv_group_names.push_back("ArrayOfRetrievalQuantity");
137  wsv_group_names.push_back("MCAntenna");
138 
141 }
142 
143 
144 bool is_valid_keyword_group(const Index group)
145 {
146  for (Index i = 0; i < valid_keyword_groups.nelem(); i++)
147  {
148  if (valid_keyword_groups[i] == group)
149  return true;
150  }
151 
152  return false;
153 }
154 
156 {
157  ids.resize(0);
158 
159  Index pos = 0;
160  while (pos < name.nelem())
161  {
162  switch (name[pos])
163  {
164  case ' ':
165  case '\r':
166  case '\t':
167  case '#':
168  name.erase(pos, 1);
169  break;
170  default:
171  pos++;
172  }
173  }
174 
175  pos = 0;
176  Index prev = 0;
177  while (pos < name.nelem())
178  {
179  while (pos < name.nelem() && name[pos] != ',') pos ++;
180  Index id = get_wsv_group_id (name.substr(prev, pos-prev));
181  if (id == -1)
182  {
183  ids.resize(0);
184  return;
185  }
186  ids.push_back (id);
187  pos++;
188  prev = pos;
189  }
190 }
191 
193 {
194  map<String, Index>::const_iterator it = WsvGroupMap.find (name);
195  if (it == WsvGroupMap.end())
196  return -1;
197  else
198  return it->second;
199 }
200 
202 {
203  String arraygroups;
204 
205  bool first = true;
206  for (Index i = 0; i < wsv_group_names.nelem(); i++)
207  {
208  if (wsv_group_names[i].substr(0, String("ArrayOf").length()) == "ArrayOf")
209  {
210  if (!first) arraygroups += ", "; else first = false;
211  arraygroups += wsv_group_names[i];
212  }
213  }
214  return arraygroups;
215 }
216 
get_array_groups_as_string
String get_array_groups_as_string()
Definition: groups.cc:201
array.h
This file contains the definition of Array.
define_wsv_group_names
void define_wsv_group_names()
Define the array of workspace variable group names.
Definition: groups.cc:80
define_valid_keyword_groups
void define_valid_keyword_groups()
Definition: groups.cc:47
Array
This can be used to make arrays out of anything.
Definition: array.h:103
WsvGroupMap
map< String, Index > WsvGroupMap
Definition: groups.cc:41
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:62
define_wsv_group_map
void define_wsv_group_map()
Definition: groups.cc:59
get_wsv_group_ids
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Definition: groups.cc:155
wsv_group_names
ArrayOfString wsv_group_names
Definition: groups.cc:40
is_valid_keyword_group
bool is_valid_keyword_group(const Index group)
Definition: groups.cc:144
my_basic_string::nelem
Index nelem() const
Number of elements.
Definition: mystring.h:242
String
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:305
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
get_wsv_group_id
Index get_wsv_group_id(const String &name)
Definition: groups.cc:192
valid_keyword_groups
ArrayOfIndex valid_keyword_groups
Definition: groups.cc:44
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:172
wsv_aux.h
Auxiliary header stuff related to workspace variable groups.
mystring.h
This file contains the definition of String, the ARTS string class.
arts.h
The global header file for ARTS.