00001
00004
00005
00006
00007
00008
00009
00010
00011 #include "tp_attributes.h"
00012
00013 namespace faudes {
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 void AttributeTimedTrans::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00024 if(IsDefault()) return;
00025 AttributeFlags::DoWrite(rTw,"",pContext);
00026 if(mGuard.Empty() && mResets.Empty()) return;
00027 std::string label=rLabel;
00028 FD_DC("AttributeTimedTrans(" << this << ")::DoWrite(tr): to section " << label);
00029 if(label=="") label="Timing";
00030 rTw.WriteBegin(label);
00031 if(!mGuard.Empty())
00032 mGuard.Write(rTw);
00033 if(!mResets.Empty())
00034 mResets.Write(rTw);
00035 rTw.WriteEnd(label);
00036 }
00037
00038
00039
00040 void AttributeTimedTrans::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00041
00042 AttributeFlags::DoRead(rTr,"",pContext);
00043
00044 std::string label=rLabel;
00045 if(label=="") label="Timing";
00046 FD_DC("AttributeTimedTrans(" << this << ")::DoRead(tr): from section " << label);
00047
00048 mGuard.Clear();
00049 mResets.Clear();
00050
00051 Token token;
00052 rTr.Peek(token);
00053 if(token.Type()!=Token::Begin) return;
00054 if(token.StringValue()!=label) return;
00055
00056 rTr.ReadBegin(label);
00057 while (rTr.Peek(token)) {
00058
00059 if (token.Type() != Token::Begin) break;
00060
00061 if (token.StringValue() == "Guard") {
00062 mGuard.Read(rTr,"Guard");
00063 continue;
00064 }
00065
00066 if (token.StringValue() == "Resets") {
00067 mResets.Read(rTr,"Resets");
00068 continue;
00069 }
00070
00071 std::stringstream errstr;
00072 errstr << "invalid transition timing" << rTr.FileLine();
00073 throw Exception("AttributeTimedTrans::Read", errstr.str(), 52);
00074 }
00075 mGuard.Name("Guard");
00076 mResets.Name("Resets");
00077 rTr.ReadEnd(label);
00078 }
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088 void AttributeTimedState::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00089 (void) pContext;
00090 if(IsDefault()) return;
00091 AttributeFlags::DoWrite(rTw,"",pContext);
00092 std::string label=rLabel;
00093 if(label=="") label="Invariant";
00094 FD_DC("AttributeTimedState(" << this << ")::DoWrite(tr): to section " << label);
00095 if(!mInvariant.Empty())
00096 mInvariant.Write(rTw,label);
00097 }
00098
00099
00100
00101 void AttributeTimedState::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00102
00103 AttributeFlags::DoRead(rTr,"",pContext);
00104
00105 std::string label=rLabel;
00106 if(label=="") label="Invariant";
00107 FD_DC("AttributeTimedState(" << this << ")::DoRead(tr): from section " << label);
00108
00109 mInvariant.Clear();
00110
00111 Token token;
00112 rTr.Peek(token);
00113 if(token.Type()!=Token::Begin) return;
00114 if(token.StringValue()!=label) return;
00115
00116 mInvariant.Read(rTr,label);
00117 }
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 void AttributeTimedGlobal::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
00128 (void) pContext;
00129 if(IsDefault()) return;
00130 std::string label=rLabel;
00131 if(label=="") label="Clocks";
00132 FD_DC("AttributeTimedGlobal(" << this << ")::DoWrite(tr): to section " << label);
00133 mClocks.Write(rTw,label);
00134 }
00135
00136
00137 void AttributeTimedGlobal::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
00138 std::string label=rLabel;
00139 if(label=="") label="Clocks";
00140 FD_DC("AttributeTimedGlobal(" << this << ")::DoRead(tr): from section " << label);
00141 (void) pContext;
00142 mClocks.Clear();
00143 Token token;
00144 rTr.Peek(token);
00145 if(token.Type()!=Token::Begin) return;
00146 if(token.StringValue()!=label) return;
00147 mClocks.Read(rTr,label);
00148 }
00149
00150
00151
00152
00153
00154
00155 }
00156