File: cpl_type.h

package info (click to toggle)
cpl 7.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,808 kB
  • sloc: ansic: 132,627; javascript: 6,382; sh: 4,232; makefile: 637
file content (289 lines) | stat: -rw-r--r-- 6,197 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
/*
 * This file is part of the ESO Common Pipeline Library
 * Copyright (C) 2001-2017 European Southern Observatory
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef CPL_TYPE_H
#define CPL_TYPE_H

#include <cxtypes.h>
#include <cpl_macros.h>

CPL_BEGIN_DECLS

/**@{*/

/**
 * @ingroup cpl_type
 *
 * @brief
 *   The CPL type codes and flags.
 */

enum _cpl_type_ {

    /* flags */

    /**
     * Flag indicating whether a type is an array or a basic type.
     * @hideinitializer
     */
    CPL_TYPE_FLAG_ARRAY  = 1 << 0,

    /* Padded for future extensions */

    /* types */

    /**
     * Invalid or undetermined type.
     * @hideinitializer
     */
    CPL_TYPE_INVALID     = 1 << 4,

    /**
     * Type code corresponding to type @c char.
     * @hideinitializer
     */
    CPL_TYPE_CHAR        = 1 << 5,

    /**
     * Type code corresponding to type @c unsigned char.
     * @hideinitializer
     */
    CPL_TYPE_UCHAR       = 1 << 6,

    /**
     * Type code corresponding to the boolean type.
     * @hideinitializer
     */
    CPL_TYPE_BOOL        = 1 << 7,

    /**
     * Type code corresponding to type @c short.
     * @hideinitializer
     */
    CPL_TYPE_SHORT       = 1 << 8,

    /**
     * Type code corresponding to type @c unsigned short.
     * @hideinitializer
     */
    CPL_TYPE_USHORT      = 1 << 9,

    /**
     * Type code corresponding to type @c int.
     * @hideinitializer
     */
    CPL_TYPE_INT         = 1 << 10,

    /**
     * Type code corresponding to type @c unsigned int.
     * @hideinitializer
     */
    CPL_TYPE_UINT        = 1 << 11,

    /**
     * Type code corresponding to type @c long.
     * @hideinitializer
     */
    CPL_TYPE_LONG        = 1 << 12,

    /**
     * Type code corresponding to type @c unsigned long.
     * @hideinitializer
     */
    CPL_TYPE_ULONG       = 1 << 13,

    /**
     * Type code corresponding to type @c long @c long.
     * @hideinitializer
     */
    CPL_TYPE_LONG_LONG   = 1 << 14,

    /**
     * Type code corresponding to type @c cpl_size
     * @hideinitializer
     */
    CPL_TYPE_SIZE        = 1 << 15,

    /**
     * Type code corresponding to type @c float.
     * @hideinitializer
     */
    CPL_TYPE_FLOAT       = 1 << 16,

    /**
     * Type code corresponding to type @c double.
     * @hideinitializer
     */
    CPL_TYPE_DOUBLE      = 1 << 17,

    /**
     * Type code corresponding to a pointer type.
     * @hideinitializer
     */
    CPL_TYPE_POINTER     = 1 << 18,

    /**
     * Type code corresponding to a complex type.
     * @hideinitializer
     */
    CPL_TYPE_COMPLEX     = 1 << 19,

    /**
     * Type code to be used for inheritance of original FITS type.
     * @hideinitializer
     */
    CPL_TYPE_UNSPECIFIED = 1 << 20,

    /**
     * Type code corresponding to type @c cpl_bitmask
     * @hideinitializer
     */
    CPL_TYPE_BITMASK     = 1 << 21,

    /**
     * Type code corresponding to a character array.
     * @hideinitializer
     */
    CPL_TYPE_STRING  = (CPL_TYPE_CHAR | CPL_TYPE_FLAG_ARRAY),

    /**
     * Type code corresponding to type @c float complex.
     * @hideinitializer
     */
    CPL_TYPE_FLOAT_COMPLEX = (CPL_TYPE_FLOAT | CPL_TYPE_COMPLEX),

    /**
     * Type code corresponding to type @c double complex.
     * @hideinitializer
     */
    CPL_TYPE_DOUBLE_COMPLEX = (CPL_TYPE_DOUBLE | CPL_TYPE_COMPLEX)
};


/**
 * @ingroup cpl_type
 *
 * @brief
 *   The type code type.
 */

typedef enum _cpl_type_ cpl_type;


enum _cpl_boolean_ {
    CPL_FALSE = 0,
    CPL_TRUE = !CPL_FALSE
};

typedef enum _cpl_boolean_ cpl_boolean;

/**
 * @ingroup cpl_type
 *
 * @brief The type used for sizes and indices in CPL
 */

#if defined CPL_SIZE_BITS && CPL_SIZE_BITS == 32

typedef int cpl_size; /* The type as is was up to CPL 5.3 */

#else

typedef long long cpl_size;

#endif

#include <stdint.h>

/*----------------------------------------------------------------------------*/
/**
 * 
 * @brief The CPL bitmask type for bitmask operations
 * @note The CPL bitmask is currently used only for bit-wise operations on CPL
 * images of integer pixel type, which are 32-bits wide.
 * For forward compatibility the CPL bitmask is 64 bits wide, which is cast to
 * 32 bits when used with a CPL_TYPE_INT.
 */
/*----------------------------------------------------------------------------*/
typedef uint64_t cpl_bitmask;

/**
 * @def CPL_SIZE_MIN
 *
 * @hideinitializer
 * @ingroup cpl_type
 *
 * @brief
 *   Minimum value a variable of type @em cpl_size can hold.
 */

/**
 * @def CPL_SIZE_MAX
 *
 * @hideinitializer
 * @ingroup cpl_type
 *
 * @brief
 *   Maximum value a variable of type @em cpl_size can hold.
 */

#if defined CPL_SIZE_BITS && CPL_SIZE_BITS == 32

#define CPL_SIZE_MIN (CX_MININT)
#define CPL_SIZE_MAX (CX_MAXINT)

#else

#define CPL_SIZE_MIN (LLONG_MIN)
#define CPL_SIZE_MAX (LLONG_MAX)

#endif


/**
 * @hideinitializer
 * @ingroup cpl_type
 *
 * @brief The format specifier for the type cpl_size 
 * @note It is "ld" when cpl_size is a @c long int and "d" when it is an @c int
 * @see cpl_size
 *
 * It can be used like this:
 *  @code
 *    cpl_size i = my_index();
 *
 *    return cpl_sprintf("The index is %" CPL_SIZE_FORMAT "\n", i);
 *
 * @endcode
 */
#if defined CPL_SIZE_BITS && CPL_SIZE_BITS == 32
#define CPL_SIZE_FORMAT "d"
#else
#define CPL_SIZE_FORMAT "lld"
#endif

/**@}*/

size_t cpl_type_get_sizeof(cpl_type type) CPL_ATTR_CONST;

const char * cpl_type_get_name(cpl_type type);

CPL_END_DECLS

#endif /* CPL_TYPE_H */