Papageno
An Advanced Pattern Matching Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
Functions
ppg_global.h File Reference
#include "ppg_input.h"
#include "ppg_time.h"
#include "ppg_event.h"
#include "ppg_layer.h"
#include "ppg_signal_callback.h"
#include <stdbool.h>
#include <inttypes.h>

Go to the source code of this file.

Functions

PPG_Input_Id ppg_global_set_abort_trigger (PPG_Input_Id input)
 Defines an input that aborts current pattern processing. More...
 
PPG_Input_Id ppg_global_get_abort_trigger (void)
 Retreives the current abort input. More...
 
void ppg_global_abort_pattern_matching (void)
 Aborts processing of the current pattern.
 
PPG_Time ppg_global_set_timeout (PPG_Time timeout)
 Set the current timeout for pattern processing. More...
 
PPG_Time ppg_global_get_timeout (void)
 Returns the current timeout value. More...
 
PPG_Event_Processor_Fun ppg_global_set_default_event_processor (PPG_Event_Processor_Fun event_processor)
 Defines the default input processor callback. More...
 
bool ppg_global_set_enabled (bool state)
 Use this function to temporarily disable/enable pattern processing. More...
 
void ppg_global_init (void)
 Initialize Papageno.
 
void ppg_global_compile (void)
 Compiles the Papageno pattern tree.
 
void ppg_global_finalize (void)
 Finalizes Papageno, i.e. clears all patterns and frees all allocated memory. More...
 
void ppg_global_reset (void)
 Resets papageno to initial state. More...
 
bool ppg_timeout_check (void)
 The timeout check function. More...
 
bool ppg_global_set_timeout_enabled (bool state)
 Toggles global timeout. More...
 
bool ppg_global_get_timeout_enabled (void)
 Determines if global timeout is enabled. More...
 
PPG_Layer ppg_global_set_layer (PPG_Layer layer)
 Set the current layer. More...
 
PPG_Layer ppg_global_get_layer (void)
 Retreives the currently active layer. More...
 
PPG_Signal_Callback ppg_global_set_signal_callback (PPG_Signal_Callback callback)
 Set a callback that is used to signal specific events. More...
 
PPG_Signal_Callback ppg_global_get_signal_callback (void)
 Get the current signal callback. More...
 

Function Documentation

void ppg_global_finalize ( void  )

Finalizes Papageno, i.e. clears all patterns and frees all allocated memory.

Please not that this operation only operates on the current context. It you have created several contexts, set and finalize them in a loop.

PPG_Input_Id ppg_global_get_abort_trigger ( void  )

Retreives the current abort input.

See ppg_global_set_abort_trigger for further information.

PPG_Layer ppg_global_get_layer ( void  )

Retreives the currently active layer.

Returns
The currently active layer
PPG_Signal_Callback ppg_global_get_signal_callback ( void  )

Get the current signal callback.

Returns
The current callback
PPG_Time ppg_global_get_timeout ( void  )

Returns the current timeout value.

Returns
The current timeout value
bool ppg_global_get_timeout_enabled ( void  )

Determines if global timeout is enabled.

Returns
The current state of global timeout enabled
void ppg_global_reset ( void  )

Resets papageno to initial state.

This creates and initializes a new context. Other contexts are not affected. The currently active context is finalized before the reset operation takes place.

PPG_Input_Id ppg_global_set_abort_trigger ( PPG_Input_Id  input)

Defines an input that aborts current pattern processing.

If pattern processing is aborted the actions of tokens that already matched are triggered.

Note
By default there is no abort input defined
Parameters
inputThe abort input
Returns
The abort input id that was previously set
PPG_Event_Processor_Fun ppg_global_set_default_event_processor ( PPG_Event_Processor_Fun  event_processor)

Defines the default input processor callback.

Some functions, e.g. ppg_event_buffer_iterate can be supplied with a custom input processor. If non is specified the default one is used if defined.

Parameters
event_processorThe default input processor callback
Returns
The callback that was active before resetting
bool ppg_global_set_enabled ( bool  state)

Use this function to temporarily disable/enable pattern processing.

Processing is enabled by default.

Parameters
stateThe new state. Enables if true, disables if false.
Returns
The previous state
PPG_Layer ppg_global_set_layer ( PPG_Layer  layer)

Set the current layer.

Returns
The previously active layer
PPG_Signal_Callback ppg_global_set_signal_callback ( PPG_Signal_Callback  callback)

Set a callback that is used to signal specific events.

Parameters
callbackThe signal callback
Returns
The previous callback
PPG_Time ppg_global_set_timeout ( PPG_Time  timeout)

Set the current timeout for pattern processing.

If no input events are encountered within the timeout interval after the last input event, pattern processing is aborted and actions are processed recursively starting with the last token that matched.

Parameters
timeoutThe timeout time value
Returns
The previous setting
bool ppg_global_set_timeout_enabled ( bool  state)

Toggles global timeout.

Parameters
stateThe current timeout state
Returns
The previous state of global timeout enabled
bool ppg_timeout_check ( void  )

The timeout check function.

This timeout check function should be called frequently in a loop, e.g. when polling input presses

Returns
True if timeout happend, i.e. the time elapsed since the last inputpress event exceeded the user defined timeout threshold.