Source: kalamaris/vartype.gmp.h
|
|
|
|
/* vartype.gmp.h -
This file is part of Kalamaris
Copyright (C) 2000 Antonio Larrosa Jimenez
Kalamaris' homepage : http://perso.wanadoo.es/antlarr/kalamaris.html
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
***************************************************************************/
#ifndef _VARTYPE_H
#define _VARTYPE_H
class QString;
#include <gmp.h>
//#define T_TYPE long double
#define T_TYPE gmf_t
class T
{
protected:
T_TYPE v;
public:
T(T_TYPE g=0.0);
T( const T &x);
virtual T *copy(void) const;
virtual inline int operator==( T v1 );
virtual inline int operator==( T_TYPE v1 );
virtual inline int operator!=( T v1 );
virtual inline int operator!=( T_TYPE v1 );
virtual inline int operator<( T v1 );
virtual inline int operator<( T_TYPE v1 );
virtual inline int operator>( T v1 );
virtual inline int operator>( T_TYPE v1 );
virtual inline int operator>=( T v1 );
virtual inline int operator>=( T_TYPE v1 );
virtual inline int operator<=( T v1 );
virtual inline int operator<=( T_TYPE v1 );
T &operator=( const T &x );
T &operator=( T_TYPE &x );
T &operator--( ) { v--; return *this; };
virtual T &operator+=( const T &x );
virtual T &operator-=( const T &x );
virtual T &operator*=( const T &x );
virtual T &operator/=( const T &x );
virtual inline void abs( void );
inline operator const T_TYPE () const { return v; };
virtual QString string(void) const;
virtual const char *isA() const { return "T"; };
/**
* XXX The next method is optimized as there's only T and TMatrix
* data types. It should be changed when more types are added
*/
virtual bool isA(char *str) const { return strlen(str)==1; };
};
// Operators
inline T operator+( const T &v1, const T &v2 )
{
T tmp( v1 );
tmp+=v2;
return tmp;
}
inline T operator-( const T &v1, const T &v2 )
{
T tmp( v1 );
tmp-=v2;
return tmp;
}
inline T operator*( const T &v1, const T &v2 )
{
T tmp( v1 );
tmp*=v2;
return tmp;
}
inline T operator/( const T &v1, const T &v2 )
{
T tmp( v1 );
tmp/=v2;
return tmp;
}
#endif
Generated by: antonio@tazend on Fri May 25 22:16:00 2001, using kdoc 2.0a38. |