gem5 v24.0.0.0
Loading...
Searching...
No Matches
gem5::Extension< Target, T > Class Template Reference

This is the extension for carrying additional information. More...

#include <extensible.hh>

Inheritance diagram for gem5::Extension< Target, T >:
gem5::ExtensionBase

Public Member Functions

 Extension ()
 
- Public Member Functions inherited from gem5::ExtensionBase
 ExtensionBase (const unsigned int id)
 
virtual ~ExtensionBase ()=default
 
virtual std::unique_ptr< ExtensionBaseclone () 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 ()
 

Detailed Description

template<typename Target, typename T>
class gem5::Extension< Target, T >

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.

Constructor & Destructor Documentation

◆ Extension()

template<typename Target , typename T >
gem5::Extension< Target, T >::Extension ( )
inline

Definition at line 110 of file extensible.hh.

Member Data Documentation

◆ extensionID

template<typename Target , typename T >
const unsigned int gem5::Extension< Target, T >::extensionID
static
Initial value:
=
static unsigned int maxNumExtensions()
Definition extensible.hh:62

Definition at line 112 of file extensible.hh.


The documentation for this class was generated from the following file:

Generated on Tue Jun 18 2024 16:24:11 for gem5 by doxygen 1.11.0