Go to the documentation of this file.
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() <<
"( ";
700 for (
Index i=0; i<mdr.
Out().nelem(); ++i )
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";
771 for (
Index i=0; i<mdr.
Out().nelem(); ++i )
784 if (buf.str().length() + desc.length() > linelen)
787 buf << endl << indent << desc;
794 os << buf.str() << endl;
797 for (
Index i=0; i<mdr.
GOut().nelem(); ++i )
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;
842 for (
Index i=0; i<mdr.
In().nelem(); ++i )
855 if (buf.str().length() + desc.length() > linelen)
858 buf << endl << indent << desc;
865 os << buf.str() << endl;
868 for (
Index i=0; i<mdr.
GIn().nelem(); ++i )
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";
const ArrayOfString & GOut() const
void limit_line_length(ostream &os, ostringstream &curline, ostringstream &token, const String &indent, size_t linelen)
Limit length of output.
static Array< WsvRecord > wsv_data
bool Supergeneric() const
const ArrayOfArrayOfIndex & GOutSpecType() const
const ArrayOfIndex & GOutType() const
ArrayOfIndex mgouttype
Generic Workspace Output Type.
const ArrayOfIndex & GInType() const
Index get_wsv_id(const String &name)
Get index of WSV.
ArrayOfArrayOfIndex mgoutspectype
Generic Workspace Output Types (Contains the valid types if the method.
const Array< MdRecord > md_data_raw
Lookup information for workspace methods.
void define_md_raw_map()
Define MdRawMap.
MdRecord()
Default constructor.
bool muses_templates
Flag, whether method implementation relies on templates.
const map< String, Index > MdRawMap
The map associated with md_data_raw.
ArrayOfIndex mgintype
Generic Workspace Input.
void get_short_wsv_description(String &s, const String &desc)
This can be used to make arrays out of anything.
ArrayOfIndex minout
Indexes of Input-Output variables.
String mname
The name of this method.
const String & ActualGroups() const
ArrayOfIndex minput
Workspace Input.
The implementation for String, the ARTS string class.
const Array< String > & GInDescription() const
const map< String, Index > MdMap
The map associated with md_data.
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Returns list of ids of the given group names.
Implements the class MakeArray, which is a derived class of Array, allowing explicit initialization.
const String & Name() const
const ArrayOfIndex & In() const
const ArrayOfIndex & InOnly() const
ArrayOfString mgin
Generic Workspace Input Names.
const Array< String > & GOutDescription() const
Index nelem() const
Number of elements.
const Array< String > & GInDefault() const
const Array< MdRecord > md_data
Lookup information for workspace methods.
ArrayOfString mgout
Generic Workspace Output Names.
ArrayOfString mgindefault
Generic Workspace Input Defaults.
const ArrayOfString & GIn() const
ostream & operator<<(ostream &os, const MdRecord &mdr)
Output operator for MdRecord.
bool format_paragraph(String &s, const String &indent, const size_t linelen, const size_t offset)
This file contains the declaration and partly the implementation of the workspace class.
All information for one workspace method.
void subst_any_with_specific_group(Index g)
Expand supergeneric record for given Index in GOutSpecType and GInSpecType.
my_basic_string< char > String
The String type for ARTS.
const ArrayOfArrayOfIndex & GInSpecType() const
void expand_md_data_raw_to_md_data()
Expand supergeneric methods.
void subst_any_with_group(Index g)
Expand supergeneric record for given group.
ostream & PrintTemplate(ostream &os, bool show_description=true) const
Print method template for the control file.
ArrayOfArrayOfIndex mginspectype
Generic Workspace Input Types (Contains the valid types if the method.
Explicit construction of Arrays.
String mactual_groups
The actual groups of a supergeneric method.
bool msupergeneric
Flag, whether this method is supergeneric.
INDEX Index
The type to use for all integer numbers and indices.
const ArrayOfIndex & Out() const
const ArrayOfString wsv_group_names
The names associated with Wsv groups as Strings.
static const Index npos
Define npos:
ArrayOfIndex minonly
Indexes of Input-only variables.
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
ArrayOfIndex moutput
Workspace Output.
const String & Description() const
void define_md_map()
Define MdMap.
Index nelem() const
Number of elements.
Declaration of the class MdRecord.
Auxiliary header stuff related to workspace variable groups.
const ArrayOfString & Authors() const
The global header file for ARTS.
ArrayOfIndex moutonly
Indexes of Output-only variables.