HAL  v4.5.0-254-g8f9f6a423
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::DataContainer Class Reference

#include <hal_core/netlist/data_container.h>

Inheritance diagram for hal::DataContainer:
Inheritance graph
Collaboration diagram for hal::DataContainer:
Collaboration graph

Public Member Functions

 DataContainer ()=default
 
virtual ~DataContainer ()=default
 
bool operator== (const DataContainer &other) const
 
bool operator!= (const DataContainer &other) const
 
bool set_data (const std::string &category, const std::string &key, const std::string &data_type, const std::string &value, const bool log_with_info_level=false)
 
bool has_data (const std::string &category, const std::string &key) const
 
std::tuple< std::string, std::string > get_data (const std::string &category, const std::string &key) const
 
bool delete_data (const std::string &category, const std::string &key, const bool log_with_info_level=false)
 
const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string > > & get_data_map () const
 
void set_data_map (const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string >> &map)
 
Result< std::monostate > set_parameter (const Parameter &param, const std::string &value)
 
Result< std::string > get_parameter_value (const std::string &name) const
 
Result< std::string > get_parameter_value (const Parameter &name) const
 
Result< Parameter > get_parameter_declaration (const std::string &name) const
 
bool has_parameter (const Parameter &param) const
 
bool has_parameter (const std::string &name) const
 
bool delete_parameter (const std::string &name)
 
const std::unordered_map< std::string, std::pair< Parameter, std::string > > & get_parameters () const
 

Protected Attributes

std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string > > m_data
 
std::unordered_map< std::string, std::pair< Parameter, std::string > > m_parameters
 

Detailed Description

Container to hold data that is associated with an entity.

Definition at line 45 of file data_container.h.

Constructor & Destructor Documentation

◆ DataContainer()

hal::DataContainer::DataContainer ( )
default

Construct a new data container.

◆ ~DataContainer()

virtual hal::DataContainer::~DataContainer ( )
virtualdefault

Member Function Documentation

◆ delete_data()

bool hal::DataContainer::delete_data ( const std::string &  category,
const std::string &  key,
const bool  log_with_info_level = false 
)

Delete a data entry.

Parameters
[in]category- The data category.
[in]key- The data key.
[in]log_with_info_level- Force explicit logging channel 'netlist' with log level 'info' to trace GUI events.
Returns
true on success, false otherwise.

Definition at line 63 of file data_container.cpp.

References log_debug, log_error, log_info, and m_data.

Referenced by hal::data_container_init(), and hal::ActionSetObjectData::exec().

◆ delete_parameter()

bool hal::DataContainer::delete_parameter ( const std::string &  name)

Delete an explicitly stored parameter value, if any.

Parameters
[in]name- The parameter name.
Returns
true if a value was deleted, false otherwise.

Definition at line 196 of file data_container.cpp.

References m_parameters, and name.

Referenced by hal::data_container_init(), and hal::ActionSetParameterValue::exec().

◆ get_data()

std::tuple< std::string, std::string > hal::DataContainer::get_data ( const std::string &  category,
const std::string &  key 
) const

Get the data entry specified by the given category and key.

Parameters
[in]category- The data category.
[in]key- The data key.
Returns
The tuple ((1) type, (2) value).

Definition at line 119 of file data_container.cpp.

References log_debug, log_error, and m_data.

Referenced by hal::data_container_init(), hal::cte::ClockTree::export_dot(), and hal::DataTableEntry::fromContainer().

◆ get_data_map()

const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string > > & hal::DataContainer::get_data_map ( ) const

Get a map from ((1) category, (2) key) to ((1) type, (2) value) containing all stored data entries.

Returns
The stored data as a map.

Definition at line 94 of file data_container.cpp.

References m_data.

Referenced by hal::NetlistModificationDecorator::connect_nets(), hal::data_container_init(), hal::CoordinateFromData::fromNode(), operator==(), hal::NetlistModificationDecorator::replace_gate(), hal::DataTableWidget::setGate(), and hal::DataTableWidget::setModule().

◆ get_parameter_declaration()

Result< Parameter > hal::DataContainer::get_parameter_declaration ( const std::string &  name) const

Get the full declaration of a typed parameter.

Parameters
[in]name- The parameter name.
Returns
OK() with the declaration on success, an error otherwise.

Definition at line 175 of file data_container.cpp.

References ERR, m_parameters, name, and OK.

Referenced by hal::ActionSetParameterValue::exec().

◆ get_parameter_value() [1/2]

Result< std::string > hal::DataContainer::get_parameter_value ( const Parameter &  name) const

Get the value of a typed parameter. Returns the explicitly-stored value or an error if the parameter does not exist.

Parameters
[in]param- The parameter.
Returns
OK() with the value string on success, an error otherwise.

Definition at line 159 of file data_container.cpp.

References ERR, hal::Parameter::get_name(), m_parameters, and OK.

◆ get_parameter_value() [2/2]

Result< std::string > hal::DataContainer::get_parameter_value ( const std::string &  name) const

Get the value of a typed parameter. Returns the explicitly-stored value or an error if the parameter does not exist.

