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

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

Release 3 du viewer:
Etape 1 et 2 du projet complet et à jour.

File size: 3.6 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,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                   
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
79                parser_pos(n.firstChild(),level);   
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));
94                ctemp[level]=comp;
95                arch[level]->addComponent(ctemp[level], e.attribute("name","").toStdString());
96               
97                fichier=absolutePath;
98                fichier.append(ent[level]->getName());
99                fichier.append("-");
100                fichier.append((e.attribute("type","").toLower()).toStdString());
101                fichier.append(".pos");
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               
110                //ajout ptr Port du sous composant
111                BaseP pt=base->get_BasePos((e.attribute("type","").toLower()).toStdString());
112                QList<Port> *sspor= (pt.getEntity())->getPort();
113                for(QList<Port>::iterator it=sspor->begin();it!=sspor->end();++it)
114                  ctemp[level]->addport(new Port(*it));
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               
128                ctemp[level]->addPortMap(p);
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
Note: See TracBrowser for help on using the repository browser.