ShVariantFactoryImpl.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 SH_VARIANTFACTORYIMPL_HPP 
00021 #define SH_VARIANTFACTORYIMPL_HPP 
00022 
00023 #include "ShVariant.hpp"
00024 #include "ShVariantFactory.hpp"
00025 
00026 namespace SH {
00027 
00028 template<typename T, ShDataType DT>
00029 ShVariant* ShDataVariantFactory<T, DT>::generate(int N) const
00030 {
00031   return new ShDataVariant<T, DT>(N);
00032 }
00033 
00034 template<typename T, ShDataType DT>
00035 ShVariant* ShDataVariantFactory<T, DT>::generate(std::string s) const
00036 {
00037   return new ShDataVariant<T, DT>(s);
00038 }
00039 
00040 template<typename T, ShDataType DT>
00041 ShVariant* ShDataVariantFactory<T, DT>::generate(int N, void *data, bool managed) const
00042 {
00043   return new ShDataVariant<T, DT>(N, data, managed);
00044 }
00045 
00046 template<typename T, ShDataType DT>
00047 ShVariant* ShDataVariantFactory<T, DT>::generateZero(int N) const
00048 {
00049   return new ShDataVariant<T, DT>(N);
00050 }
00051 
00052 template<typename T, ShDataType DT>
00053 ShVariant* ShDataVariantFactory<T, DT>::generateOne(int N) const
00054 {
00055   return new ShDataVariant<T, DT>(N, ShDataTypeConstant<T, DT>::One);
00056 }
00057 
00058 template<typename T, ShDataType DT>
00059 ShDataVariantFactory<T, DT>* ShDataVariantFactory<T, DT>::m_instance = 0;
00060 
00061 template<typename T, ShDataType DT>
00062 const ShDataVariantFactory<T, DT>*
00063 ShDataVariantFactory<T, DT>::instance() 
00064 {
00065   if(!m_instance) m_instance = new ShDataVariantFactory<T, DT>();
00066   return m_instance;
00067 }
00068 
00069 template<typename T, ShDataType DT>
00070 ShDataVariantFactory<T, DT>::ShDataVariantFactory()
00071 {}
00072 
00073 }
00074 
00075 #endif

Generated on Wed Nov 9 15:29:43 2005 for Sh by  doxygen 1.4.5