PandA-2024.02
generic_device.hpp
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) 2023-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  */
33 
41 #ifndef GENERIC_DEVICE_HPP
42 #define GENERIC_DEVICE_HPP
43 
44 #include "exceptions.hpp"
45 #include "refcount.hpp"
46 #include <boost/lexical_cast.hpp>
47 #include <map>
48 
54 class xml_element;
55 
58 {
61 
64 
66  std::map<std::string, std::string> parameters;
67 
69  std::map<std::string, std::string> vars;
70 
73 
78  void xload_device_parameters(const xml_element* dev_xml);
79 
80  public:
87 
91  virtual ~generic_device();
92 
97  void xload(const xml_element* node);
98 
103  void xwrite(xml_element* node);
104 
108  void load_devices();
109 
115  static generic_deviceRef factory(const ParameterConstRef& Param, const technology_managerRef& TM);
116 
121  template <typename G>
122  G get_parameter(const std::string& key) const
123  {
124  if(parameters.find(key) == parameters.end())
125  {
126  THROW_ERROR("Parameter \"" + key + "\" not found in target device parameters' list");
127  }
128  return boost::lexical_cast<G>(parameters.find(key)->second);
129  }
130 
134  template <typename G>
135  void set_parameter(const std::string& key, G value)
136  {
137  parameters[key] = std::to_string(value);
138  }
139 
144  bool has_parameter(const std::string& key) const
145  {
146  return parameters.find(key) != parameters.end();
147  }
148 
149  const std::map<std::string, std::string>& get_device_bash_vars() const
150  {
151  return vars;
152  }
153 
158 };
161 
162 #endif
generic device description
void xload(const xml_element *node)
XML load specialization.
This class manages the circuit structures.
int debug_level
The debug level.
exceptions managed by PandA
G get_parameter(const std::string &key) const
Returns a parameter by key.
void load_devices()
Load device characteristics.
virtual ~generic_device()
Destructor of the class.
int key[32]
Definition: aes.h:67
std::map< std::string, std::string > vars
map between bash variables and values
static generic_deviceRef factory(const ParameterConstRef &Param, const technology_managerRef &TM)
Factory method.
void set_parameter(const std::string &key, G value)
Sets the value of the parameter.
This class manages the technology library structures.
const ParameterConstRef Param
class containing all the parameters
void xwrite(xml_element *node)
XML write specialization.
#define THROW_ERROR(str_expr)
helper function used to throw an error in a standard way
Definition: exceptions.hpp:263
const technology_managerRef TM
technology manager
std::map< std::string, std::string > parameters
Map of the technology parameter.
Template definition of refcount.
CONSTREF_FORWARD_DECL(Parameter)
bool has_parameter(const std::string &key) const
Check if parameter exist.
const std::map< std::string, std::string > & get_device_bash_vars() const
technology_managerRef get_technology_manager() const
Returns the technology manager.
Template borrowed from the ANTLR library by Terence Parr (http://www.jGuru.com - Software rights: htt...
Definition: refcount.hpp:94
generic_device(const ParameterConstRef &Param, const technology_managerRef &TM)
Constructor of the class.
REF_FORWARD_DECL(structural_manager)
void xload_device_parameters(const xml_element *dev_xml)
XML load of device parameters.

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