PandA-2024.02
parse_technology.cpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
43 #include "parse_technology.hpp"
44 #include "Parameter.hpp"
45 #include "exceptions.hpp"
46 #include "polixml.hpp"
47 #include "technology_manager.hpp"
48 #include "technology_node.hpp"
49 #include "utility.hpp"
50 #include "xml_dom_parser.hpp"
51 #include <string>
52 #include <vector>
53 
54 void read_technology_File(const std::string& fn, const technology_managerRef& TM, const ParameterConstRef& Param)
55 {
56  try
57  {
58  XMLDomParser parser(fn);
59  parser.Exec();
60  if(parser)
61  {
62  // Walk the tree:
63  const xml_element* node = parser.get_document()->get_root_node(); // deleted by DomParser.
64  TM->xload(node);
65 
66  std::set<std::string> input_libraries;
67  if(Param->isOption(OPT_input_libraries))
68  {
69  auto input_libs = Param->getOption<std::string>(OPT_input_libraries);
70  string_to_container(std::inserter(input_libraries, input_libraries.end()), input_libs, ";");
71  }
72  for(const auto& library : TM->get_library_list())
73  {
74  if(WORK_LIBRARY == library || DESIGN == library || PROXY_LIBRARY == library)
75  {
76  continue;
77  }
78  input_libraries.insert(library);
79  }
81  const_cast<Parameter*>(Param.get())->setOption(OPT_input_libraries, container_to_string(input_libraries, ";"));
82  }
83  }
84  catch(const char* msg)
85  {
86  THROW_ERROR("Error during technology file parsing: " + std::string(msg));
87  }
88  catch(const std::string& msg)
89  {
90  THROW_ERROR("Error during technology file parsing: " + msg);
91  }
92  catch(const std::exception& ex)
93  {
94  THROW_ERROR("Error during technology file parsing: " + std::string(ex.what()));
95  }
96  catch(...)
97  {
98  THROW_ERROR("Error during technology file parsing");
99  }
100 }
Input function used to read the technology data structures.
void read_technology_File(const std::string &fn, const technology_managerRef &TM, const ParameterConstRef &Param)
Read an xml file describing the technology data structures.
const std::vector< std::string > & get_library_list() const
Return the list of the libraries.
exceptions managed by PandA
Class specification of the manager of the technology library data structures.
void xload(const xml_element *node)
Load a technology manager from an xml file.
#define DESIGN
Autoheader include.
Class specification of the data structures used to manage technology information. ...
XML DOM parser.
XML DOM parser.
This file collects some utility functions and macros.
void Exec()
Parse an XML document from a file.
constexpr void string_to_container(_OutputIt first, const std::string &str, const std::string &separator, bool trim_empty=true)
Definition: utility.hpp:148
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
#define WORK_LIBRARY
working library.
xml_documentRef get_document()
Obtain the parsed document.
T * get() const
Definition: refcount.hpp:169
this class is used to manage the command-line or XML options.
std::string container_to_string(_InputIt first, _InputIt last, const std::string &separator, bool trim_empty=true)
Definition: utility.hpp:122
#define PROXY_LIBRARY
proxy library

Generated on Mon Feb 12 2024 13:02:55 for PandA-2024.02 by doxygen 1.8.13