00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00030 #include "arts.h"
00031 #include "matpackI.h"
00032 #include "array.h"
00033 #include "file.h"
00034 #include "absorption.h"
00035 #include "los.h"
00036 #include "auto_wsv_groups.h"
00037 #include "wsv_aux.h"
00038 #include "mystring.h"
00039 
00040 int main()
00041 {
00042   try
00043     {
00044       
00045       define_wsv_data();
00046       define_wsv_group_names();
00047 
00048       
00049       extern const Array<WsvRecord> wsv_data;
00050       extern const ArrayOfString wsv_group_names;
00051 
00052       const Index n_wsv = wsv_data.nelem();
00053 
00054       
00055 
00056       ofstream ofs,ofs2;
00057       open_output_file(ofs,"auto_wsv.h");
00058       open_output_file(ofs2,"auto_wsv.txt");
00059 
00060       ofs << "/*! \\file  auto_wsv.h\n"
00061           << "    \\brief Declares the enum type that acts as a\n"
00062           << "    handle for workspace variables. Also declares the\n"
00063           << "    workspace itself.\n\n"
00064 
00065           << "    This file was generated automatically by make_auto_wsv_h.cc.\n"
00066 
00067           << "    <b>DO NOT EDIT!</b>\n\n"
00068 
00069           << "    \\date "
00070           << __DATE__ << ", "
00071           << __TIME__ << " */\n\n";
00072 
00073       ofs << "#ifndef auto_wsv_h\n";
00074       ofs << "#define auto_wsv_h\n\n";
00075 
00076       ofs << "#include \"absorption.h\"\n"
00077           << "#include \"los.h\"\n\n";
00078       
00079       ofs << "/*! This is only used for a consistency check. You can get the\n"
00080           << "    number of workspace variables from wsv_data.nelem(). */\n"
00081           << "#define N_WSV " << n_wsv << "\n\n";
00082 
00083       ofs << "enum WsvHandle{\n";
00084       for (Index i=0; i<n_wsv-1; ++i)
00085         {
00086           ofs << "  " << wsv_data[i].Name() << "_,\n";
00087         }
00088       ofs << "  " << wsv_data[n_wsv-1].Name() << "_\n";
00089       ofs << "};\n\n";
00090 
00091       
00092 
00093       ofs << "/** The declaration of the (great) workspace. */\n";
00094       ofs << "class WorkSpace {\n"
00095           << "public:\n";
00096       for (Index i=0; i<n_wsv; ++i)
00097         {
00098           
00099           
00100           
00101           
00102           {
00103             
00104             String s = wsv_data[i].Description();
00105 
00106             
00107             replace_all(s,"\n","\n    "); 
00108 
00109             
00110             
00111             
00112             
00113             Index full_stop = s.find('.');
00114 
00115             
00116             
00117             
00118             
00119             
00120             if ( full_stop==s.npos )
00121               full_stop = s.nelem();
00122             else
00123               full_stop += 1;
00124 
00125             String first(s,0,full_stop);
00126 
00127             
00128             
00129             String rest = "";
00130 
00131             if ( full_stop!=s.nelem() )
00132               rest = String(s,full_stop);
00133 
00134             
00135             while (
00136                    0 < rest.nelem() &&
00137                    ( ' ' == rest[0] || '\n' == rest[0] )
00138                    )
00139               {
00140                 rest.erase(0,1);
00141               }
00142 
00143             ofs << "/** " << first;
00144             if ( 0==rest.nelem() )
00145               {
00146                 ofs << " */\n";
00147               }
00148             else
00149               {
00150                 ofs << '\n'
00151                     << "    \\verbatim\n"
00152                     << "    " << rest << '\n'
00153                     << "    \\endverbatim */\n";
00154               }
00155           }
00156 
00157           ofs << "  "
00158               << wsv_group_names[wsv_data[i].Group()]
00159               << " "
00160               << wsv_data[i].Name() << ";\n";
00161 
00162         }
00163       ofs << "};\n\n";
00164 
00165       ofs << "#endif  // auto_wsv_h\n";
00166 
00167       
00168       
00169       
00170       for ( Index i=0; i<n_wsv; i++ )
00171       {
00172         ofs2 << "VARIABLE : " << wsv_data[i].Name() << "\n"
00173              << "DATA TYPE: " << wsv_group_names[wsv_data[i].Group()] <<"\n"
00174              << "DESCRIPTION:\n" 
00175              << wsv_data[i].Description() << "\n\n";
00176       }
00177 
00178     }
00179   catch (runtime_error x)
00180     {
00181       cout << "Something went wrong. Message text:\n";
00182       cout << x.what() << '\n';
00183       return 1;
00184     }
00185 
00186   return 0;
00187 }
00188