Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

lfc::HiResTimeSpan Class Reference

represents a hires period of time, using milliseconds as basic representation. More...

Inheritance diagram for lfc::HiResTimeSpan::

lfc::Object lfc::_Serializable lfc::_Formatable lfc::_Scanable List of all members.

Public Methods

 HiResTimeSpan () throw ()
 HiResTimeSpan (const HiResTimeSpan &ts) throw ()
 HiResTimeSpan (long msecs)
 creates an object with the period specified in milliseconds. More...

 HiResTimeSpan (long msecs, long seconds, long minutes=0, long hours=0, long days=0)
virtual ~HiResTimeSpan () throw ()
virtual long milliseconds () const throw ()
 
Returns:
the whole period in milliseconds.
More...


virtual long seconds () const throw ()
 
Returns:
the whole period in seconds.
More...


virtual long minutes () const throw ()
 
Returns:
the whole period in minutes.
More...


virtual long hours () const throw ()
 
Returns:
the whole period in hours.
More...


virtual long days () const throw ()
 
Returns:
the whole period in days.
More...


virtual bool operator== (const HiResTimeSpan &ts) const throw ()
virtual bool operator< (const HiResTimeSpan &ts) const throw ()
virtual const HiResTimeSpan & operator= (const HiResTimeSpan &ts) throw ()
virtual const HiResTimeSpan operator+ (const HiResTimeSpan &ts) const
virtual const HiResTimeSpan operator- (const HiResTimeSpan &ts) const
virtual void writeObject (BinaryOutput &stream) const
 platform independent serialization. More...

virtual void readObject (BinaryInput &stream)
 platform independent deserialization. More...

virtual void formatObject (TextOutput &stream, string format="") const
 formatting based on a certain format. More...

virtual void scanObject (TextInput &stream, string format="")
 scanning based on a certain format. More...


Static Public Methods

const HiResTimeSpan currentProcessTime ()

Protected Attributes

long m_span

Detailed Description

represents a hires period of time, using milliseconds as basic representation.

    See Chronometer example for a code sample.

Todo:
make this thread safe

See also:
TimeSpan, Chronometer


Constructor & Destructor Documentation

lfc::HiResTimeSpan::HiResTimeSpan   throw () [inline]
 

lfc::HiResTimeSpan::HiResTimeSpan const HiResTimeSpan &    ts throw () [inline]
 

lfc::HiResTimeSpan::HiResTimeSpan long    msecs [inline]
 

creates an object with the period specified in milliseconds.

lfc::HiResTimeSpan::HiResTimeSpan long    msecs,
long    seconds,
long    minutes = 0,
long    hours = 0,
long    days = 0
 

creates an object specifing how many days, hours, minutes, seconds and milliseconds the time span takes, so:

Parameters:
days  must be in (0..24)
hours  must be in (0..23)
minutes  must be in (0..59)
seconds  must be in (0..59)
milliseconds  must be in (0..999)
Not respecting this intervals will result in throwing a HiResTimeSpanException.

virtual lfc::HiResTimeSpan::~HiResTimeSpan   throw () [inline, virtual]
 


Member Function Documentation

virtual long lfc::HiResTimeSpan::milliseconds   const throw () [inline, virtual]
 

Returns:
the whole period in milliseconds.

virtual long lfc::HiResTimeSpan::seconds   const throw () [inline, virtual]
 

Returns:
the whole period in seconds.

virtual long lfc::HiResTimeSpan::minutes   const throw () [inline, virtual]
 

Returns:
the whole period in minutes.

virtual long lfc::HiResTimeSpan::hours   const throw () [inline, virtual]
 

Returns:
the whole period in hours.

virtual long lfc::HiResTimeSpan::days   const throw () [inline, virtual]
 

Returns:
the whole period in days.

virtual bool lfc::HiResTimeSpan::operator== const HiResTimeSpan &    ts const throw () [inline, virtual]
 

virtual bool lfc::HiResTimeSpan::operator< const HiResTimeSpan &    ts const throw () [inline, virtual]
 

virtual const HiResTimeSpan& lfc::HiResTimeSpan::operator= const HiResTimeSpan &    ts throw () [inline, virtual]
 

virtual const HiResTimeSpan lfc::HiResTimeSpan::operator+ const HiResTimeSpan &    ts const [inline, virtual]
 

virtual const HiResTimeSpan lfc::HiResTimeSpan::operator- const HiResTimeSpan &    ts const [inline, virtual]
 

void lfc::HiResTimeSpan::writeObject BinaryOutput   stream const [virtual]
 

platform independent serialization.

Reimplemented from lfc::_Serializable.

void lfc::HiResTimeSpan::readObject BinaryInput   stream [virtual]
 

platform independent deserialization.

Reimplemented from lfc::_Serializable.

void lfc::HiResTimeSpan::formatObject TextOutput   stream,
string    format = ""
const [virtual]
 

formatting based on a certain format.

The format must be as follows:

    Symbol      Meaning              Presentation       Example
    ------      -------              ------------       -------
    D           in days              Number             2.5
    d           floor(days)          Number             2
    H           in hours             Number             15.25
    h           floor(hours)         Number             15
    M           in minutes           Number             37.9
    m           floor(minutes)       Number             37
    S           in seconds           Number             125.75
    s           floor(seconds)       Number             125
    ms          in milliseconds      Number             1038
    -d          days(0..24)          Number             2
    -h          hours(0..23)         Number             12
    -m          minutes(0..59)       Number             50
    -s          seconds(0..59)       Number             43
    -ms         msecs(0..999)        Number             532
    '           escape for text      Text               'milliseconds'
    ''          single quote         Text               '
    

Any characters in the pattern that are not in this formatting list will be treated as quoted text. For instance, characters like ':', ',', '.', ' ', '#' and '@' will appear in the resulting time text even they are not embraced within single quotes.

Examples:

    Format Pattern                                 Result
    --------------                                 ------
    "S 'secs; ' ms 'msecs'"                  ->>   "12.5 secs; 12500 msecs"
    "-m 'mins', -s 'secs' and -ms 'msecs'"   ->>   "2 mins, 12 secs and 580 msecs"
    

Reimplemented from lfc::_Formatable.

void lfc::HiResTimeSpan::scanObject TextInput   stream,
string    format = ""
[virtual]
 

scanning based on a certain format.

The format used for scanning is identical to that used for formatting and if the format or the data coming from the stream are invalid, an HiResTimeSpanException will be thrown.
However, take under consideration the following rules/observations:

  • the format's symbols are split in two logical categories:
    • Category 1: D, d, H, h, M, m, S, s, ms
    • Category 2: -d, -h, -m, -s, -ms
  • the two categories are mutually exclusive;
  • the symbols in the 1st category are also mutually exclusive;
  • the symbols in the 2nd category must be used only once, so they should not be repetead; if any of the 2nd category symbols are missing, their contribution to the final result will be 0;
  • any of the uppercase symbols D, H, M and S will be rounded down if a fully conversion to milliseconds is not possible, so be careful.

Reimplemented from lfc::_Scanable.

const HiResTimeSpan lfc::HiResTimeSpan::currentProcessTime   [inline, static]
 

Returns:
how many milliseconds have passed since the beggining of the current process


Member Data Documentation

long lfc::HiResTimeSpan::m_span [protected]
 


The documentation for this class was generated from the following files:
Generated on Fri Jan 25 03:13:09 2002 for LFC2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001