Tolto close() a TDistrib

git-svn-id: svn://10.65.10.50/trunk@61 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
villa 1994-08-25 09:35:18 +00:00
parent 8b6051e689
commit 3eb401c338
2 changed files with 57 additions and 58 deletions

View File

@ -778,7 +778,7 @@ void TDistrib ::add (real slice)
_slices.add (slice); _slices.add (slice);
} }
real TDistrib ::get () real TDistrib::get ()
{ {
_ready = TRUE; _ready = TRUE;
CHECK (_current < _slices.items (), "TDistrib: too many gets"); CHECK (_current < _slices.items (), "TDistrib: too many gets");
@ -793,7 +793,7 @@ real TDistrib ::get ()
return r; return r;
} }
void TDistrib ::init (const real & r) void TDistrib::init (const real & r)
{ {
_current = 0; _prog = 0; _current = 0; _prog = 0;
_tot = r; _ready = FALSE; _tot = r; _ready = FALSE;

View File

@ -24,50 +24,50 @@
// @C // @C
class real : public TObject class real : public TObject
{ {
// @DPRIV // @DPRIV
DEC _dec; DEC _dec;
// @END // @END
protected: protected:
virtual TObject* dup() const; virtual TObject* dup() const;
char* literals() const; char* literals() const;
char* points(int decimals = 0) const; char* points(int decimals = 0) const;
public: public:
static char* eng2ita(char* s); static char* eng2ita(char* s);
static char* ita2eng(const char* s); static char* ita2eng(const char* s);
static bool is_real(const char* n); static bool is_real(const char* n);
// @FPUB // @FPUB
DEC* ptr() const { return (DEC*)&_dec; } DEC* ptr() const { return (DEC*)&_dec; }
char* string(int len = 0, int dec = UNDEFINED, char pad = ' ') const; char* string(int len = 0, int dec = UNDEFINED, char pad = ' ') const;
char* stringa(int len = 0, int dec = UNDEFINED, char pad = ' ') const; char* stringa(int len = 0, int dec = UNDEFINED, char pad = ' ') const;
char* string(const char* picture) const; char* string(const char* picture) const;
int precision() ; int precision() ;
bool is_zero() const; bool is_zero() const;
int sign() const; int sign() const;
int integer() const; // operator int is too dangerous int integer() const; // operator int is too dangerous
real& round(int prec = 0) ; real& round(int prec = 0) ;
real& trunc(int prec = 0) ; real& trunc(int prec = 0) ;
real& ceil(int prec = 0); real& ceil(int prec = 0);
real& operator =(double a); real& operator =(double a);
real& operator =(const real& b); real& operator =(const real& b);
real& operator +=(const real& b); real& operator +=(const real& b);
real& operator +=(double a); real& operator +=(double a);
real& operator -=(const real& b); real& operator -=(const real& b);
real& operator *=(const real& b); real& operator *=(const real& b);
real& operator /=(const real& b); real& operator /=(const real& b);
bool operator !() const { return is_zero(); } bool operator !() const { return is_zero(); }
real operator -() const; real operator -() const;
real(); real();
real(const real& b); real(const real& b);
real(double a); real(double a);
real(const char* s); real(const char* s);
virtual ~real() {} virtual ~real() {}
}; };
/////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////
@ -129,31 +129,30 @@ extern const real ZERO;
class TDistrib : public TObject class TDistrib : public TObject
{ {
real _tot; real _tot;
real _prog; real _prog;
bool _ready; bool _ready;
TArray _slices; TArray _slices;
int _current; int _current;
int _decs; int _decs;
public: public:
void add(real slice); void add(real slice);
real get(); real get();
void close();
void init(const real& r); void init(const real& r);
void operator =(const real& r) { init(r); } void operator =(const real& r) { init(r); }
const real& last_slice() const const real& last_slice() const
{ {
CHECK(_current,"TDistrib: slices not set"); CHECK(_current,"TDistrib: slices not set");
return (const real&)_slices[_current-1]; return (const real&)_slices[_current-1];
} }
TDistrib(const real& r, int round = UNDEFINED) : TDistrib(const real& r, int round = UNDEFINED) :
_prog(0.0), _tot(r), _ready(FALSE), _prog(0.0), _tot(r), _ready(FALSE),
_current(0), _decs(round), _slices(4) _current(0), _decs(round), _slices(4)
{} {}
virtual ~TDistrib() {} virtual ~TDistrib() {}
}; };