-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsequencediagrambuilder.cpp
92 lines (83 loc) · 3 KB
/
sequencediagrambuilder.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "sequencediagrambuilder.h"
#include "actorbuilder.h"
#include "messagebuilder.h"
#include "combinedfragmentbuilder.h"
#include "node.h"
#include <iostream>
using namespace std;
SequenceDiagramBuilder::SequenceDiagramBuilder(string inputFile)
{
(this->doc).LoadFile();
if(! (this->doc.LoadFile(inputFile.c_str())))
{
cerr << doc.ErrorDesc() << endl;
}
(this->docEle) = (this->doc).FirstChildElement();
}
void SequenceDiagramBuilder::build(SequenceDiagram& sd)
{
CombinedFragment cf_null(string(""),-1);
vector<Message> msgList;
vector<Actor> actorList = sd.getActorList();
ActorBuilder acb;
acb.build(actorList,(this->docEle));
for(unsigned int i =0; i < actorList.size(); i++)
{
string var = actorList[i].toString();
cout<<var<<endl;
}
MessageBuilder mb;
mb.build(actorList,msgList,(this->docEle));
for(unsigned int i =0; i<msgList.size();i++)
{
Message_List[msgList[i].getID()] = NULL;
}
vector<CombinedFragment> fragList;
vector<TiXmlElement*> ele_fragList;
ele_fragList = (this->docEle)->GetElementsByTagName("fragment",ele_fragList);
if(ele_fragList.size()>0)
{
for(unsigned int i =0; i<ele_fragList.size(); i++)
{
if(ele_fragList[i]->Attribute("xmi:type")!=NULL && ele_fragList[i]->Attribute("xmi:type") == string("uml:CombinedFragment"))
{
CombinedFragment cf;
CombinedFragmentBuilder cfb;
cf = cfb.build(ele_fragList[i],msgList);
fragList.push_back(cf);
}
}
}
vector<TiXmlElement*> nl;
nl = (this->docEle)->GetElementsByTagName("uml:DiagramElement",nl);
for(unsigned int i=0; i<nl.size(); i++)
{
if(nl[i]->Attribute("preferredShapeType")!= NULL && nl[i]->Attribute("preferredShapeType") == string("Message"))
{
for(unsigned int j =0; j<msgList.size(); j++)
{
if(nl[i]->Attribute("subject")!= NULL && nl[i]->Attribute("subject") == msgList[j].getID() && Message_List[msgList[j].getID()]==NULL)
{
Node temp(msgList[j].getType(),msgList[j]);
sd.push_seq(temp);
}
}
}
else if(nl[i]->Attribute("preferredShapeType")!= NULL && nl[i]->Attribute("preferredShapeType") == string("CombinedFragment"))
{
for(unsigned int j =0; j<fragList.size(); j++)
{
if(nl[i]->Attribute("subject")!= NULL && nl[i]->Attribute("subject") == fragList[j].getID())
{
CombinedFragment *tem = new CombinedFragment;
*tem = fragList[j];
Node temp(tem->getType(),tem);
sd.push_seq(temp);
}
}
}
}
/*for (map<string, int>::const_iterator i = Partitions.begin(); i != Partitions.end(); ++i)
cout << i->first << ": " << i->second << endl;*/
cout<<"asddfd "<<fragList.size()<<endl;;
}