2#ifndef AFW_TABLE_SchemaMapper_h_INCLUDED
3#define AFW_TABLE_SchemaMapper_h_INCLUDED
35 return _impl->_output.addField(newField, doReplace);
97 template <
typename Predicate>
128 template <
typename T>
132 template <
typename T>
149 template <
typename F>
151 for (
auto const & item : _impl->_map) {
152 std::visit([&func](
auto const & pair) { func(pair.first, pair.second); }, item);
155 template <
typename F>
157 for (
auto const & item : _impl->_map) {
158 std::visit([&func](
auto const & pair) { func(pair.first, pair.second); }, item);
226 template <
typename Predicate>
227 struct AddMappingsWhere {
228 template <
typename T>
230 if (predicate(item))
mapper->addMapping(item.
key, doReplace);
233 AddMappingsWhere(
SchemaMapper* mapper_, Predicate predicate_,
bool doReplace_)
234 :
mapper(mapper_), predicate(predicate_), doReplace(doReplace_) {}
241 using Impl = detail::SchemaMapperImpl;
246template <
typename Predicate>
248 _impl->_input.forEach(AddMappingsWhere<Predicate>(
this, predicate, doReplace));
A class used as a handle to a particular field in a table.
Defines the fields and offsets for a table.
A mapping between the keys of two Schemas, used to copy data between them.
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
SchemaMapper()
Construct an empty mapper; useless unless you assign a fully-constructed one to it.
SchemaMapper & operator=(SchemaMapper const &other)
Assignment (copy-on-write).
Key< T > addMapping(Key< T > const &inputKey, char const *outputName, bool doReplace=true)=delete
This deliberately deleted overload ensures we don't accidentally cast string literals to bool.
void forEach(F &func) const
Call the given functor for each key pair in the mapper.
Key< T > addOutputField(Field< T > const &newField, bool doReplace=false)
Add a new field to the output Schema that is not connected to the input Schema.
Key< T > addMapping(Key< T > const &inputKey, bool doReplace=false)
Add a new field to the output Schema that is a copy of a field in the input Schema.
static SchemaMapper removeMinimalSchema(Schema const &input, Schema const &minimal)
Create a mapper by removing fields from the front of a schema.
static std::vector< SchemaMapper > join(std::vector< Schema > const &inputs, std::vector< std::string > const &prefixes=std::vector< std::string >())
Combine a sequence of schemas into one, creating a SchemaMapper for each.
void forEach(F const &func) const
Schema & editOutputSchema()
Return a reference to the output schema that allows it to be modified in place.
Key< T > getMapping(Key< T > const &inputKey) const
Return the output Key corresponding to the given input Key, or raise NotFoundError.
bool isMapped(Key< T > const &inputKey) const
Return true if the given input Key is mapped to an output Key.
void addMinimalSchema(Schema const &minimal, bool doMap=true)
Add the given minimal schema to the output schema.
void invert()
Swap the input and output schemas in-place.
Schema const getInputSchema() const
Return the input schema (copy-on-write).
void addMappingsWhere(Predicate predicate, bool doReplace=true)
Add mappings for all fields that match criteria defined by a predicate.
class[[deprecated("Removed with no replacement (but see lsst::afw::image::TransmissionCurve). Will be " "removed after v22.")]] FilterProperty final
Describe the properties of a Filter (e.g.
A base class for image defects.
A description of a field in a table.
A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data...