diff options
Diffstat (limited to 'src/solvers/dispatch.h')
| -rw-r--r-- | src/solvers/dispatch.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/solvers/dispatch.h b/src/solvers/dispatch.h new file mode 100644 index 0000000..0cfbc3b --- /dev/null +++ b/src/solvers/dispatch.h | |||
| @@ -0,0 +1,49 @@ | |||
| 1 | typedef struct { | ||
| 2 | const char *prefix; | ||
| 3 | long long (*dataid)(const char *, char [static NISSY_SIZE_DATAID]); | ||
| 4 | long long (*gendata)( | ||
| 5 | const char *, unsigned long long, unsigned char *); | ||
| 6 | long long (*solve)(oriented_cube_t, const char *, unsigned, unsigned, | ||
| 7 | unsigned, unsigned, unsigned, unsigned, unsigned long long, | ||
| 8 | const unsigned char *, unsigned, char *, | ||
| 9 | long long [static NISSY_SIZE_SOLVE_STATS], | ||
| 10 | int (*)(void *), void *); | ||
| 11 | } solver_dispatch_t; | ||
| 12 | |||
| 13 | STATIC solver_dispatch_t *match_solver(const char *); | ||
| 14 | |||
| 15 | solver_dispatch_t solver_dispatchers[] = { | ||
| 16 | { | ||
| 17 | .prefix = "h48", | ||
| 18 | .dataid = dataid_h48, | ||
| 19 | .gendata = gendata_h48_dispatch, | ||
| 20 | .solve = solve_h48_dispatch, | ||
| 21 | }, | ||
| 22 | { | ||
| 23 | .prefix = "coord_", | ||
| 24 | .dataid = dataid_coord, | ||
| 25 | .gendata = gendata_coord_dispatch, | ||
| 26 | .solve = solve_coord_dispatch, | ||
| 27 | }, | ||
| 28 | { | ||
| 29 | .prefix = NULL | ||
| 30 | } | ||
| 31 | }; | ||
| 32 | |||
| 33 | STATIC solver_dispatch_t * | ||
| 34 | match_solver(const char *name) | ||
| 35 | { | ||
| 36 | const char *prefix; | ||
| 37 | int i; | ||
| 38 | |||
| 39 | if (name == NULL) | ||
| 40 | return NULL; | ||
| 41 | |||
| 42 | for (i = 0; solver_dispatchers[i].prefix != NULL; i++) { | ||
| 43 | prefix = solver_dispatchers[i].prefix; | ||
| 44 | if (!strncmp(name, prefix, strlen(prefix))) | ||
| 45 | return &solver_dispatchers[i]; | ||
| 46 | } | ||
| 47 | |||
| 48 | return NULL; | ||
| 49 | } | ||
