exercism-c/react/react.h
Blizzard Finnegan b92478b09c
Init commit
Leap, Difference of Squares, Grains, Collatz Conjecture, Queen Attack,
Darts, Hamming, and Space Age completed yesterday.

Binary and Linked List completed today.
2025-01-11 18:45:47 -05:00

29 lines
897 B
C

#ifndef REACT_H
#define REACT_H
struct reactor;
struct cell;
typedef int (*compute1) (int);
typedef int (*compute2) (int, int);
struct reactor *create_reactor();
// destroy_reactor should free all cells created under that reactor.
void destroy_reactor(struct reactor *);
struct cell *create_input_cell(struct reactor *, int initial_value);
struct cell *create_compute1_cell(struct reactor *, struct cell *, compute1);
struct cell *create_compute2_cell(struct reactor *, struct cell *,
struct cell *, compute2);
int get_cell_value(struct cell *);
void set_cell_value(struct cell *, int new_value);
typedef void (*callback) (void *, int);
typedef int callback_id;
// The callback should be called with the same void * given in add_callback.
callback_id add_callback(struct cell *, void *, callback);
void remove_callback(struct cell *, callback_id);
#endif