Mercator
ShaderFactory.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2005 Alistair Riddoch
4 
5 #ifndef MERCATOR_SHADER_FACTORY_H
6 #define MERCATOR_SHADER_FACTORY_H
7 
8 #include <Mercator/Shader.h>
9 
10 namespace Mercator {
11 
13 class ShaderKit {
14  protected:
15  explicit ShaderKit();
16  public:
17  virtual ~ShaderKit();
18 
22  virtual Shader * newShader(const Shader::Parameters &) const = 0;
23 };
24 
26 template <class T>
27 class ShaderFactory : public ShaderKit {
28  public:
29  ShaderFactory();
30  ~ShaderFactory();
31 
32  virtual Shader * newShader(const Shader::Parameters &) const;
33 };
34 
40  private:
42  typedef std::map<std::string, ShaderKit *> FactoryMap;
43 
46 
49 
51  ~ShaderFactories();
52  public:
53  static ShaderFactories & instance();
54  static void del();
55 
56  Shader * newShader(const std::string & type,
57  const Shader::Parameters &) const;
58 };
59 
60 } // namespace Mercator
61 
62 #endif // MERCATOR_SHADER_FACTORY_H