Teuchos_TypeNameTraits.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 #ifndef _TEUCHOS_TYPE_NAME_TRAITS_HPP_
00030 #define _TEUCHOS_TYPE_NAME_TRAITS_HPP_
00031 
00037 #include "Teuchos_ConfigDefs.hpp"
00038 
00039 #ifdef HAVE_TEUCHOS_ARPREC
00040 #include "mp/mpreal.h"
00041 #endif
00042 
00043 #ifdef HAVE_TEUCHOS_GNU_MP
00044 #include "gmp.h"
00045 #include "gmpxx.h"
00046 #endif
00047 
00048 namespace  Teuchos {
00049 
00053 template<typename T>
00054 class TypeNameTraits {
00055 public:
00056   static std::string name() { return typeid(T).name(); }
00057 };
00058 
00059 #define TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(TYPE) \
00060 template<> \
00061 class TypeNameTraits<TYPE> { \
00062 public: \
00063   static std::string name() { return (#TYPE); } \
00064 } \
00065 
00066 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(bool);
00067 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(char);
00068 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(int);
00069 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(short int);
00070 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(long int);
00071 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(float);
00072 TEUCHOS_TYPE_NAME_TRAITS_BUILTIN_TYPE_SPECIALIZATION(double);
00073 
00074 template<typename T>
00075 class TypeNameTraits<T*> {
00076 public:
00077   static std::string name() { return TypeNameTraits<T>::name() + "*"; }
00078 };
00079 
00080 template<>
00081 class TypeNameTraits<std::string> {
00082 public:
00083   static std::string name() { return "string"; }
00084 };
00085 
00086 template<typename T>
00087 class TypeNameTraits<std::vector<T> > {
00088 public:
00089   static std::string name() { return "std::vector<"+TypeNameTraits<T>::name()+">"; }
00090 };
00091 
00092 #if defined(HAVE_COMPLEX) && defined(HAVE_TEUCHOS_COMPLEX)
00093 
00094 template<typename T>
00095 class TypeNameTraits<std::complex<T> > {
00096 public:
00097   static std::string name() { return "std::complex<"+TypeNameTraits<T>::name()+">"; }
00098 };
00099 
00100 #endif // defined(HAVE_COMPLEX) && defined(HAVE_TEUCHOS_COMPLEX)
00101  
00102 } // namespace Teuchos
00103 
00104 #endif // _TEUCHOS_TYPE_NAME_TRAITS_HPP_

Generated on Thu Sep 18 12:30:31 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1