gem5 v24.0.0.0
|
This is the extension for carrying additional information. More...
#include <extensible.hh>
Public Member Functions | |
Extension () | |
Public Member Functions inherited from gem5::ExtensionBase | |
ExtensionBase (const unsigned int id) | |
virtual | ~ExtensionBase ()=default |
virtual std::unique_ptr< ExtensionBase > | clone () const =0 |
unsigned int | getExtensionID () const |
Static Public Attributes | |
static const unsigned int | extensionID |
Additional Inherited Members | |
Static Public Member Functions inherited from gem5::ExtensionBase | |
static unsigned int | maxNumExtensions () |
This is the extension for carrying additional information.
Each type of extension will have a unique extensionID. This extensionID will assign to base class for comparsion.
Example usage:
class MyTarget : Extensible<MyTarget> {};
class MyExtension : public Extension<MyTarget, MyExtension> { public: MyExtension(); std::unique_ptr<ExtensionBase> clone() const override; uint32_t getData();
private: uint32_t data_;; };
std::unique_ptr<MyTarget> mytarget(new MyTarget); std::shared_ptr<MyExtension> myext(new MyExtension); mytarget->setExtension(myext);
std::shared_ptr<MyExtension> ext = mytarget->getExtension<MyExtension>(); uint32_t data = ext->getData(); mytarget->removeExtension<MyExtension>();
In the example above, MyTarget can carry an extension named MyExtension, which contains an additional data field. This could be applicated to any debug information or any data field in any protocol.
Definition at line 107 of file extensible.hh.
|
inline |
Definition at line 110 of file extensible.hh.
|
static |
Definition at line 112 of file extensible.hh.