00001 #ifndef AFL_POINT_H
00002 #define AFL_POINT_H
00003
00004 #include "afltypes.h"
00005 #include <iostream>
00006 #include <string>
00007
00008 #include "ddf/ddf.h"
00009
00010 namespace afl
00011 {
00016 template <typename V>
00017 class PointT
00018 {
00020 public:
00021
00025 PointT( ) : _d(0) { }
00026
00031 PointT( const PointT<V>& p ) : _x(p._x), _y(p._y), _z(p._z), _t(p._t), _d(p._d) {}
00032
00038 PointT<V>& operator=( const PointT<V>& p ) { _x = p._x; _y = p._y; _z = p._z; _t = p._t; _d = p._d; return *this; }
00039
00044 PointT( V x ) : _x(x), _y(0.0), _z(0.0), _t(0.0), _d(1) { }
00045
00051 PointT( V x, V y ) : _x(x), _y(y), _z(0.0), _t(0.0), _d(2) { }
00052
00059 PointT( V x, V y, V z ) : _x(x), _y(y), _z(z), _t(0.0), _d(3) { }
00060
00068 PointT( V x, V y, V z, V t ) : _x(x), _y(y), _z(z), _t(t), _d(4) { }
00069
00073 V getX( ) const { return _x; }
00074
00078 V getY( ) const { return _y; }
00079
00083 V getZ( ) const { return _z; }
00084
00088 V getT( ) const { return _t; }
00089
00094 void setX( const V& x ) { _x = x; }
00095
00100 void setY( const V& y ) { _y = y; }
00101
00106 void setZ( const V& z ) { _z = z; }
00107
00112 void setT( const V& t ) { _t = t; }
00113
00117 size_t getDimension( ) const { return _d; }
00118
00124 V operator[]( size_t t ) const { return t == 0 ? _x : t == 1 ? _y : t == 2 ? _z : t == 3 ? _t : V() ; }
00125
00131 V& operator[]( size_t t ) { return t == 0 ? _x : t == 1 ? _y : t == 2 ? _z : t == 3 ? _t : point_null; }
00132
00137 bool operator==( const PointT<V>& other ) const { return _d == other._d && _x == other._x && _y == other._y && _z == other._z && _t == other._t; }
00138
00143 bool operator!=( const PointT<V>& other ) const { return _d != other._d || _x != other._x || _y != other._y || _z != other._z || _t != other._t; }
00144
00146 private:
00147 V _x;
00148 V _y;
00149 V _z;
00150 V _t;
00151 size_t _d;
00152 static V point_null;
00153 };
00154
00155 }
00156
00157 #endif // AFL_POINT_H
00158