util: c++-ify the call type in the m5 utility.
[gem5.git] / util / m5 / src / call_type.hh
index 92cd9c9608dc5563583e08a257e64d09538b944b..6ee536d2d19a6de742a522b8baa3ec0fb4897cc5 100644 (file)
 #ifndef __CALL_TYPE_HH__
 #define __CALL_TYPE_HH__
 
+#include <iostream>
+#include <string>
+#include <vector>
+
 #include "args.hh"
 #include "dispatch_table.hh"
 
-DispatchTable *init_call_type(Args *args);
+class CallType
+{
+  protected:
+    virtual bool isDefault() const = 0;
+    virtual bool checkArgs(Args &args) = 0;
+    virtual void init() {}
+
+    static std::vector<CallType *> &allTypes();
+
+    virtual void printBrief(std::ostream &os) const = 0;
+    virtual void printDesc(std::ostream &os) const = 0;
+    std::string formattedUsage() const;
+
+  public:
+    CallType() { allTypes().push_back(this); }
+
+    static CallType &detect(Args &args);
+    static std::string usageSummary();
+
+    virtual const DispatchTable &getDispatch() const = 0;
+};
+
 
 #endif // __CALL_TYPE_HH__