Read and Write object

Begining with v2.6p3 the parameters used for read and write operations have been changed.

Old design

Read(path,output_buffer,size,offset) 
Write(path,result_buffer,size,offset)

was  passed to lower level routines as:

function(buffer, size, offset, parsedname structure)

New design 

The new one_wire_query structure is:

struct one_wire_query <<
char * buffer ;
size_t size ;
off_t offset ;
struct parsedname pn;
union value_object val ;
>> ;

In turn union value_object is

union value_object <<
int I ;
unsigned int U ;
_FLOAT F ;
_DATE D ;
int Y ;//boolean
size_t length ;
union value_object * array ;
>> ;

The union member actually chosen depends on parsedname.filetype->format (i.e. knowledge gained from parsing the path).

Advantages

  • fewer parameters need to be passed with each call
  • fewer separate cases for display, cache, and other handling
  • far less duplication of code in ow_read.c and ow_write.c

The cost is more indirection, and slightly more awkward parameter extraction in the simplest cases.

Challenges

  • There are two classes of data: strings (ascii and binary) and numbers (integers, unsigneds, floating, dates, booleans). The string class needs special attention in C.
  • Both array and scalars must be handled. 

 


Previous page: To Do
Next page: struct owq_wire_query assumptions