[Avida-SVN] r1808 - branches/uml/source/main
hjg at myxo.css.msu.edu
hjg at myxo.css.msu.edu
Sun Jul 15 11:44:53 PDT 2007
Author: hjg
Date: 2007-07-15 14:44:53 -0400 (Sun, 15 Jul 2007)
New Revision: 1808
Modified:
branches/uml/source/main/cUMLModel.cc
branches/uml/source/main/cUMLStateDiagram.cc
branches/uml/source/main/cUMLStateDiagram.h
Log:
Modified: branches/uml/source/main/cUMLModel.cc
===================================================================
--- branches/uml/source/main/cUMLModel.cc 2007-07-15 01:54:29 UTC (rev 1807)
+++ branches/uml/source/main/cUMLModel.cc 2007-07-15 18:44:53 UTC (rev 1808)
@@ -58,7 +58,8 @@
int num_sd = 0;
int cur_sd = -1;
// char c;
- std::string tr_l, tr_o, gu, act;
+ std::string tr_l, tr_o, gu, act, temp;
+ int trig_i, guard_i, act_i, orig_i, dest_i;
std::ifstream infile;
infile.open("seed-model.cfg");
assert(infile.is_open());
@@ -107,12 +108,21 @@
// std::cout << "Adding an action " << act << std::endl;
infile >> act;
}
+ } else if (line == "-TRANSITIONS---------------") {
+ line.erase();
+ infile >> temp;
+ while (temp != "-END---------------------------") {
+// std::cout << "Ug in here again. Curr sd: " << cur_sd << std::endl;
+ infile >> orig_i >> dest_i >> trig_i >> guard_i >> act_i;
+ state_diagrams[cur_sd].addTransitionTotal(orig_i, dest_i, trig_i, guard_i, act_i);
+ infile >> temp;
+ }
+
}
+
- /* Missing code for reading in transition labels and transitions.... */
+ /* Missing code for reading in transition labels .... */
-
-
line.erase();
}
@@ -130,12 +140,11 @@
// int v;
xmi = xmi_begin;
-
-// xmi += xmi_class1;
-// xmi += state_diagrams[0].getXMI();
-// xmi += xmi_class2;
+ xmi += xmi_class1;
+ xmi += state_diagrams[0].getXMI("sd0");
+ xmi += xmi_class2;
// state_diagrams[1].printXMI();
- xmi += state_diagrams[1].getXMI();
+ xmi += state_diagrams[1].getXMI("sd1");
xmi += xmi_end;
Modified: branches/uml/source/main/cUMLStateDiagram.cc
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.cc 2007-07-15 01:54:29 UTC (rev 1807)
+++ branches/uml/source/main/cUMLStateDiagram.cc 2007-07-15 18:44:53 UTC (rev 1808)
@@ -369,7 +369,16 @@
return true;
}
+bool cUMLStateDiagram::addTransitionTotal(int o, int d, int t, int g, int a) {
+ absoluteJumpGuard(g);
+ absoluteJumpAction(a);
+ absoluteJumpTrigger(t);
+ absoluteJumpOriginState(o);
+ absoluteJumpDestinationState(d);
+ return addTransitionTotal();
+}
+
bool cUMLStateDiagram::addTransitionTotal()
{
// Check that there are two vertices
@@ -462,17 +471,19 @@
}
-std::string cUMLStateDiagram::getXMI()
+std::string cUMLStateDiagram::getXMI(std::string name)
{
- printXMI();
+ printXMI(name);
return (xmi);
}
-void cUMLStateDiagram::printXMI()
+void cUMLStateDiagram::printXMI(std::string name)
{
std::string temp, temp1, temp2, temp3;
std::string trig_label, trig_op_name;
+ std::string sd = name;
+
boost::graph_traits<state_diagram>::edge_iterator edge_start, edge_end;
boost::graph_traits<state_diagram>::edge_descriptor ed;
@@ -484,12 +495,12 @@
// edge or not.
if (numStates() > 0) {
temp = "_1";
- xmi += "<UML:Pseudostate xmi.id=\"s" + temp + "\" kind=\"initial\" outgoing=\"\" name=\"s";
+ xmi += "<UML:Pseudostate xmi.id=\"" + sd + "s" + temp + "\" kind=\"initial\" outgoing=\"\" name=\"s";
xmi += temp + "\" isSpecification=\"false\"/>\n";
}
for (; s_count < numStates(); ++s_count) {
- temp = "s" + StringifyAnInt(s_count);
+ temp = sd + "s" + StringifyAnInt(s_count);
xmi+="<UML:CompositeState xmi.id=\"";
xmi+=temp;
xmi+= "\" isConcurrent=\"false\" name=\"";
@@ -505,7 +516,6 @@
// start the set of transitions...
xmi+="<UML:StateMachine.transitions>\n";
-
// Get the set of transitions.
for (tie(edge_start, edge_end) = edges(sd0);
edge_start != edge_end; ++edge_start) {
@@ -513,9 +523,9 @@
ed = *edge_start;
// info determined from the trans itself....
- temp = "t" + StringifyAnInt(t_count);
- temp1 = "s" + StringifyAnInt(source(ed, sd0));
- temp2 = "s" + StringifyAnInt(target(ed, sd0));
+ temp = sd + "t" + StringifyAnInt(t_count);
+ temp1 = sd + "s" + StringifyAnInt(source(ed, sd0));
+ temp2 = sd + "s" + StringifyAnInt(target(ed, sd0));
temp3 = temp + temp1 + temp2;
xmi+= "<UML:Transition xmi.id=\"" + temp3 + "\"";
@@ -559,9 +569,9 @@
}
// Add one transition to connect the init state to state 0
- temp = "t" + StringifyAnInt(t_count);
- temp1 = "s" + StringifyAnInt(-1);
- temp2 = "s" + StringifyAnInt(0);
+ temp = sd + "t" + StringifyAnInt(t_count);
+ temp1 = sd + "s" + StringifyAnInt(-1);
+ temp2 = sd + "s" + StringifyAnInt(0);
temp3 = temp + temp1 + temp2;
xmi+= "<UML:Transition xmi.id=\"" + temp3 + "\"";
@@ -573,3 +583,4 @@
}
+
Modified: branches/uml/source/main/cUMLStateDiagram.h
===================================================================
--- branches/uml/source/main/cUMLStateDiagram.h 2007-07-15 01:54:29 UTC (rev 1807)
+++ branches/uml/source/main/cUMLStateDiagram.h 2007-07-15 18:44:53 UTC (rev 1808)
@@ -64,8 +64,8 @@
cUMLStateDiagram();
~cUMLStateDiagram();
- void printXMI(); // print the XMI version of the model
- std::string getXMI (); // get the xmi string (including beginning & end read from file.)
+ void printXMI(std::string); // print the XMI version of the model
+ std::string getXMI (std::string); // get the xmi string (including beginning & end read from file.)
std::string StringifyAnInt(int);
int numStates();
int numTrans();
@@ -148,6 +148,7 @@
// bool addTransition();
bool addTransitionTotal();
+ bool addTransitionTotal(int, int, int, int, int);
bool addTrigger(std::string, std::string);
bool addGuard(std::string);
bool addAction(std::string);
More information about the Avida-cvs
mailing list