pd_gotoattributes.cpp
Go to the documentation of this file.
1 /** @file pd_gotoattributes.cpp Attributes for LR machines*/
2 
3 
4 /* Pushdown plugin for FAU Discrete Event Systems Library (libfaudes)
5 
6  Copyright (C) 2013 Stefan Jacobi, Sven Schneider, Anne-Kathrin Hess
7 
8 */
9 
10 #include "pd_gotoattributes.h"
11 
12 namespace faudes {
13 
14 
15  /*******************************
16  *
17  * Implementation of AttributeGotoTransition
18  *
19  */
20 
21  // faudes type std
22  FAUDES_TYPE_IMPLEMENTATION(Void,AttributeGotoTransition,AttributeVoid)
23 
24  // Assign my members
25  void AttributeGotoTransition::DoAssign(const AttributeGotoTransition& rSrcAttr) {
26  // call base (incl. virtual clear)
27  AttributeVoid::DoAssign(rSrcAttr);
28  // my additional members
29  mpGrammarSymbol = rSrcAttr.mpGrammarSymbol;
30  }
31 
32  // Equality
34  // my members
35  if(*mpGrammarSymbol!=*rOther.mpGrammarSymbol) return false;
36  // pass
37  return true;
38  }
39 
40  //DoWrite(rTw,rLabel,pContext);
41  void AttributeGotoTransition::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
42  (void) pContext;
43  if(IsDefault()) return;
44  std::string label=rLabel;
45  if(label=="") label="";
46  FD_DC("AttributeGotoTransition(" << this << ")::DoWrite(tr): to section " << label);
47 
48  rTw.WriteText(mpGrammarSymbol->Str());
49 
50  }
51 
52  //DoRead(rTr,rLabel,pContext)
53  void AttributeGotoTransition::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
54  std::string label=rLabel;
55  if(label=="") label="";
56  FD_DC("AttributeGotoTransition(" << this << ")::DoRead(tr): from section " << label);
57  (void) pContext;
59  Token token;
60  rTr.Peek(token);
61  if(!token.IsBegin()) return;
62  if(token.StringValue()!=label) return;
63  //mStackSymbols.Read(rTr,label);
64  //TODO implement?
65  }
66 
67 
68 /*******************************
69  *
70  * Implementation of AttributeGotoState
71  *
72  */
73 
74 // faudes type std
76 
77 // Assign my members
78 void AttributeGotoState::DoAssign(const AttributeGotoState& rSrcAttr) {
79  // call base (incl. virtual clear)
80  AttributeFlags::DoAssign(rSrcAttr);
81  // my additional members
82  mConfigSet=rSrcAttr.mConfigSet;
83 }
84 
85 // Equality
87  // base
88  if(!AttributeFlags::DoEqual(rOther)) return false;
89  // my members
90  if(CompareConfigSet(mConfigSet,rOther.mConfigSet) || CompareConfigSet(rOther.mConfigSet,mConfigSet)) return false;
91  // pass
92  return true;
93 }
94 
95 
96 //DoWrite(rTw,rLabel,pContext);
97 void AttributeGotoState::DoWrite(TokenWriter& rTw, const std::string& rLabel, const Type* pContext) const {
98  (void) pContext;
99  if(IsDefault()) return;
100  AttributeFlags::DoWrite(rTw,"",pContext);
101  std::string label=rLabel;
102  if(label=="") label="State";
103  FD_DC("AttributeGotoState(" << this << ")::DoWrite(tr): to section " << label);
104 
105  rTw.WriteText(ConfigSetToStr(mConfigSet) + "\n");
106 }
107 
108 
109 //DoRead(rTr,rLabel,pContext)
110 void AttributeGotoState::DoRead(TokenReader& rTr, const std::string& rLabel, const Type* pContext) {
111  // call base first
112  AttributeFlags::DoRead(rTr,"",pContext);
113  // figure my section
114  std::string label=rLabel;
115  if(label=="") label="State";
116  FD_DC("AttributeGotoState(" << this << ")::DoRead(tr): from section " << label);
117  // clear my data
118  mConfigSet.clear();
119  // test my section
120  Token token;
121  rTr.Peek(token);
122  if(!token.IsBegin()) return;
123  if(token.StringValue()!=label) return;
124  // read my section (can throw exceptions now)
125  //TODO implement?
126 }
127 
128 
129 
130 } // namespace faudes
131 

libFAUDES 2.24g --- 2014.09.15 --- c++ api documentaion by doxygen