|
#if !defined(TransferStatus_H)
#define TransferStatus_H
/////////////////////////////////////////////////////////////////////////////////////
// TransferStatus
//
// Purpose: used to keep track of a transfer
class TransferStatus
{
long _blockSize; // no to send at one time
long _noToSend; // number of bytes left to send
long _noSent; // number of bytes sent in response
public:
TransferStatus () :
_blockSize(0),
_noToSend(0),
_noSent(0)
{}
// setup status
void reset ()
{
_noToSend = 0;
_noSent = 0;
}
void begin ( long noToSend )
{
_blockSize = noToSend;
_noToSend = noToSend;
_noSent = 0;
}
void setSizeToSend ( long noToSend )
{
begin(noToSend);
}
// get/set block size
long getBlockSize ()
{
return _blockSize;
}
void setBlockSize ( long set )
{
_blockSize = set;
}
// status methods
long size()
{
return _noToSend;
}
long getNoToSend ()
{
return _noToSend;
}
long getNoSent ()
{
return _noSent;
}
void incNoSent ( long inc )
{
// if not valid stop
if ( inc <= 0 )
return;
// update no sent
_noSent += inc;
if ( _noSent > size() )
_noSent = size();
}
void decNoToSend ( long dec )
{
// if not valid stop
if ( dec <= 0 )
return;
// update no to send
_noToSend -= dec;
if ( _noToSend < 0 )
_noToSend = 0;
}
bool finished ()
{
// if all sent show it
if ( _noSent == _noToSend )
return true;
else
return false;
}
};
#endif
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.