40 ostringstream& curline,
53 const char* description,
70 mdescription(description),
79 mgindefault(gindefault),
81 mset_method(set_method),
82 magenda_method(agenda_method),
84 muses_templates(uses_templates),
85 mpass_workspace(pass_workspace),
86 mpass_wsv_names(pass_wsv_names),
102 std::sort(gin_sorted.begin(), gin_sorted.end());
104 std::sort(gout_sorted.begin(), gout_sorted.end());
108 if (*par == *(par + 1)) {
109 std::ostringstream os;
110 os <<
"Two input parameters by the same name are not allowed: \n";
111 os <<
"Method: " <<
mname <<
", Parameter: " << *par;
112 throw std::runtime_error(os.str());
118 if (*par == *(par + 1)) {
119 std::ostringstream os;
120 os <<
"Two output parameters by the same name are not allowed: \n";
121 os <<
"Method: " <<
mname <<
", Parameter: " << *par;
122 throw std::runtime_error(os.str());
128 auto it = std::set_intersection(gin_sorted.begin(),
133 gisect.resize(it - gisect.begin());
135 if (gisect.
nelem() > 0) {
136 std::ostringstream os;
137 os <<
"Using the same name for a generic input and generic output variable is not allowed: \n";
138 os <<
"Method: " <<
mname <<
", Parameter: ";
139 for (
auto& gname : gisect) {
142 throw std::runtime_error(os.str());
147 for (Index j = 0; j < output.
nelem(); ++j) {
151 os <<
"Unknown WSV " << output[j] <<
" for output (parameter #" << j
153 <<
"in WSM " <<
mname;
154 throw runtime_error(os.str());
159 for (Index j = 0; j < input.
nelem(); ++j) {
163 os <<
"Unknown WSV " << input[j] <<
" for input (parameter #" << j <<
") "
164 <<
"in WSM " <<
mname;
165 throw runtime_error(os.str());
172 for (Index j = 0; j < gouttype.
nelem(); ++j) {
176 if (types.
nelem() == 1) {
181 os <<
"WSM " <<
mname <<
" takes \"Any\" as input and\n"
182 <<
"therefore must be implemented as a template function.\n"
183 <<
"Pass USES_TEMPLATES(true) in methods.cc!";
184 throw runtime_error(os.str());
186 }
else if (types.
nelem() > 1) {
191 os <<
"Unknown WSV Group " << gouttype[j] <<
" for generic output "
192 <<
"in WSM " <<
mname;
193 throw runtime_error(os.str());
199 for (Index j = 0; j < gintype.
nelem(); ++j) {
203 if (types.
nelem() == 1) {
208 os <<
"WSM " <<
mname <<
" defines \"Any\" as output and\n"
209 <<
"therefore must be implemented as a template function.\n"
210 <<
"Pass USES_TEMPLATES(true) in methods.cc!";
211 throw runtime_error(os.str());
213 }
else if (types.
nelem() > 1) {
218 os <<
"Unknown WSV Group " << gintype[j] <<
" for generic input "
219 <<
"in WSM " <<
mname;
220 throw runtime_error(os.str());
227 bool consistent =
true;
248 os <<
"Inconsistent number of types given for supergeneric variables"
250 <<
"in WSM " <<
mname <<
"." << endl;
251 throw runtime_error(os.str());
265 for (ArrayOfIndex::const_iterator j =
moutput.begin(); j <
moutput.end(); ++j)
266 for (ArrayOfIndex::iterator k =
minonly.begin(); k <
minonly.end(); ++k)
278 for (ArrayOfIndex::const_iterator j =
moutput.begin(); j <
moutput.end();
280 for (ArrayOfIndex::const_iterator k =
minput.begin(); k <
minput.end(); ++k)
281 if (*j == *k)
minout.push_back(i);
285 for (ArrayOfIndex::const_iterator j =
minput.begin(); j <
minput.end(); ++j)
378 if (wsv_group_id_Any ==
mgintype[j]) {
410 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
411 const MdRecord& mdd = md_data_raw[i];
414 md_data.push_back(mdd);
428 for (Index k = 0; k <
max; k++) {
433 md_data.push_back(mdlocal);
436 for (Index j = 0; j < wsv_groups.
nelem(); ++j) {
439 if (wsv_group_id_Any != j) {
446 md_data.push_back(mdlocal);
468 for (Index i = 0; i < md_data.nelem(); ++i) {
479 methodname = os.str();
481 MdMap[methodname] = i;
498 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
499 MdRawMap[md_data_raw[i].Name()] = i;
505 const size_t linelen,
506 const size_t offset) {
510 size_t currentlinelength = offset;
511 for (
size_t i = 0; i < s.length(); i++) {
512 if (s[i] ==
'\n') s[i] =
' ';
515 if (currentlinelength + token.length() > linelen) {
516 out +=
'\n' + indent;
517 currentlinelength = indent.length();
521 currentlinelength += token.length();
526 if (token.length()) {
527 if (currentlinelength + token.length() > linelen) {
528 out +=
'\n' + indent;
542 pos = desc.find(
".\n");
543 pos2 = desc.find(
". ");
547 s = desc.substr(0, pos + 1);
560 if (show_description) {
588 os << wsv_groups[
GInType()[i]];
600 for (Index i = 0; i <
GIn().
nelem(); ++i)
603 for (Index i = 0; i <
GIn().
nelem(); ++i) {
604 os <<
"\t" << setw((
int)maxsize) <<
GIn()[i] <<
" = \n";
619 ostringstream& curline,
620 ostringstream& token,
623 if (indent.length() + curline.str().length() + token.str().length() >
625 os << curline.str() << endl << indent;
628 curline << token.str();
639 const size_t linelen = 68;
643 os <<
"\n*-------------------------------------------------------------------*\n"
644 <<
"Workspace method = " << mdr.
Name()
645 <<
"\n---------------------------------------------------------------------\n"
654 while (indent.length() < mdr.
Name().length() + 2) indent +=
' ';
656 os <<
"\nSynopsis:\n\n";
657 buf << mdr.
Name() <<
"( ";
659 for (Index i = 0; i < mdr.
Out().nelem(); ++i) {
669 for (Index i = 0; i < mdr.
GOutType().nelem(); ++i) {
674 if (mdr.
GOut()[i].length())
675 param << mdr.
GOut()[i];
677 param <<
"gout" << i;
683 for (Index i = 0; i < inonly.
nelem(); ++i) {
693 for (Index i = 0; i < mdr.
GInType().nelem(); ++i) {
698 if (mdr.
GIn()[i].length()) {
699 param << mdr.
GIn()[i];
706 if (buf.str().length()) os << buf.str();
711 bool is_first_author =
true;
712 for (Index i = 0; i < mdr.
Authors().nelem(); i++) {
713 if (is_first_author) {
715 is_first_author =
false;
724 os <<
"\n\nVariables:\n\n";
732 for (Index i = 0; i < mdr.
Out().nelem(); ++i) {
744 if (buf.str().length() + desc.length() > linelen) {
746 buf << endl << indent << desc;
751 os << buf.str() << endl;
754 for (Index i = 0; i < mdr.
GOut().nelem(); ++i) {
756 buf <<
"GOUT " << mdr.
GOut()[i] <<
" (";
759 bool firstarg =
true;
760 for (Index j = 0; j < mdr.
GOutSpecType()[i].nelem(); j++) {
768 buf << wsv_groups[mdr.
GOutType()[i]];
773 lastlen = desc.length();
781 buf << endl << indent << desc;
782 }
else if (lastlen + desc.length() > linelen) {
789 os << buf.str() << endl;
792 for (Index i = 0; i < mdr.
In().nelem(); ++i) {
804 if (buf.str().length() + desc.length() > linelen) {
806 buf << endl << indent << desc;
811 os << buf.str() << endl;
814 for (Index i = 0; i < mdr.
GIn().nelem(); ++i) {
816 buf <<
"GIN " << mdr.
GIn()[i] <<
" (";
819 bool firstarg =
true;
820 for (Index j = 0; j < mdr.
GInSpecType()[i].nelem(); j++) {
828 buf << wsv_groups[mdr.
GInType()[i]];
832 buf <<
", Default: ";
842 lastlen = desc.length();
850 buf << endl << indent << desc;
851 }
else if (lastlen + desc.length() > linelen) {
853 buf << endl << indent << desc;
858 os << buf.str() << endl;
861 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.
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.