Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

expandlib-vartype-numeric-traits.h

Go to the documentation of this file.
00001 
00002 /* This file is part of Expandlib.
00003 
00004   Copyright (C) 2002 Jasper van de Gronde
00005 
00006   This software is provided 'as-is', without any express or implied
00007   warranty.  In no event will the authors be held liable for any damages
00008   arising from the use of this software.
00009 
00010   Permission is granted to anyone to use this software for any purpose,
00011   including commercial applications, and to alter it and redistribute it
00012   freely, subject to the following restrictions:
00013 
00014   1. The origin of this software must not be misrepresented; you must not
00015      claim that you wrote the original software. If you use this software
00016      in a product, an acknowledgment in the product documentation would be
00017      appreciated but is not required.
00018   2. Altered source versions must be plainly marked as such, and must not be
00019      misrepresented as being the original software.
00020   3. This notice may not be removed or altered from any source distribution.
00021 
00022   Jasper van de Gronde th.v.d.gronde@hccnet.nl
00023 
00024 */
00025 
00030 #ifndef EXPANDLIB_VARTYPE_NUMERIC_TRAITS_H_INCLUDED
00031 #define EXPANDLIB_VARTYPE_NUMERIC_TRAITS_H_INCLUDED
00032 
00033 namespace expander { // *** Start of namespace
00034 
00036     template<class NumType>
00037     class expvartype_numeric_traits_normal {
00038     public:
00039         static inline NumType defaultvalue() { return 0; }
00040         static inline NumType validate(const NumType v) { return v; }
00041     };
00042 
00044     template<class NumType, const NumType minimum, const NumType maximum>
00045     class expvartype_numeric_traits_limited {
00046     public:
00047         static inline NumType defaultvalue() { return validate(0); }
00048         static inline NumType validate(const NumType v) { return ( v > maximum ? maximum : ( v < minimum ? minimum : v ) ); }
00049     };
00050 
00052     template<class NumType, const NumType minimum, const NumType maximum, const NumType defaultval>
00053     class expvartype_numeric_traits_limited_with_default {
00054     public:
00055         static inline NumType defaultvalue() { return defaultval; }
00056         static inline NumType validate(const NumType v) { return ( v > maximum || v < minimum ? defaultval : v ); }
00057     };
00058 
00059 } // *** End of namespace
00060 
00061 #endif //EXPANDLIB_VARTYPE_NUMERIC_TRAITS_H_INCLUDED

Generated on Tue Feb 4 17:24:13 2003 for ExpandLib by doxygen1.3-rc2