ShaderFactory.h

00001 // This file may be redistributed and modified only under the terms of
00002 // the GNU General Public License (See COPYING for details).
00003 // Copyright (C) 2005 Alistair Riddoch
00004 
00005 #ifndef MERCATOR_SHADER_FACTORY_H
00006 #define MERCATOR_SHADER_FACTORY_H
00007 
00008 #include <Mercator/Shader.h>
00009 
00010 namespace Mercator {
00011 
00012 class iShaderFactory {
00013   protected:
00014     explicit iShaderFactory();
00015   public:
00016     virtual ~iShaderFactory();
00017 
00021     virtual Shader * newShader(const Shader::Parameters &) const = 0;
00022 };
00023 
00024 template <class T>
00025 class ShaderFactory : public iShaderFactory {
00026   public:
00027     ShaderFactory();
00028     ~ShaderFactory();
00029 
00030     virtual Shader * newShader(const Shader::Parameters &) const;
00031 };
00032 
00033 class ShaderFactories {
00034   private:
00035     typedef std::map<std::string, iShaderFactory *> FactoryMap;
00036 
00037     FactoryMap m_factories;
00038 
00039     static ShaderFactories * m_instance;
00040 
00041     ShaderFactories();
00042     ~ShaderFactories();
00043   public:
00044     static ShaderFactories & instance();
00045     static void del();
00046 
00047     Shader * newShader(const std::string & type,
00048                        const Shader::Parameters &) const;
00049 };
00050 
00051 } // namespace Mercator
00052 
00053 #endif // MERCATOR_SHADER_FACTORY_H

Generated on Wed Sep 12 22:21:35 2007 for Mercator by  doxygen 1.5.2