00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifdef HAVE_CONFIG_H
00029 #include <config.h>
00030 #endif
00031
00032 #include <fors_photometry_impl.h>
00033 #include <fors_dfs.h>
00034 #include <fors_utils.h>
00035
00036 #include <cpl.h>
00037
00038 static int fors_photometry_create(cpl_plugin *);
00039 static int fors_photometry_exec(cpl_plugin *);
00040 static int fors_photometry_destroy(cpl_plugin *);
00041
00062 int cpl_plugin_get_info(cpl_pluginlist *list)
00063 {
00064 cpl_recipe *recipe = cpl_calloc(1, sizeof *recipe );
00065 cpl_plugin *plugin = &recipe->interface;
00066
00067 if (FORS_BINARY_VERSION != fors_get_version_binary())
00068 {
00069 cpl_msg_error(cpl_func,
00070 "I am fors_photometry version %d, but I am linking "
00071 "against the FORS library version %d. "
00072 "This will not work. "
00073 "Please remove all previous installations "
00074 "of the " PACKAGE_NAME " and try again.",
00075 FORS_BINARY_VERSION, fors_get_version_binary());
00076 return 1;
00077 }
00078
00079 cpl_plugin_init(plugin,
00080 CPL_PLUGIN_API,
00081 FORS_BINARY_VERSION,
00082 CPL_PLUGIN_TYPE_RECIPE,
00083 fors_photometry_name,
00084 fors_photometry_description_short,
00085 fors_photometry_description,
00086 fors_photometry_author,
00087 fors_photometry_email,
00088 fors_license,
00089 fors_photometry_create,
00090 fors_photometry_exec,
00091 fors_photometry_destroy);
00092
00093 cpl_pluginlist_append(list, plugin);
00094
00095 return 0;
00096 }
00097
00098
00109 static int fors_photometry_create(cpl_plugin *plugin)
00110 {
00111 cpl_recipe *recipe;
00112
00113 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00114 cpl_msg_error(cpl_func,
00115 "CPL error code is set (%s), "
00116 "refusing to create recipe fors_photometry",
00117 cpl_error_get_message());
00118 return 1;
00119 }
00120
00121
00122
00123
00124
00125 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) {
00126 recipe = (cpl_recipe *)plugin;
00127 }
00128 else {
00129 return 1;
00130 }
00131
00132
00133
00134
00135
00136 recipe->parameters = cpl_parameterlist_new();
00137
00138 fors_photometry_define_parameters(recipe->parameters);
00139
00140 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00141 cpl_msg_error(cpl_func,
00142 "Could not create fors_photometry parameters");
00143 return 1;
00144 }
00145
00146 return 0;
00147 }
00148
00149
00158 static int fors_photometry_exec(cpl_plugin *plugin)
00159 {
00160 cpl_recipe *recipe;
00161 cpl_errorstate initial_errorstate = cpl_errorstate_get();
00162
00163 if (cpl_error_get_code() != CPL_ERROR_NONE) {
00164 cpl_msg_error(cpl_func,
00165 "CPL error code is set (%s), "
00166 "refusing to execute recipe fors_photometry",
00167 cpl_error_get_message());
00168 return 1;
00169 }
00170
00171 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) {
00172 recipe = (cpl_recipe *)plugin;
00173 }
00174 else {
00175 return 1;
00176 }
00177
00178 if (recipe->frames == NULL) {
00179 cpl_msg_error(cpl_func,
00180 "Null frameset");
00181 return 1;
00182 }
00183
00184 if (recipe->parameters == NULL) {
00185 cpl_msg_error(cpl_func,
00186 "Null parameter list");
00187 return 1;
00188 }
00189
00190 fors_begin(recipe->frames,
00191 fors_photometry_description_short);
00192
00193 fors_photometry(recipe->frames, recipe->parameters);
00194
00195 return fors_end(recipe->frames, initial_errorstate);
00196 }
00197
00198
00207 static int fors_photometry_destroy(cpl_plugin *plugin)
00208 {
00209 cpl_recipe *recipe;
00210
00211 if (cpl_plugin_get_type(plugin) == CPL_PLUGIN_TYPE_RECIPE) {
00212 recipe = (cpl_recipe *)plugin;
00213 }
00214 else {
00215 return -1;
00216 }
00217
00218 cpl_parameterlist_delete(recipe->parameters);
00219
00220 return 0;
00221 }
00222