util: c++-ify the call type in the m5 utility.
[gem5.git] / util / m5 / src / inst_call_type.cc
index 5fbd756d90d1558ed66db19ffc546ab26232c285..49f87abcc20e65f8e64ad32a9d3a4f3842565d3a 100644 (file)
 
 #include <cstring>
 
-#include "inst_call_type.hh"
+#include "call_type.hh"
 
-static DispatchTable inst_dispatch = {
+namespace
+{
+
+DispatchTable inst_dispatch = {
 #define M5OP(name, func) .name = &::name,
 M5OP_FOREACH
 #undef M5OP
 };
 
-int
-inst_call_type_detect(Args *args)
+class InstCallType : public CallType
 {
-    if (args->argc && strcmp(args->argv[0], "--inst") == 0) {
-        pop_arg(args);
-        return 1;
+  public:
+    bool isDefault() const override { return CALL_TYPE_IS_DEFAULT; }
+    const DispatchTable &getDispatch() const override { return inst_dispatch; }
+
+    bool
+    checkArgs(Args &args) override
+    {
+        if (args.argc && strcmp(args.argv[0], "--inst") == 0) {
+            pop_arg(&args);
+            return true;
+        }
+        return false;
     }
-    return 0;
-}
 
-DispatchTable *
-inst_call_type_init()
-{
-    return &inst_dispatch;
-}
+    void printBrief(std::ostream &os) const override { os << "--inst"; }
+    void
+    printDesc(std::ostream &os) const override
+    {
+        os << "Use the instruction based invocation method.";
+    }
+} inst_call_type;
+
+} // anonymous namespace