2#ifndef AFW_TABLE_Schema_h_INCLUDED
3#define AFW_TABLE_Schema_h_INCLUDED
105 template <
typename T>
116 template <
typename F>
118 _impl->
findAndApply(_aliases->apply(name), std::forward<F>(func));
170 template <
typename T>
180 template <
typename T>
193 template <
typename T>
195 bool doReplace =
false) {
200 template <
typename T>
213 template <
typename F>
216 std::visit(func,
item);
219 template <
typename F>
222 std::visit(func,
item);
267 template <typename T>
384 template <
typename T>
395 template <
typename F>
397 _impl->
findAndApply(_aliases->apply(
join(_name, name)), std::forward<F>(func));
411 template <
typename F>
413 _impl->
findAndApply(_aliases->apply(_name), std::forward<F>(func));
437 template <
typename T>
439 return _impl->
find<T>(_aliases->apply(_name)).key;
449 template <
typename T>
451 return _impl->
find<T>(_aliases->apply(_name)).field;
A simple struct that combines the two arguments that must be passed to most cfitsio routines and cont...
Lifetime-management for memory that goes into FITS memory files.
Mapping class that holds aliases for a Schema.
Tag types used to declare specialized field types.
Defines the fields and offsets for a table.
void forEach(F &func) const
Apply a functor to each SchemaItem in the Schema.
Schema & operator=(Schema &&other)
Key< T > addField(std::string const &name, std::string const &doc, FieldBase< T > const &base, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
friend std::ostream & operator<<(std::ostream &os, Schema const &schema)
Stringification.
Schema()
Construct an empty Schema.
std::size_t getFieldCount() const
The total number of fields.
void disconnectAliases()
Sever the connection between this schema and any others with which it shares aliases.
Schema & operator=(Schema const &other)
std::string join(std::string const &a, std::string const &b, std::string const &c, std::string const &d) const
Schema(Schema const &other)
Copy constructor.
std::string join(std::string const &a, std::string const &b) const
Join strings using the field delimiter appropriate for this Schema.
void setAliasMap(std::shared_ptr< AliasMap > aliases)
Set the alias map.
std::shared_ptr< AliasMap > getAliasMap() const
Return the map of aliases.
bool operator!=(Schema const &other) const
std::set< std::string > getNames(bool topOnly=false) const
Return a set of field names in the schema.
static Schema fromFitsMetadata(daf::base::PropertyList &header, bool stripMetadata=true)
Construct from reading a FITS header.
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
void forEach(F const &func) const
static Schema readFits(std::string const &filename, int hdu=fits::DEFAULT_HDU)
Construct from reading a FITS file.
SubSchema operator[](std::string const &name) const
Look up a (possibly incomplete) name in the Schema.
Key< T > addField(std::string const &name, std::string const &doc, std::string const &units="", FieldBase< T > const &base=FieldBase< T >(), bool doReplace=false)
Add a new field to the Schema, and return the associated Key.
std::size_t hash_value() const noexcept
Return a hash of this object.
void findAndApply(std::string const &name, F &&func) const
Find a SchemaItem by name and run a functor on it.
int contains(Schema const &other, int flags=EQUAL_KEYS) const
Test whether the given schema is a subset of this.
std::size_t getRecordSize() const
Return the raw size of a record in bytes.
std::string join(std::string const &a, std::string const &b, std::string const &c) const
std::size_t getNonFlagFieldCount() const
The number of non-Flag fields.
int compare(Schema const &other, int flags=EQUAL_KEYS) const
Do a detailed equality comparison of two schemas.
void replaceField(Key< T > const &key, Field< T > const &field)
Replace the Field (name/description) for an existing Key.
bool operator==(Schema const &other) const
Equality comparison.
SchemaItem< T > find(std::string const &name) const
Find a SchemaItem in the Schema by name.
ComparisonFlags
Bit flags used when comparing schemas.
@ EQUAL_DOCS
Fields have the same documentation (ordered).
@ IDENTICAL
Everything is the same.
@ EQUAL_NAMES
Fields have the same names (ordered).
@ EQUAL_UNITS
Fields have the same units (ordered).
@ EQUAL_KEYS
Keys have the same types offsets, and sizes.
@ EQUAL_FIELDS
Fields are identical (but aliases may not be).
@ EQUAL_ALIASES
Schemas have identical AliasMaps.
std::size_t getFlagFieldCount() const
The number of Flag fields.
A proxy type for name lookups in a Schema.
std::string join(std::string const &a, std::string const &b) const
Join strings using the field delimiter appropriate for this Schema.
std::string join(std::string const &a, std::string const &b, std::string const &c) const
void apply(F &&func) const
Run functor on the SchemaItem represented by this SubSchema.
std::string join(std::string const &a, std::string const &b, std::string const &c, std::string const &d) const
SubSchema operator[](std::string const &name) const
Return a nested proxy.
void findAndApply(std::string const &name, F &&func) const
Find a nested SchemaItem by name and run a functor on it.
std::set< std::string > getNames(bool topOnly=false) const
Return a set of nested names that start with the SubSchema's prefix.
std::string const & getPrefix() const
Return the prefix that defines this SubSchema relative to its parent Schema.
SchemaItem< T > find(std::string const &name) const
Find a nested SchemaItem by name.
A private implementation class to hide the messy details of Schema.
decltype(auto) findAndApply(std::string const &name, F &&func) const
Find an item by name and run the given functor on it.
std::size_t getRecordSize() const
The size of a record in bytes.
std::size_t getFlagFieldCount() const
The number of Flag fields.
std::size_t getNonFlagFieldCount() const
The number of non-Flag fields.
SchemaItem< T > find(std::string const &name) const
Find an item by name (used to implement Schema::find).
ItemContainer const & getItems() const
Return the vector of SchemaItem variants.
std::size_t getFieldCount() const
The total number of fields.
Class for storing ordered metadata with comments.
const int DEFAULT_HDU
Specify that the default HDU should be read.
decltype(sizeof(void *)) size_t
A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data...
size_t operator()(argument_type const &obj) const noexcept