UVES Pipeline Reference Manual  5.4.6
uves_recipe.h
1 /*
2  * This file is part of the ESO UVES Pipeline
3  * Copyright (C) 2004,2005 European Southern Observatory
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
18  */
19 
20 /*
21  * $Author: amodigli $
22  * $Date: 2010-09-24 09:32:07 $
23  * $Revision: 1.15 $
24  * $Name: not supported by cvs2svn $
25  * $Log: not supported by cvs2svn $
26  * Revision 1.13 2008/03/28 08:56:19 amodigli
27  * IRPLIB_RECIPE_DEFINE-->UVES_IRPLIB_RECIPE_DEFINE IRPLIB_CONCAT2X UVES_CONCAT2X irplib_plugin-->uves_plugin
28  *
29  * Revision 1.12 2007/06/06 08:17:33 amodigli
30  * replace tab with 4 spaces
31  *
32  * Revision 1.11 2007/02/09 15:10:42 jmlarsen
33  * Show recipe name correctly
34  *
35  * Revision 1.10 2007/02/09 13:40:11 jmlarsen
36  * Added year 2007
37  *
38  * Revision 1.9 2007/01/10 12:39:44 jmlarsen
39  * Replace UVES_TFLAT_ID with recipe name parameter
40  *
41  * Revision 1.8 2006/11/16 14:10:49 jmlarsen
42  * Fixed usage of recipe name string in error message
43  *
44  * Revision 1.7 2006/11/15 15:02:15 jmlarsen
45  * Implemented const safe workarounds for CPL functions
46  *
47  * Revision 1.5 2006/11/15 14:04:08 jmlarsen
48  * Removed non-const version of parameterlist_get_first/last/next which is already
49  * in CPL, added const-safe wrapper, unwrapper and deallocator functions
50  *
51  * Revision 1.4 2006/10/24 14:01:21 jmlarsen
52  * include uves_msg.h
53  *
54  * Revision 1.3 2006/10/17 12:33:08 jmlarsen
55  * Added semicolon at UVES_RECIPE_DEFINE invocation
56  *
57  * Revision 1.2 2006/10/10 14:43:48 jmlarsen
58  * Add semicolon at invocation of IRPLIB_RECIPE_DEFINE
59  *
60  * Revision 1.1 2006/10/09 13:01:33 jmlarsen
61  * Use macro to define recipe interface functions
62  *
63  * Revision 1.3 2005/12/19 16:17:55 jmlarsen
64  * Replaced bool -> int
65  *
66  */
67 
68 #ifndef UVES_RECIPE_H
69 #define UVES_RECIPE_H
70 
71 #include <uves_msg.h>
72 #include <uves_error.h>
73 #include <uves_plugin.h>
74 #include <cpl.h>
75 
76 /*-----------------------------------------------------------------------------
77  Defines
78  -----------------------------------------------------------------------------*/
79 #define UVES_RECIPE_DEFINE(NAME, MSG_DOMAIN, FILL_PARAMS_FUNC, \
80  AUTHOR, AUTHOR_EMAIL, \
81  SYNOPSIS, DESCRIPTION) \
82  UVES_IRPLIB_RECIPE_DEFINE(NAME, UVES_BINARY_VERSION, \
83  FILL_PARAMS_FUNC(recipe->parameters), \
84  AUTHOR, AUTHOR_EMAIL, "2004, 2005, 2006, 2007", SYNOPSIS, DESCRIPTION); \
85  \
86 static void UVES_CONCAT2X(NAME,exe)(cpl_frameset *, \
87  const cpl_parameterlist *, \
88  const char *starttime); \
89  \
90 /* This is the UVES pipeline specific (but common to all recipes) \
91  code to run before/after executing each recipe. It calls the function \
92  uves_rrrecipe_exe(frames, parameters, starttime) declared above. */ \
93  \
94 static int NAME(cpl_frameset *frames, \
95  const cpl_parameterlist *parameters) \
96 { \
97  char *starttime = NULL; \
98  \
99  /* Error handling (irplib) was already initialized */ \
100  \
101  /* Initialize messaging */ \
102  uves_msg_init(-1, MSG_DOMAIN); /* -1 = max level */ \
103  \
104  /* Initialize recipe */ \
105  check( (uves_msg_louder(), \
106  starttime = uves_initialize(frames, parameters, make_str(NAME), \
107  SYNOPSIS), \
108  uves_msg_softer()), \
109  "Initialization failed"); \
110  \
111  /* Recipe specific actions */ \
112  check( (uves_msg_louder(), \
113  UVES_CONCAT2X(NAME,exe)(frames, parameters, starttime), \
114  uves_msg_softer()), \
115  MSG_DOMAIN " execution failed"); \
116  \
117  /* Terminate recipe */ \
118  check( uves_end(make_str(NAME), frames), "Termination failed"); \
119  \
120  cleanup: \
121  cpl_free(starttime); \
122  \
123  return (cpl_error_get_code() == CPL_ERROR_NONE) ? 0 : 1; \
124 } \
125  /* This dummy declaration requires the macro to be invoked as if it was \
126  a kind of function declaration, with a terminating ; */ \
127 extern int uves_recipe_end
128 
129 
130 #endif