HAL
hal::DataContainer Class Reference

#include <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)
 

Protected Attributes

std::map< std::tuple< std::string, std::string >, std::tuple< std::string, std::string > > m_data
 

Detailed Description

Container to hold data that is associated with an entity.

Definition at line 41 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 41 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().

◆ 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 97 of file data_container.cpp.

References log_debug, log_error, and m_data.

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

◆ 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 72 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().

◆ 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 82 of file data_container.cpp.

References m_data.

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

◆ 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 12 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 7 of file data_container.cpp.

References get_data_map(), and m_data.

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 17 of file data_container.cpp.

References log_debug, log_error, log_info, and m_data.

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

◆ 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 77 of file data_container.cpp.

References m_data.

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

Member Data Documentation

◆ m_data

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

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