source: trunk/IPs/systemC/processor/Morpheo/Tools/Viewer/Parser/src/Parse_open_file_param.cpp @ 81

Last change on this file since 81 was 81, checked in by rosiere, 16 years ago
  • Finish Environment (and test)
  • Continue predictor_unit
  • Add external tools
  • svn keyword "Id" set
  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/*
2 *
3 * [desc.]
4 */
5#include "Tools/Viewer/Parser/include/parser.h"
6
7namespace morpheo{
8namespace tools{
9namespace viewer{
10namespace parser{
11
12  int Parse::open_file_param(string name){
13    /*!! name of entity top level!!*/
14    QString s,s2;
15
16    s.append(QString::fromStdString(name));
17
18    s2.append(QString::fromStdString(name));
19   
20    QFile file2(s.append(".gen"));
21
22    QFile file(s2.append(".cfg"));
23
24   
25    if( !file2.open( QIODevice::ReadOnly ) )
26       {
27         cerr << "Failed to load file. File not found\n";
28         return -1;
29       }
30
31    QDomDocument doc2( "pos" );
32     if( !doc2.setContent( &file2 ) )
33      {
34        cerr <<  "Failed to load file.Not Xml File\n";
35        file2.close();
36        return -1;
37      }
38     file2.close();
39     QDomElement root2 = doc2.documentElement();
40     if( root2.tagName() != "parameters" )
41       {
42         cerr <<"Invalid file.\n";
43         return -1;
44       }
45     else
46       {
47         #ifdef DBUG_PARSE
48         cout << "parameters limit" <<endl;
49         #endif
50                         
51         parser_limitparam(root2.firstChild());   
52         
53       }
54   
55
56     if( !file.open( QIODevice::ReadOnly ) )
57       {
58         cerr << "Failed to load file. File not found.\n";
59         cerr << "search temporary file if exists.\n";
60         file.setFileName (s2.append("~"));
61         if( !file.open( QIODevice::ReadOnly ) )
62           {
63             cerr << "Failed to load temporary file. Create a default configuration.\n";
64             createParam();
65             return 0;
66           }
67       
68         
69       }
70
71     QDomDocument doc( "gen2" );
72     if( !doc.setContent( &file ) )
73      {
74        cerr <<  "Failed to load file.Not Xml File\n";
75        file.close();
76        return -1;
77      }
78     file.close();
79     QDomElement root = doc.documentElement();
80     if( root.tagName() != "cpu" && \
81         strcmp((root.attribute("name","").toStdString()).c_str(),name.c_str()))
82       {
83         cout <<"Invalid file.\n";
84         return -1;
85       }
86     else
87       {
88         #ifdef DBUG_PARSE
89         cout << "parameters" <<endl;
90         #endif
91         
92         parser_param(root.firstChild(),0);   
93         
94       }
95
96     return 0;
97
98
99   }
100
101
102};//end parser
103};//end viewer
104};//end tools
105};//end morpheo
106
Note: See TracBrowser for help on using the repository browser.