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