ARTS  1.0.222
methods_aux.cc
Go to the documentation of this file.
1 /* Copyright (C) 2000, 2001 Stefan Buehler <sbuehler@uni-bremen.de>
2 
3  This program is free software; you can redistribute it and/or modify it
4  under the terms of the GNU General Public License as published by the
5  Free Software Foundation; either version 2, or (at your option) any
6  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 
30 #include "arts.h"
31 #include <map>
32 #include "make_array.h"
33 #include "auto_wsv.h"
34 #include "methods.h"
35 #include "wsv_aux.h"
36 
38 {
39  extern const Array<MdRecord> md_data;
40  extern std::map<String, Index> MdMap;
41 
42  for ( Index i=0 ; i<md_data.nelem() ; ++i)
43  {
44  MdMap[md_data[i].Name()] = i;
45  }
46 }
47 
48 
49 ostream& MdRecord::PrintTemplate(ostream& os,
50  bool show_description) const
51 {
52  extern const ArrayOfString wsv_group_names;
53 
54  if (show_description)
55  {
56  // FIXME: Print description String!
57  }
58 
59  os << Name();
60 
61  // Is this a generic method? -- Then we need round braces.
62  if ( 0 != GOutput().nelem()+GInput().nelem() )
63  {
64  // First entry needs to comma before:
65  bool first=true;
66 
67  os << '(';
68 
69  for (Index i=0; i<GOutput().nelem(); ++i)
70  {
71  if (first) first=false;
72  else os << ",\n";
73 
74  os << wsv_group_names[GOutput()[i]];
75  }
76 
77  for (Index i=0; i<GInput().nelem(); ++i)
78  {
79  if (first) first=false;
80  else os << ",\n";
81 
82  os << wsv_group_names[GInput()[i]];
83  }
84 
85  os << ')';
86  }
87 
88  // Now the keywords:
89 
90  os << '{';
91 
92  // Determine the length of the longest keyword:
93  Index maxsize = 0;
94  for (Index i=0; i<Keywords().nelem(); ++i)
95  if ( Keywords()[i].nelem() > maxsize )
96  maxsize = Keywords()[i].nelem();
97 
98 
99  for (Index i=0; i<Keywords().nelem(); ++i)
100  {
101  os << "\t" << setw((int)maxsize)
102  << Keywords()[i] << " = \n";
103  }
104 
105  os << '}';
106 
107  return os;
108 }
109 
110 ostream& operator<<(ostream& os, const MdRecord& mdr)
111 {
112  extern const Array<WsvRecord> wsv_data;
113  extern const ArrayOfString wsv_group_names;
114  extern const String TokValTypeName[];
115  bool first;
116 
117  os << "\n*--------------------------------------------------------------*\n"
118  << "Workspace method = " << mdr.Name() <<
119  "\n----------------------------------------------------------------\n"
120  << "\n" << mdr.Description() << "\n" <<
121  "\n----------------------------------------------------------------\n";
122 
123  // os << "\n-----\nName = " << mdr.Name() << '\n\n'
124  // << "Description =\n" << mdr.Description() << "\n\n";
125 
126  // Output:
127  first = true;
128  os << "Output = ";
129  for ( Index i=0; i<mdr.Output().nelem(); ++i )
130  {
131  if (first) first=false;
132  else os << ", ";
133 
134  os << wsv_data[mdr.Output()[i]].Name();
135  }
136  os << '\n';
137 
138  // Input:
139  first = true;
140  os << "Input = ";
141  for ( Index i=0; i<mdr.Input().nelem(); ++i )
142  {
143  if (first) first=false;
144  else os << ", ";
145 
146  os << wsv_data[mdr.Input()[i]].Name();
147  }
148  os << '\n';
149 
150  // GOutput:
151  first = true;
152  os << "GOutput = ";
153  for ( Index i=0; i<mdr.GOutput().nelem(); ++i )
154  {
155  if (first) first=false;
156  else os << ", ";
157 
158  os << wsv_group_names[mdr.GOutput()[i]];
159  }
160  os << '\n';
161 
162  // GInput:
163  first = true;
164  os << "GInput = ";
165  for ( Index i=0; i<mdr.GInput().nelem(); ++i )
166  {
167  if (first) first=false;
168  else os << ", ";
169 
170  os << wsv_group_names[mdr.GInput()[i]];
171  }
172  os << '\n';
173 
174  // Keywords:
175  first = true;
176  os << "Keywords = ";
177  for ( Index i=0; i<mdr.Keywords().nelem(); ++i )
178  {
179  if (first) first=false;
180  else os << ", ";
181 
182  os << mdr.Keywords()[i];
183  }
184  os << '\n';
185 
186  // Types:
187  first = true;
188  os << "Types = ";
189  for ( Index i=0; i<mdr.Types().nelem(); ++i )
190  {
191  if (first) first=false;
192  else os << ", ";
193 
194  os << TokValTypeName[mdr.Types()[i]];
195  }
196  os << "\n*--------------------------------------------------------------*\n";
197 
198  return os;
199 }
200 
MdRecord::Types
const Array< TokValType > & Types() const
Definition: methods.h:85
first
Numeric first(ConstVectorView x)
Gives the first value of a vector.
Definition: math_funcs.cc:70
MdRecord::Output
const ArrayOfIndex & Output() const
Definition: methods.h:80
wsv_data
const Array< WsvRecord > wsv_data
Definition: workspace.cc:42
MdRecord::Keywords
const Array< String > & Keywords() const
Definition: methods.h:84
MdRecord::Input
const ArrayOfIndex & Input() const
Definition: methods.h:81
Array
This can be used to make arrays out of anything.
Definition: array.h:48
MdMap
std::map< String, Index > MdMap
The map associated with md_data.
Definition: globals_2.cc:56
my_basic_string< char >
wsv_group_names
ArrayOfString wsv_group_names
Definition: groups.cc:36
make_array.h
Implements the class MakeArray, which is a derived class of Array, allowing explicit initialization.
MdRecord::Name
const String & Name() const
Definition: methods.h:78
MdRecord::GInput
const ArrayOfIndex & GInput() const
Definition: methods.h:83
md_data
Array< MdRecord > md_data
The lookup information for the workspace methods.
Definition: globals_2.cc:53
operator<<
ostream & operator<<(ostream &os, const MdRecord &mdr)
Output operator for MdRecord.
Definition: methods_aux.cc:110
MdRecord::GOutput
const ArrayOfIndex & GOutput() const
Definition: methods.h:82
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: arts.h:153
MdRecord
This class contains all information for one workspace method.
Definition: methods.h:35
TokValTypeName
String TokValTypeName[7]
The name of the type associated with the different tokens.
Definition: token.cc:26
MdRecord::PrintTemplate
ostream & PrintTemplate(ostream &os, bool show_description=true) const
Print method template for the control file.
Definition: methods_aux.cc:49
MdRecord::Description
const String & Description() const
Definition: methods.h:79
define_md_map
void define_md_map()
Define MdMap.
Definition: methods_aux.cc:37
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:115
methods.h
Declaration of the class MdRecord.
wsv_aux.h
Auxiliary header stuff related to workspace variable groups.
auto_wsv.h
Declares the enum type that acts as a handle for workspace variables. Also declares the workspace its...
arts.h
The global header file for ARTS.