--- /dev/null
+/* $Id$
+
+This file is part of gldbg
+Copyright © 2010 Mikko Rasa, Mikkosoft Productions
+Distributed under the GPL
+*/
+
+#ifndef TOOL_H_
+#define TOOL_H_
+
+#include <list>
+
+class GlDbg;
+
+class Tool
+{
+public:
+ class Factory
+ {
+ protected:
+ Factory();
+
+ public:
+ virtual Tool *create(GlDbg &) const = 0;
+ };
+
+protected:
+ Tool() { }
+public:
+ virtual ~Tool() { }
+
+ virtual void decode(const char *, unsigned) = 0;
+
+ static std::list<Factory *> &get_factories();
+};
+
+
+template<typename T>
+class RegisteredTool: public Tool
+{
+protected:
+ class Factory: public Tool::Factory
+ {
+ virtual Tool *create(GlDbg &g) const { return new T(g); }
+ };
+
+ static Factory factory;
+
+protected:
+ // The no-op expression is necessary to instantiate the static member
+ RegisteredTool() { (void)factory; }
+};
+
+template<typename T>
+typename RegisteredTool<T>::Factory RegisteredTool<T>::factory;
+
+#endif