Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ShVariantFactory.hpp

00001 // Sh: A GPU metaprogramming language.
00002 //
00003 // Copyright 2003-2005 Serious Hack Inc.
00004 // 
00005 // This library is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 //
00010 // This library is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with this library; if not, write to the Free Software
00017 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
00018 // MA  02110-1301, USA
00020 #ifndef SHVARIANTFACTORY_HPP
00021 #define SHVARIANTFACTORY_HPP
00022 
00023 #include <string>
00024 #include "ShDllExport.hpp"
00025 #include "ShRefCount.hpp"
00026 #include "ShTypeInfo.hpp"
00027 
00028 namespace SH {
00029 
00030 class ShVariant;
00031 
00032 struct 
00033 SH_DLLEXPORT 
00034 ShVariantFactory {
00035   virtual ~ShVariantFactory() {}
00036 
00038   virtual ShVariant* generate(int N) const = 0; 
00039 
00041   // decode method from the Variant type corresponding
00042   // to this factory
00043   virtual ShVariant* generate(std::string s) const = 0;
00044 
00048   //                 rather than using the given array internally.
00049   virtual ShVariant* generate(int N, void *data, bool managed = true) const = 0;  
00050 
00052   virtual ShVariant* generateZero(int N = 1) const = 0;
00053 
00055   virtual ShVariant* generateOne(int N = 1) const = 0;
00056 };
00057 
00058 template<typename T, ShDataType DT>
00059 struct ShDataVariantFactory: public ShVariantFactory {
00060   ShVariant* generate(int N) const;
00061 
00062   ShVariant* generate(std::string s) const; 
00063 
00064   ShVariant* generate(int N, void *data, bool managed = true) const;  
00065 
00066   ShVariant* generateZero(int N = 1) const;
00067   ShVariant* generateOne(int N = 1) const;
00068 
00069   static const ShDataVariantFactory* instance();
00070 
00071   protected:
00072     static ShDataVariantFactory *m_instance;
00073 
00074     ShDataVariantFactory();
00075 };
00076 
00077 
00078 }
00079 
00080 #include "ShVariantFactoryImpl.hpp"
00081 
00082 #endif

Generated on Thu Jul 28 17:33:06 2005 for Sh by  doxygen 1.4.3-20050530