stmm-games-doc  0.32.0
Classes | Public Types | Public Member Functions | Protected Member Functions | List of all members
stmg::AlarmsEvent Class Reference

Alarms event. More...

Inheritance diagram for stmg::AlarmsEvent:
Inheritance graph
[legend]

Classes

struct  AlarmsStage
 
struct  Init
 
struct  LocalInit
 

Public Types

enum  ALARMS_STAGE_TYPE {
  ALARMS_STAGE_INVALID = -1, ALARMS_STAGE_SET_TICKS = 1, ALARMS_STAGE_INC_TICKS = 2, ALARMS_STAGE_SET_MILLISEC = 3,
  ALARMS_STAGE_INC_MILLISEC = 4, ALARMS_STAGE_MULT_PERC = 5
}
 
enum  {
  MESSAGE_ALARMS_NEXT = 100, MESSAGE_ALARMS_STAGE_NEXT = 105, MESSAGE_ALARMS_FINISH = 110, MESSAGE_ALARMS_RESTART = 120,
  MESSAGE_ALARMS_REDO_CURRENT = 130, MESSAGE_ALARMS_STAGE_RESET = 135
}
 
enum  { LISTENER_GROUP_TIMEOUT = 10, LISTENER_GROUP_TIMEOUT_ACTIVE = 12 }
 
- Public Types inherited from stmg::Event
enum  MSG_FILTER_VALUE_OP {
  MSG_FILTER_VALUE_OP_FIRST = 0, MSG_FILTER_VALUE_OP_UNCHANGED = 0, MSG_FILTER_VALUE_OP_SET = 1, MSG_FILTER_VALUE_OP_MULT_ADD = 2,
  MSG_FILTER_VALUE_OP_DIV_ADD = 3, MSG_FILTER_VALUE_OP_PERCENT_ADD = 4, MSG_FILTER_VALUE_OP_PERMILL_ADD = 5, MSG_FILTER_VALUE_OP_MOD_ADD = 6,
  MSG_FILTER_VALUE_OP_MIN_ADD = 7, MSG_FILTER_VALUE_OP_MAX_ADD = 8, MSG_FILTER_VALUE_OP_LAST = 8
}
 Value filter. More...
 
enum  { LISTENER_GROUP_FINISHED = 0 }
 

Public Member Functions

 AlarmsEvent (Init &&oInit) noexcept
 Constructor. More...
 
void trigger (int32_t nMsg, int32_t nValue, Event *p0TriggeringEvent) noexcept override
 The trigger function. More...
 
- Public Member Functions inherited from stmg::Event
virtual ~Event () noexcept=default
 
virtual void addMsgFilter (int32_t nInFromMsg, int32_t nInToMsg, int32_t nInFromValue, int32_t nInToValue, bool bOutMsgDefined, int32_t nOutMsg, MSG_FILTER_VALUE_OP eOutValueOperator, int32_t nOutValueOperand, int32_t nOutValueAdd) noexcept
 Add a message filter. More...
 
virtual void addListener (int32_t nGroupId, Event *p0ListenerEvent, int32_t nMsg) noexcept
 Adds a listener to the event. More...
 
bool isActive () const noexcept
 Tells whether the event is active. More...
 
int32_t getTriggerTime () const noexcept
 The triggering time. More...
 
int32_t getPriority () const noexcept
 The priority. More...
 
int32_t getDebugTag () const noexcept
 The debug tag. More...
 

Protected Member Functions

void reInit (Init &&oInit) noexcept
 See constructor. More...
 
- Protected Member Functions inherited from stmg::Event
 Event (Init &&oInit) noexcept
 Constructor. More...
 
void reInit (Init &&oInit) noexcept
 Reinitialization. More...
 
virtual void informListeners (int32_t nGroupId, int32_t nValue) noexcept
 Calls the trigger function of a group of listeners. More...
 
const Levellevel () const noexcept
 The level this event belongs to. More...
 
