55 ostringstream& token,
const String& indent,
66 const char description[],
81 bool pass_wsv_names ) :
83 mdescription( description ),
88 mgoutdesc( goutdesc ),
92 mgindefault( gindefault ),
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 ),
122 os <<
"Unknown WSV " << output[j] <<
" for output " 123 <<
"in WSM " <<
mname;
124 throw runtime_error( os.str() );
135 os <<
"Unknown WSV " << input[j] <<
" for input " 136 <<
"in WSM " <<
mname;
137 throw runtime_error( os.str() );
149 if (types.
nelem() == 1)
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());
162 else if (types.
nelem() > 1)
170 os <<
"Unknown WSV Group " << gouttype[j] <<
" for generic output " 171 <<
"in WSM " <<
mname;
172 throw runtime_error( os.str() );
184 if (types.
nelem() == 1)
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());
197 else if (types.
nelem() > 1)
205 os <<
"Unknown WSV Group " << gintype[j] <<
" for generic input " 206 <<
"in WSM " <<
mname;
207 throw runtime_error( os.str() );
215 bool consistent =
true;
222 else if (nspecs !=
mginspectype[0].nelem()) consistent =
false;
231 else if (nspecs !=
mgoutspectype[0].nelem()) consistent =
false;
237 os <<
"Inconsistent number of types given for supergeneric variables" 238 << endl <<
"in WSM " <<
mname <<
"." << endl;
239 throw runtime_error (os.str());
255 for (ArrayOfIndex::const_iterator j=
moutput.begin(); j<
moutput.end(); ++j)
256 for (ArrayOfIndex::iterator k=
minonly.begin(); k<
minonly.end(); ++k)
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)
276 for (ArrayOfIndex::const_iterator j=
minput.begin(); j<
minput.end(); ++j)
312 assert( wsv_group_id_Any != g );
376 if ( wsv_group_id_Any ==
mgintype[j] )
452 if ( wsv_group_id_Any != j )
480 assert( 0 !=
md_data.nelem() );
492 os << mdd.
Name() <<
"_sg_" 499 methodname = os.str();
501 MdMap[methodname] = i;
532 size_t currentlinelength = offset;
533 for (
size_t i = 0; i < s.length(); i++)
535 if (s[i] ==
'\n') s[i] =
' ';
539 if (currentlinelength + token.length() > linelen)
541 out +=
'\n' + indent;
542 currentlinelength = indent.length();
546 currentlinelength += token.length();
553 if (currentlinelength + token.length() > linelen)
555 out +=
'\n' + indent;
571 pos = desc.find(
".\n");
572 pos2 = desc.find(
". ");
576 s = desc.substr(0, pos+1);
583 s.replace (pos, 1,
" ");
589 bool show_description)
const 593 if (show_description)
610 if (first) first=
false;
618 if (first) first=
false;
640 os <<
"\t" << setw((
int)maxsize)
641 <<
GIn()[i] <<
" = \n";
657 ostringstream& curline,
658 ostringstream& token,
662 if (indent.length() + curline.str().length() + token.str().length() > linelen)
664 os << curline.str() << endl << indent;
667 curline << token.str();
680 const size_t linelen = 68;
684 os <<
"\n*-------------------------------------------------------------------*\n" 685 <<
"Workspace method = " << mdr.
Name() <<
686 "\n---------------------------------------------------------------------\n" 695 while (indent.length() < mdr.
Name().length() + 2) indent +=
' ';
697 os <<
"\nSynopsis:\n\n";
698 buf << mdr.
Name() <<
"( ";
702 if (first) first=
false;
else buf <<
", ";
710 if (first) first=
false;
else buf <<
", ";
711 if (mdr.
GOut()[i].length())
712 param << mdr.
GOut()[i];
714 param <<
"gout" << i;
722 if (first) first=
false;
else buf <<
", ";
730 if (first) first=
false;
else buf <<
", ";
731 if (mdr.
GIn()[i].length())
733 param << mdr.
GIn()[i];
742 if (buf.str().length()) os << buf.str();
747 bool is_first_author =
true;
753 is_first_author =
false;
763 os <<
"\n\nVariables:\n\n";
784 if (buf.str().length() + desc.length() > linelen)
787 buf << endl << indent << desc;
794 os << buf.str() << endl;
800 buf <<
"GOUT " << mdr.
GOut()[i] <<
" (";
804 bool firstarg =
true;
807 if (!firstarg) buf <<
", ";
else firstarg =
false;
818 lastlen = desc.length();
827 buf << endl << indent << desc;
829 else if (lastlen + desc.length() > linelen)
839 os << buf.str() << endl;
855 if (buf.str().length() + desc.length() > linelen)
858 buf << endl << indent << desc;
865 os << buf.str() << endl;
871 buf <<
"GIN " << mdr.
GIn()[i] <<
" (";
875 bool firstarg =
true;
878 if (!firstarg) buf <<
", ";
else firstarg =
false;
889 buf <<
", Default: ";
903 lastlen = desc.length();
912 buf << endl << indent << desc;
914 else if (lastlen + desc.length() > linelen)
917 buf << endl << indent << desc;
924 os << buf.str() << endl;
927 os <<
"\n*-------------------------------------------------------------------*\n";
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
INDEX Index
The type to use for all integer numbers and indices.
static Array< WsvRecord > wsv_data
ostream & PrintTemplate(ostream &os, bool show_description=true) const
Print method template for the control file.
String mname
The name of this method.
Index nelem() const
Number of elements.
Explicit construction of Arrays.
ArrayOfIndex mgouttype
Generic Workspace Output Type.
void get_short_wsv_description(String &s, const String &desc)
MdRecord()
Default constructor.
ArrayOfIndex minput
Workspace Input.
bool muses_templates
Flag, whether method implementation relies on templates.
const ArrayOfIndex & Out() const
const Array< String > & GInDescription() const
const map< String, Index > MdRawMap
The map associated with md_data_raw.
All information for one workspace method.
bool Supergeneric() const
void define_md_raw_map()
Define MdRawMap.
const String & Name() const
ArrayOfArrayOfIndex mgoutspectype
Generic Workspace Output Types (Contains the valid types if the method.
const map< String, Index > MdMap
The map associated with md_data.
const ArrayOfString & GOut() const
This file contains the declaration and partly the implementation of the workspace class...
Index get_wsv_id(const String &name)
Get index of WSV.
const Array< String > & GInDefault() const
The global header file for ARTS.
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Returns list of ids of the given group names.
const String & ActualGroups() const
void subst_any_with_specific_group(Index g)
Expand supergeneric record for given Index in GOutSpecType and GInSpecType.
ArrayOfIndex minout
Indexes of Input-Output variables.
const ArrayOfIndex & In() const
const ArrayOfArrayOfIndex & GInSpecType() const
String mactual_groups
The actual groups of a supergeneric method.
const ArrayOfString & Authors() const
Implements the class MakeArray, which is a derived class of Array, allowing explicit initialization...
ArrayOfString mgin
Generic Workspace Input Names.
Index nelem() const
Number of elements.
ArrayOfString mgout
Generic Workspace Output Names.
This can be used to make arrays out of anything.
const ArrayOfIndex & InOnly() const
const ArrayOfIndex & GOutType() const
ArrayOfIndex moutput
Workspace Output.
const ArrayOfString wsv_group_names
The names associated with Wsv groups as Strings.
ArrayOfIndex moutonly
Indexes of Output-only variables.
bool format_paragraph(String &s, const String &indent, const size_t linelen, const size_t offset)
ArrayOfString mgindefault
Generic Workspace Input Defaults.
const Array< String > & GOutDescription() const
const ArrayOfArrayOfIndex & GOutSpecType() const
const Array< MdRecord > md_data
Lookup information for workspace methods.
void expand_md_data_raw_to_md_data()
Expand supergeneric methods.
const String & Description() const
const ArrayOfIndex & GInType() const
static const Index npos
Define npos:
void subst_any_with_group(Index g)
Expand supergeneric record for given group.
void limit_line_length(ostream &os, ostringstream &curline, ostringstream &token, const String &indent, size_t linelen)
Limit length of output.
ostream & operator<<(ostream &os, const MdRecord &mdr)
Output operator for MdRecord.
void define_md_map()
Define MdMap.
ArrayOfIndex mgintype
Generic Workspace Input.
bool msupergeneric
Flag, whether this method is supergeneric.
Declaration of the class MdRecord.
const ArrayOfString & GIn() const
ArrayOfArrayOfIndex mginspectype
Generic Workspace Input Types (Contains the valid types if the method.
my_basic_string< char > String
The String type for ARTS.
ArrayOfIndex minonly
Indexes of Input-only variables.
const Array< MdRecord > md_data_raw
Lookup information for workspace methods.
Auxiliary header stuff related to workspace variable groups.