From cee5940bae97612105db8b7e1ffcf513f9d9150c Mon Sep 17 00:00:00 2001 From: dooglus Date: Mon, 12 Mar 2007 22:47:18 +0000 Subject: [PATCH] Removed trailing whitespace. git-svn-id: http://svn.voria.com/code@303 1f10aa63-cdf2-0310-b900-c93c546f37ac --- ETL/trunk/ETL.pbproj/etl_profile.h | 2 +- ETL/trunk/ETL/_angle.h | 24 +- ETL/trunk/ETL/_bezier.h | 96 +- ETL/trunk/ETL/_boxblur.h | 46 +- ETL/trunk/ETL/_bspline.h | 34 +- ETL/trunk/ETL/_calculus.h | 6 +- ETL/trunk/ETL/_clock_base.h | 14 +- ETL/trunk/ETL/_clock_gettimeofday.h | 22 +- ETL/trunk/ETL/_clock_system.h | 24 +- ETL/trunk/ETL/_clock_win32hpcount.h | 10 +- ETL/trunk/ETL/_curve.h | 2 +- ETL/trunk/ETL/_curve_func.h | 6 +- ETL/trunk/ETL/_fastangle.h | 14 +- ETL/trunk/ETL/_fastangle_tables.h | 9836 +++++++++++++++++------------------ ETL/trunk/ETL/_fixed.h | 88 +- ETL/trunk/ETL/_gaussian.h | 2 +- ETL/trunk/ETL/_handle.h | 62 +- ETL/trunk/ETL/_hermite.h | 6 +- ETL/trunk/ETL/_misc.h | 12 +- ETL/trunk/ETL/_mutex_null.h | 2 +- ETL/trunk/ETL/_pen.h | 62 +- ETL/trunk/ETL/_random.h | 24 +- ETL/trunk/ETL/_rect.h | 34 +- ETL/trunk/ETL/_ref_count.h | 38 +- ETL/trunk/ETL/_smach.h | 114 +- ETL/trunk/ETL/_smart_ptr.h | 18 +- ETL/trunk/ETL/_stringf.h | 18 +- ETL/trunk/ETL/_surface.h | 176 +- ETL/trunk/ETL/_thread.h | 26 +- ETL/trunk/ETL/_trivial.h | 24 +- ETL/trunk/ETL/_value.h | 46 +- ETL/trunk/ETL/etl_config.h | 10 +- ETL/trunk/test/angle.cpp | 98 +- ETL/trunk/test/clock.cpp | 16 +- ETL/trunk/test/fixed.cpp | 76 +- ETL/trunk/test/handle.cpp | 70 +- ETL/trunk/test/hermite.cpp | 58 +- ETL/trunk/test/pen.cpp | 26 +- ETL/trunk/test/random.cpp | 6 +- ETL/trunk/test/smach.cpp | 22 +- ETL/trunk/test/smart_ptr.cpp | 2 +- ETL/trunk/test/spline.cpp | 22 +- ETL/trunk/test/stringf.cpp | 10 +- ETL/trunk/test/surface.cpp | 26 +- ETL/trunk/test/value.cpp | 42 +- 45 files changed, 5686 insertions(+), 5686 deletions(-) diff --git a/ETL/trunk/ETL.pbproj/etl_profile.h b/ETL/trunk/ETL.pbproj/etl_profile.h index 64a62f5..e63e0fe 100644 --- a/ETL/trunk/ETL.pbproj/etl_profile.h +++ b/ETL/trunk/ETL.pbproj/etl_profile.h @@ -10,7 +10,7 @@ #ifndef HAVE_GETTIMEOFDAY #define HAVE_GETTIMEOFDAY -#endif +#endif #ifndef HAVE_PTHREAD_H #define HAVE_PTHREAD_H diff --git a/ETL/trunk/ETL/_angle.h b/ETL/trunk/ETL/_angle.h index df69027..cfa7dc2 100644 --- a/ETL/trunk/ETL/_angle.h +++ b/ETL/trunk/ETL/_angle.h @@ -60,9 +60,9 @@ protected: typedef value_type unit; unit v; //! Stored in rotations - + public: - + /* ** Arithmetic Operators */ @@ -104,7 +104,7 @@ public: angle operator/(const unit &rhs)const { return angle(*this)/=rhs; } - + //! Angle Negation angle operator-()const @@ -113,7 +113,7 @@ public: ret.v=-v; return ret; } - + //! 180 degree rotation operator /*! Returns the angle directly opposite of the given angle, and will yield a result @@ -189,9 +189,9 @@ public: angle ret; ret.v=v-rhs.v; - + ret.v-=rot_floor(ret.v+PI); - + return ret; } @@ -205,7 +205,7 @@ public: ret.v-=rot_floor(ret.v); return ret; } - + static angle zero() { @@ -233,10 +233,10 @@ public: bool operator!()const { return v==0; } private: - + static value_type rot_floor(value_type x) { return static_cast(std::floor(x/(PI*2))*PI*2); } - + public: /* ** Converstion Classes @@ -252,7 +252,7 @@ public: class sin; class cos; - class tan; + class tan; /* ** Friend classes @@ -408,7 +408,7 @@ struct affine_combo //affine_combo() { std::cerr<<"affine_combo: I was created!"<: I was DELETED!"< : public std::binary_function affine_func; + affine_combo affine_func; public: bezier_base():r(0.0),s(1.0) { } @@ -65,7 +65,7 @@ public: const value_type &a, const value_type &b, const value_type &c, const value_type &d, const time_type &r=0.0, const time_type &s=1.0): a(a),b(b),c(c),d(d),r(r),s(s) { sync(); } - + void sync() { } @@ -86,12 +86,12 @@ public: ,t) ,t); } - + /* void evaluate(time_type t, value_type &f, value_type &df) const { t=(t-r)/(s-r); - + value_type p1 = affine_func( affine_func(a,b,t), affine_func(b,c,t) @@ -100,12 +100,12 @@ public: affine_func(b,c,t), affine_func(c,d,t) ,t); - + f = affine_func(p1,p2,t); df = (p2-p1)*3; } */ - + void set_rs(time_type new_r, time_type new_s) { r=new_r; s=new_s; } void set_r(time_type new_r) { r=new_r; } void set_s(time_type new_s) { s=new_s; } @@ -131,7 +131,7 @@ public: ** entire bi-infinite curve, is to iteratively ** intersect the hulls. However, we would only detect ** intersections that occur between R and S. - ** + ** ** It is entirely possible that a new construct similar ** to the affine combination function will be necessary ** for this to work properly. @@ -143,9 +143,9 @@ public: { return 0; } - + /* subdivide at some time t into 2 separate curves left and right - + b0 l1 * 0+1 l2 b1 * 1+2*1+2 l3 @@ -153,18 +153,18 @@ public: b2 * 1+2*2+2 r2 * * 2+3 r3 * b3 r4 * - * - + * + 0.1 2.3 -> 0.1 2 3 4 5.6 */ /* void subdivide(bezier_base *left, bezier_base *right, const time_type &time = (time_type)0.5) const { time_type t = (time-r)/(s-r); bezier_base lt,rt; - + value_type temp; - //1st stage points to keep + //1st stage points to keep lt.a = a; rt.d = d; @@ -172,23 +172,23 @@ public: lt.b = affine_func(a,b,t); temp = affine_func(b,c,t); rt.c = affine_func(c,d,t); - + //3rd stage calc lt.c = affine_func(lt.b,temp,t); rt.b = affine_func(temp,rt.c,t); - + //last stage calc lt.d = rt.a = affine_func(lt.c,rt.b,t); - + //set the time range for l,r (the inside values should be 1, 0 respectively) lt.r = r; rt.s = s; - + //give back the curves if(left) *left = lt; - if(right) *right = rt; + if(right) *right = rt; } - */ + */ value_type & operator[](int i) { return (&a)[i]; } @@ -208,7 +208,7 @@ public: typedef float value_type; typedef float time_type; private: - affine_combo affine_func; + affine_combo affine_func; value_type a,b,c,d; time_type r,s; @@ -229,7 +229,7 @@ public: _coeff[2]= c*3 - b*6 + a*3; _coeff[3]= d - c*3 + b*3 - a; } - + // Cost Summary: 4 products, 3 sums, and 1 difference. inline value_type operator()(time_type t)const @@ -457,7 +457,7 @@ public: typedef V value_type; typedef T difference_type; typedef V reference; - + private: difference_type t; difference_type dt; @@ -485,7 +485,7 @@ public: operator--(int) { hermite_iterator _tmp=*this; t-=dt; return _tmp; } - + surface_iterator operator+(difference_type __n) const { return surface_iterator(data+__n[0]+__n[1]*pitch,pitch); } @@ -494,7 +494,7 @@ public: operator-(difference_type __n) const { return surface_iterator(data-__n[0]-__n[1]*pitch,pitch); } */ - + }; template @@ -506,14 +506,14 @@ public: typedef float distance_type; typedef bezier_iterator iterator; typedef bezier_iterator const_iterator; - + distance_func dist; - + using bezier_base::get_r; using bezier_base::get_s; using bezier_base::get_dt; -public: +public: bezier() { } bezier(const value_type &a, const value_type &b, const value_type &c, const value_type &d): bezier_base(a,b,c,d) { } @@ -521,12 +521,12 @@ public: const_iterator begin()const; const_iterator end()const; - + time_type find_closest(const value_type& x, int i=7, time_type r=(0), time_type s=(1))const { float t((r+s)*0.5); for(;i;i--) - { + { if(dist(operator()((s-r)*(1.0/3.0)+r),x) < dist(operator()((s-r)*(2.0/3.0)+r),x)) s=t; else @@ -536,13 +536,13 @@ public: return t; } - + distance_type find_distance(time_type r, time_type s, int steps=7)const { const time_type inc((s-r)/steps); distance_type ret(0); value_type last(operator()(r)); - + for(r+=inc;r 0.1 2 3 4 5.6 */ void subdivide(bezier *left, bezier *right, const time_type &time = (time_type)0.5) const { time_type t=(t-get_r())/get_dt(); bezier lt,rt; - + value_type temp; const value_type& a((*this)[0]); const value_type& b((*this)[1]); const value_type& c((*this)[2]); const value_type& d((*this)[3]); - //1st stage points to keep + //1st stage points to keep lt[0] = a; rt[3] = d; @@ -588,27 +588,27 @@ public: lt[1] = affine_func(a,b,t); temp = affine_func(b,c,t); rt[2] = affine_func(c,d,t); - + //3rd stage calc lt[2] = affine_func(lt[1],temp,t); rt[1] = affine_func(temp,rt[2],t); - + //last stage calc lt[3] = rt[0] = affine_func(lt[2],rt[1],t); - + //set the time range for l,r (the inside values should be 1, 0 respectively) lt.set_r(get_r()); rt.set_s(get_s()); - + lt.sync(); rt.sync(); - + //give back the curves if(left) *left = lt; - if(right) *right = rt; + if(right) *right = rt; } - + void evaluate(time_type t, value_type &f, value_type &df) const { t=(t-get_r())/get_dt(); @@ -617,7 +617,7 @@ public: const value_type& b((*this)[1]); const value_type& c((*this)[2]); const value_type& d((*this)[3]); - + const value_type p1 = affine_func( affine_func(a,b,t), affine_func(b,c,t) @@ -626,7 +626,7 @@ public: affine_func(b,c,t), affine_func(c,d,t) ,t); - + f = affine_func(p1,p2,t); df = (p2-p1)*3; } diff --git a/ETL/trunk/ETL/_boxblur.h b/ETL/trunk/ETL/_boxblur.h index 392726a..8784431 100644 --- a/ETL/trunk/ETL/_boxblur.h +++ b/ETL/trunk/ETL/_boxblur.h @@ -45,19 +45,19 @@ hbox_blur(T1 pen,int w, int h, int length, T2 outpen) length=std::min(w,length); const float divisor(1.0f/(length*2+1)); - + for(y=0;ylength) ? iter[-length-1] : *pen.x(); tot += ((x+length)length) ? iter[-length-1] : *pen.y(); tot += ((y+length)%.3f),",y,&iter[y],iter[y],tot); } iter=pen.y(); - + //printf(" tot=%.3f\n",tot); - + biter = iter+(-length-1); //get the first one... eiter = iter+length; - + //y will always be > length //T2 open = outpen; for (y=0;ylength) + + if (y>length) { typename T1::value_type &v = *biter; /*if( (char*)&v < beginptr || @@ -174,25 +174,25 @@ vbox_blur(T1 pen,int w, int h, int length,T2 outpen) //printf("[%.3f,",bval); } - if (y+length= endptr) printf("crap! %d (%p off %p)\n",y,(char*)&v,(char*)&*iter);*/ tot += v; //printf("%.3f]",v); } - else + else { tot += eval; //printf("%.3f]",eval); } - + //test handled in the previous case... //tot -= (y>length) ? *biter : bval; //tot += (y+length knot_container; - typedef std::vector cpoint_container; + typedef std::vector cpoint_container; typedef typename knot_container::iterator knot_iterator; typedef typename cpoint_container::iterator cpoint_iterator; typedef C affine_func_type; typedef D distance_func_type; - + protected: affine_func_type affine_func; distance_func_type distance_func; - + private: int m; knot_container _knots; cpoint_container _cpoints; bool _loop; - -public: + +public: bspline():m(2),_loop(false) { } - + int get_m()const { return m-1; }; int set_m(int new_m) { m=new_m+1; return m-1; }; - + bool set_loop(bool x) { _loop=x; reset_knots(); return _loop; } - + knot_container & knots() { return _knots; }; cpoint_container & cpoints() { return _cpoints; }; @@ -82,7 +82,7 @@ public: void reset_knots() { int i; - + if(!_loop) { _knots.clear(); @@ -95,7 +95,7 @@ public: for(i=1;i<(signed)_cpoints.size()-m+1;i++) *_knots.insert(_knots.end())=i; for(i=0;i=_knots.back()) t=_knots.back()-0.0001; for(k=0;_knots[k]>t || _knots[k+1]<=t;k++); - - return k; + + return k; } knot_container get_segment_knots(int i)const @@ -137,7 +137,7 @@ public: return knot_container(_knots.begin()+i-m+1, _knots.begin()+i+m); } - cpoint_container get_segment_cpoints(int i)const + cpoint_container get_segment_cpoints(int i)const { if(i+11000000) { rhs.tv_sec+=tv_sec+1; @@ -100,7 +100,7 @@ protected: rhs.tv_sec+=tv_sec; return rhs; } - + inline bool operator<(const timestamp &rhs)const { return tv_sec(1)/(static_cast(1)-t)) ); - } + } }; template @@ -55,10 +55,10 @@ struct distance_func : public std::binary_function T delta=b-a; return static_cast(delta*delta); } - + K cook(const K &x)const { return x*x; } K uncook(const K &x)const { return sqrt(x); } - + }; /* -- E N D ----------------------------------------------------------------- */ diff --git a/ETL/trunk/ETL/_fastangle.h b/ETL/trunk/ETL/_fastangle.h index 1cb4674..e447a71 100644 --- a/ETL/trunk/ETL/_fastangle.h +++ b/ETL/trunk/ETL/_fastangle.h @@ -63,9 +63,9 @@ protected: typedef fixed_base unit; unit v; //! Stored in rotations - + public: - + /* ** Arithmetic Operators */ @@ -107,7 +107,7 @@ public: ret.v=v/rhs; return ret; } - + const fastangle & operator+=(const fastangle &rhs) { @@ -144,7 +144,7 @@ public: ret.v=-v; return ret; } - + //! 180 degree rotation operator /*! Returns the fastangle directly opposite of the given fastangle, and will yield a result @@ -259,7 +259,7 @@ public: class sin; class cos; - class tan; + class tan; /* ** Friend classes @@ -385,7 +385,7 @@ public: else v.data()=_fastangle_atan_table[(int)((x+1)*(value_type)((1<<(ETL_FASTANGLE_LOOKUP_RES-1))-1))]; } - + tan(const value_type &y,const value_type &x) { if(x>=0 && y>=0) // First quadrant @@ -451,7 +451,7 @@ struct distance_func : public std::binary_function _ETL::fixed_base log template _ETL::fixed_base log10(const _ETL::fixed_base&); template _ETL::fixed_base pow(const _ETL::fixed_base&, int); template _ETL::fixed_base pow(const _ETL::fixed_base&, const T&); -template _ETL::fixed_base pow(const _ETL::fixed_base&, +template _ETL::fixed_base pow(const _ETL::fixed_base&, const _ETL::fixed_base&); template _ETL::fixed_base pow(const _ETL::fixed_base&, const _ETL::fixed_base&); template _ETL::fixed_base sin(const _ETL::fixed_base&); @@ -98,7 +98,7 @@ public: typedef T value_type; private: T _data; - + typedef fixed_base _fixed; typedef fixed_base self_type; @@ -119,7 +119,7 @@ public: fixed_base(const _fixed &x)ETL_ATTRIB_INLINE; fixed_base(value_type x,raw)ETL_ATTRIB_INLINE; - T &data() ETL_ATTRIB_PURE ETL_ATTRIB_INLINE; + T &data() ETL_ATTRIB_PURE ETL_ATTRIB_INLINE; const T &data()const ETL_ATTRIB_PURE ETL_ATTRIB_INLINE; const _fixed& operator+=(const _fixed &rhs) ETL_ATTRIB_INLINE; @@ -144,7 +144,7 @@ public: _fixed operator/(const int &rhs)const ETL_ATTRIB_INLINE; _fixed operator*(const float &rhs)const ETL_ATTRIB_INLINE; _fixed operator*(const double &rhs)const ETL_ATTRIB_INLINE; - + // Negation Operator _fixed operator-()const ETL_ATTRIB_INLINE; @@ -158,7 +158,7 @@ public: _fixed floor()const; _fixed ceil()const; _fixed round()const; - + bool operator==(const _fixed &rhs)const { return data()==rhs.data(); } bool operator!=(const _fixed &rhs)const { return data()!=rhs.data(); } bool operator<(const _fixed &rhs)const { return data() fixed_base::fixed_base() -{} +{} template fixed_base::fixed_base(const _fixed &x):_data(x._data) @@ -197,55 +197,55 @@ fixed_base::fixed_base(value_type x,raw):_data(x) { } template fixed_base::fixed_base(const int &n,const int &d):_data((n< inline bool -fixed_base::_TYPE_SMALLER_THAN_INT() +fixed_base::_TYPE_SMALLER_THAN_INT() { return sizeof(T) inline bool -fixed_base::_USING_ALL_BITS() +fixed_base::_USING_ALL_BITS() { return sizeof(T)*8==FIXED_BITS; } template inline T -fixed_base::_ONE() +fixed_base::_ONE() { return static_cast((_USING_ALL_BITS()?~T(0):1< inline T -fixed_base::_F_MASK() +fixed_base::_F_MASK() { return static_cast(_USING_ALL_BITS()?~T(0):_ONE()-1); } template inline float -fixed_base::_EPSILON() +fixed_base::_EPSILON() { return 1.0f/((float)_ONE()*2); } template T & -fixed_base::data() +fixed_base::data() { return _data; } template const T & -fixed_base::data()const +fixed_base::data()const { return _data; } //! fixed+=fixed template const fixed_base & -fixed_base::operator+=(const fixed_base &rhs) +fixed_base::operator+=(const fixed_base &rhs) { _data+=rhs._data; return *this; @@ -253,7 +253,7 @@ fixed_base::operator+=(const fixed_base &rhs) //! fixed-=fixed template const fixed_base & -fixed_base::operator-=(const fixed_base &rhs) +fixed_base::operator-=(const fixed_base &rhs) { _data-=rhs._data; return *this; @@ -261,7 +261,7 @@ fixed_base::operator-=(const fixed_base &rhs) //! fixed*=fixed template const fixed_base & -fixed_base::operator*=(const fixed_base &rhs) +fixed_base::operator*=(const fixed_base &rhs) { if(_TYPE_SMALLER_THAN_INT()) _data=static_cast((int)_data*(int)rhs._data>>FIXED_BITS); @@ -270,13 +270,13 @@ fixed_base::operator*=(const fixed_base &rhs) _data*=rhs._data; _data>>=FIXED_BITS; } - + return *this; } //! fixed/=fixed template const fixed_base & -fixed_base::operator/=(const fixed_base &rhs) +fixed_base::operator/=(const fixed_base &rhs) { if(_TYPE_SMALLER_THAN_INT()) _data=static_cast((int)_data/(int)rhs._data<::operator/=(const fixed_base &rhs) } template template const fixed_base & -fixed_base::operator*=(const U &rhs) +fixed_base::operator*=(const U &rhs) { return operator*=(fixed_base(rhs)); } template template const fixed_base & -fixed_base::operator/=(const U &rhs) +fixed_base::operator/=(const U &rhs) { return operator/=(fixed_base(rhs)); } //! fixed*=int template const fixed_base & -fixed_base::operator*=(const int &rhs) +fixed_base::operator*=(const int &rhs) { _data*=rhs; return *this; } //! fixed/=int template const fixed_base & -fixed_base::operator/=(const int &rhs) +fixed_base::operator/=(const int &rhs) { _data/=rhs; return *this; } @@ -322,7 +322,7 @@ fixed_base::operator/=(const int &rhs) //! fixed + fixed template fixed_base -fixed_base::operator+(const fixed_base &rhs)const +fixed_base::operator+(const fixed_base &rhs)const { _fixed ret; ret._data=_data+rhs._data; @@ -331,7 +331,7 @@ fixed_base::operator+(const fixed_base &rhs)const //! fixed - fixed template fixed_base -fixed_base::operator-(const fixed_base &rhs)const +fixed_base::operator-(const fixed_base &rhs)const { _fixed ret; ret._data=_data-rhs._data; @@ -340,7 +340,7 @@ fixed_base::operator-(const fixed_base &rhs)const //! fixed * fixed template fixed_base -fixed_base::operator*(const fixed_base &rhs)const +fixed_base::operator*(const fixed_base &rhs)const { _fixed ret; ret._data=((_data*rhs._data)>>FIXED_BITS); @@ -350,7 +350,7 @@ fixed_base::operator*(const fixed_base &rhs)const //! fixed / fixed template fixed_base -fixed_base::operator/(const fixed_base &rhs)const +fixed_base::operator/(const fixed_base &rhs)const { _fixed ret; ret._data=((_data/rhs._data)<::operator/(const U &rhs) const //! fixed * int template fixed_base -fixed_base::operator*(const int &rhs)const +fixed_base::operator*(const int &rhs)const { _fixed ret; ret._data=_data*rhs; @@ -398,14 +398,14 @@ fixed_base::operator*(const int &rhs)const //! fixed * float template fixed_base -fixed_base::operator*(const float &rhs)const +fixed_base::operator*(const float &rhs)const { return (*this)*_fixed(rhs); } //! fixed * double template fixed_base -fixed_base::operator*(const double &rhs)const +fixed_base::operator*(const double &rhs)const { return (*this)*_fixed(rhs); } @@ -413,7 +413,7 @@ fixed_base::operator*(const double &rhs)const //! fixed / int template fixed_base -fixed_base::operator/(const int &rhs)const +fixed_base::operator/(const int &rhs)const { _fixed ret; ret._data=_data/rhs; @@ -423,14 +423,14 @@ fixed_base::operator/(const int &rhs)const //! float * fixed template fixed_base -operator*(const float& lhs, const fixed_base &rhs) +operator*(const float& lhs, const fixed_base &rhs) { return rhs*lhs; } //! double * fixed template fixed_base -operator*(const double& lhs, const fixed_base &rhs) +operator*(const double& lhs, const fixed_base &rhs) { return rhs*lhs; } @@ -442,38 +442,38 @@ operator*(const double& lhs, const fixed_base &rhs) // Negation Operator template fixed_base -fixed_base::operator-()const +fixed_base::operator-()const { _fixed ret; ret._data=-_data; return ret; } // Casting Operators template -fixed_base::operator float()const +fixed_base::operator float()const { return static_cast(_data)/static_cast(_ONE()); -} +} template -fixed_base::operator double()const +fixed_base::operator double()const { return static_cast(_data)/static_cast(_ONE()); -} +} template -fixed_base::operator long double()const +fixed_base::operator long double()const { return static_cast(_data)/static_cast(_ONE()); -} +} template -fixed_base::operator int()const +fixed_base::operator int()const { return static_cast(_data>>FIXED_BITS); } template -fixed_base::operator bool()const +fixed_base::operator bool()const { return static_cast(_data); } diff --git a/ETL/trunk/ETL/_gaussian.h b/ETL/trunk/ETL/_gaussian.h index f60b887..b251be1 100644 --- a/ETL/trunk/ETL/_gaussian.h +++ b/ETL/trunk/ETL/_gaussian.h @@ -209,7 +209,7 @@ gaussian_blur_3(I begin, I end, bool endpts = true) if(iter!=begin && ( endpts || (prev != begin) )) *prev=(Tmp1)/4; } - + if(endpts) { Tmp1=*prev; diff --git a/ETL/trunk/ETL/_handle.h b/ETL/trunk/ETL/_handle.h index 317f6c2..9c0b2ba 100644 --- a/ETL/trunk/ETL/_handle.h +++ b/ETL/trunk/ETL/_handle.h @@ -66,7 +66,7 @@ class shared_object { private: mutable int refcount; - + protected: shared_object():refcount(0) { } @@ -75,11 +75,11 @@ protected: #else ~shared_object() { } #endif - -public: + +public: void ref()const { assert(refcount>=0); refcount++; } - + //! Returns \c false if object needs to be deleted bool unref()const { @@ -97,7 +97,7 @@ public: return true; } - + int count()const { return refcount; } }; // END of class shared_object @@ -182,7 +182,7 @@ public: return *this; } */ - + //! Assignment operator handle & operator=(const handle &x) @@ -229,7 +229,7 @@ public: void reset() { detach(); } bool empty()const { return obj==0; } - + //! Creates a new instance of a T object and puts it in the handle. /*! Uses the default constructor */ void spawn() { operator=(handle(new T())); } @@ -327,20 +327,20 @@ private: public: void *front_; void *back_; - + protected: rshared_object():rrefcount(0),front_(0),back_(0) { } - -public: + +public: void rref()const { rrefcount++; } - + void runref()const { assert(rrefcount>0); rrefcount--; } - + int rcount()const { return rrefcount; } }; // END of class rshared_object @@ -372,7 +372,7 @@ public: using handle::get; using handle::operator *; using handle::operator ->; - + /* operator const handle&()const { return *this; } @@ -380,7 +380,7 @@ public: private: using handle::obj; - + rhandle *prev_; rhandle *next_; @@ -398,7 +398,7 @@ private: prev_=next_=0; return; } - + prev_=reinterpret_cast*>(obj->back_); next_=0; prev_->next_=this; @@ -429,7 +429,7 @@ private: else next_->prev_=prev_; } - + public: //! Default constructor - empty handle @@ -457,7 +457,7 @@ public: //! Handle is released on deletion ~rhandle() { detach(); } - + //! Template Assignment operator /*! \note This class may not be necessary, and may be removed ** at some point in the future. @@ -480,7 +480,7 @@ public: return *this; } */ - + //! Assignment operator rhandle & operator=(const rhandle &x) @@ -578,32 +578,32 @@ public: // value_type*& obj(handle::obj); // Required to keep gcc 3.4.2 form barfing assert(obj); assert(x.get()!=obj); - + if(x.get()==obj) return 0; - + rhandle *iter; rhandle *next; - + iter=reinterpret_cast*>(obj->front_); - assert(iter); + assert(iter); next=iter->next_; - + int i=0; #ifndef NDEBUG pointer obj_=obj; #endif - + for(;iter;iter=next,next=iter?iter->next_:0,i++) { - assert(iter->get()==obj_); + assert(iter->get()==obj_); (*iter)=x; } assert(obj==x.get()); - + return i; } @@ -711,7 +711,7 @@ public: //void release() { detach(); } void reset() { detach(); } - + bool empty()const { return obj==0; } handle clone()const { assert(obj); return obj->clone(); } @@ -782,8 +782,8 @@ template template handle handle::cast_reinterpret(const loose_handle &x) { return handle(reinterpret_cast(x.get())); } - - + + template template handle handle::cast_static(const rhandle &x) { return handle(static_cast(x.get())); } @@ -800,8 +800,8 @@ template template handle handle::cast_reinterpret(const rhandle &x) { return handle(reinterpret_cast(x.get())); } - - + + template template handle handle::cast_static(U* x) { return handle(static_cast(x)); } diff --git a/ETL/trunk/ETL/_hermite.h b/ETL/trunk/ETL/_hermite.h index 27a5fb6..9be678f 100644 --- a/ETL/trunk/ETL/_hermite.h +++ b/ETL/trunk/ETL/_hermite.h @@ -95,10 +95,10 @@ class hermite : public hermite_base public: typedef T value_type; typedef float time_type; - - -public: + + +public: hermite() { } hermite(const value_type &p1, const value_type &p2, const value_type &t1, const value_type &t2): P1(p1),P2(p2),T1(t1),T2(t2) { sync(); } diff --git a/ETL/trunk/ETL/_misc.h b/ETL/trunk/ETL/_misc.h index f0bf3ed..33d02b3 100644 --- a/ETL/trunk/ETL/_misc.h +++ b/ETL/trunk/ETL/_misc.h @@ -42,28 +42,28 @@ binary_find(I begin, I end, const T& value) { #if 1 I iter(begin+(end-begin)/2); - + while(end-begin>1 && !(*iter==value)) { ((*iter1 && !(*iter==value)) { ((*iter() const { assert(data_); return &(operator*()); } - + void inc() { assert(data_); data_ = (pointer)((char*)data_ + pitch_); } void inc(int n) { assert(data_); data_ = (pointer)((char*)data_ + n*pitch_); } - + void dec() { assert(data_); data_ = (pointer)((char*)data_ - pitch_); } void dec(int n) { assert(data_); data_ = (pointer)((char*)data_ - n*pitch_); } @@ -151,7 +151,7 @@ private: { data_ = (pointer)((char*)data_ + nbytes); } - + void subptr(int nbytes) { data_ = (pointer)((char*)data_ + nbytes); @@ -181,12 +181,12 @@ public: generic_pen():data_(NULL) { } - self_type& move(int a, int b) - { - assert(data_); + self_type& move(int a, int b) + { + assert(data_); x_ += a, y_ += b; - addptr(b*pitch_ + a*sizeof(value_type)); - return *this; + addptr(b*pitch_ + a*sizeof(value_type)); + return *this; } self_type& move_to(int x, int y) { assert(data_); return move(x - x_,y - y_);} void set_value(const value_type &v) { value_=v; } @@ -220,49 +220,49 @@ public: void put_hline(int l,const value_type &v) {for(;l>0;l--,inc_x())put_value(v);} - + void put_hline(int l) {put_hline(l,value_);} void put_hline_clip(int l, const value_type &v) {l=std::min(l,w_-x_);for(;l>0;l--,inc_x())put_value_clip(v);} - + void put_hline_clip(int l) {put_hline_clip(l,value_);} - + //the put_block functions do not modify the pen void put_block(int h, int w, const value_type &v) { self_type row(*this); for(;h>0;h--,row.inc_y()) - { + { self_type col(row); col.put_hline(w,v); } } - + void put_block(int h, int w) { put_block(h,w,value_); } void put_block_clip(int h, int w, const value_type &v) { self_type row(*this); - + //clip start position - if(row.x_ < 0) { w+=row.x_; row.inc_x(-row.x_); } + if(row.x_ < 0) { w+=row.x_; row.inc_x(-row.x_); } if(row.y_ < 0) { h+=row.y_; row.inc_y(-row.y_); } - + //clip width and height of copy rect h = std::min(h,h_-y_); w = std::min(w,w_-x_); - + //copy rect for(;h>0;h--,row.inc_y()) - { + { self_type col(row); col.put_hline(w,v); //already clipped } } - + void put_block_clip(int h, int w) { put_block(h,w,value_); } - + iterator_x operator[](int i)const { assert(data_); return (pointer)(((char*)data_)+i*pitch_); } @@ -294,15 +294,15 @@ public: assert(data_); self_type ret(*this); ret.move(rhs.x,rhs.y); - return ret; + return ret; } - + difference_type diff_begin()const {return difference_type(-x_,-y_);} difference_type diff_end()const {return difference_type(w_-x_,h_-y_);} - + self_type get_start()const {return *this + diff_begin(); } self_type get_end()const {return *this + diff_end(); } - + int get_width()const {return w_;} int get_height()const {return h_;} @@ -343,7 +343,7 @@ public: using PEN_::h_; using PEN_::x_; using PEN_::y_; - + alpha_pen(const alpha_type &a = 1, const affine_func_type &func = affine_func_type()):alpha_(a),affine_func_(func) { } alpha_pen(const PEN_ &x, const alpha_type &a=1, const affine_func_type &func=affine_func_type()) :PEN_(x),alpha_(a),affine_func_(func) { } @@ -363,13 +363,13 @@ public: void put_value_clip()const { put_value_clip(get_pen_value()); } void put_value_clip_alpha(alpha_type a)const { put_value_clip(get_pen_value(),a); } void put_hline_clip(int l, const alpha_type &a = 1){l=std::min(l,w_-x_);for(;l>0;l--,inc_x())put_value_clip_alpha(a);} - + //the put_block functions do not modify the pen void put_block(int h, int w, const alpha_type &a = 1) { self_type row(*this); for(;h>0;h--,row.inc_y()) - { + { self_type col(row); col.put_hline(w,a); } @@ -378,18 +378,18 @@ public: void put_block_clip(int h, int w, const alpha_type &a = 1) { self_type row(*this); - + //clip start position if(row.x_ < 0) { w+=row.x_; row.inc_x(-row.x_); } if(row.y_ < 0) { h+=row.y_; row.inc_y(-row.y_); } - + //clip width and height of copy rect h = std::min(h,h_-y_); w = std::min(w,w_-x_); - + //copy rect for(;h>0;h--,row.inc_y()) - { + { self_type col(row); col.put_hline(w,a); //already clipped } diff --git a/ETL/trunk/ETL/_random.h b/ETL/trunk/ETL/_random.h index 0af2dcb..c65b93a 100644 --- a/ETL/trunk/ETL/_random.h +++ b/ETL/trunk/ETL/_random.h @@ -41,28 +41,28 @@ class rand_source_xor public: typedef int seed_type; typedef short value_type; - + private: short entropy_pool[256]; int pool_index; - + public: random() { seed(0); mod=offset=0; } - + void seed(const seed_type &x) { pool_index=0; } - + void add_entropy(value_type entropy) { int i; for(i=0;iPOOL_SIZE) diff --git a/ETL/trunk/ETL/_rect.h b/ETL/trunk/ETL/_rect.h index d19959b..0153f2a 100644 --- a/ETL/trunk/ETL/_rect.h +++ b/ETL/trunk/ETL/_rect.h @@ -47,48 +47,48 @@ public: //type niceties typedef T value_type; public: //representation - + value_type minx,maxx,miny,maxy; public: //interface - + rect() {} - + rect(const value_type &x1,const value_type &y1) { set_point(x1,y1); } - + rect(const value_type &x1,const value_type &y1, const value_type &x2,const value_type &y2) { set_point(x1,y1); expand(x2,y2); } - + rect(const rect &o) :minx(o.minx),maxx(o.maxx),miny(o.miny),maxy(o.maxy) {} - + template < typename U > rect(const rect &o) :minx(o.minx),maxx(o.maxx),miny(o.miny),maxy(o.maxy) {} - + void set_point(const value_type &x1,const value_type &y1) { minx = maxx = x1; - miny = maxy = y1; + miny = maxy = y1; } - + void expand(const value_type &x1,const value_type &y1) { minx = std::min(minx,x1); maxx = std::max(maxx,x1); miny = std::min(miny,y1); - maxy = std::max(maxy,y1); + maxy = std::max(maxy,y1); } - + void set(const value_type &x1,const value_type &y1, const value_type &x2,const value_type &y2) { @@ -101,7 +101,7 @@ public: //interface { return valid(std::less()); } - + template < typename F > bool valid(const F & func) const { @@ -113,18 +113,18 @@ template < typename T, typename F > inline bool intersect(const rect &r1, const rect &r2, const F & func) { /* We wan to do the edge compare test - |-----| + |-----| |------| intersecting - + |-----| |-----| not intersecting - + So we want to compare the mins of the one against the maxs of the other, and visa versa - + by default (exclude edge sharing) less will not be true if they are equal... */ - + return func(r1.minx,r2.maxx) && func(r2.minx,r1.maxx) && func(r1.miny,r2.maxy) && diff --git a/ETL/trunk/ETL/_ref_count.h b/ETL/trunk/ETL/_ref_count.h index 1d01590..95ca857 100644 --- a/ETL/trunk/ETL/_ref_count.h +++ b/ETL/trunk/ETL/_ref_count.h @@ -1,6 +1,6 @@ /*! ======================================================================== ** Extended Template Library -** +** ** $Id: _ref_count.h,v 1.1.1.1 2005/01/04 01:31:48 darco Exp $ ** ** Copyright (c) 2002 Robert B. Quattlebaum Jr. @@ -41,7 +41,7 @@ _ETL_BEGIN_NAMESPACE class weak_reference_counter; - + // ======================================================================== /*! \class reference_counter _ref_count.h ETL/ref_count ** \brief Reference counter @@ -56,14 +56,14 @@ private: public: reference_counter(const bool &x=true):counter_(x?new int(1):0) { } - + reference_counter(const reference_counter &x):counter_(x.counter_) { if(counter_) (*counter_)++; } reference_counter(const weak_reference_counter &x); - + ~reference_counter() { detach(); } - + reference_counter& operator=(const reference_counter &rhs) { detach(); @@ -71,9 +71,9 @@ public: if(counter_) { assert(*counter_>0); - (*counter_)++; + (*counter_)++; } - return *this; + return *this; } void detach() @@ -84,19 +84,19 @@ public: if(!--(*counter_)) delete counter_; counter_=0; - } - } - + } + } + void reset() { detach(); - counter_=new int(1); + counter_=new int(1); } - + int count()const { return counter_?*counter_:0; } bool unique()const { return counter_?*counter_==1:0; } - + operator int()const { return count(); } }; // END of class reference_counter @@ -113,13 +113,13 @@ private: int* counter_; public: weak_reference_counter():counter_(0) { } - + weak_reference_counter(const weak_reference_counter &x):counter_(x.counter_) { } weak_reference_counter(const reference_counter &x):counter_(x.counter_) { } - + ~weak_reference_counter() { } - + weak_reference_counter& operator=(const reference_counter &rhs) { counter_=rhs.counter_; @@ -134,12 +134,12 @@ public: return *this; } - void detach() { counter_=0; } - + void detach() { counter_=0; } + int count()const { return counter_?*counter_:0; } bool unique()const { return counter_?*counter_==1:0; } - + operator int()const { return count(); } }; // END of class weak_reference_counter diff --git a/ETL/trunk/ETL/_smach.h b/ETL/trunk/ETL/_smach.h index 24f6b5e..d634ec5 100644 --- a/ETL/trunk/ETL/_smach.h +++ b/ETL/trunk/ETL/_smach.h @@ -65,7 +65,7 @@ public: typedef M _mutex; typedef CON context_type; - + struct egress_exception { }; struct pop_exception { }; @@ -79,7 +79,7 @@ public: RESULT_OK, //!< Event has been processed RESULT_ACCEPT, //!< The event has been explicitly accepted. RESULT_REJECT, //!< The event has been explicitly rejected. - + RESULT_END //!< Not a valid result }; @@ -89,13 +89,13 @@ public: struct event { event_key key; - + event() { } event(const event_key& key):key(key) { } - + operator event_key()const { return key; } }; - + //! Event definition class template class event_def @@ -116,7 +116,7 @@ public: funcptr handler; // class state : public state_base { // Our parent is our friend friend class smach; - + public: typedef event_def event_def; typedef T state_context_type; - + private: - + std::vector event_list; - + smach *nested; //! Nested machine event_key low,high; //! Lowest and Highest event values const char *name; //! Name of the state @@ -187,9 +187,9 @@ public: state(const char *n, smach* nest=0): nested(nest),name(n),default_handler(NULL) { } - + virtual ~state() { } - + //! Setup a nested state machine /*! A more detailed explanation needs to be written */ void set_nested_machine(smach *sm) { nested=sm; } @@ -199,19 +199,19 @@ public: //! Returns given the name of the state virtual const char *get_name() const { return name; } - + state_context_type& get_context(smach& machine) { state_context_type *context(dynamic_cast(machine.state_context)); if(context) return context; - + } //! Adds an event_def onto the list and then make sure it is sorted correctly. void insert(const event_def &x) - { + { // If this is our first event_def, // setup the high and low values. if(!event_list.size()) @@ -227,29 +227,29 @@ public: if(high::iterator find(const event_key &x) { return binary_find(event_list.begin(),event_list.end(),x); } typename std::vector::const_iterator find(const event_key &x)const { return binary_find(event_list.begin(),event_list.end(),x); } - + protected: - + virtual void* enter_state(context_type* machine_context)const { return new state_context_type(machine_context); } - + virtual bool leave_state(void* x)const { state_context_type* state_context(reinterpret_cast(x)); delete state_context; return true; } - + virtual event_result process_event(void* x,const event& id)const { state_context_type* state_context(reinterpret_cast(x)); - + // Check for nested machine in state if(nested) { @@ -257,27 +257,27 @@ public: if(ret!=RESULT_OK) return ret; } - + // Quick test to make sure that the // given event is in the state if(id.key::const_iterator iter(find(id.key)); - + // If search results were negative, fail. if(iter->id!=id.key) return RESULT_OK; - + // Execute event function event_result ret((state_context->*(iter->handler))(id)); - + if(ret==RESULT_OK && default_handler) ret=(state_context->*(default_handler))(id); - + return ret; - } + } }; private: @@ -291,14 +291,14 @@ public: // this really should be private private: context_type* machine_context; //!< Machine Context - + const state_base* default_state; void* default_context; #ifdef ETL_MUTEX_LOCK _mutex mutex; #endif - + //! State stack data const state_base* state_stack[SMACH_STATE_STACK_SIZE]; void* state_context_stack[SMACH_STATE_STACK_SIZE]; @@ -319,7 +319,7 @@ public: return default_state->get_name(); return 0; } - + //! Determines if a given event result is an error /*! This function allows us to quickly see if an event_result contained an error */ @@ -345,7 +345,7 @@ public: // Set this as our current state default_state=nextstate; default_context=0; - + // Attempt to enter the state if(default_state) { @@ -362,12 +362,12 @@ public: // If we had a previous state, enter it if(default_state) default_context=default_state->enter_state(machine_context); - + // At this point we are not in the // requested state, so return failure return false; } - + //! Leaves the current state /*! Effectively makes the state_depth() function return zero. */ bool @@ -387,7 +387,7 @@ public: // Grab the return value from the exit function bool ret=true; - + const state_base* old_state=curr_state; void *old_context=state_context; @@ -396,7 +396,7 @@ public: // Leave the state return old_state->leave_state(old_context); - + return ret; } @@ -423,7 +423,7 @@ public: // Set this as our current state curr_state=nextstate; state_context=0; - + // Attempt to enter the state state_context=curr_state->enter_state(machine_context); if(state_context) @@ -435,7 +435,7 @@ public: // If we had a previous state, enter it if(curr_state) state_context=curr_state->enter_state(machine_context); - + // At this point we are not in the // requested state, so return failure return false; @@ -499,13 +499,13 @@ public: { const state_base* old_state=curr_state; void *old_context=state_context; - + // Pop previous state off of stack --states_on_stack; curr_state=state_stack[states_on_stack]; state_context=state_context_stack[states_on_stack]; - old_state->leave_state(old_context); + old_state->leave_state(old_context); } else // If there are no states on stack, just egress egress(); @@ -522,7 +522,7 @@ public: default_context(0), states_on_stack(0) { } - + //! The destructor ~smach() { @@ -531,7 +531,7 @@ public: if(default_state) default_state->leave_state(default_context); } - + //! Sets up a child state machine /*! A child state machine runs in parallel with its parent, and gets event priority. This @@ -544,7 +544,7 @@ public: #endif child=x; } - + //! Returns the number states currently active int state_depth() @@ -552,7 +552,7 @@ public: event_result process_event(const event_key& id) { return process_event(event(id)); } - + //! Process an event event_result process_event(const event& id) @@ -560,25 +560,25 @@ public: #ifdef ETL_MUTEX_LOCK ETL_MUTEX_LOCK(); #endif - + event_result ret(RESULT_OK); - + // Check for child machine if(child) - { + { ret=child->process_event(id); if(ret!=RESULT_OK) return ret; } - + try - { + { if(curr_state) ret=curr_state->process_event(state_context,id); - + if(ret==RESULT_OK) return default_state->process_event(default_context,id); - + return ret; } catch(egress_exception) { return egress()?RESULT_ACCEPT:RESULT_ERROR; } diff --git a/ETL/trunk/ETL/_smart_ptr.h b/ETL/trunk/ETL/_smart_ptr.h index 479c966..c25b050 100644 --- a/ETL/trunk/ETL/_smart_ptr.h +++ b/ETL/trunk/ETL/_smart_ptr.h @@ -73,7 +73,7 @@ public: typedef D destructor_type; #ifdef DOXYGEN_SHOULD_SKIP_THIS // #ifdef is not a typo -private: +private: #endif value_type *obj; //!< \internal Pointer to object reference_counter refcount; @@ -128,7 +128,7 @@ public: obj=(pointer)x.get(); refcount=x.refcount; } - + return *this; } @@ -138,31 +138,31 @@ public: { if(x.get()==obj) return *this; - + reset(); if(x.obj) { - + obj=(pointer)x.get(); refcount=x.refcount; } - + return *this; } //! smart_ptr reset procedure void reset() - { + { if(obj) - { + { if(refcount.unique()) destructor_type()(obj); refcount.detach(); obj=0; } } - + void spawn() { operator=(smart_ptr(new T)); } //! Returns number of instances @@ -269,7 +269,7 @@ public: const count_type& count()const { return refcount; } bool unique()const { return refcount.unique(); } - + reference operator*()const { assert(obj); return *obj; } pointer operator->()const { assert(obj); return obj; } diff --git a/ETL/trunk/ETL/_stringf.h b/ETL/trunk/ETL/_stringf.h index d266453..9e11de3 100644 --- a/ETL/trunk/ETL/_stringf.h +++ b/ETL/trunk/ETL/_stringf.h @@ -195,7 +195,7 @@ is_absolute_path(const std::string &path) #ifdef WIN32 if(path.size()>=3 && path[1]==':' && (path[2]=='\\' || path[2]=='/')) return true; -#endif +#endif if(!path.empty() && path[0]==ETL_DIRECTORY_SEPERATOR) return true; return false; @@ -235,7 +235,7 @@ get_root_from_path(std::string path) { std::string ret; std::string::const_iterator iter; - + for(iter=path.begin();iter!=path.end();++iter) { if(*iter==ETL_DIRECTORY_SEPERATOR) @@ -268,7 +268,7 @@ cleanup_path(std::string path) std::string ret; while(basename(path)==".")path=dirname(path); - + while(!path.empty()) { std::string dir(get_root_from_path(path)); @@ -282,7 +282,7 @@ cleanup_path(std::string path) } path=remove_root_from_path(path); } - + // Remove any trailing directory seperators if(ret.size() && ret[ret.size()-1]==ETL_DIRECTORY_SEPERATOR) { @@ -295,7 +295,7 @@ inline std::string absolute_path(std::string path) { std::string ret(current_working_directory()); - + if(path.empty()) return cleanup_path(ret); if(is_absolute_path(path)) @@ -306,14 +306,14 @@ absolute_path(std::string path) inline std::string relative_path(std::string curr_path,std::string dest_path) -{ +{ // If dest_path is already a relative path, // then there is no need to do anything. if(!is_absolute_path(dest_path)) dest_path=absolute_path(dest_path); else dest_path=cleanup_path(dest_path); - + if(!is_absolute_path(curr_path)) curr_path=absolute_path(curr_path); else @@ -332,7 +332,7 @@ relative_path(std::string curr_path,std::string dest_path) { return basename(dest_path); } - + while(!dest_path.empty() && !curr_path.empty() && get_root_from_path(dest_path)==get_root_from_path(curr_path)) { dest_path=remove_root_from_path(dest_path); @@ -344,7 +344,7 @@ relative_path(std::string curr_path,std::string dest_path) dest_path=std::string("..")+ETL_DIRECTORY_SEPERATOR+dest_path; curr_path=remove_root_from_path(curr_path); } - + return dest_path; } diff --git a/ETL/trunk/ETL/_surface.h b/ETL/trunk/ETL/_surface.h index 58a3efa..cd1afed 100644 --- a/ETL/trunk/ETL/_surface.h +++ b/ETL/trunk/ETL/_surface.h @@ -82,7 +82,7 @@ private: bool deletable_; value_prep_type cooker_; - + void swap(const surface &x) { std::swap(data_,x.data_); @@ -92,7 +92,7 @@ private: std::swap(h_,x.h_); std::swap(deletable_,x.deletable_); } - + public: surface(): data_(0), @@ -121,7 +121,7 @@ public: pitch_(sizeof(value_type)*s.x), w_(s.x),h_(s.y), deletable_(true) { } - + template surface(const _pen &_begin, const _pen &_end) { @@ -163,8 +163,8 @@ public: if(deletable_) delete [] data_; } - - size_type + + size_type size()const { return size_type(w_,h_); } @@ -175,24 +175,24 @@ public: const surface &mirror(const surface &rhs) { if(deletable_)delete [] data_; - + data_=rhs.data_; zero_pos_=rhs.zero_pos_; pitch_=rhs.pitch_; w_=rhs.w_; h_=rhs.h_; deletable_=false; - + return *this; } - + const surface &operator=(const surface &rhs) { set_wh(rhs.w_,rhs.h_); zero_pos_=data_+(rhs.zero_pos_-rhs.data_); pitch_=rhs.pitch_; deletable_=true; - + memcpy(data_,rhs.data_,pitch_*h_); return *this; @@ -228,7 +228,7 @@ public: PEN.put_hline(w); } - template void + template void fill(value_type v, _pen& PEN, int w, int h) { assert(data_); @@ -252,7 +252,7 @@ public: template void blit_to(_pen &pen) { return blit_to(pen,0,0, get_w(),get_h()); } - + template void blit_to(_pen &DEST_PEN, int x, int y, int w, int h) //src param @@ -264,28 +264,28 @@ public: if(x<0) { w+=x; //decrease - x=0; + x=0; } - + if(y<0) { h+=y; //decrease - y=0; + y=0; } - + //clip width against dest width w = std::min((long)w,(long)(DEST_PEN.end_x()-DEST_PEN.x())); h = std::min((long)h,(long)(DEST_PEN.end_y()-DEST_PEN.y())); - + //clip width against src width - w = std::min(w,w_-x); - h = std::min(h,h_-y); + w = std::min(w,w_-x); + h = std::min(h,h_-y); if(w<=0 || h<=0) return; - + pen SOURCE_PEN(get_pen(x,y)); - + for(; h>0; h--,DEST_PEN.inc_y(),SOURCE_PEN.inc_y()) { int i; @@ -335,9 +335,9 @@ public: && pitch_!=0 ; } - + operator bool()const { return is_valid(); } - + pen begin() { assert(data_); return pen(data_,w_,h_,pitch_); } pen get_pen(int x, int y) { assert(data_); return begin().move(x,y); } pen end() { assert(data_); return get_pen(w_,h_); } @@ -345,22 +345,22 @@ public: const_pen begin()const { assert(data_); return const_pen(data_,w_,h_,pitch_); } const_pen get_pen(int x, int y)const { assert(data_); return begin().move(x,y); } const_pen end()const { assert(data_); return get_pen(w_,h_); } - + //! Linear sample value_type linear_sample(const float x, const float y)const { int u(floor_to_int(x)), v(floor_to_int(y)); float a, b; static const float epsilon(1.0e-6); - + if(x<0.0f)u=0,a=0.0f; else if(x>w_-1)u=w_-1,a=0.0f; else a=x-u; - + if(y<0.0f)v=0,b=0.0f; else if(y>h_-1)v=h_-1,b=0.0f; else b=y-v; - + const float c(1.0f-a), d(1.0f-b), e(a*d),f(c*b),g(a*b); @@ -378,22 +378,22 @@ public: int u(floor_to_int(x)), v(floor_to_int(y)); float a, b; static const float epsilon(1.0e-6); - + if(x<0.0f)u=0,a=0.0f; else if(x>w_-1)u=w_-1,a=0.0f; else a=x-u; - + if(y<0.0f)v=0,b=0.0f; else if(y>h_-1)v=h_-1,b=0.0f; else b=y-v; a=(1.0f-cos(a*3.1415927f))*0.5f; b=(1.0f-cos(b*3.1415927f))*0.5f; - + const float c(1.0f-a), d(1.0f-b), e(a*d),f(c*b),g(a*b); - + accumulator_type ret(cooker_.cook((*this)[v][u])*(c*d)); if(e>=epsilon)ret+=cooker_.cook((*this)[v][u+1])*e; if(f>=epsilon)ret+=cooker_.cook((*this)[v+1][u])*f; @@ -402,7 +402,7 @@ public: return cooker_.uncook(ret); } - //! Cubic sample + //! Cubic sample value_type cubic_sample(float x, float y)const { #if 0 @@ -411,15 +411,15 @@ public: #define F(i,j) (cooker_.cook((*this)[max(min(j+v,h_-1),0)][max(min(i+u,w_-1),0)])*(R((i)-a)*R(b-(j)))) #define Z(i,j) ret+=F(i,j) #define X(i,j) // placeholder... To make box more symetric - + int u(floor_to_int(x)), v(floor_to_int(y)); float a, b; - + // Clamp X if(x<0.0f)u=0,a=0.0f; else if(u>w_-1)u=w_-1,a=0.0f; else a=x-u; - + // Clamp Y if(y<0.0f)v=0,b=0.0f; else if(v>h_-1)v=h_-1,b=0.0f; @@ -433,52 +433,52 @@ public: Z( 2,-1); Z( 2, 0); Z( 2, 1); Z( 2, 2); return cooker_.uncook(ret); - + #undef X #undef Z #undef F #undef P #undef R #else - + #define f(j,i) (cooker_.cook((*this)[j][i])) //Using catmull rom interpolation because it doesn't blur at all //bezier curve with intermediate ctrl pts: 0.5/3(p(i+1) - p(i-1)) and similar accumulator_type xfa [4]; - + //precalculate indices (all clamped) and offset const int xi = x > 0 ? (x < w_ ? (int)floor(x) : w_-1) : 0; const int xa[] = {std::max(0,xi-1),xi,std::min(w_-1,xi+1),std::min(w_-1,xi+2)}; - + const int yi = y > 0 ? (y < h_ ? (int)floor(y) : h_-1) : 0; const int ya[] = {std::max(0,yi-1),yi,std::min(h_-1,yi+1),std::min(h_-1,yi+2)}; - + const float xf = x-xi; const float yf = y-yi; - + //figure polynomials for each point - const float txf[] = + const float txf[] = { 0.5*xf*(xf*(xf*(-1) + 2) - 1), //-t + 2t^2 -t^3 0.5*(xf*(xf*(3*xf - 5)) + 2), //2 - 5t^2 + 3t^3 0.5*xf*(xf*(-3*xf + 4) + 1), //t + 4t^2 - 3t^3 0.5*xf*xf*(xf-1) //-t^2 + t^3 }; - - const float tyf[] = + + const float tyf[] = { 0.5*yf*(yf*(yf*(-1) + 2) - 1), //-t + 2t^2 -t^3 0.5*(yf*(yf*(3*yf - 5)) + 2), //2 - 5t^2 + 3t^3 0.5*yf*(yf*(-3*yf + 4) + 1), //t + 4t^2 - 3t^3 0.5*yf*yf*(yf-1) //-t^2 + t^3 }; - - //evaluate polynomial for each row + + //evaluate polynomial for each row for(int i = 0; i < 4; ++i) { xfa[i] = f(ya[i],xa[0])*txf[0] + f(ya[i],xa[1])*txf[1] + f(ya[i],xa[2])*txf[2] + f(ya[i],xa[3])*txf[3]; } - + //return the cumulative column evaluation return cooker_.uncook(xfa[0]*tyf[0] + xfa[1]*tyf[1] + xfa[2]*tyf[2] + xfa[3]*tyf[3]); #undef f @@ -488,150 +488,150 @@ public: value_type sample_rect(float x0,float y0,float x1,float y1) const { const surface &s = *this; - + //assumes it's clamped to the boundary of the image //force min max relationship for x0,x1 and y0,y1 if(x0 > x1) std::swap(x0,x1); if(y0 > y1) std::swap(y0,y1); - + //local variable madness //all things that want to interoperate should provide a default value constructor for = 0 accumulator_type acum = 0; int xi=0,yi=0; - + int xib=(int)floor(x0), xie=(int)floor(x1); - + int yib=(int)floor(y0), yie=(int)floor(y1); - + //the weight for the pixel should remain the same... float weight = (y1-y0)*(x1-x0); assert(weight != 0); - - float ylast = y0, xlastb = x0; + + float ylast = y0, xlastb = x0; const_pen pen_ = s.get_pen(xib,yib); - + for(yi = yib; yi < yie; ylast = ++yi, pen_.inc_y()) { const float yweight = yi+1 - ylast; - - float xlast = xlastb; + + float xlast = xlastb; for(xi = xib; xi < xie; xlast = ++xi, pen_.inc_x()) { - const float w = yweight*(xi+1 - xlast); + const float w = yweight*(xi+1 - xlast); acum += cooker_.cook(pen_.get_value())*w; } - + //post... with next being fractional... const float w = yweight*(x1 - xlast); acum += cooker_.cook(pen_.get_value())*w; - + pen_.dec_x(xie-xib); } - + //post in y direction... must have all x... { const float yweight = y1 - ylast; - + float xlast = xlastb; for(xi = xib; xi < xie; xlast = ++xi) { const float w = yweight*(xi+1 - xlast); - + acum += cooker_.cook(pen_.get_value())*w; } - + //post... with next being fractional... const float w = yweight*(x1 - xlast); acum += cooker_.cook(pen_.get_value())*w; } - + acum *= 1/weight; return cooker_.uncook(acum); } - + value_type sample_rect_clip(float x0,float y0,float x1,float y1) const { const surface &s = *this; - + //assumes it's clamped to the boundary of the image //force min max relationship for x0,x1 and y0,y1 if(x0 > x1) std::swap(x0,x1); if(y0 > y1) std::swap(y0,y1); - + //local variable madness //all things that want to interoperate should provide a default value constructor for = 0 accumulator_type acum = 0; int xi=0,yi=0; - + int xib=(int)floor(x0), xie=(int)floor(x1); - + int yib=(int)floor(y0), yie=(int)floor(y1); - + //the weight for the pixel should remain the same... float weight = (y1-y0)*(x1-x0); - + assert(weight != 0); - + //clip to the input region if(x0 >= s.get_w() || x1 <= 0) return acum; if(y0 >= s.get_h() || y1 <= 0) return acum; - + if(x0 < 0) { x0 = 0; xib = 0; } if(x1 >= s.get_w()) { x1 = s.get_w(); //want to be just below the last pixel... xie = s.get_w()-1; } - + if(y0 < 0) { y0 = 0; yib = 0; } - if(y1 >= s.get_h()) + if(y1 >= s.get_h()) { y1 = s.get_h(); //want to be just below the last pixel... yie = s.get_h()-1; } - - float ylast = y0, xlastb = x0; + + float ylast = y0, xlastb = x0; const_pen pen = s.get_pen(xib,yib); - + for(yi = yib; yi < yie; ylast = ++yi, pen.inc_y()) { const float yweight = yi+1 - ylast; - - float xlast = xlastb; + + float xlast = xlastb; for(xi = xib; xi < xie; xlast = ++xi, pen.inc_x()) { - const float w = yweight*(xi+1 - xlast); + const float w = yweight*(xi+1 - xlast); acum += cooker_.cook(pen.get_value())*w; } - + //post... with next being fractional... const float w = yweight*(x1 - xlast); acum += cooker_.cook(pen.get_value())*w; - + pen.dec_x(xie-xib); } - + //post in y direction... must have all x... { const float yweight = y1 - ylast; - + float xlast = xlastb; for(xi = xib; xi < xie; xlast = ++xi) { const float w = yweight*(xi+1 - xlast); - + acum += cooker_.cook(pen.get_value())*w; } - + //post... with next being fractional... const float w = yweight*(x1 - xlast); acum += cooker_.cook(pen.get_value())*w; } - + acum *= 1/weight; return cooker_.uncook(acum); } diff --git a/ETL/trunk/ETL/_thread.h b/ETL/trunk/ETL/_thread.h index 6939ee3..555cb02 100644 --- a/ETL/trunk/ETL/_thread.h +++ b/ETL/trunk/ETL/_thread.h @@ -108,7 +108,7 @@ public: (*references)++; return *this; } - + void start(void) { references = new int; @@ -125,12 +125,12 @@ public: pthread_cancel(thread); pthread_join(thread,&exit_status); } - + static void TestStop() { pthread_testcancel(); } - + static void SyncStop() { int i; @@ -307,18 +307,18 @@ private: unsigned long thread; HANDLE handle; int *references; - + entrypoint_return (THREAD_ENTRYPOINT *entrypoint)(void *); - + void *context; - + HDC hdc; HGLRC hglrc; - + static entrypoint_return THREAD_ENTRYPOINT thread_prefix(void*data) { Thread *thread=(Thread *)data; - + if(thread->hglrc) wglMakeCurrent(thread->hdc, thread->hglrc); @@ -356,7 +356,7 @@ public: (*references)++; return *this; } - + void start(void) { references = new int; @@ -379,10 +379,10 @@ public: { delete references; references=NULL; - + TerminateThread(handle, FALSE); } - + int wait(void) { if(handle) @@ -392,11 +392,11 @@ public: } return 0; } - + static void TestStop() { } - + static void SyncStop() { } diff --git a/ETL/trunk/ETL/_trivial.h b/ETL/trunk/ETL/_trivial.h index 4732ad3..6d82bfa 100644 --- a/ETL/trunk/ETL/_trivial.h +++ b/ETL/trunk/ETL/_trivial.h @@ -55,33 +55,33 @@ class trivial typedef const T& const_reference; typedef T* pointer; typedef const T* const_pointer; - + char data[sizeof(T)]; public: - operator reference() + operator reference() { return *reinterpret_cast(data); } // HACK - Rather dangerous - //operator reference()const + //operator reference()const //{ return *reinterpret_cast(const_cast(data)); } - - operator const_reference()const + + operator const_reference()const { return *reinterpret_cast(data); } - + reference get() { return *reinterpret_cast(data); } const_reference get()const { return *reinterpret_cast(data); } - + void construct() { new(&get()) value_type(); } void destruct() { get().~value_type(); } - + void destroy() { destruct(); } - + template reference operator=(const U &rhs) { return get()=rhs; } @@ -125,11 +125,11 @@ public: template reference operator<<=(const U &rhs) { return get()<<=rhs; } - - operator bool()const + + operator bool()const { return get(); } - bool operator!()const + bool operator!()const { return !get(); } }; // END of template class trivial diff --git a/ETL/trunk/ETL/_value.h b/ETL/trunk/ETL/_value.h index a8369c6..42bbc81 100644 --- a/ETL/trunk/ETL/_value.h +++ b/ETL/trunk/ETL/_value.h @@ -70,20 +70,20 @@ class value virtual contentholder *clone() const = 0; virtual const std::type_info &type() const = 0; }; - - contentholder *content; - + + contentholder *content; + public: //structor interface value() - :content(0) + :content(0) { } - + value(const value &v) :content( v.content ? v.content->clone() : 0 ) { } - + /* Copies the object passed to it */ template < typename T > @@ -92,9 +92,9 @@ public: //structor interface (reinterpret_cast::value_type &>(v)) ) { } - + public: //modifier interface - + value & swap(value & rhs) { std::swap(content, rhs.content); @@ -113,21 +113,21 @@ public: //modifier interface value(rhs).swap(*this); return *this; } - + public: //query interface - + bool empty() const { return content == 0; } - + const std::type_info & type() const { return content ? content->type() : typeid(void); } - + private: //implementation interface - + template < typename T > class holder : public contentholder { @@ -135,12 +135,12 @@ private: //implementation interface T obj; public: //structor interface - + holder(const T &o) :obj(o) { } - + holder(const holder &h) :obj(h.obj) { @@ -151,21 +151,21 @@ private: //implementation interface { return new holder(*this); } - + virtual const std::type_info &type() const { return typeid(T); } - + public: //allocation interface void *operator new(unsigned int size) { assert(size == sizeof(holder)); - + //use pool allocation at some point return malloc(size); } - + void operator delete(void *p) { assert(p); @@ -173,7 +173,7 @@ private: //implementation interface return free(p); } }; - + template < typename ValueType > friend ValueType *value_cast(value *v); }; @@ -199,8 +199,8 @@ template < typename ValueType > ValueType *value_cast(value *v) { assert(v); - - return ( typeid(typename value_store_type::value_type) == v->type() ) + + return ( typeid(typename value_store_type::value_type) == v->type() ) ? &static_cast *>(v->content)->obj : 0; } @@ -214,7 +214,7 @@ const ValueType * value_cast(const value *v) return value_cast(const_cast(v)); } -/*! Extract a copy of the internal object and will throw a bad_value_cast exception +/*! Extract a copy of the internal object and will throw a bad_value_cast exception if the types do not agree. \note I'm not sure why boost::any didn't use a reference here... there must be a reason... diff --git a/ETL/trunk/ETL/etl_config.h b/ETL/trunk/ETL/etl_config.h index 9bdcb9e..faea695 100644 --- a/ETL/trunk/ETL/etl_config.h +++ b/ETL/trunk/ETL/etl_config.h @@ -22,20 +22,20 @@ #ifndef ETL_FLAG_NONAMESPACE # define _ETL ETL_NAMESPACE -# define _ETL_BEGIN_NAMESPACE namespace _ETL { +# define _ETL_BEGIN_NAMESPACE namespace _ETL { # define _ETL_END_NAMESPACE }; -# define _STD_BEGIN_NAMESPACE namespace std { +# define _STD_BEGIN_NAMESPACE namespace std { # define _STD_END_NAMESPACE }; #else # define _ETL # define _ETL_BEGIN_NAMESPACE -# define _ETL_END_NAMESPACE +# define _ETL_END_NAMESPACE # define _STD_BEGIN_NAMESPACE -# define _STD_END_NAMESPACE +# define _STD_END_NAMESPACE #endif #define _ETL_BEGIN_CDECLS extern "C" { -#define _ETL_END_CDECLS } +#define _ETL_END_CDECLS } #ifdef _REENTRANT #define ETL_REENTRANT 1 diff --git a/ETL/trunk/test/angle.cpp b/ETL/trunk/test/angle.cpp index 00a06f6..e6a6ad3 100644 --- a/ETL/trunk/test/angle.cpp +++ b/ETL/trunk/test/angle.cpp @@ -41,13 +41,13 @@ int fastangle_test(void) { int ret=0; float largest_error; - + { angle theta; fastangle theta2; float error; largest_error=0.0f; - + for( theta=angle::degrees(0),theta2=fastangle::degrees(0); theta<=angle::degrees(360); @@ -68,18 +68,18 @@ int fastangle_test(void) largest_error=error; if(error < -largest_error) largest_error=-error; - + } } printf("fastangle: Largest SIN error: (+/-)%f\n",largest_error); if(largest_error>0.075)ret++; - + { angle theta; fastangle theta2; float error; largest_error=0.0f; - + for( theta=angle::degrees(0),theta2=fastangle::degrees(0); theta<=angle::degrees(360); @@ -100,7 +100,7 @@ int fastangle_test(void) largest_error=error; if(error < -largest_error) largest_error=-error; - + } } printf("fastangle: Largest COS error: (+/-)%f\n",largest_error); @@ -110,7 +110,7 @@ int fastangle_test(void) double val; float error; largest_error=0.0f; - + for( val=-1.0f; val<1.0f; @@ -131,7 +131,7 @@ int fastangle_test(void) largest_error=error; if(error < -largest_error) largest_error=-error; - + } } printf("fastangle: Largest ASIN error: (+/-)%frad\n",largest_error); @@ -142,7 +142,7 @@ int fastangle_test(void) double val; float error; largest_error=0.0f; - + for( val=-1.0f; val<1.0f; @@ -163,7 +163,7 @@ int fastangle_test(void) largest_error=error; if(error < -largest_error) largest_error=-error; - + } } printf("fastangle: Largest ACOS error: (+/-)%frad\n",largest_error); @@ -175,7 +175,7 @@ int fastangle_test(void) fastangle theta2; float error; largest_error=0.0f; - + for( theta=angle::degrees(0),theta2=fastangle::degrees(0); theta @@ -298,7 +298,7 @@ void angle_sin_speed_test(void) { Angle a,b,c,d; float tmp,tmp2; - + for(tmp=-1.0;tmp<1.0;tmp+=0.000002) { a=(typename Angle::sin)(tmp); @@ -308,7 +308,7 @@ void angle_sin_speed_test(void) tmp2=((typename Angle::sin)(a)).get(); tmp2=((typename Angle::sin)(b)).get(); tmp2=((typename Angle::sin)(c)).get(); - tmp2=((typename Angle::sin)(d)).get(); + tmp2=((typename Angle::sin)(d)).get(); } } template @@ -316,7 +316,7 @@ void angle_tan_speed_test(void) { Angle a,b,c,d; float tmp,tmp2; - + for(tmp=-1.0;tmp<1.0;tmp+=0.000002) { a=(typename Angle::tan)(tmp); @@ -326,7 +326,7 @@ void angle_tan_speed_test(void) tmp2=((typename Angle::tan)(a)).get(); tmp2=((typename Angle::tan)(b)).get(); tmp2=((typename Angle::tan)(c)).get(); - tmp2=((typename Angle::tan)(d)).get(); + tmp2=((typename Angle::tan)(d)).get(); } } template @@ -334,7 +334,7 @@ void angle_atan2_speed_test(void) { Angle a,b,c; float x,y; - + for(y=-10.0;y<10.0;y+=0.05) for(x=-10.0;x<10.0;x+=0.05) { @@ -365,25 +365,25 @@ int fastangle_speed_test(void) fastangle_atan2_time, angle_sin_time, fastangle_sin_time ; - + etl::clock MyTimer; - + MyTimer.reset(); angle_cos_speed_test(); angle_cos_time=MyTimer(); printf("angle: Cosine test: %f seconds\n",angle_cos_time); - + MyTimer.reset(); angle_cos_speed_test(); fastangle_cos_time=MyTimer(); printf("fastangle: Cosine test: %f seconds\n",fastangle_cos_time); printf("fastangle is %.02f%% faster\n",(angle_cos_time/fastangle_cos_time)*100.0-100.0); - + MyTimer.reset(); angle_sin_speed_test(); angle_sin_time=MyTimer(); printf("angle: Sine test: %f seconds\n",angle_sin_time); - + MyTimer.reset(); angle_sin_speed_test(); fastangle_sin_time=MyTimer(); @@ -394,7 +394,7 @@ int fastangle_speed_test(void) angle_tan_speed_test(); angle_tan_time=MyTimer(); printf("angle: Tangent test: %f seconds\n",angle_tan_time); - + MyTimer.reset(); angle_tan_speed_test(); fastangle_tan_time=MyTimer(); @@ -405,13 +405,13 @@ int fastangle_speed_test(void) angle_atan2_speed_test(); angle_atan2_time=MyTimer(); printf("angle: arcTangent2 test: %f seconds\n",angle_atan2_time); - + MyTimer.reset(); angle_atan2_speed_test(); fastangle_atan2_time=MyTimer(); printf("fastangle: arcTangent2 test: %f seconds\n",fastangle_atan2_time); - printf("fastangle is %.02f%% faster\n",(angle_atan2_time/fastangle_atan2_time)*100.0-100.0); - + printf("fastangle is %.02f%% faster\n",(angle_atan2_time/fastangle_atan2_time)*100.0-100.0); + return ret; } @@ -419,14 +419,14 @@ int angle_test() { int ret=0; float dist; - + dist=angle::deg(angle::deg(330).dist(angle::deg(30))).get(); printf("angle: angular difference between 330deg and 30deg is %0.1fdeg\n",dist); if(floor(dist+0.5)!=-60) { printf("angle: error: should be -60deg!\n"); ret++; - } + } dist=angle::deg(angle::deg(30).dist(angle::deg(330))).get(); printf("angle: angular difference between 30deg and 330deg is %0.1fdeg\n",dist); @@ -434,7 +434,7 @@ int angle_test() { printf("angle: error: should be 60deg!\n"); ret++; - } + } dist=angle::deg(angle::deg(30).dist(angle::deg(-30))).get(); printf("angle: angular difference between 30deg and -30deg is %0.1fdeg\n",dist); @@ -442,7 +442,7 @@ int angle_test() { printf("angle: error: should be 60deg!\n"); ret++; - } + } dist=angle::deg(angle::deg(-30).dist(angle::deg(30))).get(); printf("angle: angular difference between -30deg and 30deg is %0.1fdeg\n",dist); @@ -450,7 +450,7 @@ int angle_test() { printf("angle: error: should be -60deg!\n"); ret++; - } + } dist=angle::deg(angle::deg(20).dist(angle::deg(195))).get(); printf("angle: angular difference between 20deg and 195deg is %0.1fdeg\n",dist); @@ -458,7 +458,7 @@ int angle_test() { printf("angle: error: should be -175deg!\n"); ret++; - } + } dist=angle::deg(angle::deg(20).dist(angle::deg(205))).get(); printf("angle: angular difference between 20deg and 205deg is %0.1fdeg\n",dist); @@ -466,7 +466,7 @@ int angle_test() { printf("angle: error: should be 175deg!\n"); ret++; - } + } int i; @@ -477,8 +477,8 @@ int angle_test() { printf("angle: error: Badness at %d!\n",i); ret++; - } - + } + } for(i=-1000;i<1000;i++) @@ -488,8 +488,8 @@ int angle_test() { printf("angle: error: Badness at %d!\n",i); ret++; - } - + } + } @@ -500,14 +500,14 @@ int angle_test() angle b(angle::deg(200)); affine_combo combo; - + hermite hermie(a,b,b.dist(a),b.dist(a)); - + for(f=0;f<1.001;f+=0.1) { printf("@%f--affine_combo: %f hermie: %f\n",angle::deg(f).get(),angle::deg(combo(a,b,f)).get(),angle::deg(hermie(f)).get()); } - + } return ret; @@ -518,10 +518,10 @@ int angle_test() int main() { int error=0; - + error+=fastangle_test(); error+=fastangle_speed_test(); error+=angle_test(); - + return error; } diff --git a/ETL/trunk/test/clock.cpp b/ETL/trunk/test/clock.cpp index 9ca841c..8b96422 100644 --- a/ETL/trunk/test/clock.cpp +++ b/ETL/trunk/test/clock.cpp @@ -39,10 +39,10 @@ int basic_test(void) fprintf(stderr,"default etl::clock precision: %0.8f\n",etl::clock::precision()); fprintf(stderr,"realtime etl::clock precision: %0.8f\n",etl::clock_realtime::precision()); fprintf(stderr,"proctime etl::clock precision: %0.8f\n",etl::clock_proctime::precision()); - + etl::clock_realtime timer; etl::clock::value_type amount,total; - + for(amount=3.0;amount>=0.00015;amount/=2.0) { if(amount*1000000.0<1000.0f) @@ -56,12 +56,12 @@ int basic_test(void) etl::clock::sleep(amount); total=timer(); if((total-amount)*1000000.0<1000.0f) - fprintf(stderr," ** I waited %f seconds, error of %f microseconds\n",total,(total-amount)*1000000); + fprintf(stderr," ** I waited %f seconds, error of %f microseconds\n",total,(total-amount)*1000000); else if((total-amount)*1000.0<400.0f) - fprintf(stderr," ** I waited %f seconds, error of %f milliseconds\n",total,(total-amount)*1000); + fprintf(stderr," ** I waited %f seconds, error of %f milliseconds\n",total,(total-amount)*1000); else - fprintf(stderr," ** I waited %f seconds, error of %f seconds\n",total,total-amount); - + fprintf(stderr," ** I waited %f seconds, error of %f seconds\n",total,total-amount); + } return ret; } @@ -71,9 +71,9 @@ int basic_test(void) int main() { int error=0; - + error+=basic_test(); - + return error; } diff --git a/ETL/trunk/test/fixed.cpp b/ETL/trunk/test/fixed.cpp index 030b5c7..4278609 100644 --- a/ETL/trunk/test/fixed.cpp +++ b/ETL/trunk/test/fixed.cpp @@ -89,8 +89,8 @@ struct speed_test a-=a; } - - + + return MyTimer(); } @@ -105,7 +105,7 @@ struct speed_test etl::clock MyTimer; MyTimer.reset(); for(i=0;i0.0005) { fprintf(stderr,"fixed: Failed test on line %d in "__FILE__".\n",__LINE__); @@ -230,23 +230,23 @@ int basic_test(void) fprintf(stderr,"fixed: Failed test on line %d in "__FILE__".\n",__LINE__); ret++; } - + return ret; } int char_test(void) { int ret=0; - + fixed_base fix; double flt; - + if(sizeof(fix)!=sizeof(unsigned char)) { ret++; fprintf(stderr,"fixed: Size of fixed_base is wrong!\n"); } - + flt=1.0; fix=1.0; fprintf(stderr,"fixed: value=%f, data=%d, shouldbe=%f, error=%f\n",(float)fix,fix.data(),flt,(float)fix-flt); @@ -258,15 +258,15 @@ int char_test(void) flt*=0.7; fix*=0.7; fprintf(stderr,"fixed: value=%f, data=%d, shouldbe=%f, error=%f\n",(float)fix,fix.data(),flt,(float)fix-flt); - + flt*=0.7; fix*=0.7; fprintf(stderr,"fixed: value=%f, data=%d, shouldbe=%f, error=%f\n",(float)fix,fix.data(),flt,(float)fix-flt); - + flt*=0.7; fix*=0.7; fprintf(stderr,"fixed: value=%f, data=%d, shouldbe=%f, error=%f\n",(float)fix,fix.data(),flt,(float)fix-flt); - + flt*=0.7; fix*=0.7; fprintf(stderr,"fixed: value=%f, data=%d, shouldbe=%f, error=%f\n",(float)fix,fix.data(),flt,(float)fix-flt); @@ -283,7 +283,7 @@ int char_test(void) fix*=2; fprintf(stderr,"fixed: value=%f, data=%d, shouldbe=%f, error=%f\n",(float)fix,fix.data(),flt,(float)fix-flt); - + return ret; } @@ -292,27 +292,27 @@ int char_test(void) int main() { int error=0; - + error+=basic_test(); error+=char_test(); - + speed_test float_test; speed_test int_test; speed_test fixed_test; - + { double flt,fix,inte; - fprintf(stderr,"Addition/subtraction test..."); + fprintf(stderr,"Addition/subtraction test..."); - fprintf(stderr,"calculating float..."); + fprintf(stderr,"calculating float..."); flt=float_test.add_sub_test(); fprintf(stderr,"float time: %fsec\n",flt); - fprintf(stderr,"calculating fixed..."); + fprintf(stderr,"calculating fixed..."); fix=fixed_test.add_sub_test(); fprintf(stderr,"fixed time: %fsec\n",fix); - fprintf(stderr,"calculating integer..."); + fprintf(stderr,"calculating integer..."); inte=int_test.add_sub_test(); fprintf(stderr,"integer time: %fsec\n",inte); @@ -320,46 +320,46 @@ int main() fprintf(stderr,"Fixed point wins by %f seconds! (%f%% faster)\n",flt-fix,flt/fix*100.0f-100.0f); else fprintf(stderr,"Floating point wins by %f seconds! (%f%% faster)\n",fix-flt,fix/flt*100.0f-100.0f); - + } - + { double flt,fix,inte; - fprintf(stderr,"Product test..."); - fprintf(stderr,"calculating float..."); + fprintf(stderr,"Product test..."); + fprintf(stderr,"calculating float..."); flt=float_test.mul_test(); fprintf(stderr,"float time: %fsec\n",flt); - fprintf(stderr,"calculating fixed..."); + fprintf(stderr,"calculating fixed..."); fix=fixed_test.mul_test(); fprintf(stderr,"fixed time: %fsec\n",fix); - fprintf(stderr,"calculating integer..."); + fprintf(stderr,"calculating integer..."); inte=int_test.mul_test(); fprintf(stderr,"integer time: %fsec\n",inte); if(flt>fix) fprintf(stderr,"Fixed point wins by %f seconds! (%f%% faster)\n",flt-fix,flt/fix*100.0f-100.0f); else fprintf(stderr,"Floating point wins by %f seconds! (%f%% faster)\n",fix-flt,fix/flt*100.0f-100.0f); - + } { double flt,fix,inte; - fprintf(stderr,"Division test..."); - fprintf(stderr,"calculating float..."); + fprintf(stderr,"Division test..."); + fprintf(stderr,"calculating float..."); flt=float_test.div_test(); fprintf(stderr,"float time: %fsec\n",flt); - fprintf(stderr,"calculating fixed..."); + fprintf(stderr,"calculating fixed..."); fix=fixed_test.div_test(); fprintf(stderr,"fixed time: %fsec\n",fix); - fprintf(stderr,"calculating integer..."); + fprintf(stderr,"calculating integer..."); inte=int_test.div_test(); fprintf(stderr,"integer time: %fsec\n",inte); if(flt>fix) fprintf(stderr,"Fixed point wins by %f seconds! (%f%% faster)\n",flt-fix,flt/fix*100.0f-100.0f); else fprintf(stderr,"Floating point wins by %f seconds! (%f%% faster)\n",fix-flt,fix/flt*100.0f-100.0f); - + } - + return error; } diff --git a/ETL/trunk/test/handle.cpp b/ETL/trunk/test/handle.cpp index fd40e25..77be9f5 100644 --- a/ETL/trunk/test/handle.cpp +++ b/ETL/trunk/test/handle.cpp @@ -44,14 +44,14 @@ struct my_test_obj : public etl::rshared_object { instance_count++; } - + virtual ~my_test_obj() { if(instance_count==0) printf("Error, instance count is going past zero!\n"); instance_count--; } - + bool operator<(const my_test_obj &rhs)const { return my_id obj_handle(new my_test_obj(rand())); - if(obj_handle != obj_handle.constant()) + if(obj_handle != obj_handle.constant()) { printf("FAILED!\n"); printf(__FILE__":%d: on call to handle<>::constant().\n",__LINE__); return 1; } - + printf("PASSED\n"); return 0; @@ -136,13 +136,13 @@ int handle_general_use_test(void) { printf("handle: General-use test: "); my_test_obj::instance_count=0; - + obj_list my_list, my_other_list; int i; - + for(i=0;i my_item_list; for(i=0;i=2); } - + my_item_list.clear(); if(my_test_obj::instance_count) @@ -319,7 +319,7 @@ int rhandle_general_use_test(void) } printf("PASSED\n"); - + return 0; } @@ -328,13 +328,13 @@ int handle_inheritance_test(void) printf("handle: Inheritance test: "); my_test_obj::instance_count=0; my_other_test_obj::instance_count=0; - + other_obj_list my_other_list; int i; - + for(i=0;i obj; etl::handle other_obj; etl::loose_handle loose_obj; - + other_obj.spawn(); loose_obj=other_obj; - + obj=etl::handle::cast_dynamic(loose_obj); - + if(obj!=other_obj) { printf("FAILED!\n"); printf(__FILE__":%d: on handle assignment from loose_handle.\n",__LINE__); return 1; } - + printf("PASSED\n"); return 0; } @@ -477,6 +477,6 @@ int main() error+=handle_inheritance_test(); error+=loose_handle_test(); error+=rhandle_general_use_test(); - + return error; } diff --git a/ETL/trunk/test/hermite.cpp b/ETL/trunk/test/hermite.cpp index 26eca4e..59c5566 100644 --- a/ETL/trunk/test/hermite.cpp +++ b/ETL/trunk/test/hermite.cpp @@ -40,21 +40,21 @@ int basic_test(void) { int ret=0; float f; - + hermite Hermie; etl::clock timer; double t; - + Hermie.p1()=0; Hermie.t1()=1; Hermie.p2()=0; Hermie.t2()=1; - + Hermie.sync(); - + integral > inte(Hermie); - + fprintf(stderr,"integral of curve() on [0,1] = %f\n",inte(0,1.0)); fprintf(stderr,"integral of curve() on [-1,3] = %f\n",inte(-1.0,3.0)); Hermie.set_rs(-1.0,7.0); @@ -62,8 +62,8 @@ int basic_test(void) fprintf(stderr,"integral of curve()[%f,%f] on [-1,7] = %f\n",Hermie.get_r(),Hermie.get_s(),inte(-1.0,7.0)); fprintf(stderr,"integral of curve()[%f,%f] on [0,1] = %f\n",Hermie.get_r(),Hermie.get_s(),inte(0,1.0)); Hermie.set_rs(0.0,1.0); - - + + for(f=0.0f,timer.reset();f<1.001f;f+=0.000005f) { t+=Hermie(f)+Hermie(f+0.1f); @@ -80,7 +80,7 @@ int basic_test(void) t+=Hermie(f)+Hermie(f+0.1f); } t=timer(); - + fprintf(stderr,"time=%f milliseconds\n",t*1000); return ret; } @@ -89,21 +89,21 @@ int angle_test(void) { int ret=0; float f; - + hermite Hermie; etl::clock timer; angle tmp; double t; - + Hermie.p1()=angle::degrees(0); Hermie.t1()=angle::degrees(45); Hermie.p2()=angle::degrees(-45); Hermie.t2()=angle::degrees(180); - Hermie.sync(); - - + Hermie.sync(); + + for(f=0.0f,timer.reset();f<1.001f;f+=0.000005f) { tmp+=Hermie(f)+Hermie(f+0.1f); @@ -120,7 +120,7 @@ int angle_test(void) tmp+=Hermie(f)+Hermie(f+0.1f); } t=timer(); - + fprintf(stderr,"angle time=%f milliseconds\n",t*1000); return ret; @@ -130,20 +130,20 @@ int fixed_test(void) { int ret=0; float f; - + hermite Hermie; etl::clock timer; double t; - + Hermie.p1()=0; Hermie.t1()=1; Hermie.p2()=0; Hermie.t2()=1; - + Hermie.sync(); - - - + + + for(f=0.0f,timer.reset();f<1.001f;f+=0.005f) { t+=Hermie(f)+Hermie(f+0.1f); @@ -160,7 +160,7 @@ int fixed_test(void) t+=Hermie(f)+Hermie(f+0.1f); } t=timer(); - + fprintf(stderr,"time=%f milliseconds\n",t*1000); return ret; } @@ -170,21 +170,21 @@ int anglefixed_test(void) { int ret=0; float f; - + hermite Hermie; etl::clock timer; angle tmp; double t; - + Hermie.p1()=angle::degrees(0); Hermie.t1()=angle::degrees(45); Hermie.p2()=angle::degrees(-45); Hermie.t2()=angle::degrees(180); - Hermie.sync(); - - + Hermie.sync(); + + for(f=0.0f,timer.reset();f<1.001f;f+=0.0005f) { tmp+=Hermie(f)+Hermie(f+0.1f); @@ -201,7 +201,7 @@ int anglefixed_test(void) tmp+=Hermie(f)+Hermie(f+0.1f); } t=timer(); - + fprintf(stderr,"angle fixed time=%f milliseconds\n",t*1000); return ret; @@ -220,7 +220,7 @@ int float_intersection_test() t2=curve2.intersect(curve1); d=curve1(t1)-curve2(t2); - + fprintf(stderr,"float:Intersection difference: %f (t1=%f, t2=%f)\n",d,t1,t2); if(d>0.01) @@ -237,7 +237,7 @@ int float_intersection_test() int main() { int error=0; - + error+=basic_test(); error+=angle_test(); error+=fixed_test(); diff --git a/ETL/trunk/test/pen.cpp b/ETL/trunk/test/pen.cpp index d89af0d..8b1a555 100644 --- a/ETL/trunk/test/pen.cpp +++ b/ETL/trunk/test/pen.cpp @@ -115,7 +115,7 @@ int generic_pen_test(int w, int h) printf("FAILURE! "__FILE__"@%d: iterator_x inconsistancy\n",__LINE__); return 1; } - + printf("PASSED\n"); return 0; @@ -260,18 +260,18 @@ int box_blur_test(void) // Pen 2 will be the end pen2=pen; pen2.move(w,h); - + //temporary vbox_blur(pen,pen2,2,pen3); printf("\n VBLUR ONLY:\n"); display_pen(pen3,w,h); - + // box_blur(pen,w,h,4); hbox_blur(pen,pen2,2,pen3); - + printf("\n HBLUR ONLY:\n"); display_pen(pen3,w,h); - + pen2=pen3; pen2.move(w,h); vbox_blur(pen3,pen2,2,pen); @@ -286,7 +286,7 @@ int box_blur_test(void) printf("FAILURE! "__FILE__"@%d: blur result contained %d bad values\n",__LINE__,bad_values); return 1; } - + boxblur_float max=0; printf("CHECK BOXBLUR RESULTS %d,%d:\n",pen.diff_begin().x, pen.diff_begin().y); for(y=0;y= h) iy = h-1; - + for(int ox=-2; ox <= 2; ++ox) { int ix = x+ox; if(ix < 0) ix = 0; if(ix >= w) ix = w-1; - + if(ix-iy<=1 && iy-ix<=1 || iy==h/2 || ix==w/2) f += 2; } } - + //print out if the relative error is high /*f /= 25; float rf = pen.get_value() - f/25; @@ -326,7 +326,7 @@ int box_blur_test(void) pen.dec_x(x); } pen.dec_y(y); - + /*if(max) { for(y=0;y Rand; - + return ret; } @@ -42,7 +42,7 @@ int random_basic_test(void) int main() { int error=0; - - + + return error; } diff --git a/ETL/trunk/test/smach.cpp b/ETL/trunk/test/smach.cpp index 47915a4..007af1c 100644 --- a/ETL/trunk/test/smach.cpp +++ b/ETL/trunk/test/smach.cpp @@ -44,7 +44,7 @@ enum EventKey struct MachineContext { smach machine; - + MachineContext():machine(this) { } @@ -65,7 +65,7 @@ class DefaultStateContext public: DefaultStateContext(MachineContext *context):context(context) { printf("Enterted Default State\n"); } ~DefaultStateContext() { printf("Left Default State\n"); } - + Smach::event_result event1_handler(const Smach::event& x) { printf("DEFAULT STATE: Received Event 1\n"); @@ -80,7 +80,7 @@ public: { insert(event_def(EVENT_1,&DefaultStateContext::event1_handler)); } - + } default_state; @@ -95,7 +95,7 @@ class State1Context public: State1Context(MachineContext *context):context(context) { printf("Enterted State 1\n"); } ~State1Context() { printf("Left State 1\n"); } - + Smach::event_result event1_handler(const Smach::event& x) { printf("STATE1: Received Event 1\n"); @@ -113,7 +113,7 @@ public: insert(event_def(EVENT_1,&State1Context::event1_handler)); insert(event_def(EVENT_3,&State1Context::event3_handler)); } - + } state_1; @@ -123,7 +123,7 @@ class State2Context public: State2Context(MachineContext *context):context(context) { printf("Enterted State 2\n"); } ~State2Context() { printf("Left State 2\n"); } - + Smach::event_result event1_handler(const Smach::event& x) { printf("STATE2: Received Event 1\n"); @@ -152,14 +152,14 @@ public: insert(event_def(EVENT_2,&State2Context::event2_handler)); insert(event_def(EVENT_3,&State2Context::event3_handler)); } - + } state_2; Smach::event_result State1Context::event3_handler(const Smach::event& x) { printf("STATE1: Received Event 3, throwing state to change to...\n"); - + throw &state_2; // context->machine.enter(&state_2); // return Smach::RESULT_ACCEPT; @@ -173,7 +173,7 @@ int main() { int error=0; - MachineContext context; + MachineContext context; try { Smach& state_machine(context.machine); @@ -181,7 +181,7 @@ int main() state_machine.set_default_state(&default_state); state_machine.enter(&state_1); - + state_machine.process_event(Event1()); state_machine.process_event(EVENT_1); state_machine.process_event(EVENT_2); @@ -202,6 +202,6 @@ int main() printf("Uncaught exception\n"); error++; } - + return error; } diff --git a/ETL/trunk/test/smart_ptr.cpp b/ETL/trunk/test/smart_ptr.cpp index e0fc8ba..c686859 100644 --- a/ETL/trunk/test/smart_ptr.cpp +++ b/ETL/trunk/test/smart_ptr.cpp @@ -314,6 +314,6 @@ int main() error+=smart_ptr_general_use_test(); error+=smart_ptr_inheritance_test(); error+=loose_smart_ptr_test(); - + return error; } diff --git a/ETL/trunk/test/spline.cpp b/ETL/trunk/test/spline.cpp index 872d52f..f32ab15 100644 --- a/ETL/trunk/test/spline.cpp +++ b/ETL/trunk/test/spline.cpp @@ -40,31 +40,31 @@ int bspline_basic_test(void) { int ret=0; float f; - + bspline BSpline; etl::clock timer; double t; - + *BSpline.cpoints().insert(BSpline.cpoints().end())=0; *BSpline.cpoints().insert(BSpline.cpoints().end())=-1; *BSpline.cpoints().insert(BSpline.cpoints().end())=0; *BSpline.cpoints().insert(BSpline.cpoints().end())=1; *BSpline.cpoints().insert(BSpline.cpoints().end())=0; - + BSpline.set_m(4); BSpline.reset_knots(); - + integral > inte(BSpline); - + /* for(f=0.0;f<1.001;f+=0.05) fprintf(stderr,"BSpline(%f)= %f\n",f,BSpline(f)); */ - + fprintf(stderr,"integral of BSpline() on [0,1] = %f\n",inte(0,1.0)); - - + + for(f=0.0f,timer.reset();f<1.001f;f+=0.000005f) { t+=BSpline(f)+BSpline(f+0.1f); @@ -81,7 +81,7 @@ int bspline_basic_test(void) t+=BSpline(f)+BSpline(f+0.1f); } t=timer(); - + fprintf(stderr,"BSpline time=%f milliseconds\n",t*1000); return ret; } @@ -91,9 +91,9 @@ int bspline_basic_test(void) int main() { int error=0; - + error+=bspline_basic_test(); - + return error; } diff --git a/ETL/trunk/test/stringf.cpp b/ETL/trunk/test/stringf.cpp index 4312016..9df482b 100644 --- a/ETL/trunk/test/stringf.cpp +++ b/ETL/trunk/test/stringf.cpp @@ -40,13 +40,13 @@ int basic_test(void) int ret=0; char mystring[80]="My formatted string!"; string myotherstring="my other string!"; - + cout<>%s<<.",mystring)< pen, int w, int h) int basic_test() { printf("Surface:basic_test(): Running...\n"); - + int ret=0; surface my_surface(100,100); @@ -132,14 +132,14 @@ int linear_sample_test() int ret=0; surface my_surface(16,16); - + my_surface.fill(0.0f); - + make_pattern(my_surface.begin(),my_surface.get_w(),my_surface.get_h()); int extra(5); surface dest(18+extra*2,18+extra*2); - + int x,y; for(x=-extra;x my_surface(16,16); - + my_surface.fill(0.0f); - + make_pattern(my_surface.begin(),my_surface.get_w(),my_surface.get_h()); { surface dest(24,24); - + int x,y; for(x=0;x dest(16,16); - + int x,y; for(x=0;x class etl::value_store_type { - typedef stupidv value_type; + typedef stupidv value_type; }; int main() -{ +{ try { value v(10.0); //construction value v2; //default construct... - + //get type... printf("type of 10.0: %s\n", v.type().name()); - + v2 = 1; //assignment printf("type of 1: %s\n", v2.type().name()); - + //extract int test - + int *pi = value_cast(&v2); printf("v2 is an int(%p)\n", pi); printf(" %d\n", value_cast(v2)); - + printf(" const version: %d\n", value_cast(value(5))); - + v = 'c'; //assignment again... printf("type of c: %s\n", v.type().name()); - + v2 = v; //value assignment printf("type of v2 , v: %s , %s\n", v2.type().name(), v.type().name()); - + //random type test v = stupidv(0,1); printf("type of vec: %s\n", v.type().name()); - + //type cast with binary change test value_cast(&v)->print(); value_cast(stupidp(5,10)).print(); //copy test - + printf("type of v: %s\n", v.type().name()); - printf("type of v2: %s\n", v2.type().name()); + printf("type of v2: %s\n", v2.type().name()); v.swap(v2); printf("type of v: %s\n", v.type().name()); printf("type of v2: %s\n", v2.type().name()); - + // test the exception throwing... value_cast(stupidp(6,66)); - - }catch(const etl::bad_value_cast &e) + + }catch(const etl::bad_value_cast &e) { printf(" Exploded: %s\n",e.what()); }catch(...) { printf(" Exploded\n"); } - + return 0; } -- 2.7.4