00001
00011 #ifndef BEHAVIORTEMPLATE_H
00012 #define BEHAVIORTEMPLATE_H
00013
00014 #include "VariableTableTemplate.h"
00015 #include "parser/impcomp/UnresOpSeq.h"
00016 #include "parser/impcomp/OpSeq.h"
00017
00018 namespace green
00019 {
00027 class BehaviorTemplate : public VariableTableTemplate
00028 {
00029 public:
00030 BehaviorTemplate() : VariableTableTemplate(), mMsgType(0)
00031 {
00032 isGeneric = 0;
00033 }
00034
00041 inline
00042 void SetMessageType(Key msgType) {
00043 mMsgType = msgType;
00044 }
00045
00051 inline
00052 void SetMessageName(const Name& name) {
00053 mMsgName = name;
00054 }
00055
00062 inline
00063 Key GetMessageType() const {
00064 return mMsgType;
00065 }
00066
00073 inline
00074 const Name& GetMessageName() const {
00075 return mMsgName;
00076 }
00077
00081 void SetGeneric(int genericIn) {
00082 isGeneric = genericIn;
00083 }
00084
00088 int GetGeneric() const {
00089 return isGeneric;
00090 }
00091
00092
00096 void addInitCode(UnresOpSeqPtr uInitCodeIn) {
00097
00098 unresInitCode = uInitCodeIn;
00099 }
00100
00105 UnresOpSeqPtr getInitCode() {
00106 return unresInitCode;
00107 }
00108
00112 void addBodyCode(UnresOpSeqPtr uBodyCodeIn) {
00113
00114 unresBodyCode = uBodyCodeIn;
00115 }
00116
00121 UnresOpSeqPtr getBodyCode() {
00122 return unresBodyCode;
00123 }
00124
00125
00133 void addResolvedInit(VariableTableTemplatePtr argList,OpSeqPtr resdCode) {
00134
00135 initCode = resdCode;
00136
00137
00138
00139 InitFormatPtr initFormat(new InitFormat());
00140 for (size_t i=0;i<argList->GetNumEntries();++i)
00141 initFormat->push_back(InitArgFormat(i,argList->GetEntry(i).mType));
00142 }
00143
00148 void addResolvedBody(OpSeqPtr resdCode) {
00149
00150 bodyCode = resdCode;
00151 }
00152
00153
00154
00159 OpSeqPtr getResInitCode() {
00160 return initCode;
00161 }
00162
00163
00168 OpSeqPtr getResBodyCode() {
00169 return bodyCode;
00170 }
00171
00172
00173
00178 virtual void Print(std::ostream& os)
00179 {
00180 VariableTableTemplate::Print(os);
00181 os << std::endl;
00182 os << "Behavior:" << std::endl;
00183
00184 os << "msg name: " << mMsgName << " key: " << mMsgType << std::endl;
00185
00186 os << "CODE:" << std::endl;
00187 os << "init:" << std::endl;
00188 if(unresInitCode.get())
00189 unresInitCode->dumpScreen();
00190 else
00191 os << " undefined unresInitCode" << std::endl;
00192
00193 if(initCode.get())
00194 initCode->dumpScreen();
00195 else
00196 os << " undefined initCode" << std::endl;
00197
00198 os << "body:" << std::endl;
00199
00200 if(unresBodyCode.get())
00201 unresBodyCode->dumpScreen();
00202 else
00203 os << " undefined unresBodyCode" << std::endl;
00204
00205 if(bodyCode.get())
00206 bodyCode->dumpScreen();
00207 else
00208 os << " undefined bodyCode" << std::endl;
00209 }
00210
00211
00212
00213
00214 protected:
00215 Key mMsgType;
00216 Name mMsgName;
00217
00218 int isGeneric;
00219
00220
00221 UnresOpSeqPtr unresInitCode;
00222 OpSeqPtr initCode;
00223 UnresOpSeqPtr unresBodyCode;
00224 OpSeqPtr bodyCode;
00225 };
00226 typedef boost::shared_ptr<BehaviorTemplate> BehaviorTemplatePtr;
00227 #define BEHAVIOR_TEMPLATE_CAST(x) boost::dynamic_pointer_cast<BehaviorTemplate>(x)
00228 }
00229
00230 #endif