Ceylan::Timestamp Class Reference

The purpose of this class is to record specific times, in order to be able to date events and compare their order, at least on a local computer. More...

#include <CeylanTimestamp.h>

Inheritance diagram for Ceylan::Timestamp:

Inheritance graph
[legend]
Collaboration diagram for Ceylan::Timestamp:

Collaboration graph
[legend]

List of all members.

Public Types

typedef Ceylan::Uint16 Year
 Years are coded as pure numerical value, starting from 0 AC.
typedef Ceylan::Uint8 MonthOfTheYear
 Months of the year range from 1 to 12, from January to December.
typedef Ceylan::Uint8 DayOfTheMonth
 Days of the month range from 1 to 31.
typedef Ceylan::Uint8 HourOfTheDay
 Hours of the day range from 0 to 23.
typedef Ceylan::Uint8 MinuteOfTheHour
 Minutes of the hour range from 0 to 59.
typedef Ceylan::Uint8 SecondOfTheMinute
 Seconds of the minute range from 0 to 61, to allow for leap seconds.
enum  TextOutputFormat { rawText, html }
 Defines what text output formats for TextDisplayable instances are available. More...

Public Member Functions

 Timestamp ()
 Creates the timestamp corresponding to the moment when it is called.
virtual ~Timestamp () throw ()
 Basic virtual destructor.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns a user-friendly description of the state of this object.
bool operator< (Timestamp &second)
 Tells whether this Timestamp's recorded time is strictly inferior to the one of second Timestamp.

Static Public Member Functions

static std::string DescribeDuration (Ceylan::System::Second duration)
 Returns a string describing litterally the specied duration.
static const std::string ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high)
 Returns a user-friendly description of this list of pointers to text displayable instances.
static TextOutputFormat GetOutputFormat ()
 Returns the current overall text format to be used by TextDisplayable instances.
static void SetOutputFormat (TextOutputFormat newOutputFormat)
 Sets the current overall text format to be used by TextDisplayable instances.

Protected Attributes

Year _year
 Timestamp's year.
MonthOfTheYear _month
 Timestamp's month.
DayOfTheMonth _day
 Timestamp's day.
HourOfTheDay _hour
 Timestamp's hour.
MinuteOfTheHour _minute
 Timestamp's minute.
SecondOfTheMinute _second
 Timestamp's second.

Static Protected Attributes

static TextOutputFormat _OutputFormat = rawText
 The text format to be used currently by TextDisplayable instances.

Private Member Functions

 Timestamp (const Timestamp &source)
 Copy constructor made private to ensure that it will never be called.
Timestampoperator= (const Timestamp &source)
 Assignment operator made private to ensure that it will never be called.


Detailed Description

The purpose of this class is to record specific times, in order to be able to date events and compare their order, at least on a local computer.

Note:
On a distributed system, one should check that clocks are, at least roughly (ex: thanks to NTP), in synch or, preferably, rely on an algorithm that can recreate an appropriate abstract overall time.

To understand numerical conventions behind the time units, one can have a look to UNIX 'ctime' manual, for example.

The granularity (accuracy) of this timestamp implementation is only one second, hence two timestamps may be exactly equal whereas they were not created at the same time.

See also:
CeylanSystem.h for precise time measurement and fine-grained waiting.

Definition at line 65 of file CeylanTimestamp.h.


Member Typedef Documentation

Days of the month range from 1 to 31.

Definition at line 138 of file CeylanTimestamp.h.

Hours of the day range from 0 to 23.

Definition at line 142 of file CeylanTimestamp.h.

Minutes of the hour range from 0 to 59.

Definition at line 146 of file CeylanTimestamp.h.

Months of the year range from 1 to 12, from January to December.

Definition at line 134 of file CeylanTimestamp.h.

Seconds of the minute range from 0 to 61, to allow for leap seconds.

Definition at line 154 of file CeylanTimestamp.h.

Years are coded as pure numerical value, starting from 0 AC.

Definition at line 130 of file CeylanTimestamp.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

Timestamp::Timestamp (  ) 

Creates the timestamp corresponding to the moment when it is called.

Exceptions:
UtilsException if the time could not be obtained.

Definition at line 59 of file CeylanTimestamp.cc.

References _day, _hour, _minute, _month, _second, _year, Ceylan::System::explainError(), and Ceylan::System::getTime().

Timestamp::~Timestamp (  )  throw () [virtual]

Basic virtual destructor.

Definition at line 163 of file CeylanTimestamp.cc.

Ceylan::Timestamp::Timestamp ( const Timestamp source  )  [private]

Copy constructor made private to ensure that it will never be called.

The compiler should complain whenever this undefined constructor is called, implicitly or not.


Member Function Documentation

static std::string Ceylan::Timestamp::DescribeDuration ( Ceylan::System::Second  duration  )  [static]

Returns a string describing litterally the specied duration.

Parameters:
duration the duration, in seconds, to describe.
Returns:
the textual description of the duration.
Note:
For this evaluation, years all have exactly 365 days.

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]

bool Timestamp::operator< ( Timestamp second  ) 

Tells whether this Timestamp's recorded time is strictly inferior to the one of second Timestamp.

Definition at line 292 of file CeylanTimestamp.cc.

References _day, _hour, _minute, _month, _second, _year, generalUtils::false, and generalUtils::true.

Timestamp& Ceylan::Timestamp::operator= ( const Timestamp source  )  [private]

Assignment operator made private to ensure that it will never be called.

The compiler should complain whenever this undefined operator is called, implicitly or not.

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

const std::string TextDisplayable::ToString ( std::list< TextDisplayable * >  displayables,
Ceylan::VerbosityLevels  level = Ceylan::high 
) [static, inherited]

Returns a user-friendly description of this list of pointers to text displayable instances.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const string Timestamp::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]

Returns a user-friendly description of the state of this object.

The timestamp format is [year/month/day hours:minutes:seconds] For instance: [2004/05/07 19:07:54]

Another format could have been the one given by System::timeToString( System::getTime() ) ;

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
TextDisplayable, Displayable

Ceylan::VerbosityLevels

Implements Ceylan::TextDisplayable.

Definition at line 172 of file CeylanTimestamp.cc.

References _day, _hour, _minute, _month, _second, _year, and Ceylan::toNumericalString().

Referenced by Ceylan::Log::LogAggregatorRaw::aggregate(), Ceylan::Log::LogAggregatorHTML::aggregate(), Ceylan::Log::LogAggregatorConsole::aggregate(), Ceylan::Log::LogMessage::getPreformattedText(), and Ceylan::Log::LogMessage::toString().


Member Data Documentation

Timestamp's day.

Definition at line 168 of file CeylanTimestamp.h.

Referenced by operator<(), Timestamp(), and toString().

Timestamp's hour.

Definition at line 171 of file CeylanTimestamp.h.

Referenced by operator<(), Timestamp(), and toString().

Timestamp's minute.

Definition at line 174 of file CeylanTimestamp.h.

Referenced by operator<(), Timestamp(), and toString().

Timestamp's month.

Definition at line 165 of file CeylanTimestamp.h.

Referenced by operator<(), Timestamp(), and toString().

TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().

Timestamp's second.

Definition at line 177 of file CeylanTimestamp.h.

Referenced by operator<(), Timestamp(), and toString().

Timestamp's year.

Definition at line 162 of file CeylanTimestamp.h.

Referenced by operator<(), Timestamp(), and toString().


The documentation for this class was generated from the following files:

Generated on Thu Jun 4 20:40:09 2009 for Ceylan by  doxygen 1.5.8