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

Keeps two numbers and compares them if requested. More...

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

Classes

struct  Init
 
struct  LocalInit
 

Public Types

enum  ON_COMPARE_TYPE {
  ON_COMPARE_UNCHANGED = 0, ON_COMPARE_RESET_BOTH = 1, ON_COMPARE_RESET_LEFT = 2, ON_COMPARE_RESET_RIGHT = 3,
  ON_COMPARE_SET_TO_INITIAL_BOTH = 5, ON_COMPARE_SET_TO_INITIAL_LEFT = 6, ON_COMPARE_SET_TO_INITIAL_RIGHT = 7, ON_COMPARE_COPY_LEFT_TO_RIGHT = 11,
  ON_COMPARE_COPY_RIGHT_TO_LEFT = 12
}
 
enum  {
  MESSAGE_CUMUL_COMPARE = 100, MESSAGE_CUMUL_SET = 110, MESSAGE_CUMUL_SET_LEFT = 111, MESSAGE_CUMUL_SET_RIGHT = 112,
  MESSAGE_CUMUL_SET_LEFT_COMPARE = 113, MESSAGE_CUMUL_SET_RIGHT_COMPARE = 114, MESSAGE_CUMUL_ADD_TO = 120, MESSAGE_CUMUL_ADD_TO_LEFT = 121,
  MESSAGE_CUMUL_ADD_TO_RIGHT = 122, MESSAGE_CUMUL_ADD_TO_LEFT_COMPARE = 123, MESSAGE_CUMUL_ADD_TO_RIGHT_COMPARE = 124, MESSAGE_CUMUL_MULT = 130,
  MESSAGE_CUMUL_MULT_LEFT = 131, MESSAGE_CUMUL_MULT_RIGHT = 132, MESSAGE_CUMUL_MULT_LEFT_COMPARE = 133, MESSAGE_CUMUL_MULT_RIGHT_COMPARE = 134,
  MESSAGE_CUMUL_DIV = 140, MESSAGE_CUMUL_DIV_LEFT = 141, MESSAGE_CUMUL_DIV_RIGHT = 142, MESSAGE_CUMUL_DIV_LEFT_COMPARE = 143,
  MESSAGE_CUMUL_DIV_RIGHT_COMPARE = 144, MESSAGE_CUMUL_RESET = 210, MESSAGE_CUMUL_RESET_LEFT = 211, MESSAGE_CUMUL_RESET_RIGHT = 212,
  MESSAGE_CUMUL_SET_TO_INITIAL = 220, MESSAGE_CUMUL_SET_TO_INITIAL_LEFT = 221, MESSAGE_CUMUL_SET_TO_INITIAL_RIGHT = 222
}
 
enum  { LISTENER_GROUP_COMPARED = 10, LISTENER_GROUP_COMPARED_EQUAL = 20, LISTENER_GROUP_COMPARED_NOT_EQUAL = 21 }
 
