operator.h
Go to the documentation of this file.
00001 #ifndef OPERATOR_H
00002 #define OPERATOR_H
00003 
00004 #include <iostream>
00005 #include <fstream>
00006 #include <string>
00007 #include <vector>
00008 #include "helper_functions.h"
00009 using namespace std;
00010 
00011 class Variable;
00012 
00013 class Operator {
00014     public:
00015         struct Prevail {
00016             Variable *var;
00017             int prev;
00018             Prevail(Variable *v, int p) :
00019                 var(v), prev(p) {
00020                 }
00021         };
00022         struct EffCond {
00023             Variable *var;
00024             int cond;
00025             EffCond(Variable *v, int c) :
00026                 var(v), cond(c) {
00027                 }
00028         };
00029         struct PrePost {
00030             Variable *var;
00031             int pre, post;
00032             bool is_conditional_effect;
00033             vector<EffCond> effect_conds_start;
00034             vector<EffCond> effect_conds_overall;
00035             vector<EffCond> effect_conds_end;
00036             PrePost(Variable *v, int pr, int po) :
00037                 var(v), pre(pr), post(po) {
00038                     is_conditional_effect = false;
00039                 }
00040             PrePost(Variable *v, vector<EffCond> ecs_start, vector<EffCond> ecs_overall,
00041                     vector<EffCond> ecs_end, int pr, int po) :
00042                 var(v), pre(pr), post(po), effect_conds_start(ecs_start),
00043                 effect_conds_overall(ecs_overall), effect_conds_end(ecs_end) {
00044                     is_conditional_effect = true;
00045                 }
00046         };
00047 
00048         struct NumericalEffect {
00049             Variable *var;
00050             vector<EffCond> effect_conds_start;
00051             vector<EffCond> effect_conds_overall;
00052             vector<EffCond> effect_conds_end;
00053             foperator fop;
00054             Variable *foperand;
00055             bool is_conditional_effect;
00056             NumericalEffect(Variable *v, foperator fotor, Variable *fand) :
00057                 var(v), fop(fotor), foperand(fand) {
00058                     is_conditional_effect = false;
00059                 }
00060             NumericalEffect(Variable *v, vector<EffCond> ecs_start, vector<EffCond> ecs_overall,
00061                     vector<EffCond> ecs_end, foperator fotor, Variable *fand) :
00062                 var(v), effect_conds_start(ecs_start), effect_conds_overall(ecs_overall), effect_conds_end(ecs_end), 
00063                 fop(fotor), foperand(fand) {
00064                     is_conditional_effect = true;
00065                 }
00066         };
00067 
00068         struct ModuleEffect
00069         {
00070                 string name;
00071                 vector<EffCond> effect_conds_start;
00072                 vector<EffCond> effect_conds_overall;
00073                 vector<EffCond> effect_conds_end;
00074                 ModuleEffect(string _name, vector<EffCond> ecs_start, vector<
00075                         EffCond> ecs_overall, vector<EffCond> ecs_end) :
00076                     name(_name), effect_conds_start(ecs_start),
00077                             effect_conds_overall(ecs_overall),
00078                             effect_conds_end(ecs_end)
00079                 {
00080                 }
00081                 ModuleEffect(string _name) :
00082                     name(_name)
00083                 {
00084                 }
00085         };
00086 
00087     private:
00088         string name;
00089         vector<Prevail> prevail_start; // var, val
00090         vector<Prevail> prevail_overall; // var, val
00091         vector<Prevail> prevail_end; // var, val
00092         vector<PrePost> pre_post_start; // var, old-val, new-val
00093         vector<PrePost> pre_post_end; // var, old-val, new-val
00094         vector<NumericalEffect> numerical_effs_start; // comp, first-op, sec-op
00095         vector<NumericalEffect> numerical_effs_end; // comp, first-op, sec-op
00096         vector<ModuleEffect> module_effs_start;
00097         vector<ModuleEffect> module_effs_end;
00098 
00099         DurationCond duration_cond;
00100     public:
00101         Operator(istream &in, const vector<Variable *> &variables);
00102 
00103         void strip_unimportant_effects();
00104         bool is_redundant() const;
00105 
00106         void dump() const;
00107         void generate_cpp_input(ostream &outfile) const;
00108         void write_prevails(ostream &outfile, const vector<Prevail> &prevails) const;
00109         void write_effect_conds(ostream &outfile, const vector<EffCond> &conds) const;
00110         void write_pre_posts(ostream &outfile, const vector<PrePost> &pre_posts) const;
00111         void write_num_effect(ostream &outfile, const vector<NumericalEffect> &num_effs) const;
00112         void write_module_effect(ostream &outfile, const vector<ModuleEffect> &mod_effs) const;
00113         string get_name() const {
00114             return name;
00115         }
00116         const DurationCond &get_duration_cond() const {
00117             return duration_cond;
00118         }
00119 
00120         const vector<Prevail> &get_prevail_start() const {
00121             return prevail_start;
00122         }
00123         const vector<Prevail> &get_prevail_overall() const {
00124             return prevail_overall;
00125         }
00126         const vector<Prevail> &get_prevail_end() const {
00127             return prevail_end;
00128         }
00129         const vector<PrePost> &get_pre_post_start() const {
00130             return pre_post_start;
00131         }
00132         const vector<PrePost> &get_pre_post_end() const {
00133             return pre_post_end;
00134         }
00135         const vector<NumericalEffect> &get_numerical_effs_start() const {
00136             return numerical_effs_start;
00137         }
00138         const vector<NumericalEffect> &get_numerical_effs_end() const {
00139             return numerical_effs_end;
00140         }
00141 };
00142 
00143 extern void strip_operators(vector<Operator> &operators);
00144 
00145 #endif


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