ARTS  2.2.66
methods_aux.cc
Go to the documentation of this file.
1 /* Copyright (C) 2000-2012 Stefan Buehler <sbuehler@ltu.se>
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 "methods.h"
34 #include "wsv_aux.h"
35 #include "workspace_ng.h"
36 
37 namespace global_data {
39 map<String, Index> MdMap;
41 map<String, Index> MdRawMap;
43 
49 
50 extern const Array<MdRecord> md_data_raw;
51 extern const ArrayOfString wsv_group_names;
52 }
53 
54 void limit_line_length( ostream& os, ostringstream& curline,
55  ostringstream& token, const String& indent,
56  size_t linelen);
57 
59 
65 MdRecord::MdRecord(const char name[],
66  const char description[],
67  const MakeArray<String>& authors,
68  const MakeArray<String>& output,
69  const MakeArray<String>& gout,
70  const MakeArray<String>& gouttype,
71  const MakeArray<String>& goutdesc,
72  const MakeArray<String>& input,
73  const MakeArray<String>& gin,
74  const MakeArray<String>& gintype,
75  const MakeArray<String>& gindefault,
76  const MakeArray<String>& gindesc,
77  bool set_method,
78  bool agenda_method,
79  bool uses_templates,
80  bool pass_workspace,
81  bool pass_wsv_names ) :
82  mname( name ),
83  mdescription( description ),
84  mauthors( authors ),
85  moutput( 0 ),
86  mgout( gout ),
87  mgouttype( 0 ),
88  mgoutdesc( goutdesc ),
89  minput( 0 ),
90  mgin( gin ),
91  mgintype( 0 ),
92  mgindefault( gindefault ),
93  mgindesc( gindesc ),
94  mset_method( set_method ),
95  magenda_method( agenda_method ),
96  msupergeneric( false ),
97  muses_templates( uses_templates ),
98  mpass_workspace( pass_workspace ),
99  mpass_wsv_names( pass_wsv_names ),
100  mactual_groups( "" )
101 {
102  // Initializing the various arrays with input data should now
103  // work correctly.
104 
105  // Generic variable names, types and defaults must have the same number of
106  // elements. (Defaults specifies the default values associated with each
107  // generic input.)
108  assert( mgout.nelem() == gouttype.nelem() );
109  assert( mgout.nelem() == goutdesc.nelem() );
110  assert( mgin.nelem() == mgindefault.nelem() );
111  assert( mgin.nelem() == gintype.nelem() );
112  assert( mgin.nelem() == gindesc.nelem() );
113 
114  // Map the WSV names to indexes
115  moutput.resize(output.nelem());
116  for ( Index j=0; j<output.nelem(); ++j )
117  {
118  moutput[j] = get_wsv_id (output[j]);
119  if (moutput[j] == -1)
120  {
121  ostringstream os;
122  os << "Unknown WSV " << output[j] << " for output "
123  << "in WSM " << mname;
124  throw runtime_error( os.str() );
125  }
126  }
127 
128  minput.resize(input.nelem());
129  for ( Index j=0; j<input.nelem(); ++j )
130  {
131  minput[j] = get_wsv_id (input[j]);
132  if (minput[j] == -1)
133  {
134  ostringstream os;
135  os << "Unknown WSV " << input[j] << " for input "
136  << "in WSM " << mname;
137  throw runtime_error( os.str() );
138  }
139  }
140 
141  // Map the group names to groups' indexes
142  mgoutspectype.resize(gouttype.nelem());
143  mgouttype.resize(gouttype.nelem());
144  for ( Index j=0; j<gouttype.nelem(); ++j )
145  {
146  ArrayOfIndex types;
147  get_wsv_group_ids (types, gouttype[j]);
148 
149  if (types.nelem() == 1)
150  {
151  mgouttype[j] = types[0];
152  mgoutspectype[j].resize(0);
153  if (types[0] == get_wsv_group_id("Any") && !muses_templates)
154  {
155  ostringstream os;
156  os << "WSM " << mname << " takes \"Any\" as input and\n"
157  << "therefore must be implemented as a template function.\n"
158  << "Pass USES_TEMPLATES(true) in methods.cc!";
159  throw runtime_error(os.str());
160  }
161  }
162  else if (types.nelem() > 1)
163  {
164  mgouttype[j] = get_wsv_group_id ("Any");
165  mgoutspectype[j] = types;
166  }
167  else
168  {
169  ostringstream os;
170  os << "Unknown WSV Group " << gouttype[j] << " for generic output "
171  << "in WSM " << mname;
172  throw runtime_error( os.str() );
173  }
174 
175  }
176 
177  mginspectype.resize(gintype.nelem());
178  mgintype.resize(gintype.nelem());
179  for ( Index j=0; j<gintype.nelem(); ++j )
180  {
181  ArrayOfIndex types;
182  get_wsv_group_ids (types, gintype[j]);
183 
184  if (types.nelem() == 1)
185  {
186  mgintype[j] = get_wsv_group_id (gintype[j]);
187  mginspectype[j].resize(0);
188  if (types[0] == get_wsv_group_id("Any") && !muses_templates)
189  {
190  ostringstream os;
191  os << "WSM " << mname << " defines \"Any\" as output and\n"
192  << "therefore must be implemented as a template function.\n"
193  << "Pass USES_TEMPLATES(true) in methods.cc!";
194  throw runtime_error(os.str());
195  }
196  }
197  else if (types.nelem() > 1)
198  {
199  mgintype[j] = get_wsv_group_id ("Any");
200  mginspectype[j] = types;
201  }
202  else
203  {
204  ostringstream os;
205  os << "Unknown WSV Group " << gintype[j] << " for generic input "
206  << "in WSM " << mname;
207  throw runtime_error( os.str() );
208  }
209  }
210 
211  // Check that the number of types for all supergeneric variables are
212  // consistent
214  {
215  bool consistent = true;
216  Index nspecs = 0;
217  for (Index i = 0; consistent && i < mginspectype.nelem(); i++)
218  {
219  if (mginspectype[0].nelem())
220  {
221  if (!nspecs) nspecs = mginspectype[0].nelem();
222  else if (nspecs != mginspectype[0].nelem()) consistent = false;
223  }
224  }
225 
226  for (Index i = 0; consistent && i < mgoutspectype.nelem(); i++)
227  {
228  if (mgoutspectype[0].nelem())
229  {
230  if (!nspecs) nspecs = mgoutspectype[0].nelem();
231  else if (nspecs != mgoutspectype[0].nelem()) consistent = false;
232  }
233  }
234  if (!consistent)
235  {
236  ostringstream os;
237  os << "Inconsistent number of types given for supergeneric variables"
238  << endl << "in WSM " << mname << "." << endl;
239  throw runtime_error (os.str());
240  }
241  }
242 
243  // Find out if this method is supergeneric, and set the flag if
244  // yes:
245  const Index anyid = get_wsv_group_id("Any");
246  for ( Index j=0; j<mgouttype.nelem(); ++j )
247  if ( anyid == mgouttype[j] )
248  msupergeneric = true;
249  for ( Index j=0; j<mgintype.nelem(); ++j )
250  if ( anyid == mgintype[j] )
251  msupergeneric = true;
252 
253  // Determine variables that are only input
254  minonly = minput; // Input
255  for (ArrayOfIndex::const_iterator j=moutput.begin(); j<moutput.end(); ++j)
256  for (ArrayOfIndex::iterator k=minonly.begin(); k<minonly.end(); ++k)
257  if ( *j == *k )
258  {
259  k = minonly.erase(k) - 1;
260  // We need the -1 here, otherwise due to the
261  // following increment we would miss the element
262  // behind the erased one, which is now at the
263  // position of the erased one.
264  }
265 
266  // Determine variables that are input and output
267  minout.resize(0);
268  Index i = 0;
269  for (ArrayOfIndex::const_iterator j=moutput.begin(); j<moutput.end(); ++j,++i)
270  for (ArrayOfIndex::const_iterator k=minput.begin(); k<minput.end(); ++k)
271  if ( *j == *k )
272  minout.push_back(i);
273 
274  // Determine variables that are only output
275  moutonly = moutput; // Output
276  for (ArrayOfIndex::const_iterator j=minput.begin(); j<minput.end(); ++j)
277  for (ArrayOfIndex::iterator k=moutonly.begin(); k<moutonly.end(); ++k)
278  if ( *j == *k )
279  {
280  k = moutonly.erase(k) - 1;
281  // We need the -1 here, otherwise due to the
282  // following increment we would miss the element
283  // behind the erased one, which is now at the
284  // position of the erased one.
285  }
286 
287 }
288 
289 
291 
301 {
302  const Index wsv_group_id_Any = get_wsv_group_id("Any");
303  // The group names, we need them for the expansion:
305 
306  // Make sure they are initialized:
307  assert( 0 != wsv_group_names.nelem() );
308 
309  // Make sure that g is in the allowed range, which means
310  // 0<=g<wsv_group_names.nelem() and g != Any_
311  assert( 0 <= g );
312  assert( wsv_group_id_Any != g );
313  assert( g < wsv_group_names.nelem() );
314 
315  // Make sure that this really is a supergeneric method:
316  assert( Supergeneric() );
317 
318  // Modify the name:
319 // {
320 // ostringstream os;
321 // os << mname << "_sg_" << wsv_group_names[g];
322 // mname = os.str();
323 // }
324 
325  for ( Index j=0; j<mgouttype.nelem(); ++j )
326  if ( wsv_group_id_Any == mgouttype[j] ) mgouttype[j] = g;
327  for ( Index j=0; j<mgintype.nelem(); ++j )
328  if ( wsv_group_id_Any == mgintype[j] ) mgintype[j] = g;
329 
330  // Set the field for the actual group:
332 }
333 
334 
336 
346 {
347  // The group names, we need them for the expansion:
349 
350  const Index wsv_group_id_Any = get_wsv_group_id("Any");
351 
352  // Make sure that g is in the allowed range, which means
353  // 0<=g<wsv_group_names.nelem() and g != Any_
354  assert( 0 <= g );
355 
356  // Make sure that this really is a supergeneric method:
357  assert( Supergeneric() );
358 
359  // Modify the name:
360 // {
361 // ostringstream os;
362 // os << mname << "_sg_" << wsv_group_names[g];
363 // mname = os.str();
364 // }
365 
366  mactual_groups = "";
367  for ( Index j=0; j<mgouttype.nelem(); ++j )
368  if ( wsv_group_id_Any == mgouttype[j] )
369  {
370  mgouttype[j] = mgoutspectype[j][g];
371  // Set the field for the actual group:
373  }
374 
375  for ( Index j=0; j<mgintype.nelem(); ++j )
376  if ( wsv_group_id_Any == mgintype[j] )
377  {
378  mgintype[j] = mginspectype[j][g];
379  // Set the field for the actual group:
381  }
382 
383 }
384 
385 
387 
397 {
399  using global_data::md_data;
400 
401  // The group names, we need them for the expansion:
403 
404  const Index wsv_group_id_Any = get_wsv_group_id("Any");
405 
406  // Make sure that they have been initialized:
407  assert ( 0!=wsv_group_names.nelem() );
408 
409  // Reset md_data, just in case:
410  md_data.resize(0);
411 
412  for ( Index i=0; i<md_data_raw.nelem(); ++i )
413  {
414  const MdRecord& mdd = md_data_raw[i];
415 
416  if ( !mdd.Supergeneric() )
417  {
418  md_data.push_back(mdd);
419  }
420  else
421  {
422  // Special treatment for supergeneric methods:
423 
424  // Check if the method is really supergeneric or just valid
425  // for certain types.
426 
427  if ((mdd.GInSpecType().nelem() && mdd.GInSpecType()[0].nelem())
428  || (mdd.GOutSpecType().nelem() && mdd.GOutSpecType()[0].nelem()))
429  {
430  Index max = 0;
431  if (mdd.GInSpecType().nelem())
432  max = mdd.GInSpecType()[0].nelem();
433  if (mdd.GOutSpecType().nelem()
434  && mdd.GOutSpecType()[0].nelem() > max )
435  max = mdd.GOutSpecType()[0].nelem();
436 
437  for (Index k=0; k<max; k++)
438  {
439  MdRecord mdlocal = mdd;
440 
442 
443  md_data.push_back(mdlocal);
444  }
445  }
446  else
447  {
448  for ( Index j=0; j<wsv_group_names.nelem(); ++j )
449  {
450  // Any_ itself is also a group, but we don't want to
451  // create a record for Any_!
452  if ( wsv_group_id_Any != j )
453  {
454  // Not a reference but a copy this time, since we
455  // have to manipulate this.
456  MdRecord mdlocal = mdd;
457 
458  mdlocal.subst_any_with_group( j );
459 
460  md_data.push_back(mdlocal);
461  }
462  }
463  }
464  }
465  }
466 }
467 
469 
473 {
474  // md_data is constant here and should never be changed
475  using global_data::md_data;
476  using global_data::MdMap;
478 
479  // Check that md_data and wsv_group_names have already be defined:
480  assert( 0 != md_data.nelem() );
481  assert( 0 != wsv_group_names.nelem() );
482 
483  for ( Index i=0 ; i<md_data.nelem() ; ++i)
484  {
485  const MdRecord& mdd = md_data[i];
486 
487  // For supergeneric methods, add group to method name
488  String methodname;
489  ostringstream os;
490  if ( mdd.Supergeneric() )
491  {
492  os << mdd.Name() << "_sg_"
493  << mdd.ActualGroups();
494  }
495  else
496  {
497  os << mdd.Name();
498  }
499  methodname = os.str();
500 
501  MdMap[methodname] = i;
502  }
503 }
504 
506 
515 {
517  using global_data::MdRawMap;
518 
519  for ( Index i=0 ; i<md_data_raw.nelem() ; ++i)
520  {
521  MdRawMap[md_data_raw[i].Name()] = i;
522  }
523 }
524 
525 
526 bool format_paragraph (String &s, const String &indent, const size_t linelen,
527  const size_t offset)
528 {
529  bool fit = true;
530  String out;
531  String token;
532  size_t currentlinelength = offset;
533  for (size_t i = 0; i < s.length(); i++)
534  {
535  if (s[i] == '\n') s[i] = ' ';
536  token += s[i];
537  if (s[i] == ' ')
538  {
539  if (currentlinelength + token.length() > linelen)
540  {
541  out += '\n' + indent;
542  currentlinelength = indent.length();
543  fit = false;
544  }
545  out += token;
546  currentlinelength += token.length();
547  token = "";
548  }
549  }
550 
551  if (token.length())
552  {
553  if (currentlinelength + token.length() > linelen)
554  {
555  out += '\n' + indent;
556  fit = false;
557  }
558  out += token;
559  }
560  s = out;
561  return fit;
562 }
563 
564 
566 {
567  Index pos;
568  Index pos2;
569 
570  // Find the end of the short WSV description
571  pos = desc.find(".\n");
572  pos2 = desc.find(". ");
573  if (pos == String::npos || (pos2 != String::npos && pos2 < pos)) pos = pos2;
574  if (pos == String::npos) pos = desc.find("\n");
575  if (pos != String::npos)
576  s = desc.substr(0, pos+1);
577  else
578  s = desc;
579 
580  // Replace any newlines inside the description with spaces
581  while ((pos = s.find("\n")) != String::npos)
582  {
583  s.replace (pos, 1, " ");
584  }
585 }
586 
587 
588 ostream& MdRecord::PrintTemplate(ostream& os,
589  bool show_description) const
590 {
592 
593  if (show_description)
594  {
595  // FIXME: Print description String!
596  }
597 
598  os << Name();
599 
600  // Is this a generic method? -- Then we need round braces.
601  if ( 0 != GOutType().nelem()+GInType().nelem() )
602  {
603  // First entry needs to comma before:
604  bool first=true;
605 
606  os << '(';
607 
608  for (Index i=0; i<GOutType().nelem(); ++i)
609  {
610  if (first) first=false;
611  else os << ",\n";
612 
613  os << wsv_group_names[GOutType()[i]];
614  }
615 
616  for (Index i=0; i<GInType().nelem(); ++i)
617  {
618  if (first) first=false;
619  else os << ",\n";
620 
621  os << wsv_group_names[GInType()[i]];
622  }
623 
624  os << ')';
625  }
626 
627  // Now the keywords:
628 
629  os << '{';
630 
631  // Determine the length of the longest keyword:
632  Index maxsize = 0;
633  for (Index i=0; i<GIn().nelem(); ++i)
634  if ( GIn()[i].nelem() > maxsize )
635  maxsize = GIn()[i].nelem();
636 
637 
638  for (Index i=0; i<GIn().nelem(); ++i)
639  {
640  os << "\t" << setw((int)maxsize)
641  << GIn()[i] << " = \n";
642  }
643 
644  os << '}';
645 
646  return os;
647 }
648 
649 
651 
656 void limit_line_length( ostream& os,
657  ostringstream& curline,
658  ostringstream& token,
659  const String& indent,
660  size_t linelen)
661 {
662  if (indent.length() + curline.str().length() + token.str().length() > linelen)
663  {
664  os << curline.str() << endl << indent;
665  curline.str("");
666  }
667  curline << token.str();
668  token.str("");
669 }
670 
671 
673 ostream& operator<<(ostream& os, const MdRecord& mdr)
674 {
676  bool first;
677  ostringstream buf;
678  ostringstream param;
679  String indent = "";
680  const size_t linelen = 68;
681  bool fit;
682  size_t lastlen;
683 
684  os << "\n*-------------------------------------------------------------------*\n"
685  << "Workspace method = " << mdr.Name() <<
686  "\n---------------------------------------------------------------------\n"
687  << "\n" << mdr.Description() << "\n";
688 
689  if (mdr.Description()[mdr.Description().nelem() - 1] != '\n')
690  {
691  os << "\n";
692  }
693 
694  // Print the method's synopsis
695  while (indent.length() < mdr.Name().length() + 2) indent += ' ';
696 
697  os << "\nSynopsis:\n\n";
698  buf << mdr.Name() << "( ";
699  first = true;
700  for ( Index i=0; i<mdr.Out().nelem(); ++i )
701  {
702  if (first) first=false; else buf << ", ";
703  param << Workspace::wsv_data[mdr.Out()[i]].Name();
704 
705  limit_line_length( os, buf, param, indent, linelen );
706  }
707 
708  for ( Index i=0; i<mdr.GOutType().nelem(); ++i )
709  {
710  if (first) first=false; else buf << ", ";
711  if (mdr.GOut()[i].length())
712  param << mdr.GOut()[i];
713  else
714  param << "gout" << i;
715 
716  limit_line_length( os, buf, param, indent, linelen );
717  }
718 
719  const ArrayOfIndex &inonly = mdr.InOnly();
720  for ( Index i=0; i<inonly.nelem(); ++i )
721  {
722  if (first) first=false; else buf << ", ";
723  param << Workspace::wsv_data[inonly[i]].Name();
724 
725  limit_line_length( os, buf, param, indent, linelen );
726  }
727 
728  for ( Index i=0; i<mdr.GInType().nelem(); ++i )
729  {
730  if (first) first=false; else buf << ", ";
731  if (mdr.GIn()[i].length())
732  {
733  param << mdr.GIn()[i];
734  }
735  else
736  {
737  param << "gin" << i;
738  }
739 
740  limit_line_length( os, buf, param, indent, linelen );
741  }
742  if (buf.str().length()) os << buf.str();
743 
744  os << " )\n\n\n";
745 
746  {
747  bool is_first_author = true;
748  for (Index i = 0; i < mdr.Authors().nelem(); i++)
749  {
750  if (is_first_author)
751  {
752  os << "Authors: ";
753  is_first_author = false;
754  }
755  else
756  os << ", ";
757 
758  os << mdr.Authors()[i];
759  }
760  os << "\n";
761  }
762 
763  os << "\n\nVariables:\n\n";
764 
765  // os << "\n-----\nName = " << mdr.Name() << '\n\n'
766  // << "Description =\n" << mdr.Description() << "\n\n";
767 
768  // Out:
769  indent = String(6);
770  String desc;
771  for ( Index i=0; i<mdr.Out().nelem(); ++i )
772  {
773  buf.str("");
774  buf << "OUT ";
775 
776  buf << Workspace::wsv_data[mdr.Out()[i]].Name();
777  buf << " (";
778  buf << wsv_group_names[Workspace::wsv_data[mdr.Out()[i]].Group()];
779  buf << "): ";
780 
782  desc, Workspace::wsv_data[mdr.Out()[i]].Description());
783 
784  if (buf.str().length() + desc.length() > linelen)
785  {
786  format_paragraph (desc, indent, linelen);
787  buf << endl << indent << desc;
788  }
789  else
790  {
791  buf << desc;
792  }
793 
794  os << buf.str() << endl;
795  }
796 
797  for ( Index i=0; i<mdr.GOut().nelem(); ++i )
798  {
799  buf.str("");
800  buf << "GOUT " << mdr.GOut()[i] << " (";
801  if (mdr.GOutType()[i] == get_wsv_group_id("Any")
802  && mdr.GOutSpecType()[i].nelem())
803  {
804  bool firstarg = true;
805  for (Index j = 0; j < mdr.GOutSpecType()[i].nelem(); j++)
806  {
807  if (!firstarg) buf << ", "; else firstarg = false;
808  buf << wsv_group_names[mdr.GOutSpecType()[i][j]];
809  }
810  }
811  else
812  {
813  buf << wsv_group_names[mdr.GOutType()[i]];
814  }
815 
816  buf << "): ";
817  desc = buf.str();
818  lastlen = desc.length();
819  fit = format_paragraph (desc, indent, linelen);
820  buf.str("");
821  os << desc;
822 
823  desc = mdr.GOutDescription()[i];
824  if (!fit)
825  {
826  format_paragraph (desc, indent, linelen);
827  buf << endl << indent << desc;
828  }
829  else if (lastlen + desc.length() > linelen)
830  {
831  format_paragraph (desc, indent, linelen, lastlen);
832  buf << endl << desc;
833  }
834  else
835  {
836  buf << desc;
837  }
838 
839  os << buf.str() << endl;
840  }
841 
842  for ( Index i=0; i<mdr.In().nelem(); ++i )
843  {
844  buf.str("");
845  buf << "IN ";
846 
847  buf << Workspace::wsv_data[mdr.In()[i]].Name();
848  buf << " (";
849  buf << wsv_group_names[Workspace::wsv_data[mdr.In()[i]].Group()];
850  buf << "): ";
851 
853  desc, Workspace::wsv_data[mdr.In()[i]].Description());
854 
855  if (buf.str().length() + desc.length() > linelen)
856  {
857  format_paragraph (desc, indent, linelen, indent.length());
858  buf << endl << indent << desc;
859  }
860  else
861  {
862  buf << desc;
863  }
864 
865  os << buf.str() << endl;
866  }
867 
868  for ( Index i=0; i<mdr.GIn().nelem(); ++i )
869  {
870  buf.str("");
871  buf << "GIN " << mdr.GIn()[i] << " (";
872  if (mdr.GInType()[i] == get_wsv_group_id("Any")
873  && mdr.GInSpecType()[i].nelem())
874  {
875  bool firstarg = true;
876  for (Index j = 0; j < mdr.GInSpecType()[i].nelem(); j++)
877  {
878  if (!firstarg) buf << ", "; else firstarg = false;
879  buf << wsv_group_names[mdr.GInSpecType()[i][j]];
880  }
881  }
882  else
883  {
884  buf << wsv_group_names[mdr.GInType()[i]];
885  }
886 
887  if (mdr.GInDefault()[i] != NODEF)
888  {
889  buf << ", Default: ";
890  if (mdr.GInType()[i] == get_wsv_group_id ("String"))
891  {
892  buf << "\"" << mdr.GInDefault()[i] << "\"";
893  }
894  else
895  {
896  buf << mdr.GInDefault()[i];
897  }
898 
899  }
900 
901  buf << "): ";
902  desc = buf.str();
903  lastlen = desc.length();
904  fit = format_paragraph (desc, indent, linelen);
905  buf.str("");
906  os << desc;
907 
908  desc = mdr.GInDescription()[i];
909  if (!fit)
910  {
911  format_paragraph (desc, indent, linelen);
912  buf << endl << indent << desc;
913  }
914  else if (lastlen + desc.length() > linelen)
915  {
916  format_paragraph (desc, indent, linelen, indent.length());
917  buf << endl << indent << desc;
918  }
919  else
920  {
921  buf << desc;
922  }
923 
924  os << buf.str() << endl;
925  }
926 
927  os << "\n*-------------------------------------------------------------------*\n";
928 
929  return os;
930 }
931 
MdRecord::GOut
const ArrayOfString & GOut() const
Definition: methods.h:93
limit_line_length
void limit_line_length(ostream &os, ostringstream &curline, ostringstream &token, const String &indent, size_t linelen)
Limit length of output.
Definition: methods_aux.cc:656
Workspace::wsv_data
static Array< WsvRecord > wsv_data
Definition: workspace_ng.h:64
MdRecord::Supergeneric
bool Supergeneric() const
Definition: methods.h:108
MdRecord::GOutSpecType
const ArrayOfArrayOfIndex & GOutSpecType() const
Definition: methods.h:95
MdRecord::GOutType
const ArrayOfIndex & GOutType() const
Definition: methods.h:94
MdRecord::mgouttype
ArrayOfIndex mgouttype
Generic Workspace Output Type.
Definition: methods.h:164
MdRecord::GInType
const ArrayOfIndex & GInType() const
Definition: methods.h:99
get_wsv_id
Index get_wsv_id(const String &name)
Get index of WSV.
Definition: workspace.cc:4998
MdRecord::mgoutspectype
ArrayOfArrayOfIndex mgoutspectype
Generic Workspace Output Types (Contains the valid types if the method.
Definition: methods.h:168
global_data::md_data_raw
const Array< MdRecord > md_data_raw
Lookup information for workspace methods.
Definition: methods.cc:39
define_md_raw_map
void define_md_raw_map()
Define MdRawMap.
Definition: methods_aux.cc:514
MdRecord::MdRecord
MdRecord()
Default constructor.
Definition: methods.h:46
MdRecord::muses_templates
bool muses_templates
Flag, whether method implementation relies on templates.
Definition: methods.h:227
global_data::MdRawMap
const map< String, Index > MdRawMap
The map associated with md_data_raw.
Definition: methods_aux.cc:41
DEBUG_ONLY
#define DEBUG_ONLY(...)
Definition: debug.h:37
MdRecord::mgintype
ArrayOfIndex mgintype
Generic Workspace Input.
Definition: methods.h:180
get_short_wsv_description
void get_short_wsv_description(String &s, const String &desc)
Definition: methods_aux.cc:565
Array
This can be used to make arrays out of anything.
Definition: array.h:107
MdRecord::minout
ArrayOfIndex minout
Indexes of Input-Output variables.
Definition: methods.h:199
MdRecord::mname
String mname
The name of this method.
Definition: methods.h:149
MdRecord::ActualGroups
const String & ActualGroups() const
Definition: methods.h:112
MdRecord::minput
ArrayOfIndex minput
Workspace Input.
Definition: methods.h:174
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:64
NODEF
#define NODEF
Definition: methods.h:36
MdRecord::GInDescription
const Array< String > & GInDescription() const
Definition: methods.h:102
global_data::MdMap
const map< String, Index > MdMap
The map associated with md_data.
Definition: methods_aux.cc:39
get_wsv_group_ids
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Returns list of ids of the given group names.
Definition: groups.cc:168
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:89
MdRecord::In
const ArrayOfIndex & In() const
Definition: methods.h:97
MdRecord::InOnly
const ArrayOfIndex & InOnly() const
Definition: methods.h:103
MdRecord::mgin
ArrayOfString mgin
Generic Workspace Input Names.
Definition: methods.h:177
MdRecord::GOutDescription
const Array< String > & GOutDescription() const
Definition: methods.h:96
max
#define max(a, b)
Definition: continua.cc:20461
my_basic_string::nelem
Index nelem() const
Number of elements.
Definition: mystring.h:278
MdRecord::GInDefault
const Array< String > & GInDefault() const
Definition: methods.h:101
global_data::md_data
const Array< MdRecord > md_data
Lookup information for workspace methods.
Definition: methods_aux.cc:48
MdRecord::mgout
ArrayOfString mgout
Generic Workspace Output Names.
Definition: methods.h:161
MdRecord::mgindefault
ArrayOfString mgindefault
Generic Workspace Input Defaults.
Definition: methods.h:187
MdRecord::GIn
const ArrayOfString & GIn() const
Definition: methods.h:98
operator<<
ostream & operator<<(ostream &os, const MdRecord &mdr)
Output operator for MdRecord.
Definition: methods_aux.cc:673
format_paragraph
bool format_paragraph(String &s, const String &indent, const size_t linelen, const size_t offset)
Definition: methods_aux.cc:526
workspace_ng.h
This file contains the declaration and partly the implementation of the workspace class.
MdRecord
All information for one workspace method.
Definition: methods.h:42
MdRecord::subst_any_with_specific_group
void subst_any_with_specific_group(Index g)
Expand supergeneric record for given Index in GOutSpecType and GInSpecType.
Definition: methods_aux.cc:345
global_data
Definition: agenda_record.cc:33
String
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:318
MdRecord::GInSpecType
const ArrayOfArrayOfIndex & GInSpecType() const
Definition: methods.h:100
expand_md_data_raw_to_md_data
void expand_md_data_raw_to_md_data()
Expand supergeneric methods.
Definition: methods_aux.cc:396
MdRecord::subst_any_with_group
void subst_any_with_group(Index g)
Expand supergeneric record for given group.
Definition: methods_aux.cc:300
MdRecord::PrintTemplate
ostream & PrintTemplate(ostream &os, bool show_description=true) const
Print method template for the control file.
Definition: methods_aux.cc:588
MdRecord::mginspectype
ArrayOfArrayOfIndex mginspectype
Generic Workspace Input Types (Contains the valid types if the method.
Definition: methods.h:184
MakeArray
Explicit construction of Arrays.
Definition: make_array.h:52
MdRecord::mactual_groups
String mactual_groups
The actual groups of a supergeneric method.
Definition: methods.h:248
MdRecord::msupergeneric
bool msupergeneric
Flag, whether this method is supergeneric.
Definition: methods.h:220
Index
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:35
MdRecord::Out
const ArrayOfIndex & Out() const
Definition: methods.h:92
global_data::wsv_group_names
const ArrayOfString wsv_group_names
The names associated with Wsv groups as Strings.
Definition: global_data.h:94
my_basic_string::npos
static const Index npos
Define npos:
Definition: mystring.h:105
MdRecord::minonly
ArrayOfIndex minonly
Indexes of Input-only variables.
Definition: methods.h:193
get_wsv_group_id
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
Definition: groups.cc:205
MdRecord::moutput
ArrayOfIndex moutput
Workspace Output.
Definition: methods.h:158
MdRecord::Description
const String & Description() const
Definition: methods.h:90
define_md_map
void define_md_map()
Define MdMap.
Definition: methods_aux.cc:472
Array::nelem
Index nelem() const
Number of elements.
Definition: array.h:176
methods.h
Declaration of the class MdRecord.
wsv_aux.h
Auxiliary header stuff related to workspace variable groups.
MdRecord::Authors
const ArrayOfString & Authors() const
Definition: methods.h:91
arts.h
The global header file for ARTS.
MdRecord::moutonly
ArrayOfIndex moutonly
Indexes of Output-only variables.
Definition: methods.h:196