IIINSTRUMENT Pipeline Reference Manual 4.4.3
visir_cpl_compat.h
1/* $Id: visir_cpl_compat.h,v 1.3 2013-05-13 16:02:43 jtaylor Exp $
2 *
3 * This file is part of the VISIR Pipeline
4 * Copyright (C) 2013 European Southern Observatory
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
19 */
20
21/*
22 * $Author: jtaylor $
23 * $Date: 2013-05-13 16:02:43 $
24 * $Revision: 1.3 $
25 * $Name: not supported by cvs2svn $
26 */
27
28#ifndef VISIR_CPL_COMPAT_H
29#define VISIR_CPL_COMPAT_H
30
31#ifdef HAVE_CONFIG_H
32#include "config.h"
33#endif
34
35/*-----------------------------------------------------------------------------
36 Includes
37 -----------------------------------------------------------------------------*/
38
39#include <cpl.h>
40
41/*-----------------------------------------------------------------------------
42 Defines
43 -----------------------------------------------------------------------------*/
44
45#if !defined CPL_VERSION_CODE || CPL_VERSION_CODE < CPL_VERSION(6, 0, 0)
46/* cpl < 6, not supported by visir */
47#error CPL too old, at least cpl 6 required
48#endif
49
50#if CPL_VERSION_CODE < CPL_VERSION(6, 1, 0)
51#define CPL_FFT_FIND_MEASURE 0
52#endif
53
54#if CPL_VERSION_CODE < CPL_VERSION(6, 1, 0)
55#define CPL_FITS_START_CACHING
56#define CPL_FITS_RESTART_CACHING
57#define CPL_FITS_STOP_CACHING
58#define cpl_fits_set_mode(x)
59#endif
60
61#if CPL_VERSION_CODE < CPL_VERSION(6, 3, 0)
62#define CPL_IO_COMPRESS_RICE 0
63#endif
64
65
66/*-----------------------------------------------------------------------------
67 Function code
68 -----------------------------------------------------------------------------*/
69
70/* ---------------------------------------------------------------------------*/
79/* ---------------------------------------------------------------------------*/
80static inline cpl_frame *
81visir_frameset_get_frame(cpl_frameset *self, cpl_size position)
82{
83#if CPL_VERSION_CODE >= CPL_VERSION(6, 3, 0)
84 return cpl_frameset_get_position(self, position);
85#else
86 return cpl_frameset_get_frame(self, position);
87#endif
88}
89
90
91/* ---------------------------------------------------------------------------*/
97/* ---------------------------------------------------------------------------*/
98static inline double
99visir_vector_sum(const cpl_vector * vs)
100{
101#if CPL_VERSION_CODE >= CPL_VERSION(6, 3, 0)
102 double sum = cpl_vector_get_sum(vs);
103#else
104 const size_t n = cpl_vector_get_size(vs);
105 const double * data = cpl_vector_get_data_const(vs);
106 double sum = 0;
107 for (size_t j = 0; j < n; j++)
108 sum += data[j];
109#endif
110 return sum;
111}
112
113
114/* ---------------------------------------------------------------------------*/
120/* ---------------------------------------------------------------------------*/
121static inline void
122visir_imagelist_unwrap(cpl_imagelist * list)
123{
124#if CPL_VERSION_CODE >= CPL_VERSION(6, 1, 0)
125 cpl_imagelist_unwrap(list);
126#else
127 for (cpl_size i = cpl_imagelist_get_size(list); i-- > 0;)
128 cpl_imagelist_unset(list, i);
129 cpl_imagelist_delete(list);
130#endif
131}
132
133#endif