gem5 v24.0.0.0
|
PortWrapper Object Declaration. More...
Go to the source code of this file.
Classes | |
class | gem5::RequestPortWrapper |
The RequestPortWrapper converts inherit-based RequestPort into callback-based. More... | |
class | gem5::ResponsePortWrapper |
The ResponsePortWrapper converts inherit-based ResponsePort into callback-based. More... | |
Namespaces | |
namespace | gem5 |
Copyright (c) 2024 - Pranith Kumar Copyright (c) 2020 Inria All rights reserved. | |
PortWrapper Object Declaration.
The RequestPortWrapper and ResponsePortWrapper converts inherit-based RequestPort and ResponsePort into callback-based. This help reducing redundant code and increase code reusability in most cases, allowing composition over inheritance pattern.
Example usage:
class MySimObject : public SimObject { public: ResponsePortWrapper inPort;
MySimObject(...) : inPort("in_port", this)... { inPort.setGetAddrRangesCallback([this]() { return getRange(); });
inPort.setAtomicCallbacks([this](PacketPtr packet) { // process the packet ... return Tick(); }); }
private: AddrRangeList getRange() const {...} };
Definition in file port_wrapper.hh.