57 ostringstream& curline,
70 const char* description,
87 mdescription(description),
96 mgindefault(gindefault),
98 mset_method(set_method),
99 magenda_method(agenda_method),
100 msupergeneric(false),
101 muses_templates(uses_templates),
102 mpass_workspace(pass_workspace),
103 mpass_wsv_names(pass_wsv_names),
119 std::sort(gin_sorted.begin(), gin_sorted.end());
121 std::sort(gout_sorted.begin(), gout_sorted.end());
125 if (*par == *(par + 1)) {
126 std::ostringstream os;
127 os <<
"Two input parameters by the same name are not allowed: \n";
128 os <<
"Method: " <<
mname <<
", Parameter: " << *par;
129 throw std::runtime_error(os.str());
135 if (*par == *(par + 1)) {
136 std::ostringstream os;
137 os <<
"Two output parameters by the same name are not allowed: \n";
138 os <<
"Method: " <<
mname <<
", Parameter: " << *par;
139 throw std::runtime_error(os.str());
145 auto it = std::set_intersection(gin_sorted.begin(),
150 gisect.resize(it - gisect.begin());
152 if (gisect.
nelem() > 0) {
153 std::ostringstream os;
154 os <<
"Using the same name for a generic input and generic output variable is not allowed: \n";
155 os <<
"Method: " <<
mname <<
", Parameter: ";
156 for (
auto& gname : gisect) {
159 throw std::runtime_error(os.str());
168 os <<
"Unknown WSV " << output[j] <<
" for output (parameter #" << j
170 <<
"in WSM " <<
mname;
171 throw runtime_error(os.str());
180 os <<
"Unknown WSV " << input[j] <<
" for input (parameter #" << j <<
") "
181 <<
"in WSM " <<
mname;
182 throw runtime_error(os.str());
189 for (
Index j = 0; j < gouttype.
nelem(); ++j) {
193 if (types.
nelem() == 1) {
198 os <<
"WSM " <<
mname <<
" takes \"Any\" as input and\n"
199 <<
"therefore must be implemented as a template function.\n"
200 <<
"Pass USES_TEMPLATES(true) in methods.cc!";
201 throw runtime_error(os.str());
203 }
else if (types.
nelem() > 1) {
208 os <<
"Unknown WSV Group " << gouttype[j] <<
" for generic output "
209 <<
"in WSM " <<
mname;
210 throw runtime_error(os.str());
220 if (types.
nelem() == 1) {
225 os <<
"WSM " <<
mname <<
" defines \"Any\" as output and\n"
226 <<
"therefore must be implemented as a template function.\n"
227 <<
"Pass USES_TEMPLATES(true) in methods.cc!";
228 throw runtime_error(os.str());
230 }
else if (types.
nelem() > 1) {
235 os <<
"Unknown WSV Group " << gintype[j] <<
" for generic input "
236 <<
"in WSM " <<
mname;
237 throw runtime_error(os.str());
244 bool consistent =
true;
265 os <<
"Inconsistent number of types given for supergeneric variables"
267 <<
"in WSM " <<
mname <<
"." << endl;
268 throw runtime_error(os.str());
282 for (ArrayOfIndex::const_iterator j =
moutput.begin(); j <
moutput.end(); ++j)
283 for (ArrayOfIndex::iterator k =
minonly.begin(); k <
minonly.end(); ++k)
295 for (ArrayOfIndex::const_iterator j =
moutput.begin(); j <
moutput.end();
297 for (ArrayOfIndex::const_iterator k =
minput.begin(); k <
minput.end(); ++k)
298 if (*j == *k)
minout.push_back(i);
302 for (ArrayOfIndex::const_iterator j =
minput.begin(); j <
minput.end(); ++j)
395 if (wsv_group_id_Any ==
mgintype[j]) {
427 for (
Index i = 0; i < md_data_raw.nelem(); ++i) {
428 const MdRecord& mdd = md_data_raw[i];
431 md_data.push_back(mdd);
450 md_data.push_back(mdlocal);
453 for (
Index j = 0; j < wsv_groups.
nelem(); ++j) {
456 if (wsv_group_id_Any != j) {
463 md_data.push_back(mdlocal);
485 for (
Index i = 0; i < md_data.nelem(); ++i) {
496 methodname = os.str();
498 MdMap[methodname] = i;
515 for (
Index i = 0; i < md_data_raw.nelem(); ++i) {
516 MdRawMap[md_data_raw[i].Name()] = i;
522 const size_t linelen,
523 const size_t offset) {
527 size_t currentlinelength = offset;
528 for (
size_t i = 0; i < s.length(); i++) {
529 if (s[i] ==
'\n') s[i] =
' ';
532 if (currentlinelength + token.length() > linelen) {
533 out +=
'\n' + indent;
534 currentlinelength = indent.length();
538 currentlinelength += token.length();
543 if (token.length()) {
544 if (currentlinelength + token.length() > linelen) {
545 out +=
'\n' + indent;
559 pos = desc.find(
".\n");
560 pos2 = desc.find(
". ");
564 s = desc.substr(0, pos + 1);
577 if (show_description) {
605 os << wsv_groups[
GInType()[i]];
621 os <<
"\t" << setw((
int)maxsize) <<
GIn()[i] <<
" = \n";
636 ostringstream& curline,
637 ostringstream& token,
640 if (indent.length() + curline.str().length() + token.str().length() >
642 os << curline.str() << endl << indent;
645 curline << token.str();
656 const size_t linelen = 68;
660 os <<
"\n*-------------------------------------------------------------------*\n"
661 <<
"Workspace method = " << mdr.
Name()
662 <<
"\n---------------------------------------------------------------------\n"
671 while (indent.length() < mdr.
Name().length() + 2) indent +=
' ';
673 os <<
"\nSynopsis:\n\n";
674 buf << mdr.
Name() <<
"( ";
676 for (
Index i = 0; i < mdr.
Out().nelem(); ++i) {
691 if (mdr.
GOut()[i].length())
692 param << mdr.
GOut()[i];
694 param <<
"gout" << i;
715 if (mdr.
GIn()[i].length()) {
716 param << mdr.
GIn()[i];
723 if (buf.str().length()) os << buf.str();
728 bool is_first_author =
true;
730 if (is_first_author) {
732 is_first_author =
false;
741 os <<
"\n\nVariables:\n\n";
749 for (
Index i = 0; i < mdr.
Out().nelem(); ++i) {
761 if (buf.str().length() + desc.length() > linelen) {
763 buf << endl << indent << desc;
768 os << buf.str() << endl;
771 for (
Index i = 0; i < mdr.
GOut().nelem(); ++i) {
773 buf <<
"GOUT " << mdr.
GOut()[i] <<
" (";
776 bool firstarg =
true;
785 buf << wsv_groups[mdr.
GOutType()[i]];
790 lastlen = desc.length();
798 buf << endl << indent << desc;
799 }
else if (lastlen + desc.length() > linelen) {
806 os << buf.str() << endl;
809 for (
Index i = 0; i < mdr.
In().nelem(); ++i) {
821 if (buf.str().length() + desc.length() > linelen) {
823 buf << endl << indent << desc;
828 os << buf.str() << endl;
831 for (
Index i = 0; i < mdr.
GIn().nelem(); ++i) {
833 buf <<
"GIN " << mdr.
GIn()[i] <<
" (";
836 bool firstarg =
true;
845 buf << wsv_groups[mdr.
GInType()[i]];
849 buf <<
", Default: ";
859 lastlen = desc.length();
867 buf << endl << indent << desc;
868 }
else if (lastlen + desc.length() > linelen) {
870 buf << endl << indent << desc;
875 os << buf.str() << endl;
878 os <<
"\n*-------------------------------------------------------------------*\n";
base max(const Array< base > &x)
Max function.
The global header file for ARTS.
This can be used to make arrays out of anything.
Index nelem() const ARTS_NOEXCEPT
All information for one workspace method.
ArrayOfIndex mgouttype
Generic Workspace Output Type.
ArrayOfArrayOfIndex mginspectype
Generic Workspace Input Types (Contains the valid types if the method.
bool muses_templates
Flag, whether method implementation relies on templates.
const ArrayOfIndex & In() const
ArrayOfIndex moutput
Workspace Output.
String mactual_groups
The actual groups of a supergeneric method.
const String & Name() const
void subst_any_with_specific_group(Index g)
Expand supergeneric record for given Index in GOutSpecType and GInSpecType.
const ArrayOfIndex & InOnly() const
const ArrayOfIndex & GOutType() const
const Array< String > & GOutDescription() const
const String & ActualGroups() const
String mname
The name of this method.
const Array< String > & GInDefault() const
MdRecord()
Default constructor.
ArrayOfIndex minout
Indexes of Input-Output variables.
const ArrayOfArrayOfIndex & GInSpecType() const
ArrayOfString mgindefault
Generic Workspace Input Defaults.
const String & Description() const
const ArrayOfString & GOut() const
ArrayOfIndex minput
Workspace Input.
ArrayOfIndex mgintype
Generic Workspace Input.
void subst_any_with_group(Index g)
Expand supergeneric record for given group.
ArrayOfIndex moutonly
Indexes of Output-only variables.
const Array< String > & GInDescription() const
friend void subst_any_with_group(MdRecord &mdd, Index g)
ArrayOfIndex minonly
Indexes of Input-only variables.
bool Supergeneric() const
ostream & PrintTemplate(ostream &os, bool show_description=true) const
Print method template for the control file.
const ArrayOfString & Authors() const
ArrayOfString mgin
Generic Workspace Input Names.
const ArrayOfArrayOfIndex & GOutSpecType() const
const ArrayOfIndex & Out() const
const ArrayOfIndex & GInType() const
ArrayOfString mgout
Generic Workspace Output Names.
ArrayOfArrayOfIndex mgoutspectype
Generic Workspace Output Types (Contains the valid types if the method.
const ArrayOfString & GIn() const
bool msupergeneric
Flag, whether this method is supergeneric.
static const Index npos
Define npos:
#define ARTS_ASSERT(condition,...)
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Returns list of ids of the given group names.
INDEX Index
The type to use for all integer numbers and indices.
Declaration of the class MdRecord.
void define_md_raw_map()
Define MdRawMap.
void get_short_wsv_description(String &s, const String &desc)
void define_md_map()
Define MdMap.
void expand_md_data_raw_to_md_data()
Expand supergeneric methods.
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.
bool format_paragraph(String &s, const String &indent, const size_t linelen, const size_t offset)
my_basic_string< char > String
The String type for ARTS.
const ArrayOfGroupRecord wsv_groups
The names associated with Wsv groups as Strings.
const Array< MdRecord > md_data_raw
Lookup information for workspace methods.
Array< WsvRecord > wsv_data
const Array< MdRecord > md_data
Lookup information for workspace methods.
std::map< String, Index > WsvMap
const map< String, Index > MdMap
The map associated with md_data.
const map< String, Index > MdRawMap
The map associated with md_data_raw.
This file contains the Workspace class.
Auxiliary header stuff related to workspace variable groups.