From: petr000 Date: Thu, 11 Aug 2011 09:06:07 +0000 (+0200) Subject: Add support for orthogonal states. X-Git-Url: http://rtime.felk.cvut.cz/gitweb/boost-statechart-viewer.git/commitdiff_plain/38c30df17ef0c04c9eac169343008c48f6f9d118 Add support for orthogonal states. The orthogonal states are correctly printed into the output file and also into the transition table Add method test_start that tests all start states in that context. --- diff --git a/src/iooper.h b/src/iooper.h index f85ed64..4ce3658 100644 --- a/src/iooper.h +++ b/src/iooper.h @@ -104,33 +104,62 @@ class IO_operations { this->outputFilename = outputFilename; } + + bool test_start(const string *sState, const string state, const int num) + { + for(int i = 0; i nstates = states; context = name_of_machine; table[0] = "S"; table[1] = "Context"; table[2] = "State"; + cnt = count(name_of_first_state,','); + sState = new string [cnt+1]; + str = name_of_first_state; + if(cnt>0) str = get_params(str); + num_start = cnt+1; + for(int i = 0;i<=cnt;i++) + { + if(i == cnt) sState[i] = str; + else + { + sState[i] = str.substr(0,str.find(',')); + str = str.substr(str.find(',')+1); + } + } for(list::iterator i = nstates.begin();i!=nstates.end();i++) // write all states in the context of the automaton { state = *i; cnt = count(state,','); - if(cnt==1) + if(count(state,'>')==1) //ortho states + { + orto = 1; + if(cnt>1)cnt = 2; + } + if(cnt==1) { pos1 = state.find(","); - ctx = cut_namespaces(state.substr(pos1+1)); + if(orto == 1) ctx = cut_namespaces(cut_namespaces(state.substr(pos1+1),1)); + else ctx = cut_namespaces(state.substr(pos1+1)); if(ctx.compare(0,context.length(),context)==0 && context.length()==ctx.length()) { str = cut_namespaces(state.substr(0,pos1)); - if(str.compare(0,name_of_first_state.length(),name_of_first_state)==0 && name_of_first_state.length()==str.length()) + if(test_start(sState,str,num_start)) { filestr<0) str = get_params(str); + num_start = cnt+1; + for(int i = 0;i<=cnt;i++) + { + if(i == cnt) sState[i] = str; + else + { + sState[i] = str.substr(0,str.find(',')); + str = str.substr(str.find(',')+1); + } + } + nstates.pop_front(); for(list::iterator i = nstates.begin();i!=nstates.end();i++) { state = *i; cnt = count(state,','); + if(count(state,'>')==1) //ortho states + { + orto = 1; + if(cnt>1)cnt = 2; + } if(cnt==1) { pos1 = state.find(","); - ctx = cut_namespaces(state.substr(pos1+1)); + if(orto == 1) ctx = cut_namespaces(cut_namespaces(state.substr(pos1+1),1)); + else ctx = cut_namespaces(state.substr(pos1+1)); if(ctx.compare(0,context.length(),context)==0 && context.length()==ctx.length()) { str = cut_namespaces(state.substr(0,pos1)); - if(str.compare(0,sState.length(),sState)==0 && sState.length()==str.length()) + if(test_start(sState,str,num_start)) { filestr<0;i--) + { + if(line[i]=='<') brackets+=1; + if(line[i]=='>') brackets-=1; + if(line[i]==':' && line[i-1]==':') + { + if(brackets == 0) break; + else i--; + } + } + if(i==0) return line; + return line.substr(0,i-1); +} + bool is_derived(const string line) /** Test whether this struct or class is derived */ { unsigned i; @@ -234,7 +252,7 @@ bool test_model(const string line, const string model) /** Test the string to ha string get_params(string line) /** Return parameters of the specified transition */ { int pos_front = line.find("<")+1; - int pos_end = line.find(">"); + int pos_end = line.rfind(">"); return line.substr(pos_front,pos_end-pos_front); }