refactor db_field_log and filters to get rid of dbfl_type_rec

This refactor simplifies and streamlines the code associated with server
side filters. Apart from immediate benefits (clearer code, less duplication)
it is also hoped that this will make it easier to add write filters.

The data pointer dbfl_ref.field can now either point to a copy owned by a
filter, or it can point to the original data owned by a record. In the
latter case, the dbfl_ref.dtor is NULL.

The dbExtractArray* functions are unified to the single function
dbExtractArray and stripped of conversion functionality. This is redundant
because we always call dbGet after applying filters, which takes care of
conversion. Accordingly, dbChannelMakeArrayCopy is now obsolete and its
single use (in the ts filter) replaced with dbExtractArray. Instead, we add
the helper function dbChannelGetArrayInfo to wrap the common boilerplate
around calls to the get_array_info method, used in both arr.c and ts.c.
This commit is contained in:
Ben Franksen
2020-03-30 21:34:32 +02:00
parent 4ab9808180
commit 27fe3e4468
12 changed files with 239 additions and 281 deletions

View File

@@ -22,11 +22,36 @@
extern "C" {
#endif
epicsShareFunc void dbExtractArrayFromRec(const DBADDR *paddr, void *pto,
long nRequest, long no_elements, long offset, long increment);
epicsShareFunc void dbExtractArrayFromBuf(const void *pfrom, void *pto,
short field_size, short field_type,
long nRequest, long no_elements, long offset, long increment);
/** @brief Make a copy of parts of an array.
*
* The source array may or may not be a record field.
*
* The increment parameter is used to support array filters; it
* means: copy only every increment'th element, starting at offset.
*
* The offset and no_elements parameters are used to support the
* circular buffer feature of record fields: elements before offset
* are treated as if they came right after no_elements.
*
* This function does not do any conversion on the array elements.
*
* Preconditions:
* nRequest >= 0, no_elements >= 0, increment > 0
* 0 <= offset < no_elements
* pto points to a buffer with at least field_size*nRequest bytes
* pfrom points to a buffer with exactly field_size*no_elements bytes
*
* @param pfrom Pointer to source array.
* @param pto Pointer to target array.
* @param field_size Size of an array element.
* @param nRequest Number of elements to copy.
* @param no_elements Number of elements in source array.
* @param offset Wrap-around point in source array.
* @param increment Copy only every increment'th element.
*/
epicsShareFunc void dbExtractArray(const void *pfrom, void *pto,
short field_size, long nRequest, long no_elements, long offset,
long increment);
#ifdef __cplusplus
}