source: trunk/IPs/systemC/processor/Morpheo/Behavioural/Configuration/src/Instance_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: 1.4 KB
Line 
1/*
2 * $Id: Instance_fromFile.cpp 88 2008-12-10 18:31:39Z rosiere $
3 *
4 * [ Description ]
5 *
6 */
7
8#include "Behavioural/Configuration/include/Instance.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 "Instance::fromFile"
20  void Instance::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    // 1) FILL _array
33    XML_t * _xml = new FileXMLLight<char,ClassicReferenceCounter>(file);
34
35    // Test root node : Root name, must not a singleton, have none attribute
36    testNodeName   (_xml,"core");
37    testSingleton  (_xml,false);
38
39    attributes_t attributes = _xml->getAttributes();
40    _name = getAttribute(_xml,attributes,"name" );
41
42    fromXMLLight (_xml,
43                  "",
44                  _list_parameters,
45                  _list_links,
46                  _list_components);
47   
48    delete _xml;
49   
50    // 2) TEST/CREATE Parameters
51    fromInternalStructure();
52   
53    log_end(Configuration,FUNCTION);
54  };
55
56}; // end namespace configuration
57}; // end namespace behavioural
58}; // end namespace morpheo             
Note: See TracBrowser for help on using the repository browser.