1 | /* |
---|
2 | * |
---|
3 | * [desc.] |
---|
4 | */ |
---|
5 | #include "Tools/Viewer/Parser/include/parser.h" |
---|
6 | using namespace morpheo::tools::viewer::bdd; |
---|
7 | namespace morpheo{ |
---|
8 | namespace tools{ |
---|
9 | namespace viewer{ |
---|
10 | namespace parser{ |
---|
11 | |
---|
12 | void Parse::parser_pos(QDomNode n){ |
---|
13 | while( !n.isNull() ) |
---|
14 | { |
---|
15 | QDomElement e = n.toElement(); |
---|
16 | if( !e.isNull() ) |
---|
17 | { |
---|
18 | |
---|
19 | if( e.tagName() == "comment" ) |
---|
20 | { |
---|
21 | #ifdef DBUG_PARSE |
---|
22 | cout << "comment" <<endl; |
---|
23 | cout << e.text().toStdString() <<endl; |
---|
24 | #endif |
---|
25 | //BaseP |
---|
26 | pos->setComment(e.text().toStdString()); |
---|
27 | } |
---|
28 | if (e.tagName() == "entity" ) |
---|
29 | { |
---|
30 | #ifdef DBUG_PARSE |
---|
31 | cout << "entity" <<endl; |
---|
32 | cout << e.attribute("name","").toStdString() <<endl; |
---|
33 | #endif |
---|
34 | ent=new morpheo::tools::viewer::bdd::Entity\ |
---|
35 | (e.attribute("name","").toStdString(),\ |
---|
36 | e.attribute("schema","").toInt(0,10)); |
---|
37 | s=e.attribute("type","").toStdString(); |
---|
38 | pos->setEntity(ent); |
---|
39 | parser_pos(n.firstChild()); |
---|
40 | |
---|
41 | if((n.nextSiblingElement()).tagName() !="architecture") |
---|
42 | { |
---|
43 | #ifdef DBUG_PARSE |
---|
44 | cout << "pas d'archi" <<endl; |
---|
45 | #endif |
---|
46 | base->addBaseP(pos,s); |
---|
47 | |
---|
48 | } |
---|
49 | } |
---|
50 | if (e.tagName() == "port" ) |
---|
51 | { |
---|
52 | #ifdef DBUG_PARSE |
---|
53 | cout << "port" <<endl; |
---|
54 | #endif |
---|
55 | morpheo::tools::viewer::bdd::Port \ |
---|
56 | *p=new morpheo::tools::viewer::bdd::\ |
---|
57 | Port(e.attribute("name","").toStdString(),\ |
---|
58 | e.attribute("direction","").toStdString(),\ |
---|
59 | e.attribute("localisation","").toStdString()); |
---|
60 | p->setComment(e.text().toStdString()); |
---|
61 | ent->addport(p); |
---|
62 | } |
---|
63 | if (e.tagName() == "architecture" ) |
---|
64 | { |
---|
65 | #ifdef DBUG_PARSE |
---|
66 | cout << "architecture" <<endl; |
---|
67 | #endif |
---|
68 | arch=new morpheo::tools::viewer::bdd::Architecture(); |
---|
69 | pos->setArchitecture(arch); |
---|
70 | |
---|
71 | base->addBaseP(pos,s); |
---|
72 | |
---|
73 | parser_pos(n.firstChild()); |
---|
74 | } |
---|
75 | if (e.tagName() == "component" ) |
---|
76 | { |
---|
77 | #ifdef DBUG_PARSE |
---|
78 | cout << "component" <<endl; |
---|
79 | #endif |
---|
80 | morpheo::tools::viewer::bdd::Component \ |
---|
81 | *comp=new morpheo::tools::viewer::bdd::\ |
---|
82 | Component(e.attribute("name","").toStdString(),\ |
---|
83 | e.attribute("type","").toStdString(),\ |
---|
84 | e.attribute("pos_x","").toInt(0,10),\ |
---|
85 | e.attribute("pos_y","").toInt(0,10),\ |
---|
86 | e.attribute("size_x","").toInt(0,10),\ |
---|
87 | e.attribute("size_y","").toInt(0,10)); |
---|
88 | arch->addComponent(comp, e.attribute("type","").toStdString()); |
---|
89 | ctemp=comp; |
---|
90 | |
---|
91 | string fichier=absolutePath; |
---|
92 | fichier.append(e.attribute("type","").toStdString()); |
---|
93 | fichier.append(".pos"); |
---|
94 | #ifdef DBUG_PARSE |
---|
95 | cout << fichier <<endl; |
---|
96 | #endif |
---|
97 | open_file(fichier); |
---|
98 | parser_pos(n.firstChild()); |
---|
99 | //ajout ptr Port du sous composant |
---|
100 | BaseP pt=base->get_BasePos(e.attribute("type","").toStdString()); |
---|
101 | QList<Port> *sspor= (pt.getEntity())->getPort(); |
---|
102 | for(QList<Port>::iterator it=sspor->begin();it!=sspor->end();++it) |
---|
103 | ctemp->addport(new Port(*it)); |
---|
104 | |
---|
105 | } |
---|
106 | if (e.tagName() == "port_map" ) |
---|
107 | { |
---|
108 | #ifdef DBUG_PARSE |
---|
109 | cout << "port_map" <<endl; |
---|
110 | #endif |
---|
111 | morpheo::tools::viewer::bdd::PortMap \ |
---|
112 | *p=new morpheo::tools::viewer::bdd::\ |
---|
113 | PortMap(e.attribute("name","").toStdString(),\ |
---|
114 | e.attribute("component","").toStdString(),\ |
---|
115 | e.attribute("port","").toStdString()); |
---|
116 | |
---|
117 | ctemp->addPortMap(p); |
---|
118 | |
---|
119 | } |
---|
120 | |
---|
121 | } |
---|
122 | n = n.nextSibling(); //next channel |
---|
123 | |
---|
124 | } |
---|
125 | |
---|
126 | } |
---|
127 | |
---|
128 | };//end parser |
---|
129 | };//end viewer |
---|
130 | };//end tools |
---|
131 | };//end morpheo |
---|
132 | |
---|