gem5 [DEVELOP-FOR-25.0]
Loading...
Searching...
No Matches
port_wrapper.hh File Reference

PortWrapper Object Declaration. More...

#include <functional>
#include "mem/port.hh"

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 Arm Limited All rights reserved.
 

Detailed Description

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.


Generated on Mon May 26 2025 09:19:16 for gem5 by doxygen 1.13.2