]> git.tdb.fi Git - gldbg.git/blob - source/tool.h
Add some virtual destructors to shut up older gcc versions
[gldbg.git] / source / tool.h
1 /* $Id$
2
3 This file is part of gldbg
4 Copyright © 2010  Mikko Rasa, Mikkosoft Productions
5 Distributed under the GPL
6 */
7
8 #ifndef TOOL_H_
9 #define TOOL_H_
10
11 #include <list>
12
13 class GlDbg;
14
15 class Tool
16 {
17 public:
18         class Factory
19         {
20         protected:
21                 Factory();
22         public:
23                 virtual ~Factory() { }
24
25                 virtual Tool *create(GlDbg &) const = 0;
26         };
27
28 protected:
29         Tool() { }
30 public:
31         virtual ~Tool() { }
32
33         virtual void decode(const char *, unsigned) = 0;
34
35         static std::list<Factory *> &get_factories();
36 };
37
38
39 template<typename T>
40 class RegisteredTool: public Tool
41 {
42 protected:
43         class Factory: public Tool::Factory
44         {
45                 virtual Tool *create(GlDbg &g) const { return new T(g); }
46         };
47
48         static Factory factory;
49
50 protected:
51         // The no-op expression is necessary to instantiate the static member
52         RegisteredTool() { (void)factory; }
53 };
54
55 template<typename T>
56 typename RegisteredTool<T>::Factory RegisteredTool<T>::factory;
57
58 #endif