IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ticket #160: psMetadata.h

File psMetadata.h, 5.0 KB (added by Paul Price, 22 years ago)

Header file for psMetadata

Line 
1#if !defined(PS_META_DATA_H)
2#define PS_META_DATA_H 1
3
4/** \file psMetadata.h
5 * \brief Metadata handling structures and functions
6 * \ingroup AstroGroup
7 */
8
9/** Possible types of metadata. */
10typedef enum { ///< type of val is:
11 PS_META_ITEM_SET = 0, ///< NULL; metadata is in psMetadataType.items
12 PS_META_S32, ///< int (.i)
13 PS_META_F32, ///< float (.f)
14 PS_META_F64, ///< float (.f)
15 PS_META_STR, ///< string (.v)
16 PS_META_IMG, ///< image (.v)
17 PS_META_JPEG, ///< JPEG (.v)
18 PS_META_PNG, ///< PNG (.v)
19 PS_META_ASTROM, ///< astrometric coefficients (.v)
20 PS_META_UNKNOWN, ///< other (.v)
21 PS_META_NTYPE ///< Number of types; must be last
22} psMetadataType;
23
24/** A struct to define a single item of metadata */
25typedef struct {
26 const int id; ///< unique ID for this item
27 const char *name; ///< Name of item
28 psMetadataType type; ///< type of this item
29 const union {
30 psS32 S32; ///< integer value
31 psF32 F32; ///< floating value
32 psF64 F64; ///< double value
33 void *void; ///< other type
34 } data; ///< value of metadata
35 char *comment; ///< optional comment ("", not NULL)
36 psDlist *items; ///< list of psMetadataItems with the same name
37} psMetadataItem;
38
39/** A set of metadata */
40typedef struct {
41 psDlist *list; ///< list of psMetadataItem
42 psHash *table; ///< hash table of the same metadata
43} psMetadata;
44
45/** Functions **************************************************************/
46/** \addtogroup AstroGroup Astronomy-Specific Utilities
47 * \{
48 */
49
50/** Constructor */
51psMetadataItem *psMetadataItemAlloc(const char *name, ///< name of new item of metadata (sprintf format)
52 psMetadataType type, ///< type of this piece of metadata
53 const char *comment, ///< comment associated with item
54 ...) ///< arguments for name and data
55;
56
57psMetadataItem *psMetadataItemAllocV(const char *name, ///< name of new item of metadata (sprintf format)
58 psMetadataType type, ///< type of this piece of metadata
59 const char *comment, ///< comment associated with item
60 va_list ap) ///< arguments for name and data
61;
62
63/** Constructor */
64psMetadata *psMetadataAlloc(void) ///< make a new set of metadata
65;
66
67/**** Utilities **********************************************************************/
68
69/// Add item to the end of the metadata
70bool *psMetadataAddItem(psMetadata *md, ///< metadata to add to
71 int location, ///< Where to add item
72 psMetadataItem *item) ///< Metatdata item to add
73;
74
75/// Add item to the end of the metadata. Combines psMetadataItemAlloc and psMetadataAppendItem
76bool *psMetadataAdd(psMetadata *md, ///< Metadata to add to
77 int location, ///< Where to add item
78 const char *name, ///< name of new item of metadata (sprintf format)
79 int format, ///< type of this piece of metadata + flags
80 const char *comment, ///< comment associated with item
81 ...) ///< possible arguments for name format
82;
83
84/// delete item from the metadata
85bool *psMetadataRemove(psMetadata *md, ///< metadata to delete from
86 int location, ///< Where to remove
87 const char *key ///< Key to delete
88 );
89
90/// find the metadata with the specified key
91psMetadataItem *psMetadataLookup(const psMetadata *md, ///< metadata to look up
92 const char *key ///< Key to find
93 );
94
95/// retrieve the metadata on the basis of entry position
96psMetadataItem *psMetadataGet(const psMetadata *md, ///< metadata to look up
97 int location ///< entry position
98 );
99
100/// reset the iterator to the start of the list
101void psMetadataSetIterator(psMetadata *md, ///< metadata to set iterator for
102 int iterator, ///< Which iterator to set
103 int location ///< Where to set iterator
104 );
105
106/// get the next item in the sequence
107psMetadataItem *psMetadataGetNext(psMetadata *md, ///< metadata to get from
108 const char *match, ///< String to match
109 int iterator ///< Which iterator to use
110 );
111
112/// get the next item in the sequence
113psMetadataItem *psMetadataGetPrevious(psMetadata *md, ///< metadata to get from
114 const char *match, ///< String to match
115 int iterator ///< Which iterator to use
116 );
117
118/// print metadata item to the specified stream
119void psMetadataItemPrint(FILE *fd, ///< file descriptor to write to
120 const char *format, ///< Format of output
121 const psMetadataItem *md ///< item of metadata to print
122 );
123
124/// Read only header from image file.
125psMetadata *
126psMetadataReadHeader(psMetadata *out, ///< read data to this structure
127 const char *ext, ///< MEF extension name ("PHU" for primary header)
128 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
129 const char *file) ///< file to read from
130;
131
132/// Read only header from image file descriptor.
133psMetadata *
134psMetadataFReadHeader(psMetadata *out, ///< read data to this structure
135 const char *ext, ///< MEF extension name ("PHU" for primary header)
136 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1)
137 FILE *f) ///< file descriptor to read from
138;
139
140/* \} */ // End of AstroGroup Functions
141#endif