00001 /* @file pmConcepts.h 00002 * @brief Top-level functions for defining, registering, reading and writing concepts 00003 * 00004 * @author Paul Price, IfA 00005 * 00006 * @version $Revision: 1.11 $ $Name: $ 00007 * @date $Date: 2007/01/24 02:54:14 $ 00008 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 00009 */ 00010 00011 #ifndef PM_CONCEPTS_H 00012 #define PM_CONCEPTS_H 00013 00014 /// @addtogroup Concepts Data Abstraction Concepts 00015 /// @{ 00016 00017 #include <pslib.h> 00018 #include "pmFPA.h" 00019 #include "pmFPALevel.h" 00020 00021 /// Function to call to parse a concept once it has been read 00022 typedef psMetadataItem* (*pmConceptParseFunc)(const psMetadataItem *concept, ///< Concept to parse 00023 const psMetadataItem *pattern, ///< Pattern for parsing 00024 const psMetadata *cameraFormat, ///< Camera format definition 00025 const pmFPA *fpa, ///< FPA for concept, or NULL 00026 const pmChip *chip, ///< Chip for concept, or NULL 00027 const pmCell *cell ///< Cell for concept, or NULL 00028 ); 00029 00030 /// Function to call to format a concept for writing 00031 typedef psMetadataItem* (*pmConceptFormatFunc)(const psMetadataItem *concept, ///< Concept to format 00032 const psMetadata *cameraFormat, ///< Camera format definition 00033 const pmFPA *fpa, ///< FPA for concept, or NULL 00034 const pmChip *chip, ///< Chip for concept, or NULL 00035 const pmCell *cell ///< Cell for concept, or NULL 00036 ); 00037 00038 /// A "concept" specification 00039 /// 00040 /// Defines the name, default comment, blank value, and functions to parse (after reading) and format (before 00041 /// writing) the concept. 00042 typedef struct 00043 { 00044 psMetadataItem *blank; ///< Blank value of concept; also contains the name and comment 00045 pmConceptParseFunc parse; ///< Function to call to read the concept 00046 pmConceptFormatFunc format; ///< Function to call to write the concept 00047 } 00048 pmConceptSpec; 00049 00050 /// Allocator for pmConceptSpec 00051 pmConceptSpec *pmConceptSpecAlloc(psMetadataItem *blank, ///< Blank value; contains the name 00052 pmConceptParseFunc parse, ///< Function to call to parse the concept 00053 pmConceptFormatFunc format ///< Function to call to format the concept 00054 ); 00055 00056 /// Register a new concept for parsing and formatting 00057 /// 00058 /// Defines a new concept, based on the blank value (with name and default comment), and functions to parse 00059 /// and format the concept. The new concept is registered at the specified level (FPA, chip or cell). If the 00060 /// parse function is NULL, then a default parse function is used, which performs minimal parsing. Similarly 00061 /// for the format function. 00062 bool pmConceptRegister(psMetadataItem *blank, ///< Blank value; contains the name and default comment 00063 pmConceptParseFunc parse, ///< Function to call to parse the concept, or NULL 00064 pmConceptFormatFunc format, ///< Function to call to format the concept, or NULL 00065 pmFPALevel level ///< Level at which to store concept in the FPA hierarchy 00066 ); 00067 00068 /// Source for concepts when reading and writing. 00069 /// 00070 /// Since some sources become available at different times from others, we need to provide some specificity to 00071 /// reading and writing concepts (or we're forced to wait until everything's available, which we don't want to 00072 /// do). Concepts may be read from or written to multiple sources at once by OR-ing them. 00073 typedef enum { 00074 PM_CONCEPT_SOURCE_NONE = 0x00, ///< No concepts 00075 PM_CONCEPT_SOURCE_CELLS = 0x01, ///< Concept comes from the camera information 00076 PM_CONCEPT_SOURCE_DEFAULTS = 0x02, ///< Concept comes from defaults 00077 PM_CONCEPT_SOURCE_PHU = 0x04, ///< Concept comes from PHU 00078 PM_CONCEPT_SOURCE_HEADER = 0x08, ///< Concept comes from FITS header 00079 PM_CONCEPT_SOURCE_DATABASE = 0x10, ///< Concept comes from database 00080 PM_CONCEPT_SOURCE_ALL = 0xff ///< All concepts 00081 } pmConceptSource; 00082 00083 /// Get a list of defined concepts for a particular level. 00084 psList *pmConceptsList(pmFPALevel level); 00085 00086 /// Read the concepts for the given set of fpa, chip, cell 00087 /// 00088 /// Attempts to read as many concepts as possible from the specified source for the specified FPA, chip and 00089 /// cell. That is, it will read chip- and cell-level concepts in addition to fpa-level concepts, if the chip 00090 /// and cell are provided. 00091 bool pmConceptsRead(pmFPA *fpa, ///< FPA for which to read concepts 00092 pmChip *chip, ///< Chip for which to read concepts, or NULL 00093 pmCell *cell, ///< Cell for which to read concepts, or NULL 00094 pmConceptSource source, ///< The source of the concepts to read 00095 psDB *db ///< Database handle 00096 ); 00097 00098 /// Set the concepts within the FPA to the blank value 00099 bool pmConceptsBlankFPA(pmFPA *fpa ///< FPA for which to set blank concepts 00100 ); 00101 00102 /// Read concepts for an FPA; optionally, read concepts at all lower levels. 00103 /// 00104 /// Once concepts should be available for reading at the FPA-level, this function attempts to read the 00105 /// concepts from the specified source. It also allows concepts to be read at lower levels by iterating over 00106 /// the components. 00107 bool pmConceptsReadFPA(pmFPA *fpa, ///< FPA for which to read concepts 00108 pmConceptSource source, ///< Source for concepts 00109 bool propagateDown, ///< Propagate to lower levels? 00110 psDB *db ///< Database handle 00111 ); 00112 00113 /// Write concepts for an FPA; optionally, write concepts at all lower levels. 00114 /// 00115 /// This function writes all concepts for the FPA to the specified "source". It also allows concepts to be 00116 /// written for all lower levels by iterating over the components. 00117 bool pmConceptsWriteFPA(const pmFPA *fpa, ///< FPA for which to write concepts 00118 pmConceptSource source, ///< Source for concepts 00119 bool propagateDown, ///< Propagate to lower levels? 00120 psDB *db ///< Database handle 00121 ); 00122 00123 /// Set the concepts within the chip to the blank value 00124 bool pmConceptsBlankChip(pmChip *chip ///< FPA for which to set blank concepts 00125 ); 00126 00127 /// Read concepts for a chip; optionally, read concepts at the FPA and cell levels. 00128 /// 00129 /// Once concepts should be available for reading at the FPA-level, this function attempts to read the 00130 /// concepts from the specified source. It also allows concepts to be read at the fpa level (through the 00131 /// parent), and the cell level by iterating over the components. 00132 bool pmConceptsReadChip(pmChip *chip, ///< Chip for which to read concepts 00133 pmConceptSource source, ///< Source for concepts 00134 bool propagateUp, ///< Propagate to higher levels? 00135 bool propagateDown, ///< Propagate to lower levels? 00136 psDB *db ///< Database handle 00137 ); 00138 00139 /// Write concepts for a chip; optionally, write concepts at the FPA and cell levels. 00140 /// 00141 /// This function writes all concepts for the chip to the specified "source". It also allows concepts to be 00142 /// written for the FPA, and the cell level by iterating over the components. 00143 bool pmConceptsWriteChip(const pmChip *chip, ///< Chip for which to write concepts 00144 pmConceptSource source, ///< Source for concepts 00145 bool propagateUp,///< Propagate to higher levels? 00146 bool propagateDown, ///< Propagate to lower levels? 00147 psDB *db ///< Database handle 00148 ); 00149 00150 /// Set the concepts within the cell to the blank value 00151 bool pmConceptsBlankCell(pmCell *cell ///< Cell for which to set blank concepts 00152 ); 00153 00154 /// Read concepts for a cell; optionally, read concepts for the parents. 00155 /// 00156 /// Once concepts should be available for reading at the FPA-level, this function attempts to read the 00157 /// concepts from the specified source. It also allows concepts to be read at upper levels through the 00158 /// parents (note, it would not read concepts for all chips, but only the parent of this cell). 00159 bool pmConceptsReadCell(pmCell *cell, ///< Cell for which to read concepts 00160 pmConceptSource source, ///< Source for concepts 00161 bool propagateUp, ///< Propagate to higher levels? 00162 psDB *db ///< Database handle 00163 ); 00164 00165 /// Write concepts for a cell; optionally, write concepts for the parents. 00166 /// 00167 /// This function writes all concepts for the chip to the specified "source". It also allows concepts to be 00168 /// written for the upper levels through the parents (note, it would not write concepts for all chips, but 00169 /// only the parent of this cell). 00170 bool pmConceptsWriteCell(const pmCell *cell, ///< FPA for which to write concepts 00171 pmConceptSource source, ///< Source for concepts 00172 bool propagateUp, ///< Propagate to higher levels? 00173 psDB *db ///< Database handle 00174 ); 00175 00176 /// Initialise the concepts system. 00177 /// 00178 /// Register the standard concepts, so that concepts may be read and written. This function is called 00179 /// automatically the first time the concepts functions are used. 00180 bool pmConceptsInit(void); 00181 00182 /// Signifies that the user is done with the concepts system. 00183 /// 00184 /// Frees the registered concepts so there is no memory leak when the user checks "persistent" memory. 00185 void pmConceptsDone(void); 00186 00187 /// Copy all the concepts within an FPA to another FPA 00188 /// 00189 /// Iterates over all components of the FPA, and copies the concepts metadata from the source to the target. 00190 bool pmFPACopyConcepts(pmFPA *target, ///< The target FPA 00191 const pmFPA *source ///< The source FPA 00192 ); 00193 /// @} 00194 #endif
1.5.1