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));
52 gasket_map_[id].set_gasket(std::move(gasketInterface));
66 GasketOwnerMap::const_iterator it = gasket_map_.find(
id);
67 if (it != gasket_map_.end()) {
68 return it->second.gasket();
69 }
else if (!
empty()) {
70 return gasket_map_.begin()->second.gasket();
75 std::set<int>
keys()
const {
77 for (
auto i = gasket_map_.begin(); i != gasket_map_.end(); ++i)
85 return gasket_map_.count(
id);
88 return gasket_map_.empty();
92 typedef std::map<int, GasketOwner> GasketOwnerMap;
93 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:65
bool hasId(int id) const
Definition: multi_gasket_owner.h:84
std::set< int > keys() const
Definition: multi_gasket_owner.h:75
void addGasket(int id, GasketInterface::Ptr gasketInterface)
Definition: multi_gasket_owner.h:44
int empty() const
Definition: multi_gasket_owner.h:87
virtual ~MultiGasketOwner()=default
Definition: null_gasket.h:34