16#ifndef SIMICS_SYSTEMC_SIMICS2TLM_MULTI_GASKET_OWNER_H
17#define SIMICS_SYSTEMC_SIMICS2TLM_MULTI_GASKET_OWNER_H
45 FATAL_ERROR_IF(
hasId(
id),
46 "Cannot bind the same ID (%d) to multiple gaskets",
id);
47 gasket_map_.emplace(std::piecewise_construct,
48 std::forward_as_tuple(
id),
49 std::forward_as_tuple());
51 gasket_map_[id].ClassType::operator=(*
static_cast<ClassType *
>(
this));
53 gasket_map_[id].set_gasket(gasketInterface);
67 GasketOwnerMap::const_iterator it = gasket_map_.find(
id);
68 if (it != gasket_map_.end()) {
69 return it->second.gasket();
70 }
else if (!
empty()) {
71 return gasket_map_.begin()->second.gasket();
76 std::set<int>
keys()
const {
78 for (
auto i = gasket_map_.begin(); i != gasket_map_.end(); ++i)
86 return gasket_map_.count(
id);
89 return gasket_map_.empty();
93 typedef std::map<int, GasketOwner> GasketOwnerMap;
94 GasketOwnerMap gasket_map_;
Definition: class_type.h:25
std::shared_ptr< GasketInterface > Ptr
Definition: gasket_interface.h:37
Base class, responsible for handling a gasket.
Definition: gasket_owner.h:32
GasketInterface::Ptr gasket() const
Definition: gasket_owner.h:47
GasketInterface::Ptr gasket_
Definition: gasket_owner.h:51
Container class for multiple GasketOwners, each given a unique ID.
Definition: multi_gasket_owner.h:40
GasketInterface::Ptr findGasket(int id) const
Returns the gasket matching the ID given.
Definition: multi_gasket_owner.h:66
bool hasId(int id) const
Definition: multi_gasket_owner.h:85
std::set< int > keys() const
Definition: multi_gasket_owner.h:76
void addGasket(int id, GasketInterface::Ptr gasketInterface)
Definition: multi_gasket_owner.h:44
int empty() const
Definition: multi_gasket_owner.h:88
virtual ~MultiGasketOwner()=default
Definition: null_gasket.h:34