]> git.tdb.fi Git - gldbg.git/blob - source/tool.h
Replace per-file license notices with License.txt
[gldbg.git] / source / tool.h
1 #ifndef TOOL_H_
2 #define TOOL_H_
3
4 #include <list>
5
6 class GlDbg;
7
8 class Tool
9 {
10 public:
11         class Factory
12         {
13         protected:
14                 Factory();
15         public:
16                 virtual ~Factory() { }
17
18                 virtual Tool *create(GlDbg &) const = 0;
19         };
20
21 protected:
22         Tool() { }
23 public:
24         virtual ~Tool() { }
25
26         virtual void decode(const char *, unsigned) = 0;
27         virtual void process_started() { }
28         virtual void process_stopped(int) { }
29
30         static std::list<Factory *> &get_factories();
31 };
32
33
34 template<typename T>
35 class RegisteredTool: public Tool
36 {
37 protected:
38         class Factory: public Tool::Factory
39         {
40                 virtual Tool *create(GlDbg &g) const { return new T(g); }
41         };
42
43         static Factory factory;
44
45 protected:
46         // The no-op expression is necessary to instantiate the static member
47         RegisteredTool() { (void)factory; }
48 };
49
50 template<typename T>
51 typename RegisteredTool<T>::Factory RegisteredTool<T>::factory;
52
53 #endif