1 #ifndef MAPPER_H 2 #define MAPPER_H 3 4 #include <stdio.h> 5 #include "lib/context.h" 6 #include "cli/mlrcli.h" 7 #include "containers/lrec.h" 8 #include "containers/sllv.h" 9 10 // See ../README.md for memory-management conventions. 11 12 // ---------------------------------------------------------------- 13 // Data plane: 14 15 struct _mapper_t; // forward reference for method declarations 16 17 // Returns linked list of records (lrec_t*). 18 typedef sllv_t* mapper_process_func_t(lrec_t* pinrec, context_t* pctx, void* pvstate); 19 20 typedef void mapper_free_func_t(struct _mapper_t* pmapper, context_t* pctx); 21 22 typedef struct _mapper_t { 23 void* pvstate; 24 mapper_process_func_t* pprocess_func; 25 mapper_free_func_t* pfree_func; // virtual destructor 26 } mapper_t; 27 28 // ---------------------------------------------------------------- 29 // Control plane: 30 31 typedef void mapper_usage_func_t(FILE* o, char* argv0, char* verb); 32 typedef mapper_t* mapper_parse_cli_func_t(int* pargi, int argc, char** argv, 33 cli_reader_opts_t* pmain_reader_opts, cli_writer_opts_t* pmain_writer_opts); 34 35 typedef struct _mapper_setup_t { 36 char* verb; 37 mapper_usage_func_t* pusage_func; 38 mapper_parse_cli_func_t* pparse_func; 39 int ignores_input; // most don't; data-generators like seqgen do 40 } mapper_setup_t; 41 42 #endif // MAPPER_H 43