35 #include "muse_processing.h"
37 #include "muse_utils.h"
55 typedef struct muse_processinginfo_s {
56 struct muse_processinginfo_s *prev;
57 struct muse_processinginfo_s *next;
59 cpl_recipeconfig *recipeconfig;
61 muse_processing_prepare_header_func *prepare_header;
63 muse_processing_get_frame_level_func *get_frame_level;
65 muse_processing_get_frame_mode_func *get_frame_mode;
86 if (m->plugin == aRecipe) {
109 ( cpl_recipe *plugin,
110 cpl_recipeconfig *recipeconfig,
111 muse_processing_prepare_header_func *prepare_header,
112 muse_processing_get_frame_level_func *get_frame_level,
113 muse_processing_get_frame_mode_func *get_frame_mode) {
120 while (m->next != NULL) {
128 m->recipeconfig = recipeconfig;
129 m->prepare_header = prepare_header;
130 m->get_frame_level = get_frame_level;
131 m->get_frame_mode = get_frame_mode;
155 m->prev->next = m->next;
156 if (m->next != NULL) {
157 m->next->prev = m->prev;
160 cpl_recipeconfig_delete(m->recipeconfig);
174 const char *aFrametag,
175 cpl_propertylist *aHeader) {
177 return (m != NULL)? (* m->prepare_header)(aFrametag, aHeader): CPL_ERROR_NONE;
190 const char *aFrametag) {
192 return (m != NULL)? (* m->get_frame_level)(aFrametag): CPL_FRAME_LEVEL_NONE;
205 const char *aFrametag) {
220 return (m != NULL)?m->recipeconfig: NULL;
242 cpl_type aType,
const char *aDescription)
244 cpl_ensure_code(aHeader, CPL_ERROR_NULL_INPUT);
245 cpl_ensure_code(aName, CPL_ERROR_NULL_INPUT);
247 cpl_error_code rc = CPL_ERROR_NONE;
249 cpl_propertylist *list = cpl_propertylist_new();
250 cpl_propertylist_copy_property_regexp(list, aHeader, aName, 0);
251 if (cpl_propertylist_is_empty(list)) {
252 cpl_propertylist_delete(list);
258 if (!cpl_propertylist_has(aHeader,
"MUSE PRIVATE DOCUMENTATION")) {
259 cpl_msg_warning(__func__,
"Property %s (%s) not used", aName,
261 return CPL_ERROR_DATA_NOT_FOUND;
268 cpl_propertylist_append_float(aHeader, aName, NAN);
270 case CPL_TYPE_DOUBLE:
271 cpl_propertylist_append_double(aHeader, aName, NAN);
273 case CPL_TYPE_STRING:
274 cpl_propertylist_append_string(aHeader, aName,
"");
277 cpl_propertylist_append_int(aHeader, aName, INT_MAX);
280 cpl_propertylist_append_long(aHeader, aName, LONG_MAX);
283 cpl_propertylist_append_bool(aHeader, aName, FALSE);
286 return CPL_ERROR_INVALID_TYPE;
291 cpl_property *
property = cpl_propertylist_get_property(aHeader, aName);
292 if (aDescription != NULL && strlen(aDescription)>0) {
293 rc = cpl_property_set_comment(property, aDescription);
295 cpl_type type = cpl_property_get_type(property);
297 cpl_msg_warning(__func__,
"Type of property %s is %s but should be %s",
298 aName, cpl_type_get_name(type), cpl_type_get_name(aType));
299 return CPL_ERROR_TYPE_MISMATCH;
301 return CPL_ERROR_NONE;
306 for (i = 0; i < cpl_propertylist_get_size(list); i++) {
307 cpl_property *prop = cpl_propertylist_get(list, i);
308 cpl_property *
property =
309 cpl_propertylist_get_property(aHeader, cpl_property_get_name(prop));
310 if (aDescription != NULL && strlen(aDescription)>0) {
311 rc = cpl_property_set_comment(property, aDescription);
313 cpl_type type = cpl_property_get_type(property);
315 cpl_msg_warning(__func__,
"Type of property %s is %s but should be %s",
316 aName, cpl_type_get_name(type), cpl_type_get_name(aType));
317 cpl_propertylist_delete(list);
318 return CPL_ERROR_TYPE_MISMATCH;
321 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.