lsst.afw  13.0-91-g2a3e2ee
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FitsSchemaInputMapper.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #ifndef AFW_TABLE_IO_FitsSchemaInputMapper_h_INCLUDED
3 #define AFW_TABLE_IO_FitsSchemaInputMapper_h_INCLUDED
4 
5 #include "lsst/afw/fits.h"
9 
10 namespace lsst {
11 namespace afw {
12 namespace table {
13 namespace io {
14 
16 public:
18 
19  // Neither copyable nor moveable.
20  FitsColumnReader(FitsColumnReader const &) = delete;
22  FitsColumnReader &operator=(FitsColumnReader const &) = delete;
24 
25  virtual void readCell(BaseRecord &record, std::size_t row, fits::Fits &fits,
26  std::shared_ptr<InputArchive> const &archive) const = 0;
27 
28  virtual ~FitsColumnReader() {}
29 };
30 
35  int column; // column number (0-indexed); -1 for Flag fields
36  int bit; // flag bit number (0-indexed); -1 for non-Flag fields
37  std::string ttype; // name of the field (from TTYPE keys)
38  std::string tform; // FITS column format code (from TFORM keys)
39  std::string tccls; // which field class to use (from our own TCCLS keys)
40  std::string tunit; // field units (from TUNIT keys)
41  std::string doc; // field docs (from comments on TTYPE keys)
42 
43  explicit FitsSchemaItem(int column_, int bit_) : column(column_), bit(bit_) {}
44 };
45 
64 public:
66 
68  FitsSchemaInputMapper(daf::base::PropertyList &metadata, bool stripMetadata);
69 
73  void setArchive(std::shared_ptr<InputArchive> archive);
74 
80  bool readArchive(afw::fits::Fits &fits);
81 
83  bool hasArchive() const;
84 
91  Item const *find(std::string const &ttype) const;
92 
99  Item const *find(int column) const;
100 
105  void erase(Item const *item);
106 
111  void erase(std::string const &ttype);
112 
117  void erase(int column);
118 
122  void customize(std::unique_ptr<FitsColumnReader> reader);
123 
129  Schema finalize();
130 
134  void readRecord(BaseRecord &record, afw::fits::Fits &fits, std::size_t row);
135 
136 private:
137  class Impl;
138  std::shared_ptr<Impl> _impl;
139 };
140 }
141 }
142 }
143 } // namespace lsst::afw::table::io
144 
145 #endif // !AFW_TABLE_IO_FitsSchemaInputMapper_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
A class that describes a mapping from a FITS binary table to an afw::table Schema.
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Definition: fits.h:199
A structure that describes a field as a collection of related strings read from the FITS header...
bool hasArchive() const
Return true if the mapper has an InputArchive.
FitsSchemaInputMapper(daf::base::PropertyList &metadata, bool stripMetadata)
Construct a mapper from a PropertyList of FITS header values, stripping recognized keys if desired...
FitsColumnReader & operator=(FitsColumnReader const &)=delete
Item const * find(std::string const &ttype) const
Find an item with the given column name (ttype), returning nullptr if no such column exists...
Base class for all records.
Definition: BaseRecord.h:29
Schema finalize()
Map any remaining items into regular Schema items, and return the final Schema.
virtual void readCell(BaseRecord &record, std::size_t row, fits::Fits &fits, std::shared_ptr< InputArchive > const &archive) const =0
bool readArchive(afw::fits::Fits &fits)
Set the Archive by reading from the HDU specified by the AR_HDU header entry.
void erase(Item const *item)
Remove the given item (which should have been retrieved via find()) from the mapping, preventing it from being included in the regular fields added by finalize().
void setArchive(std::shared_ptr< InputArchive > archive)
Set the Archive to an externally-provided one, overriding any that may have been read.
void customize(std::unique_ptr< FitsColumnReader > reader)
Customize a mapping by providing a FitsColumnReader instance that will be invoked by readRecords()...
lsst::daf::base::PropertyList PropertyList
Definition: Wcs.cc:56
void readRecord(BaseRecord &record, afw::fits::Fits &fits, std::size_t row)
Fill a record from a FITS binary table row.