34 #include "muse_processing.h"
36 #include "muse_utils.h"
54 typedef struct muse_processinginfo_s {
55 struct muse_processinginfo_s *prev;
56 struct muse_processinginfo_s *next;
58 cpl_recipeconfig *recipeconfig;
60 muse_processing_prepare_header_func *prepare_header;
62 muse_processing_get_frame_level_func *get_frame_level;
64 muse_processing_get_frame_mode_func *get_frame_mode;
85 if (m->plugin == aRecipe) {
108 ( cpl_recipe *plugin,
109 cpl_recipeconfig *recipeconfig,
110 muse_processing_prepare_header_func *prepare_header,
111 muse_processing_get_frame_level_func *get_frame_level,
112 muse_processing_get_frame_mode_func *get_frame_mode) {
119 while (m->next != NULL) {
127 m->recipeconfig = recipeconfig;
128 m->prepare_header = prepare_header;
129 m->get_frame_level = get_frame_level;
130 m->get_frame_mode = get_frame_mode;
154 m->prev->next = m->next;
155 if (m->next != NULL) {
156 m->next->prev = m->prev;
159 cpl_recipeconfig_delete(m->recipeconfig);
173 const char *aFrametag,
174 cpl_propertylist *aHeader) {
176 return (m != NULL)? (* m->prepare_header)(aFrametag, aHeader): CPL_ERROR_NONE;
189 const char *aFrametag) {
191 return (m != NULL)? (* m->get_frame_level)(aFrametag): CPL_FRAME_LEVEL_NONE;
204 const char *aFrametag) {
219 return (m != NULL)?m->recipeconfig: NULL;
241 cpl_type aType,
const char *aDescription)
243 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
244 cpl_ensure_code(aName, CPL_ERROR_NULL_INPUT);
246 cpl_error_code rc = CPL_ERROR_NONE;
248 cpl_propertylist *list = cpl_propertylist_new();
249 cpl_propertylist_copy_property_regexp(list, aHeader, aName, 0);
250 if (cpl_propertylist_is_empty(list)) {
251 cpl_propertylist_delete(list);
257 if (!cpl_propertylist_has(aHeader,
"MUSE PRIVATE DOCUMENTATION")) {
258 cpl_msg_warning(__func__,
"Property %s (%s) not used", aName,
260 return CPL_ERROR_DATA_NOT_FOUND;
267 cpl_propertylist_append_float(aHeader, aName, NAN);
269 case CPL_TYPE_DOUBLE:
270 cpl_propertylist_append_double(aHeader, aName, NAN);
272 case CPL_TYPE_STRING:
273 cpl_propertylist_append_string(aHeader, aName,
"");
276 cpl_propertylist_append_int(aHeader, aName, INT_MAX);
279 cpl_propertylist_append_long(aHeader, aName, LONG_MAX);
282 cpl_propertylist_append_bool(aHeader, aName, FALSE);
285 return CPL_ERROR_INVALID_TYPE;
290 cpl_property *
property = cpl_propertylist_get_property(aHeader, aName);
291 if (aDescription != NULL && strlen(aDescription)>0) {
292 rc = cpl_property_set_comment(property, aDescription);
294 cpl_type type = cpl_property_get_type(property);
296 cpl_msg_warning(__func__,
"Type of property %s is %s but should be %s",
297 aName, cpl_type_get_name(type), cpl_type_get_name(aType));
298 return CPL_ERROR_TYPE_MISMATCH;
300 return CPL_ERROR_NONE;
305 for (i = 0; i < cpl_propertylist_get_size(list); i++) {
306 cpl_property *prop = cpl_propertylist_get(list, i);
307 cpl_property *
property =
308 cpl_propertylist_get_property(aHeader, cpl_property_get_name(prop));
309 if (aDescription != NULL && strlen(aDescription)>0) {
310 rc = cpl_property_set_comment(property, aDescription);
312 cpl_type type = cpl_property_get_type(property);
314 cpl_msg_warning(__func__,
"Type of property %s is %s but should be %s",
315 aName, cpl_type_get_name(type), cpl_type_get_name(aType));
316 cpl_propertylist_delete(list);
317 return CPL_ERROR_TYPE_MISMATCH;
320 cpl_propertylist_delete(list);
int muse_processing_get_frame_mode(const cpl_recipe *aRecipe, const char *aFrametag)
Get the mode for a product frame with a certain tag.
cpl_error_code muse_processing_prepare_header(const cpl_recipe *aRecipe, const char *aFrametag, cpl_propertylist *aHeader)
Prepare and check a FITS header for a certain frame tag.
struct muse_processinginfo_s muse_processinginfo_t
cpl_frame_level muse_processing_get_frame_level(const cpl_recipe *aRecipe, const char *aFrametag)
Get the level for a product frame with a certain tag.
void muse_processinginfo_delete(cpl_recipe *aRecipe)
Clear all information from the processing info and from the recipe config.
cpl_recipeconfig * muse_processing_get_recipeconfig(cpl_recipe *aRecipe)
Get the recipe (frame) configuration.
void muse_processinginfo_register(cpl_recipe *plugin, cpl_recipeconfig *recipeconfig, muse_processing_prepare_header_func *prepare_header, muse_processing_get_frame_level_func *get_frame_level, muse_processing_get_frame_mode_func *get_frame_mode)
Register extended functionalities for MUSE recipes.
static muse_processinginfo_t * muse_processinginfo_get(const cpl_recipe *aRecipe)
Get processinginfo for a certain recipe.
static muse_processinginfo_t * muse_processinginfo
cpl_error_code muse_processing_prepare_property(cpl_propertylist *aHeader, const char *aName, cpl_type aType, const char *aDescription)
Prepare and check the specified property.