[20] | 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 | |
---|
[26] | 12 | void Parse::parser_pos(QDomNode n,int level){ |
---|
| 13 | string fichier; |
---|
[20] | 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()); |
---|
[26] | 28 | pos->setLevel(level); |
---|
| 29 | |
---|
[20] | 30 | } |
---|
| 31 | if (e.tagName() == "entity" ) |
---|
| 32 | { |
---|
[26] | 33 | #ifdef DBUG_PARSE |
---|
[20] | 34 | cout << "entity" <<endl; |
---|
| 35 | cout << e.attribute("name","").toStdString() <<endl; |
---|
| 36 | #endif |
---|
[26] | 37 | |
---|
| 38 | ent[level]=new morpheo::tools::viewer::bdd::Entity\ |
---|
[20] | 39 | (e.attribute("name","").toStdString(),\ |
---|
[26] | 40 | e.attribute("type","").toStdString(),\ |
---|
[20] | 41 | e.attribute("schema","").toInt(0,10)); |
---|
[26] | 42 | s=e.attribute("name","").toStdString(); |
---|
| 43 | pos->setEntity(ent[level]); |
---|
| 44 | |
---|
| 45 | parser_pos(n.firstChild(),level); |
---|
[20] | 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 | |
---|
| 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()); |
---|
[26] | 67 | ent[level]->addport(p); |
---|
[20] | 68 | } |
---|
| 69 | if (e.tagName() == "architecture" ) |
---|
| 70 | { |
---|
| 71 | #ifdef DBUG_PARSE |
---|
| 72 | cout << "architecture" <<endl; |
---|
| 73 | #endif |
---|
[26] | 74 | arch[level]=new morpheo::tools::viewer::bdd::Architecture(); |
---|
| 75 | pos->setArchitecture(arch[level]); |
---|
[20] | 76 | |
---|
| 77 | base->addBaseP(pos,s); |
---|
| 78 | |
---|
[26] | 79 | parser_pos(n.firstChild(),level); |
---|
[20] | 80 | } |
---|
| 81 | if (e.tagName() == "component" ) |
---|
| 82 | { |
---|
| 83 | #ifdef DBUG_PARSE |
---|
| 84 | cout << "component" <<endl; |
---|
| 85 | #endif |
---|
| 86 | morpheo::tools::viewer::bdd::Component \ |
---|
| 87 | *comp=new morpheo::tools::viewer::bdd::\ |
---|
| 88 | Component(e.attribute("name","").toStdString(),\ |
---|
| 89 | e.attribute("type","").toStdString(),\ |
---|
| 90 | e.attribute("pos_x","").toInt(0,10),\ |
---|
| 91 | e.attribute("pos_y","").toInt(0,10),\ |
---|
| 92 | e.attribute("size_x","").toInt(0,10),\ |
---|
| 93 | e.attribute("size_y","").toInt(0,10)); |
---|
[26] | 94 | ctemp[level]=comp; |
---|
| 95 | arch[level]->addComponent(ctemp[level], e.attribute("name","").toStdString()); |
---|
[20] | 96 | |
---|
[26] | 97 | fichier=absolutePath; |
---|
| 98 | fichier.append(ent[level]->getName()); |
---|
| 99 | fichier.append("-"); |
---|
| 100 | fichier.append((e.attribute("type","").toLower()).toStdString()); |
---|
[20] | 101 | fichier.append(".pos"); |
---|
[26] | 102 | #ifdef DBUG_PARSE |
---|
| 103 | cout << fichier <<endl; |
---|
| 104 | #endif |
---|
| 105 | if(open_file(fichier,level+1)==-1) |
---|
| 106 | exit(1); |
---|
| 107 | |
---|
| 108 | parser_pos(n.firstChild(),level); |
---|
| 109 | |
---|
[20] | 110 | //ajout ptr Port du sous composant |
---|
[26] | 111 | BaseP pt=base->get_BasePos((e.attribute("type","").toLower()).toStdString()); |
---|
[20] | 112 | QList<Port> *sspor= (pt.getEntity())->getPort(); |
---|
| 113 | for(QList<Port>::iterator it=sspor->begin();it!=sspor->end();++it) |
---|
[26] | 114 | ctemp[level]->addport(new Port(*it)); |
---|
[20] | 115 | |
---|
| 116 | } |
---|
| 117 | if (e.tagName() == "port_map" ) |
---|
| 118 | { |
---|
| 119 | #ifdef DBUG_PARSE |
---|
| 120 | cout << "port_map" <<endl; |
---|
| 121 | #endif |
---|
| 122 | morpheo::tools::viewer::bdd::PortMap \ |
---|
| 123 | *p=new morpheo::tools::viewer::bdd::\ |
---|
| 124 | PortMap(e.attribute("name","").toStdString(),\ |
---|
| 125 | e.attribute("component","").toStdString(),\ |
---|
| 126 | e.attribute("port","").toStdString()); |
---|
| 127 | |
---|
[26] | 128 | ctemp[level]->addPortMap(p); |
---|
[20] | 129 | |
---|
| 130 | } |
---|
| 131 | |
---|
| 132 | } |
---|
| 133 | n = n.nextSibling(); //next channel |
---|
| 134 | |
---|
| 135 | } |
---|
| 136 | |
---|
| 137 | } |
---|
| 138 | |
---|
| 139 | };//end parser |
---|
| 140 | };//end viewer |
---|
| 141 | };//end tools |
---|
| 142 | };//end morpheo |
---|
| 143 | |
---|