Go to the documentation of this file.
55 ostringstream& curline,
68 const char description[],
85 mdescription(description),
94 mgindefault(gindefault),
96 mset_method(set_method),
97 magenda_method(agenda_method),
99 muses_templates(uses_templates),
100 mpass_workspace(pass_workspace),
101 mpass_wsv_names(pass_wsv_names),
117 std::sort(gin_sorted.begin(), gin_sorted.end());
119 std::sort(gout_sorted.begin(), gout_sorted.end());
123 if (*par == *(par + 1)) {
124 std::ostringstream os;
125 os <<
"Two input parameters by the same name are not allowed: \n";
126 os <<
"Method: " <<
mname <<
", Parameter: " << *par;
127 throw std::runtime_error(os.str());
133 if (*par == *(par + 1)) {
134 std::ostringstream os;
135 os <<
"Two output parameters by the same name are not allowed: \n";
136 os <<
"Method: " <<
mname <<
", Parameter: " << *par;
137 throw std::runtime_error(os.str());
143 auto it = std::set_intersection(gin_sorted.begin(),
148 gisect.resize(it - gisect.begin());
150 if (gisect.
nelem() > 0) {
151 std::ostringstream os;
152 os <<
"Using the same name for a generic input and generic output variable is not allowed: \n";
153 os <<
"Method: " <<
mname <<
", Parameter: ";
154 for (
auto& gname : gisect) {
157 throw std::runtime_error(os.str());
166 os <<
"Unknown WSV " << output[j] <<
" for output (parameter #" << j
168 <<
"in WSM " <<
mname;
169 throw runtime_error(os.str());
178 os <<
"Unknown WSV " << input[j] <<
" for input (parameter #" << j <<
") "
179 <<
"in WSM " <<
mname;
180 throw runtime_error(os.str());
187 for (
Index j = 0; j < gouttype.
nelem(); ++j) {
191 if (types.
nelem() == 1) {
196 os <<
"WSM " <<
mname <<
" takes \"Any\" as input and\n"
197 <<
"therefore must be implemented as a template function.\n"
198 <<
"Pass USES_TEMPLATES(true) in methods.cc!";
199 throw runtime_error(os.str());
201 }
else if (types.
nelem() > 1) {
206 os <<
"Unknown WSV Group " << gouttype[j] <<
" for generic output "
207 <<
"in WSM " <<
mname;
208 throw runtime_error(os.str());
218 if (types.
nelem() == 1) {
223 os <<
"WSM " <<
mname <<
" defines \"Any\" as output and\n"
224 <<
"therefore must be implemented as a template function.\n"
225 <<
"Pass USES_TEMPLATES(true) in methods.cc!";
226 throw runtime_error(os.str());
228 }
else if (types.
nelem() > 1) {
233 os <<
"Unknown WSV Group " << gintype[j] <<
" for generic input "
234 <<
"in WSM " <<
mname;
235 throw runtime_error(os.str());
242 bool consistent =
true;
263 os <<
"Inconsistent number of types given for supergeneric variables"
265 <<
"in WSM " <<
mname <<
"." << endl;
266 throw runtime_error(os.str());
280 for (ArrayOfIndex::const_iterator j =
moutput.begin(); j <
moutput.end(); ++j)
281 for (ArrayOfIndex::iterator k =
minonly.begin(); k <
minonly.end(); ++k)
293 for (ArrayOfIndex::const_iterator j =
moutput.begin(); j <
moutput.end();
295 for (ArrayOfIndex::const_iterator k =
minput.begin(); k <
minput.end(); ++k)
296 if (*j == *k)
minout.push_back(i);
300 for (ArrayOfIndex::const_iterator j =
minput.begin(); j <
minput.end(); ++j)
332 assert(wsv_group_id_Any != g);
393 if (wsv_group_id_Any ==
mgintype[j]) {
454 if (wsv_group_id_Any != j) {
494 methodname = os.str();
496 MdMap[methodname] = i;
520 const size_t linelen,
521 const size_t offset) {
525 size_t currentlinelength = offset;
526 for (
size_t i = 0; i < s.length(); i++) {
527 if (s[i] ==
'\n') s[i] =
' ';
530 if (currentlinelength + token.length() > linelen) {
531 out +=
'\n' + indent;
532 currentlinelength = indent.length();
536 currentlinelength += token.length();
541 if (token.length()) {
542 if (currentlinelength + token.length() > linelen) {
543 out +=
'\n' + indent;
557 pos = desc.find(
".\n");
558 pos2 = desc.find(
". ");
562 s = desc.substr(0, pos + 1);
568 s.replace(pos, 1,
" ");
575 if (show_description) {
619 os <<
"\t" << setw((
int)maxsize) <<
GIn()[i] <<
" = \n";
634 ostringstream& curline,
635 ostringstream& token,
638 if (indent.length() + curline.str().length() + token.str().length() >
640 os << curline.str() << endl << indent;
643 curline << token.str();
654 const size_t linelen = 68;
658 os <<
"\n*-------------------------------------------------------------------*\n"
659 <<
"Workspace method = " << mdr.
Name()
660 <<
"\n---------------------------------------------------------------------\n"
669 while (indent.length() < mdr.
Name().length() + 2) indent +=
' ';
671 os <<
"\nSynopsis:\n\n";
672 buf << mdr.
Name() <<
"( ";
689 if (mdr.
GOut()[i].length())
690 param << mdr.
GOut()[i];
692 param <<
"gout" << i;
713 if (mdr.
GIn()[i].length()) {
714 param << mdr.
GIn()[i];
721 if (buf.str().length()) os << buf.str();
726 bool is_first_author =
true;
728 if (is_first_author) {
730 is_first_author =
false;
739 os <<
"\n\nVariables:\n\n";
759 if (buf.str().length() + desc.length() > linelen) {
761 buf << endl << indent << desc;
766 os << buf.str() << endl;
771 buf <<
"GOUT " << mdr.
GOut()[i] <<
" (";
774 bool firstarg =
true;
788 lastlen = desc.length();
796 buf << endl << indent << desc;
797 }
else if (lastlen + desc.length() > linelen) {
804 os << buf.str() << endl;
819 if (buf.str().length() + desc.length() > linelen) {
821 buf << endl << indent << desc;
826 os << buf.str() << endl;
831 buf <<
"GIN " << mdr.
GIn()[i] <<
" (";
834 bool firstarg =
true;
847 buf <<
", Default: ";
857 lastlen = desc.length();
865 buf << endl << indent << desc;
866 }
else if (lastlen + desc.length() > linelen) {
868 buf << endl << indent << desc;
873 os << buf.str() << endl;
876 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
Global 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.
Index nelem(const Lines &l)
Number of lines.
String mname
The name of this method.
const String & ActualGroups() const
ArrayOfIndex minput
Workspace Input.
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.
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 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.
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.