ARTS  1.0.222
make_auto_wsv_pointers_cc.cc
Go to the documentation of this file.
1 /* Copyright (C) 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 
18 #include "arts.h"
19 #include "matpackI.h"
20 #include "array.h"
21 #include "file.h"
22 #include "auto_wsv_groups.h"
23 #include "wsv_aux.h"
24 
25 int main()
26 {
27  try
28  {
29  // We need group names and WSV data:
30  extern const ArrayOfString wsv_group_names;
31  extern const Array<WsvRecord> wsv_data;
32 
33  // Initialize:
36 
37  const Index n_wsv = wsv_data.nelem();
38 
39  ofstream ofs;
40  open_output_file(ofs,"auto_wsv_pointers.cc");
41 
42  ofs << "/** \\file auto_wsv_pointers.cc\n"
43  << " Defines the smart pointers that are used by\n"
44  << " the engine to access workspace variables.\n\n"
45 
46  << " This file was generated automatically by make_auto_wsv_pointers_cc.cc.\n"
47 
48  << " <b>DO NOT EDIT!</b>\n\n"
49 
50  << " \\date "
51  << __DATE__ << ", "
52  << __TIME__ << " */\n\n";
53 
54  ofs << "#include \"arts.h\"\n"
55  << "//#include \"matpackI.h\"\n"
56  << "#include \"array.h\"\n"
57  << "#include \"auto_wsv_groups.h\"\n"
58  << "#include \"wsv_aux.h\"\n"
59  << "#include \"auto_wsv.h\"\n\n";
60 
61  ofs << "/** The array of WSV pointers.\n"
62  << " This can be used to access a WSV by its index. */\n"
63  << "Array<WsvP*> wsv_pointers;\n\n";
64 
65  ofs << "void define_wsv_pointers(Array<WsvP*>& wsv_pointers,\n"
66  << " WorkSpace& workspace)\n"
67  << "{\n\n";
68 
69  // Now write the pointers one by one:
70  for (Index i=0; i<n_wsv; ++i)
71  {
72  const WsvRecord& wr = wsv_data[i];
73 
74  ofs << " {\n"
75  << " static WsvPointer<"
76  << wsv_group_names[wr.Group()]
77  << "> p(&workspace."
78  << wr.Name()
79  << ");\n";
80 
81  ofs << " wsv_pointers.push_back(&p);\n"
82  << " }\n\n";
83  }
84 
85  ofs << "};\n";
86 
87  }
88  catch (runtime_error x)
89  {
90  cout << "Something went wrong. Message text:\n";
91  cout << x.what() << '\n';
92  return 1;
93  }
94 
95  return 0;
96 }
auto_wsv_groups.h
Defines the enum type that acts as a handle for workspace variables groups.
define_wsv_data
void define_wsv_data()
Define the lookup data for the workspace variables.
Definition: workspace.cc:44
wsv_data
const Array< WsvRecord > wsv_data
Definition: workspace.cc:42
array.h
This file contains the definition of Array.
matpackI.h
Array< String >
WsvRecord::Group
Index Group() const
The wsv group to which this variable belongs.
Definition: wsv_aux.h:84
WsvRecord::Name
const String & Name() const
Name of this workspace variable.
Definition: wsv_aux.h:80
wsv_group_names
ArrayOfString wsv_group_names
Definition: groups.cc:36
define_wsv_group_names
void define_wsv_group_names()
Define the array of workspace variable group names.
Definition: groups.cc:51
main
int main()
Definition: make_auto_wsv_pointers_cc.cc:25
open_output_file
void open_output_file(ofstream &file, const String &name)
Open a file for writing.
Definition: file.cc:91
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: arts.h:153
WsvRecord
This class contains all static information for one workspace variable.
Definition: wsv_aux.h:60
file.h
This file contains basic functions to handle ASCII and binary (HDF) data files.
wsv_aux.h
Auxiliary header stuff related to workspace variable groups.
arts.h
The global header file for ARTS.