S3FC project page | S3FC home page |
00001 /* 00002 * Stone Three Foundation Class (s3fc) provides a number of utility classes. 00003 * Copyright (C) 2001 by Stone Three Signal Processing (Pty) Ltd. 00004 * 00005 * Authored by Stone Three Signal Processing (Pty) Ltd. 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * Please see the file 'COPYING' in the source root directory. 00022 */ 00023 00033 #ifndef S3_UTILS_H 00034 #define S3_UTILS_H 00035 00036 #ifndef _WIN32 00037 #include <sys/time.h> 00038 #endif 00039 00043 class s3_utils 00044 { 00045 public: 00046 00052 template<typename T> 00053 inline static T sqr( const T &t ) 00054 { 00055 return ( t * t ); 00056 } 00057 00061 template<typename T> 00062 inline static T min( const T &t0, const T &t1 ) 00063 { 00064 return ( ( t0 < t1 ) ? t0 : t1 ); 00065 } 00066 00070 template<typename T> 00071 inline static T max( const T &t0, const T &t1 ) 00072 { 00073 return ( ( t0 > t1 ) ? t0 : t1 ); 00074 } 00075 00076 #ifndef _WIN32 00077 00086 inline static float time_diff( const timeval& time_start, const timeval& time_end ) 00087 { 00088 return 00089 static_cast<float>( time_end.tv_sec - time_start.tv_sec ) + 00090 1e-6 * static_cast<float>( time_end.tv_usec - time_start.tv_usec ); 00091 } 00092 #endif 00093 }; 00094 00095 #endif //S3_UTILS_H
Send comments to: s3fc@stonethree.com |
|