source: trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Parser/src/Parse_parser_pos.cpp @ 20

Last change on this file since 20 was 20, checked in by chou, 17 years ago

1ere release du Viewer :

  • Parseur xml sur Base de données
  • Chargement d'un fichier de positions
  • Dessin du top-level
  • Dessin des ports du top level
  • Dessin des sous composants
  • Dessin des ports de ces sous composants

les valeurs de positions et de taille sont en %.

File size: 3.3 KB
Line 
1/*
2 *
3 * [desc.]
4 */
5#include "Tools/Viewer/Parser/include/parser.h"
6using namespace morpheo::tools::viewer::bdd;
7namespace morpheo{
8namespace tools{
9namespace viewer{
10namespace 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
Note: See TracBrowser for help on using the repository browser.