Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef MODELCOMP_H
00019 #define MODELCOMP_H
00020
00021 #include "CompDescr.h"
00022 #include <list>
00023 #include <string>
00024 #include <vector>
00025
00026 class AmplModel;
00027 class StochModel;
00028 class SyntaxNode;
00029 class SyntaxNodeIx;
00030 class SyntaxNodeIDREF;
00031
00032 enum { NOARG = 0,
00033 WITHARG = 1,
00034 ONLYARG = 2};
00035
00037 typedef enum {TVAR, TCON, TPARAM, TSET, TMIN, TMAX, TMODEL, TNOTYPE} compType;
00038
00052 class ModelComp{
00053 public:
00054 static const std::string nameTypes[];
00055 static const std::string compTypes[];
00056
00058 compType type;
00059
00061 std::string id;
00062
00064 SyntaxNode *attributes;
00065
00067 SyntaxNodeIx *indexing;
00068
00070 AmplModel *model;
00071
00074 AmplModel *other;
00075
00076 protected:
00077
00082 std::list<ModelComp*> dependencies;
00083
00087 bool tag;
00088
00092 CompDescr *value;
00093
00094 public:
00095
00097 ModelComp(const std::string& id_, compType type_,
00098 SyntaxNode *indexing_, SyntaxNode *attrib);
00099
00101 ModelComp(const std::string& id);
00102
00104 virtual ~ModelComp();
00105
00107 void setTo(const std::string& id_, compType type_,
00108 SyntaxNodeIx *indexing_, SyntaxNode *attrib);
00109
00111 void setUpDependencies();
00112
00114 void dump(std::ostream& fout) const;
00115
00117 void print() const;
00118
00120 void printBrief() const;
00121
00123 void tagDependencies();
00124
00126 void reassignDependencies();
00127
00129 bool isTagged() const { return tag; }
00130
00132 static void untagAll();
00133
00135 static void untagAll(AmplModel *start);
00136
00138 static void writeAllTagged(AmplModel *start);
00139
00141 static void modifiedWriteAllTagged(std::ostream &fout);
00142
00144 CompDescr* getValue() const { return value; }
00145
00147 void setValue(CompDescr *val) { value = val; }
00148
00150 void moveUp(int level);
00151
00153 virtual ModelComp *clone() const;
00154
00156 ModelComp *deep_copy() const;
00157
00158
00159
00160 virtual void setStochModel(StochModel *stoch) { throw; }
00161 virtual void setStageSet(SyntaxNode *stageSet) { throw; }
00162 virtual void setDeterministic(bool det) { throw; }
00163 virtual const SyntaxNode* getStageSet() const { throw; }
00164 virtual void addStageName(const std::string& name) { throw; }
00165 virtual const std::vector<std::string>& getStageNames() const { throw; }
00166 virtual ModelComp* transcribeToModelComp(AmplModel *current_model,
00167 const std::string& nodedummy,
00168 const std::string& stagedummy,
00169 const int level) { throw; }
00170
00171 protected:
00172
00174 int count;
00175
00176 private:
00177
00179 static std::list<ModelComp*> global_list;
00180
00182 static int tt_count;
00183
00185 void findDependencies(const SyntaxNode *nd);
00186
00187 };
00188
00189 std::string
00190 getGlobalName(const ModelComp *node, const SyntaxNode *opn,
00191 const AmplModel *current_model, int witharg);
00192 std::string
00193 getGlobalNameNew(const ModelComp *node, const SyntaxNode *opn,
00194 const AmplModel *current_model, int witharg);
00195
00196 #endif