// PropStat.cpp #include "PropStat.h" #include #include using trf::PropStat; const double DEFAULT_PATH_DISTANCE = 1.e30; //********************************************************************** // constructor PropStat::PropStat() : _success(false), _s(0.0) { } //********************************************************************** // set the propagation distance void PropStat::set_path_distance(double s) { _success = true; _s = s; } //********************************************************************** // set successful propagation forward void PropStat::set_forward() { _success = true; _s = DEFAULT_PATH_DISTANCE; } //********************************************************************** // set successful propagation backward void PropStat::set_backward() { _success = true; _s = -DEFAULT_PATH_DISTANCE; } //********************************************************************** // set successful propagation to the same position void PropStat::set_same() { _success = true; _s = 0.0; } //********************************************************************** // was propagation successful? bool PropStat::success() const { return _success; } //********************************************************************** // did track move forward? bool PropStat::forward() const { return _success && _s>0.0; } //********************************************************************** // did track move backward? bool PropStat::backward() const { return _success && _s<0.0; } //********************************************************************** // did track propagate succesfully without moving? bool PropStat::same() const { return _success && _s==0.0; } //********************************************************************** // dhow far did we go? double PropStat::path_distance() const { assert( _success ); return _s; } //********************************************************************** std::ostream& operator<<(std::ostream& stream, const PropStat& pst ) { if ( pst.forward() ) stream << "successful forward propagation"; if ( pst.backward() ) stream << "successful backward propagation"; if ( pst.same() ) stream << "successful propagation with no movement"; if ( ! pst.success() ) stream << "propagation failed"; if ( pst.success() ) stream << " " << pst.path_distance(); return stream; } //**********************************************************************