Files
c_state_pattern/src/device.c

29 lines
618 B
C

#include <string.h>
#include "device.h"
// these functions are where the bulk of the ugliness happens
// these function just pass through and call the method that
// is defined within the state structs methods
void pressPwrButton(Device_t *device) {
device->state.methods.pressPwr(device);
}
void pressStrInputButton(Device_t *device) {
device->state.methods.pressStrInput(device);
}
void pressLockButton(Device_t *device) {
device->state.methods.pressLock(device);
}
void initDevice(Device_t* device) {
*device = (Device_t){
.state = NULL,
.entered_string = "frogs",
};
}