Time Class Reference

#include <time.h>

Collaboration diagram for Time:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void Reset ()
bool IsGamePaused () const
uint Read () const
uint ReadSec () const
uint ReadMin () const
void Refresh ()
uint GetDelta () const
void RefreshMaxTime (uint updated_max_time)
uint ClockSec ()
uint ClockMin ()
std::string GetString ()
void Pause ()
void Continue ()

Static Public Member Functions

static TimeGetInstance ()

Private Member Functions

 Time ()

Private Attributes

uint current_time
uint max_time
uint delta_t
bool is_game_paused

Static Private Attributes

static Timesingleton = NULL

Detailed Description

Definition at line 28 of file time.h.


Constructor & Destructor Documentation

Time::Time (  )  [private]

Definition at line 48 of file time.cpp.

00048           {
00049   is_game_paused = false;
00050   delta_t = 20;
00051 }

Here is the caller graph for this function:


Member Function Documentation

uint Time::ClockMin (  ) 

Definition at line 110 of file time.cpp.

00110                    {
00111   return ReadMin() % 60;
00112 }

Here is the call graph for this function:

Here is the caller graph for this function:

uint Time::ClockSec (  ) 

Definition at line 106 of file time.cpp.

00106                    {
00107   return ReadSec() % 60;
00108 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Time::Continue (  ) 

Definition at line 101 of file time.cpp.

00101                    {
00102   assert (is_game_paused);
00103   is_game_paused = false;
00104 }

Here is the caller graph for this function:

uint Time::GetDelta (  )  const

Definition at line 91 of file time.cpp.

00091                          {
00092   return delta_t;
00093 }

Here is the caller graph for this function:

Time * Time::GetInstance (  )  [static]

Definition at line 37 of file time.cpp.

00037                          {
00038   if (singleton == NULL) {
00039     singleton = new Time();
00040   }
00041   return singleton;
00042 }

Here is the call graph for this function:

Here is the caller graph for this function:

std::string Time::GetString (  ) 

Definition at line 114 of file time.cpp.

00114                          {
00115   std::ostringstream ss;
00116 
00117   ss << ClockMin() << ":" << std::setfill('0') << std::setw(2) << ClockSec();
00118   return ss.str();
00119 }

Here is the call graph for this function:

bool Time::IsGamePaused (  )  const

Definition at line 44 of file time.cpp.

00044                               {
00045   return is_game_paused;
00046 }

Here is the caller graph for this function:

void Time::Pause (  ) 

Definition at line 95 of file time.cpp.

00095                 {
00096   if (is_game_paused)
00097     return;
00098   is_game_paused = true;
00099 }

Here is the caller graph for this function:

uint Time::Read (  )  const

Definition at line 58 of file time.cpp.

00058                      {
00059   return current_time;
00060 }

Here is the caller graph for this function:

uint Time::ReadMin (  )  const

Definition at line 87 of file time.cpp.

00087                         {
00088   return ReadSec() / 60;
00089 }

Here is the call graph for this function:

Here is the caller graph for this function:

uint Time::ReadSec (  )  const

Definition at line 83 of file time.cpp.

00083                         {
00084   return Read() / 1000;
00085 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Time::Refresh (  ) 

Definition at line 62 of file time.cpp.

00062                   {
00063   /*
00064   TODO : Activate this condition later.
00065   Refresh time condition :
00066   - active team is Local 
00067   - current node is server and game loop is not in Playing state
00068   - game don't use network
00069   if((ActiveTeam().IsLocal() || ActiveTeam().IsLocalAI()) ||
00070      (network.IsServer() && GameLoop::GetInstance()->ReadState() != GameLoop::PLAYING) ||
00071      (!network.IsServer() && !network.IsClient()) ||
00072      current_time < max_time)
00073   */
00074   current_time += delta_t;
00075   RefreshMaxTime(current_time);
00076 }

Here is the call graph for this function:

Here is the caller graph for this function:

void Time::RefreshMaxTime ( uint  updated_max_time  ) 

Definition at line 78 of file time.cpp.

00078                                               {
00079   if(updated_max_time > max_time)
00080     max_time = updated_max_time;
00081 }

Here is the caller graph for this function:

void Time::Reset (  ) 

Definition at line 53 of file time.cpp.

00053                 {
00054   current_time = 0;
00055   is_game_paused = false;
00056 }

Here is the caller graph for this function:


Member Data Documentation

uint Time::current_time [private]

Definition at line 31 of file time.h.

uint Time::delta_t [private]

Definition at line 33 of file time.h.

bool Time::is_game_paused [private]

Definition at line 34 of file time.h.

uint Time::max_time [private]

Definition at line 32 of file time.h.

Time * Time::singleton = NULL [static, private]

Definition at line 35 of file time.h.


The documentation for this class was generated from the following files:
Generated on Mon Jan 1 14:27:26 2007 for Wormux by  doxygen 1.4.7