module.cpp
Go to the documentation of this file.
00001 #include "module.h"
00002 #include <cassert>
00003 
00004 Module::Module(istream &in)
00005 {
00006     string complete_name;
00007     in >> complete_name;
00008     extractNameAndLib(complete_name);
00009     int count;
00010     in >> count;
00011     for (int i = 0; i < count; ++i) {
00012         params.push_back(Parameter(in));
00013     }
00014 }
00015 
00016 void Module::generate_cpp_input(ostream &outfile) const
00017 {
00018     outfile << name << " " << lib << " " << params.size() << " ";
00019     for (int i = 0; i < params.size(); ++i) {
00020         outfile << " " << params[i].name << " " << params[i].type << " "
00021                 << params[i].obj << " ";
00022     }
00023 }
00024 
00025 ConditionModule::ConditionModule(istream &in,
00026         const vector<Variable*> &variables) :
00027     Module(in)
00028 {
00029     int var_no;
00030     in >> var_no;
00031     var = variables[var_no];
00032     var->set_module();
00033 
00034 }
00035 
00036 void ConditionModule::generate_cpp_input(ostream &outfile) const
00037 {
00038     Module::generate_cpp_input(outfile);
00039     outfile << var->get_level() << endl;
00040 }
00041 
00042 EffectModule::EffectModule(istream &in, const vector<Variable*> &variables) :
00043     Module(in)
00044 {
00045     in >> name;
00046     int count;
00047     in >> count;
00048     writtenVars.reserve(count);
00049     int var_no;
00050     for (int i = 0; i < count; ++i) {
00051         in >> var_no;
00052         Variable *var = variables[var_no];
00053         writtenVars.push_back(var);
00054         var->set_module();
00055     }
00056 }
00057 
00058 void EffectModule::generate_cpp_input(ostream &outfile) const
00059 {
00060     Module::generate_cpp_input(outfile);
00061     outfile << name << " " << writtenVars.size();
00062     for (int i = 0; i < writtenVars.size(); ++i) {
00063         outfile << " " << writtenVars[i]->get_level();
00064     }
00065     outfile << endl;
00066 }
00067 
00068 void Module::extractNameAndLib(const string &complete_name)
00069 {
00070     int posOfAt = complete_name.find("@");
00071     name = complete_name.substr(0, posOfAt);
00072     lib = complete_name.substr(posOfAt + 1);
00073 }
00074 
00075 Translate::Translate(istream &in, vector<Variable*> variables)
00076 {
00077     in >> name;
00078     int count;
00079     in >> count;
00080     params.reserve(count);
00081     string param;
00082     for (int i = 0; i < count; ++i) {
00083         in >> param;
00084         params.push_back(param);
00085     }
00086     int var_no;
00087     in >> var_no;
00088     var = variables[var_no];
00089 }
00090 
00091 void Translate::generate_cpp_input(ostream &outfile) const
00092 {
00093     outfile << name;
00094     outfile << " " << params.size();
00095     for (int i = 0; i < params.size(); ++i) {
00096         outfile << " " << params[i];
00097     }
00098     outfile << " " << var->get_level();
00099 }
00100 
00101 TranslatePredicate::TranslatePredicate(istream &in, vector<Variable*> variables) :
00102     Translate(in, variables)
00103 {
00104     in >> value;
00105 }
00106 
00107 void TranslatePredicate::generate_cpp_input(ostream &outfile) const
00108 {
00109     Translate::generate_cpp_input(outfile);
00110     outfile << " " << value << endl;
00111 }
00112 
00113 TranslateFunction::TranslateFunction(istream &in, vector<Variable*> variables) :
00114     Translate(in, variables)
00115 {
00116 }
00117 
00118 void TranslateFunction::generate_cpp_input(ostream &outfile) const
00119 {
00120     Translate::generate_cpp_input(outfile);
00121     outfile << endl;
00122 }
00123 
00124 Parameter::Parameter(istream &in)
00125 {
00126     in >> name >> type >> obj;
00127 }
00128 
00129 Module::~Module()
00130 {
00131 }
00132 
00133 Parameter::~Parameter()
00134 {
00135 }
00136 
00137 Translate::~Translate()
00138 {
00139 }
00140 


tfd_modules
Author(s): Maintained by Christian Dornhege (see AUTHORS file).
autogenerated on Mon Oct 6 2014 07:52:06