- 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

 CumulCmpEvent (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

Keeps two numbers and compares them if requested.

The two numbers are called "left" and "right".

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
MESSAGE_CUMUL_COMPARE 

Compares the "left" and "right" vars.

MESSAGE_CUMUL_SET 

Sets the "left" and "right" vars to input nValue.

MESSAGE_CUMUL_SET_LEFT 

Sets the "left" var to input nValue.

MESSAGE_CUMUL_SET_RIGHT 

Sets the "right" var to input nValue.

MESSAGE_CUMUL_SET_LEFT_COMPARE 

Sets the "left" var to input nValue and comparison is forced.

MESSAGE_CUMUL_SET_RIGHT_COMPARE 

Sets the "right" var to input nValue and comparison is forced.

MESSAGE_CUMUL_ADD_TO 

Input nValue is added to the "left" and "right" vars.

MESSAGE_CUMUL_ADD_TO_LEFT 

Input nValue is added to the "left" var.

MESSAGE_CUMUL_ADD_TO_RIGHT 

Input nValue is added to the "right" var.

MESSAGE_CUMUL_ADD_TO_LEFT_COMPARE 

Input nValue is added to the "left" var and comparison is forced.

MESSAGE_CUMUL_ADD_TO_RIGHT_COMPARE 

Input nValue is added to the "right" var and comparison is forced.

MESSAGE_CUMUL_MULT 

The "left" and "right" vars are multiplied by input nValue.

MESSAGE_CUMUL_MULT_LEFT 

The "left" var is multiplied by input nValue.

MESSAGE_CUMUL_MULT_RIGHT 

The "right" var is multiplied by input nValue.

MESSAGE_CUMUL_MULT_LEFT_COMPARE 

The "left" var is multiplied by input nValue and comparison is forced.

MESSAGE_CUMUL_MULT_RIGHT_COMPARE 

the "right" var is multiplied by input nValue and comparison is forced.

MESSAGE_CUMUL_DIV 

The "left" and "right" vars are divided by input nValue.

Division by 0 is 0.

MESSAGE_CUMUL_DIV_LEFT 

The "left" var is divided by input nValue.

Division by 0 is 0.

MESSAGE_CUMUL_DIV_RIGHT 

The "right" var is divided by input nValue.

Division by 0 is 0.

MESSAGE_CUMUL_DIV_LEFT_COMPARE 

The "left" var is divided by input nValue and comparison is forced.

Division by 0 is 0.

MESSAGE_CUMUL_DIV_RIGHT_COMPARE 

the "right" var is divided by input nValue and comparison is forced.

Division by 0 is 0.

MESSAGE_CUMUL_RESET 

Sets the "left" and "right" vars to 0.

MESSAGE_CUMUL_RESET_LEFT 

Sets the "left" var to 0.

MESSAGE_CUMUL_RESET_RIGHT 

Sets the "right" var to 0.

MESSAGE_CUMUL_SET_TO_INITIAL 

Sets the "left" and "right" vars to their initial value.

MESSAGE_CUMUL_SET_TO_INITIAL_LEFT 

Sets the "left" var to its initial value.

MESSAGE_CUMUL_SET_TO_INITIAL_RIGHT 

Sets the "right" var to its initial value.

◆ anonymous enum

anonymous enum
Enumerator
LISTENER_GROUP_COMPARED 

Comparison result containing output nValue set to "left" - "right".

LISTENER_GROUP_COMPARED_EQUAL 

Only fires if "left" equals "right".

Output nValue is "left".

LISTENER_GROUP_COMPARED_NOT_EQUAL 

Only fires if "left" not equal "right".

Output nValue is "left" - "right".

◆ ON_COMPARE_TYPE

Enumerator
ON_COMPARE_UNCHANGED 

When compared both vars are unchanged.

ON_COMPARE_RESET_BOTH 

When compared both vars are reset to 0.

ON_COMPARE_RESET_LEFT 

When compared the left var is reset to 0.

ON_COMPARE_RESET_RIGHT 

When compared the right var is reset to 0.

ON_COMPARE_SET_TO_INITIAL_BOTH 

When compared both vars are set to the initial value (see ctor).

ON_COMPARE_SET_TO_INITIAL_LEFT 

When compared the left var is set to its initial value (see ctor).

ON_COMPARE_SET_TO_INITIAL_RIGHT 

When compared the right var is set to its initial value (see ctor).

ON_COMPARE_COPY_LEFT_TO_RIGHT 

When compared the right var takes the value of the left var.

ON_COMPARE_COPY_RIGHT_TO_LEFT 

When compared the left var takes the value of the right var.

Constructor & Destructor Documentation

◆ CumulCmpEvent()

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

Constructor.

Parameters
oInitThe initialization data.

Member Function Documentation

◆ reInit()

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

See constructor.

◆ trigger()

void stmg::CumulCmpEvent::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.