Levellevel () noexcept
 The level this event belongs to. More...
 

Detailed Description

Alarms event.

Allows one to set a sequence of alarms. Each alarm timeout of the sequence can be defined in relation to the preceding except for the first.

The sequence can be subdivided into stages, each of which repeats a certain timeout duration change.

When a timeout expires the next is only started as soon as MESSAGE_ALARMS_NEXT is received. To start the next alarm immediately, a typical instance will therefore send a MESSAGE_ALARMS_NEXT to itself (triggered by LISTENER_GROUP_TIMEOUT).

If MESSAGE_ALARMS_NEXT is received while an alarm is already active, the message LISTENER_GROUP_TIMEOUT_ACTIVE is sent to listeners.

Input MESSAGE_ALARMS_RESTART restarts the whole thing, but only if no alarm is active. If an alarm is active LISTENER_GROUP_TIMEOUT_ACTIVE is sent to listeners.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MESSAGE_ALARMS_NEXT 

Start next alarm.

The current must not be active (LISTENER_GROUP_TIMEOUT was already fired).

MESSAGE_ALARMS_STAGE_NEXT 

Next alarm will be first of next stage.

If there isn't a next stage, does nothing.

MESSAGE_ALARMS_FINISH 

Finishes the whole alarms sequence.

MESSAGE_ALARMS_RESTART 

Restarts the alarms with nValue initial ticks if >=0, otherwise the value SET by the first stage.

MESSAGE_ALARMS_REDO_CURRENT 

Restarts the currently active timeout from now.

If no timeout is active same as MESSAGE_ALARMS_NEXT.

MESSAGE_ALARMS_STAGE_RESET 

The next alarm will be the first of the current stage.

◆ anonymous enum

anonymous enum
Enumerator
LISTENER_GROUP_TIMEOUT 

The timeout signal.

nValue contains a counter incremented at each timeout (starts from 0).

LISTENER_GROUP_TIMEOUT_ACTIVE 

Emitted if MESSAGE_ALARMS_NEXT or MESSAGE_ALARMS_RESTART is received while alarms still active.

◆ ALARMS_STAGE_TYPE

Enumerator
ALARMS_STAGE_INVALID 
ALARMS_STAGE_SET_TICKS 

Set the next alarm timeout to the m_nChange value (in game ticks).

ALARMS_STAGE_INC_TICKS 

Set the next alarm timeout by adding m_nChange to the current (in game ticks).

ALARMS_STAGE_SET_MILLISEC 

Set the next alarm timeout to the m_nChange value (in milliseconds).

ALARMS_STAGE_INC_MILLISEC 

Set the next alarm timeout by adding m_nChange to the current (in milliseconds).

ALARMS_STAGE_MULT_PERC 

Set the next alarm timeout by multiplying the current timeout by m_nChange and dividing by 100.

Constructor & Destructor Documentation

◆ AlarmsEvent()

stmg::AlarmsEvent::AlarmsEvent ( Init &&  oInit)
explicitnoexcept

Constructor.

Whatever the operation to calculate the new timeout is, the result is guaranteed to be > 0.

Parameters
oInitInitialization data.

Member Function Documentation

◆ reInit()

void stmg::AlarmsEvent::reInit ( Init &&  oInit)
protectednoexcept

See constructor.

◆ trigger()

void stmg::AlarmsEvent::trigger ( int32_t  nMsg,
int32_t  nValue,
Event p0TriggeringEvent 
)
overridevirtualnoexcept

The trigger function.

This function provides the functionality of the event and can be called in two ways.

It can be called by an event through informListeners() this event was listening to. Note: events can listen to themselves.

It can also be called by the timer if the event was active.

When this function is called the event has already been deactivated by the level (if it was active in the first place).

When this function is called the filters of this event have already been applied.

Parameters
nMsgThe message received.
nValueThe value received.
p0TriggeringEventThe triggering event or null if triggered by timer.

Implements stmg::Event.