Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
driven_table_example.C File Reference

Example demonstrating both legacy and modern use of Event Tables. More...

#include <iostream>
#include <string>
#include <vector>
#include <driven_table.H>
Include dependency graph for driven_table_example.C:

Go to the source code of this file.

Classes

struct  SmartHomeState
 
struct  ModernSmartHome
 

Functions

void * on_lights_on (void *data)
 
void * on_lights_off (void *data)
 
void * on_temp_up (void *data)
 
void * on_arm_alarm (void *data)
 
void * on_panic (void *data)
 
void run_legacy_example ()
 
void run_modern_example ()
 
int main ()
 

Detailed Description

Example demonstrating both legacy and modern use of Event Tables.

This example simulates a simple "Smart Home" system where different devices (Lights, Thermostat, Security System) respond to events.

It demonstrates:

  1. Legacy interface: Using void* function pointers (for backward compatibility)
  2. Modern interface: Using type-safe lambdas with templates
  3. Passing context data to events
  4. Executing events by ID
Author
Leandro Rabindranath León

Definition in file driven_table_example.C.

Function Documentation

◆ main()

int main ( )

Definition at line 302 of file driven_table_example.C.

References Aleph::maps(), run_legacy_example(), and run_modern_example().

◆ on_arm_alarm()

void * on_arm_alarm ( void *  data)

Definition at line 108 of file driven_table_example.C.

References SmartHomeState::alarm_armed.

Referenced by run_legacy_example().

◆ on_lights_off()

void * on_lights_off ( void *  data)

Definition at line 90 of file driven_table_example.C.

References SmartHomeState::lights_on.

Referenced by run_legacy_example().

◆ on_lights_on()

void * on_lights_on ( void *  data)

Definition at line 81 of file driven_table_example.C.

References SmartHomeState::lights_on.

Referenced by run_legacy_example().

◆ on_panic()

void * on_panic ( void *  data)

Definition at line 117 of file driven_table_example.C.

References SmartHomeState::lights_on.

Referenced by run_legacy_example().

◆ on_temp_up()

void * on_temp_up ( void *  data)

Definition at line 99 of file driven_table_example.C.

References SmartHomeState::temperature, and Aleph::to_string().

Referenced by run_legacy_example().

◆ run_legacy_example()

void run_legacy_example ( )

◆ run_modern_example()

void run_modern_example ( )

Definition at line 203 of file driven_table_example.C.

References h, Aleph::maps(), and Aleph::to_string().

Referenced by main().