14#ifndef SIMICS_SYSTEMC_SIMICS2TLM_MULTI_GASKET_OWNER_H
15#define SIMICS_SYSTEMC_SIMICS2TLM_MULTI_GASKET_OWNER_H
43 FATAL_ERROR_IF(
hasId(
id),
44 "Cannot bind the same ID (%d) to multiple gaskets",
id);
45 gasket_map_.emplace(std::piecewise_construct,
46 std::forward_as_tuple(
id),
47 std::forward_as_tuple());
49 gasket_map_[id].ClassType::operator=(*
static_cast<ClassType *
>(
this));
50 gasket_map_[id].set_gasket(std::move(gasketInterface));
64 GasketOwnerMap::const_iterator it = gasket_map_.find(
id);
65 if (it != gasket_map_.end()) {
66 return it->second.gasket();
67 }
else if (!
empty()) {
68 return gasket_map_.begin()->second.gasket();
73 std::set<int>
keys()
const {
75 for (
auto i = gasket_map_.begin(); i != gasket_map_.end(); ++i)
83 return gasket_map_.count(
id);
86 return gasket_map_.empty();
90 typedef std::map<int, GasketOwner> GasketOwnerMap;
91 GasketOwnerMap gasket_map_;
Definition: class_type.h:23
std::shared_ptr< GasketInterface > Ptr
Definition: gasket_interface.h:35
Base class, responsible for handling a gasket.
Definition: gasket_owner.h:30
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:38
GasketInterface::Ptr findGasket(int id) const
Returns the gasket matching the ID given.
Definition: multi_gasket_owner.h:63
bool hasId(int id) const
Definition: multi_gasket_owner.h:82
std::set< int > keys() const
Definition: multi_gasket_owner.h:73
void addGasket(int id, GasketInterface::Ptr gasketInterface)
Definition: multi_gasket_owner.h:42
int empty() const
Definition: multi_gasket_owner.h:85
virtual ~MultiGasketOwner()=default
Definition: null_gasket.h:40