aboutsummaryrefslogtreecommitdiff
path: root/libcrystfel/src/datatemplate.c
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2021-03-30 17:01:11 +0200
committerThomas White <taw@physics.org>2021-03-30 17:01:11 +0200
commit00f88dac5a2b63ec1c5f7ad65efef3d4f9d93b77 (patch)
treefc8a5f77c1b88f526cbdd7efb53b09183cc5ca14 /libcrystfel/src/datatemplate.c
parentab2158fb3f8053c6277113b4fb22007859f53de8 (diff)
Add header caching layer
This simultaneously implements --copy-header/--copy-hdf5-field and gives access to metadata (e.g. detector position or wavelength) when loading from a stream with header-specified values.
Diffstat (limited to 'libcrystfel/src/datatemplate.c')
-rw-r--r--libcrystfel/src/datatemplate.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/libcrystfel/src/datatemplate.c b/libcrystfel/src/datatemplate.c
index 290b9227..185847ea 100644
--- a/libcrystfel/src/datatemplate.c
+++ b/libcrystfel/src/datatemplate.c
@@ -1047,6 +1047,7 @@ DataTemplate *data_template_new_from_string(const char *string_in)
dt->peak_list = NULL;
dt->shift_x_from = NULL;
dt->shift_y_from = NULL;
+ dt->n_headers_to_copy = 0;
/* The default defaults... */
defaults.orig_min_fs = -1;
@@ -1489,6 +1490,10 @@ void data_template_free(DataTemplate *dt)
}
}
+ for ( i=0; i<dt->n_headers_to_copy; i++ ) {
+ free(dt->headers_to_copy[i]);
+ }
+
free(dt->wavelength_from);
free(dt->peak_list);
@@ -1574,8 +1579,12 @@ int data_template_panel_name_to_number(const DataTemplate *dt,
void data_template_add_copy_header(DataTemplate *dt,
const char *header)
{
- /* FIXME: Add "header" to list of things to copy */
- STATUS("Adding %s\n", header);
+ if ( dt->n_headers_to_copy >= MAX_COPY_HEADERS ) {
+ ERROR("Too many extra headers to copy\n");
+ return;
+ }
+
+ dt->headers_to_copy[dt->n_headers_to_copy++] = strdup(header);
}