Adonthell  0.4
time_event Class Reference

The time event executes the attached script or callback at a certain point in game-time. More...

#include <time_event.h>

Inheritance diagram for time_event:
Collaboration diagram for time_event:

List of all members.

Public Member Functions

u_int32 time () const
 Get the event's "alarm" time, i.e.
Initialization
  
 time_event (const string &time, bool absolute=false)
 Create a new time event.
 time_event ()
 Standard constructor.
 time_event (const u_int32 &time)
 Create a new time event.
void set_repeat (const string &interval, s_int32 count=-1)
 Set whether the event should be raised at fixed intervals.
Event Handling
  
bool equals (const event *evnt)
 Compare two time events for equality.
s_int32 execute (const event *evnt)
 Executes the script associated with this time event.
Loading / Saving
  
void put_state (ogzstream &out) const
 Saves the basic event data (such as the type or script data) to a file.
bool get_state (igzstream &in)
 Loads the basic event date from a file.
Pausing / Resuming execution
  
void pause ()
 Disable the event temporarily.
void resume ()
 Re-enable an event that has been paused.

Detailed Description

The time event executes the attached script or callback at a certain point in game-time.

This point can either be relative to the current time, or absolute in time. In any case, this point should be in the future. Time event with an alarm time in the past will be triggered at once.

Definition at line 34 of file time_event.h.


Constructor & Destructor Documentation

time_event::time_event ( const string &  time,
bool  absolute = false 
)

Create a new time event.

Parameters:
timeThe time when the event should be raised. The string specifies week, day, hour, minute and 1/10 minute in the format "<number>w<number>d<number>h<number>m<number>t". If a number is 0, it can be omitted.
absoluteDecides whether the given time is relative from now on, or an absolute time

Definition at line 33 of file time_event.cc.

time_event::time_event ( ) [inline]

Standard constructor.

Definition at line 58 of file time_event.h.

time_event::time_event ( const u_int32 time) [inline]

Create a new time event.

This constructor is primarily used for raising time events.

Parameters:
timeThe "alarm" time in gametime minutes.

Definition at line 70 of file time_event.h.


Member Function Documentation

void time_event::set_repeat ( const string &  interval,
s_int32  count = -1 
)

Set whether the event should be raised at fixed intervals.

Parameters:
intervalThe time between two occurences of the event.
countThe number of times the event shall be repeated. Specify -1 to repeat it an unlimited number of times.

Definition at line 43 of file time_event.cc.

bool time_event::equals ( const event evnt) [inline, virtual]

Compare two time events for equality.

Parameters:
evntThe time event to compare this to.
Returns:
True if the two events equal, false otherwise.

Implements event.

Definition at line 99 of file time_event.h.

s_int32 time_event::execute ( const event evnt) [virtual]

Executes the script associated with this time event.

If the event repeats it is re-registered with the event handler.

Parameters:
evntThe event that triggered this time event.
Returns:
The number of times the event needs to be repeated.

Implements event.

Definition at line 50 of file time_event.cc.

void time_event::put_state ( ogzstream out) const [virtual]

Saves the basic event data (such as the type or script data) to a file.

Parameters:
outfile where to save the event.

Reimplemented from event.

Definition at line 102 of file time_event.cc.

bool time_event::get_state ( igzstream in) [virtual]

Loads the basic event date from a file.

Parameters:
infile to load the event from.
Returns:
true if the event could be loaded, false otherwise

Reimplemented from event.

Definition at line 114 of file time_event.cc.

void time_event::pause ( ) [virtual]

Disable the event temporarily.

As long as it in this state, the event will neither be executed, nor will its repeat-count change.

The alarm time of relative time events will be prolongued be the time the event was paused. Absolute events will only be deferred until they are resumed.

Reimplemented from event.

Definition at line 84 of file time_event.cc.

void time_event::resume ( ) [virtual]

Re-enable an event that has been paused.

Absolute events that are past their alarm time are executed at once.

Reimplemented from event.

Definition at line 93 of file time_event.cc.

u_int32 time_event::time ( ) const [inline]

Get the event's "alarm" time, i.e.

the time when it needs to be executed.

Returns:
the "alarm" time in 1/10 gametime minutes.

Definition at line 169 of file time_event.h.


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