Loading [MathJax]/extensions/TeX/AMSsymbols.js
LAL 7.7.0.1-00ddc7f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALCache.h
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 Jolien Creighton
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20#ifndef _LALCACHE_H_
21#define _LALCACHE_H_
22
23#include <stdio.h>
24#include <lal/LALDatatypes.h>
25#include <lal/FileIO.h>
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30#if 0
31} /* to match preceeding brace */
32#endif
33
34/**
35 * \defgroup LALCache_h Header LALCache.h
36 * \ingroup lal_support
37 * \author Creighton, J. D. E.
38 * \date 2007
39 *
40 * \brief This header covers routines to create and manipulate LALCache structures and to read LAL cache files.
41 *
42 * ### Synopsis ###
43 *
44 * \code
45 * #include <lal/LALCache.h>
46 * \endcode
47 *
48 */
49/** @{ */
50struct tagLALCacheEntry;
51struct tagLALCache;
52
53/** An entry in a LAL cache. */
54typedef struct tagLALCacheEntry {
55 CHAR *src; /**< File source field */
56 CHAR *dsc; /**< File description field */
57 INT4 t0; /**< GPS time (seconds) of beginning of data in file */
58 INT4 dt; /**< Duration (seconds) of data in file */
59 CHAR *url; /**< URL of file */
61
62/** The LALCache structure is an array of entries. */
63typedef struct tagLALCache {
66} LALCache;
67
68/** Creates a LALCache structure. */
70
71/** Destroys a LALCache structure. */
72void XLALDestroyCache(LALCache * cache);
73
74/** Duplicates a LALCache structure. */
76
77/** Returns a new LALCache structure that is the merge of two. */
78LALCache *XLALCacheMerge(const LALCache * cache1, const LALCache * cache2);
79
80/** Reads a LAL cache file and produces a LALCache structure. */
81LALCache *XLALCacheFileRead(LALFILE * fp);
82
83/** Reads a LAL cache file and produces a LALCache structure. */
84LALCache *XLALCacheImport(const char *fname);
85
86/**
87 * Globs a directory and construct LALCache from matching entries.
88 * \param [in] dirstr Colon-delimited list of directories.
89 * \param [in] fnptrn Glob pattern for matching files.
90 * \returns LALCache structure.
91 */
92LALCache *XLALCacheGlob(const char *dirstr, const char *fnptrn);
93
94/** Writes a LALCache structure to output LALFILE. */
95int XLALCacheFileWrite(LALFILE * fp, const LALCache * cache);
96
97/** Exports a LALCache structure to an output LAL cache file. */
98int XLALCacheExport(const LALCache * cache, const char *filename);
99
100/** Sorts entries in a LALCache structure. */
101int XLALCacheSort(LALCache * cache);
102
103/**
104 * Prunes duplicate entries keeping the second one; cache is reduced in
105 * length if there are. Entries are duplicates if their metadata are
106 * the same (even if the urls are different
107 */
108int XLALCacheUniq(LALCache * cache);
109
110/**
111 * Selects only matching entries in a LALCache structure -- other entries
112 * are deleted from the LALCache structure.
113 * \param cache *UNDOCUMENTED*
114 * \param t0 Remove entries ending before t0 (0 to disable).
115 * \param t1 Remove entries ending after t1 (0 to disable).
116 * \param srcregex Regular expression to match src field (NULL to disable).
117 * \param dscregex Regular expression to match dsc field (NULL to disable).
118 * \param urlregex Regular expression to match url field (NULL to disable).
119 */
120int XLALCacheSieve(LALCache * cache, INT4 t0, INT4 t1,
121 const char *srcregex, const char *dscregex,
122 const char *urlregex);
123
124/**
125 * Finds the first entry that contains the requested time, or the first entry
126 * after the time if the time is in a gap or before the first entry. Returns
127 * NULL if the time is after the last entry.
128 */
129LALCacheEntry *XLALCacheEntrySeek(const LALCache * cache, double t);
130
131
132/** Open a file identified by an entry in a LALCache structure. */
133LALFILE *XLALCacheEntryOpen(const LALCacheEntry * entry);
134
135/** @} */
136
137#if 0
138{ /* to match succeding brace */
139#endif
140#if defined(__cplusplus)
141}
142#endif
143#endif /* _LALCACHE_H_ */
LALFILE * XLALCacheEntryOpen(const LALCacheEntry *entry)
Open a file identified by an entry in a LALCache structure.
Definition: LALCache.c:663
LALCacheEntry * XLALCacheEntrySeek(const LALCache *cache, double t)
Finds the first entry that contains the requested time, or the first entry after the time if the time...
Definition: LALCache.c:654
void XLALDestroyCache(LALCache *cache)
Destroys a LALCache structure.
Definition: LALCache.c:172
LALCache * XLALCacheFileRead(LALFILE *fp)
Reads a LAL cache file and produces a LALCache structure.
Definition: LALCache.c:225
LALCache * XLALCacheGlob(const char *dirstr, const char *fnptrn)
Globs a directory and construct LALCache from matching entries.
Definition: LALCache.c:314
int XLALCacheFileWrite(LALFILE *fp, const LALCache *cache)
Writes a LALCache structure to output LALFILE.
Definition: LALCache.c:382
int XLALCacheUniq(LALCache *cache)
Prunes duplicate entries keeping the second one; cache is reduced in length if there are.
Definition: LALCache.c:477
LALCache * XLALCacheImport(const char *fname)
Reads a LAL cache file and produces a LALCache structure.
Definition: LALCache.c:252
int XLALCacheExport(const LALCache *cache, const char *filename)
Exports a LALCache structure to an output LAL cache file.
Definition: LALCache.c:408
LALCache * XLALCreateCache(UINT4 length)
Creates a LALCache structure.
Definition: LALCache.c:154
LALCache * XLALCacheDuplicate(const LALCache *cache)
Duplicates a LALCache structure.
Definition: LALCache.c:187
int XLALCacheSort(LALCache *cache)
Sorts entries in a LALCache structure.
Definition: LALCache.c:466
LALCache * XLALCacheMerge(const LALCache *cache1, const LALCache *cache2)
Returns a new LALCache structure that is the merge of two.
Definition: LALCache.c:201
int XLALCacheSieve(LALCache *cache, INT4 t0, INT4 t1, const char *srcregex, const char *dscregex, const char *urlregex)
Selects only matching entries in a LALCache structure – other entries are deleted from the LALCache s...
Definition: LALCache.c:544
char CHAR
One-byte signed integer, see Headers LAL(Atomic)Datatypes.h for more details.
uint32_t UINT4
Four-byte unsigned integer.
int32_t INT4
Four-byte signed integer.
An entry in a LAL cache.
Definition: LALCache.h:54
CHAR * src
File source field.
Definition: LALCache.h:55
CHAR * dsc
File description field.
Definition: LALCache.h:56
CHAR * url
URL of file.
Definition: LALCache.h:59
INT4 t0
GPS time (seconds) of beginning of data in file.
Definition: LALCache.h:57
INT4 dt
Duration (seconds) of data in file.
Definition: LALCache.h:58
The LALCache structure is an array of entries.
Definition: LALCache.h:63
UINT4 length
Definition: LALCache.h:64
LALCacheEntry * list
Definition: LALCache.h:65
FILE * fp
Definition: tconvert.c:105