source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Configuration/src/Simulator_fromFile.cpp @ 88

Last change on this file since 88 was 88, checked in by rosiere, 15 years ago

Almost complete design
with Test and test platform

  • Property svn:keywords set to Id
File size: 2.0 KB
Line 
1/*
2 * $Id: Simulator_fromFile.cpp 88 2008-12-10 18:31:39Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Configuration/include/Simulator.h"
9#include "Common/include/FromString.h"
10#include <fstream>
11
12namespace morpheo {
13namespace behavioural {
14namespace configuration {
15
16  using namespace XMLUtils;
17
18#undef  FUNCTION
19#define FUNCTION "Simulator::fromFile"
20  void Simulator::fromFile (std::string filename)
21  {
22    log_begin(Configuration,FUNCTION);
23
24    msg_printf(INFORMATION,_("Read file \"%s\"."),filename.c_str());
25
26    std::ifstream file (filename.c_str());
27
28    // Test the file open
29    if (!file)
30      throw ERRORMORPHEO(FUNCTION,toString(_("Error opening \"%s\" file.\n"),filename.c_str()));
31
32    XML_t * _xml = new FileXMLLight<char,ClassicReferenceCounter>(file);
33
34    // Test root node : Root name, must not a singleton, have none attribute
35    testNodeName   (_xml,"parameters");
36    testSingleton  (_xml,false);
37    testNoAttribute(_xml);
38
39    XMLLightVector<XML_t> vect = _xml->getNodes(); 
40
41//     std::cout << vect << std::endl;
42
43    for (uint32_t i=0; i<vect.size(); ++i)
44      {
45        XML_t * xml = vect[i];
46
47        // Test node
48        testNodeName   (xml,"parameter");
49        testSingleton  (xml,true);       
50
51        // Take attributes of this tag
52
53        attributes_t attributes = xml->getAttributes();
54
55//         std::cout << "Node [" << name           << "]" << std::endl;
56//         std::cout << "  * nb attributes : " << xml->getAttributes().size()  << std::endl;
57
58        attribute_t value_name  = getAttribute(xml,attributes,"name" );
59        attribute_t value       = getAttribute(xml,attributes,"value");
60
61        testAttributesEmpty(xml,attributes);
62
63        // Insert in array
64        Parameter_affectation * param = new Parameter_affectation(value_name,
65                                                                  value     );
66
67        insert(param);
68      }
69         
70    delete _xml;
71
72    log_end(Configuration,FUNCTION);
73  };
74
75}; // end namespace configuration
76}; // end namespace behavioural
77}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.