Yan Lee has uploaded this change for review. (
https://gem5-review.googlesource.com/c/public/gem5/+/68017?usp=email )
Change subject: base: extensible: add example codes of extension
......................................................................
base: extensible: add example codes of extension
Change-Id: Iaab1f2998a3f621b86d63bed7274373ba433d71c
---
M src/base/extensible.hh
1 file changed, 36 insertions(+), 0 deletions(-)
diff --git a/src/base/extensible.hh b/src/base/extensible.hh
index eb79c71..e6aab8e 100644
--- a/src/base/extensible.hh
+++ b/src/base/extensible.hh
@@ -69,6 +69,33 @@
* 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.
*/
template <typename Target, typename T>
class Extension : public ExtensionBase
--
To view, visit
https://gem5-review.googlesource.com/c/public/gem5/+/68017?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: Iaab1f2998a3f621b86d63bed7274373ba433d71c
Gerrit-Change-Number: 68017
Gerrit-PatchSet: 1
Gerrit-Owner: Yan Lee <yan...@google.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org