SINFONI Pipeline Reference Manual  2.5.2
sinfo_utils.c
1 /* *
2  * This file is part of the ESO SINFONI Pipeline *
3  * Copyright (C) 2004,2005 European Southern Observatory *
4  * *
5  * This library 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  * $Author: amodigli $
21  * $Date: 2012-03-03 10:17:31 $
22  * $Revision: 1.7 $
23  * $Name: not supported by cvs2svn $
24  */
25 
26 #ifdef HAVE_CONFIG_H
27 # include <config.h>
28 #endif
29 
31 /*---------------------------------------------------------------------------*/
38 /*---------------------------------------------------------------------------*/
39 
40 /*----------------------------------------------------------------------------
41  Includes
42  ----------------------------------------------------------------------------*/
43 
44 #include <sinfo_utils.h>
51 /*----------------------------------------------------------------------------
52  Functions prototypes
53  ----------------------------------------------------------------------------*/
54 /*----------------------------------------------------------------------------
55  Implementation
56  ----------------------------------------------------------------------------*/
57 
58 /*---------------------------------------------------------------------------*/
67 /*---------------------------------------------------------------------------*/
68 long
69 sinfo_round_double(double x)
70 {
71  return (x >=0) ? (long)(x+0.5) : (long)(x-0.5);
72 }
78 int
79 sinfo_parameter_get_default_flag ( const cpl_parameter* p )
80 {
81  int flag_gasgano=0;
82  int flag_norm=0;
83  int flag=0;
84  cpl_type type =0;
85 
86  flag_norm = ( cpl_parameter_get_default_flag ( p ) == 0 ) ? 1 : 0;
87  type=cpl_parameter_get_type ( p );
88 
89  switch ( type )
90  {
91  case CPL_TYPE_BOOL:
92  flag_gasgano = ( cpl_parameter_get_default_bool ( p ) ==
93  cpl_parameter_get_bool ( p ) ) ? 1:0;
94  break;
95  case CPL_TYPE_INT:
96  flag_gasgano = ( cpl_parameter_get_default_int ( p ) ==
97  cpl_parameter_get_int ( p ) ) ? 1:0;
98  break;
99  case CPL_TYPE_DOUBLE:
100  flag_gasgano = ( cpl_parameter_get_default_double ( p ) ==
101  cpl_parameter_get_double ( p ) ) ? 1:0;
102  break;
103  case CPL_TYPE_STRING:
104  flag_gasgano = ( cpl_parameter_get_default_string ( p ) ==
105  cpl_parameter_get_string ( p ) ) ? 1:0;
106  break;
107 
108  default:
109  cpl_msg_error (cpl_func, "type not supported" );
110  }
111 
112  flag = ( flag_gasgano && flag_norm ) ? 0 : 1;
113 
114  return flag;
115 }