Teuchos_OrdinalTraits.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 // Kris
00030 // 07.08.03 -- Move into Teuchos package/namespace
00031 
00032 #ifndef _TEUCHOS_ORDINALTRAITS_HPP_
00033 #define _TEUCHOS_ORDINALTRAITS_HPP_
00034 
00052 namespace Teuchos {
00053   
00054   template<class T>
00055   struct OrdinalTraits {
00056 
00058     static inline int unsupportedType() {
00059 #ifndef TEUCHOS_NO_ERROR_REPORTS
00060       cerr << endl << "Teuchos::OrdinalTraits: unsupported ordinal type." << endl;
00061 #endif
00062       return(-1);
00063     }
00064 
00066     static inline bool haveMachineParameters() {return(false);}; 
00067     
00069     static inline T zero()                     {throw(unsupportedType());};
00070 
00072     static inline T one()                      {throw(unsupportedType());};
00073 
00075     static inline const char* name()           {throw(unsupportedType());};
00076   };
00077   
00078 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00079 
00080   template<>
00081   struct OrdinalTraits<int> {
00082 
00083     static inline bool haveMachineParameters() {return(false);}; // Allows testing to see if ordinal traits machine parameters defined 
00084     static inline int zero()                   {return(0);};
00085     static inline int one()                    {return(1);};
00086     static inline const char* name()           {return("int");};
00087   };
00088 
00089   template<>
00090   struct OrdinalTraits<long int> {
00091 
00092     static inline bool haveMachineParameters() {return(false);}; // Allows testing to see if ordinal traits machine parameters defined 
00093     static inline long int zero()                   {return((long int)0);};
00094     static inline long int one()                    {return((long int)1);};
00095     static inline const char* name()           {return("long int");};
00096   };
00097 
00098 #endif
00099 
00100 } // namespace Teuchos
00101 
00102 #endif // _TEUCHOS_ORDINALTRAITS_HPP_

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