[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); |
---|
[32] | 53 | delete pos; |
---|
[20] | 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); |
---|
[32] | 78 | delete pos; |
---|
| 79 | parser_pos(n.firstChild(),level); |
---|
[34] | 80 | |
---|
[20] | 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)); |
---|
[26] | 95 | ctemp[level]=comp; |
---|
| 96 | arch[level]->addComponent(ctemp[level], e.attribute("name","").toStdString()); |
---|
[20] | 97 | |
---|
[26] | 98 | fichier=absolutePath; |
---|
[35] | 99 | // fichier.append(ent[level]->getName()); |
---|
| 100 | // fichier.append("-"); |
---|
[34] | 101 | fichier.append((e.attribute("name","")).toStdString()); |
---|
[35] | 102 | // fichier.append((e.attribute("type","").toLower()).toStdString()); |
---|
[20] | 103 | fichier.append(".pos"); |
---|
[34] | 104 | |
---|
[26] | 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); |
---|
[34] | 111 | |
---|
[20] | 112 | //ajout ptr Port du sous composant |
---|
[34] | 113 | BaseP pt=base->get_BasePos((e.attribute("name","")).toStdString()); |
---|
| 114 | //BaseP pt=base->get_BasePos((e.attribute("type","").toLower()).toStdString()); |
---|
[20] | 115 | QList<Port> *sspor= (pt.getEntity())->getPort(); |
---|
| 116 | for(QList<Port>::iterator it=sspor->begin();it!=sspor->end();++it) |
---|
[26] | 117 | ctemp[level]->addport(new Port(*it)); |
---|
[20] | 118 | |
---|
| 119 | } |
---|
| 120 | if (e.tagName() == "port_map" ) |
---|
| 121 | { |
---|
| 122 | #ifdef DBUG_PARSE |
---|
[34] | 123 | cout << "port_map " <<endl; |
---|
[20] | 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 | |
---|
[26] | 131 | ctemp[level]->addPortMap(p); |
---|
[34] | 132 | |
---|
[32] | 133 | delete p; |
---|
[20] | 134 | } |
---|
| 135 | } |
---|
| 136 | n = n.nextSibling(); //next channel |
---|
| 137 | } |
---|
[34] | 138 | |
---|
[20] | 139 | } |
---|
| 140 | |
---|
| 141 | };//end parser |
---|
| 142 | };//end viewer |
---|
| 143 | };//end tools |
---|
| 144 | };//end morpheo |
---|
| 145 | |
---|