First class data visualization and communication library with embedded devices. Code is maintained at github.com/Overdrivr/Telemetry
Dependents: telemetry_car_demo telemetry_demo_FRDM-TFC telemetry_example_01 telemetry_indexed_data_demo ... more
Diff: c_api/dictionnary.h
- Revision:
- 7:d224bddd5405
diff -r f5e1b079bffd -r d224bddd5405 c_api/dictionnary.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/c_api/dictionnary.h Tue Apr 12 07:40:10 2016 +0000 @@ -0,0 +1,44 @@ +#ifndef TELEMETRY_DICTIONNARY_H_ +#define TELEMETRY_DICTIONNARY_H_ + +#include "stdint.h" + + +enum ptr_type { + ptr_f32 = 0, + ptr_u8 = 1, + ptr_u16 = 2, + ptr_u32 = 3, + ptr_i8 = 4, + ptr_i16 = 5, + ptr_i32 = 6, + ptr_function = 8 +}; + +typedef enum ptr_type ptr_type; + +struct nlist { /* table entry: */ + struct nlist *next; /* next entry in chain */ + char * key; + + // Table can store for a given key all following pointers + float * ptr_f32; + uint8_t * ptr_u8; + uint16_t * ptr_u16; + uint32_t * ptr_u32; + int8_t * ptr_i8; + int16_t * ptr_i16; + int32_t * ptr_i32; + void * ptr_function; +}; + +#define HASHSIZE 101 + +void init_table(struct nlist ** hashtab); + +/* lookup: look for s in hashtab */ +struct nlist * lookup(struct nlist ** hashtab, const char * key); + +struct nlist * install(struct nlist ** hashtab, const char * key, void * ptr, ptr_type type); + +#endif