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)) {
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)) {
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) {
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();
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";
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";
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
Global 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.
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 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.
_CS_string_type str() const
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
ArrayOfString mgin
Generic Workspace Input Names.
Index nelem() const
Number of elements.
ArrayOfString mgout
Generic Workspace Output Names.
basic_ostringstream< char, string_char_traits< char >, alloc > ostringstream
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.
Index nelem(const Lines &l)
Number of lines.
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.