Make the Node member of SUnit private, and add accessors.
[oota-llvm.git] / include / llvm / CompilerDriver / Plugin.h
1 //===--- Plugin.h - The LLVM Compiler Driver --------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open
6 // Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 //  Plugin support for llvmc2.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TOOLS_LLVMC2_PLUGIN_H
15 #define LLVM_TOOLS_LLVMC2_PLUGIN_H
16
17 #include "llvm/Support/Registry.h"
18
19 namespace llvmc {
20
21   class LanguageMap;
22   class CompilationGraph;
23
24   /// BasePlugin - An abstract base class for all LLVMC plugins.
25   struct BasePlugin {
26
27     /// PopulateLanguageMap - The auto-generated function that fills in
28     /// the language map (map from file extensions to language names).
29     virtual void PopulateLanguageMap(LanguageMap&) const = 0;
30
31     /// PopulateCompilationGraph - The auto-generated function that
32     /// populates the compilation graph with nodes and edges.
33     virtual void PopulateCompilationGraph(CompilationGraph&) const = 0;
34
35     /// Needed to avoid a compiler warning.
36     virtual ~BasePlugin() {}
37   };
38
39   typedef llvm::Registry<BasePlugin> PluginRegistry;
40
41   template <class P>
42   struct RegisterPlugin
43     : public PluginRegistry::Add<P> {
44     typedef PluginRegistry::Add<P> Base;
45
46     RegisterPlugin(const char* Name = "Nameless",
47                    const char* Desc = "Auto-generated plugin")
48       : Base(Name, Desc) {}
49   };
50
51
52   /// PluginLoader - Helper class used by the main program for
53   /// lifetime management.
54   struct PluginLoader {
55     PluginLoader();
56     ~PluginLoader();
57
58     /// PopulateLanguageMap - Fills in the language map by calling
59     /// PopulateLanguageMap methods of all plugins.
60     void PopulateLanguageMap(LanguageMap& langMap);
61
62     /// PopulateCompilationGraph - Populates the compilation graph by
63     /// calling PopulateCompilationGraph methods of all plugins.
64     void PopulateCompilationGraph(CompilationGraph& tools);
65
66   private:
67     // noncopyable
68     PluginLoader(const PluginLoader& other);
69     const PluginLoader& operator=(const PluginLoader& other);
70   };
71
72 }
73
74 #endif // LLVM_TOOLS_LLVMC2_PLUGIN_H