Parameters
[in]name- The parameter name.
Returns
OK() with the value string on success, an error otherwise.

Definition at line 149 of file data_container.cpp.

References ERR, m_parameters, name, and OK.

Referenced by hal::ActionSetParameterValue::exec(), and hal::xilinx_toolbox::split_shift_register().

◆ get_parameters()

const std::unordered_map< std::string, std::pair< Parameter, std::string > > & hal::DataContainer::get_parameters ( ) const

Get all explicitly stored parameters as a map from name to (declaration, value).

Returns
The parameter map.

Definition at line 201 of file data_container.cpp.

References m_parameters.

Referenced by hal::data_container_init(), operator==(), and hal::ParameterTableModel::updateData().

◆ has_data()

bool hal::DataContainer::has_data ( const std::string &  category,
const std::string &  key 
) const

Determine whether an entry of given category and key exists.

Parameters
[in]category- The data category.
[in]key- The data key.
Returns
true if the entry exists, false otherwise.

Definition at line 104 of file data_container.cpp.

References m_data.

Referenced by hal::data_container_init(), and hal::DataTableEntry::fromContainer().

◆ has_parameter() [1/2]

bool hal::DataContainer::has_parameter ( const Parameter &  param) const

Check whether a parameter exists and has an explicitly stored value.

Parameters
[in]param- The parameter.
Returns
true if the parameter is explicitly set, false otherwise.

Definition at line 190 of file data_container.cpp.

References hal::Parameter::get_name(), and m_parameters.

Referenced by hal::data_container_init(), hal::ActionSetParameterValue::exec(), and hal::xilinx_toolbox::split_shift_register().

◆ has_parameter() [2/2]

bool hal::DataContainer::has_parameter ( const std::string &  name) const

Check whether a parameter with the given name exists and has an explicitly stored value.

Parameters
[in]name- The parameter name.
Returns
true if the parameter is explicitly set, false otherwise.

Definition at line 185 of file data_container.cpp.

References m_parameters, and name.

◆ operator!=()

bool hal::DataContainer::operator!= ( const DataContainer &  other) const

Check whether two data containers are unequal.

Parameters
[in]other- The data container to compare against.
Returns
true if both data containers are unequal, false otherwise.

Definition at line 34 of file data_container.cpp.

References operator==().

◆ operator==()

bool hal::DataContainer::operator== ( const DataContainer &  other) const

Check whether two data containers are equal.

Parameters
[in]other- The data container to compare against.
Returns
true if both data containers are equal, false otherwise.

Definition at line 29 of file data_container.cpp.

References get_data_map(), get_parameters(), m_data, and m_parameters.

Referenced by operator!=().

◆ set_data()

bool hal::DataContainer::set_data ( const std::string &  category,
const std::string &  key,
const std::string &  data_type,
const std::string &  value,
const bool  log_with_info_level = false 
)

Add a data entry.
May overwrite an existing entry.

Parameters
[in]category- The data category.
[in]key- The data key.
[in]data_type- The data type.
[in]value- The data value.
[in]log_with_info_level- Force explicit logging channel 'netlist' with log level 'info' to trace GUI events.
Returns
true on success, false otherwise.

Definition at line 39 of file data_container.cpp.

References log_debug, log_error, log_info, and m_data.

Referenced by hal::module_identification::Result::create_modules_in_netlist(), hal::data_container_init(), hal::xilinx_toolbox::split_lut(), and hal::DataTableEntry::toContainer().

◆ set_data_map()

void hal::DataContainer::set_data_map ( const std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string >> &  map)

Overwrite the existing data with a new map from ((1) category, (2) key) to ((1) type, (2) value).

Parameters
[in]map- The new data map.

Definition at line 99 of file data_container.cpp.

References m_data.

Referenced by hal::NetlistModificationDecorator::connect_nets(), hal::SubgraphNetlistDecorator::copy_subgraph_netlist(), and hal::NetlistModificationDecorator::replace_gate().

◆ set_parameter()

Result< std::monostate > hal::DataContainer::set_parameter ( const Parameter &  param,
const std::string &  value 
)

Set (or overwrite) the value of a typed parameter as a string. The value is validated and normalized before being stored. Any existing entry with the same name is replaced.

Parameters
[in]param- The parameter declaration.
[in]value- The value to store as a string.
Returns
OK() on success, an error otherwise.

Definition at line 136 of file data_container.cpp.

References ERR, hal::Parameter::get_name(), hal::Parameter::get_type(), m_parameters, OK, and hal::Parameter::validate().

Referenced by hal::SubgraphNetlistDecorator::copy_subgraph_netlist(), hal::ActionSetParameterValue::exec(), and hal::LUTComponent::set_init_string().

Member Data Documentation

◆ m_data

std::map<std::tuple<std::string, std::string>, std::tuple<std::string, std::string> > hal::DataContainer::m_data
protected

◆ m_parameters

std::unordered_map<std::string, std::pair<Parameter, std::string> > hal::DataContainer::m_parameters
protected

The documentation for this class was generated from the following files: