00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <stdexcept>
00019 #include "arts.h"
00020 #include "matpackI.h"
00021 #include "file.h"
00022 #include "array.h"
00023
00024 int main()
00025 {
00026 try
00027 {
00028
00029 define_wsv_group_names();
00030
00031
00032 extern const ArrayOfString wsv_group_names;
00033
00034 const Index n_wsv_groups = wsv_group_names.nelem();
00035
00036 ofstream ofs;
00037 open_output_file(ofs,"auto_wsv_groups.h");
00038
00039 ofs << "/*! \\file auto_wsv_groups.h\n"
00040 << " \\brief Defines the enum type that acts as a\n"
00041 << " handle for workspace variables groups.\n\n"
00042
00043 << " Also defined here is a special pointer class that can hold\n"
00044 << " a pointer to any workspace variable.\n\n"
00045
00046 << " This file was generated automatically by make_auto_wsv_groups_h.cc.\n"
00047
00048 << " <b>DO NOT EDIT!</b>\n\n"
00049
00050 << " \\date "
00051 << __DATE__ << ", "
00052 << __TIME__ << " */\n\n";
00053
00054 ofs << "#ifndef auto_wsv_groups_h\n"
00055 << "#define auto_wsv_groups_h\n\n";
00056
00057 ofs << "#include \"los.h\"\n"
00058 << "#include \"absorption.h\"\n\n";
00059
00060 ofs << "/*! This is only used for a consistency check. You can get the\n"
00061 << " number of groups from wsv_group_names.nelem(). */\n"
00062 << "#define N_WSV_GROUPS " << n_wsv_groups << "\n\n";
00063
00064 ofs << "/*! The enum type that identifies wsv groups.\n"
00065 << " This is used to group workspace variables of the same type\n"
00066 << " together, so that generic methods can operate on any of them. */\n";
00067
00068 ofs << "enum WsvGroup{\n";
00069
00070 for (Index i=0; i<n_wsv_groups; ++i)
00071 {
00072 ofs << " " << wsv_group_names[i] << "_,\n";
00073 }
00074 ofs << "};\n\n";
00075
00076
00077
00078
00079 ofs << "/*! Base class for the different Wsv pointers.\n"
00080 << " This contains a virtual function for the\n"
00081 << " conversion operator for each group.\n\n"
00082 << " \\author Stefan Buehler */\n";
00083
00084 ofs << "class WsvP {\n"
00085 << "public:\n";
00086 for (Index i=0; i<n_wsv_groups; ++i)
00087 {
00088 ofs << " virtual operator "
00089 << wsv_group_names[i]
00090 << "*(){safety();return NULL;};\n";
00091 }
00092
00093 ofs << "\nvirtual ~WsvP(){};\n";
00094
00095 ofs << "\nprivate:\n";
00096
00097 ofs << "/*! Safety check. This is called by all the virtual conversion\n"
00098 << " operators. It just stops the program with an error message. This\n"
00099 << " should never happen, because conversion should only be attempted\n"
00100 << " to the correct type, for which an overloaded conversion operator\n"
00101 << " exists. */\n";
00102
00103 ofs << " void safety() {\n"
00104 << " cerr << \"Internal error: Tried to convert a WsvP \"\n"
00105 << " << \"pointer to the wrong type.\\n\";\n"
00106 << " exit(1);\n"
00107 << " };\n";
00108
00109 ofs << "};\n\n";
00110
00111
00112 ofs << "#endif // auto_wsv_groups_h\n";
00113 }
00114 catch (runtime_error x)
00115 {
00116 cout << "Something went wrong. Message text:\n";
00117 cout << x.what() << '\n';
00118 return 1;
00119 }
00120
00121 return 0;
00122 }