2 #ifndef AFW_TABLE_SchemaMapper_h_INCLUDED 3 #define AFW_TABLE_SchemaMapper_h_INCLUDED 35 return _impl->_output.addField(newField, doReplace);
89 template <
typename Predicate>
120 template <
typename T>
124 template <
typename T>
140 template <
typename F>
143 std::for_each(_impl->_map.begin(), _impl->_map.end(), visitor);
189 SchemaMapper&
operator=(SchemaMapper
const& other);
200 static std::vector<SchemaMapper>
join(
201 std::vector<Schema>
const& inputs,
202 std::vector<std::string>
const& prefixes = std::vector<std::string>());
205 template <
typename Predicate>
206 struct AddMappingsWhere {
207 template <
typename T>
209 if (predicate(item)) mapper->addMapping(item.
key, doReplace);
212 AddMappingsWhere(SchemaMapper* mapper_, Predicate predicate_,
bool doReplace_)
213 : mapper(mapper_), predicate(predicate_), doReplace(doReplace_) {}
215 SchemaMapper* mapper;
222 std::unique_ptr<Impl> _impl;
225 template <
typename Predicate>
227 _impl->_input.forEach(AddMappingsWhere<Predicate>(
this, predicate, doReplace));
233 #endif // !AFW_TABLE_SchemaMapper_h_INCLUDED Defines the fields and offsets for a table.
A functor-wrapper used in the implementation of SchemaMapper::forEach.
Key< T > getMapping(Key< T > const &inputKey) const
Return the output Key corresponding to the given input Key, or raise NotFoundError.
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.
void forEach(F &&func) const
Call the given functor for each key pair in the mapper.
SchemaMapper()
Construct an empty mapper; useless unless you assign a fully-constructed one to it.
Schema const getInputSchema() const
Return the input schema (copy-on-write).
A mapping between the keys of two Schemas, used to copy data between them.
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.
Schema const getOutputSchema() const
Return the output schema (copy-on-write).
A private implementation class to hide the messy details of SchemaMapper.
SchemaMapper & operator=(SchemaMapper const &other)
Assignement (copy-on-write).
A base class for image defects.
void addMappingsWhere(Predicate predicate, bool doReplace=true)
Add mappings for all fields that match criteria defined by a predicate.
A description of a field in a table.
bool isMapped(Key< T > const &inputKey) const
Return true if the given input Key is mapped to an output Key.
Schema & editOutputSchema()
Return a reference to the output schema that allows it to be modified in place.
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.
A class used as a handle to a particular field in a table.
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.
static SchemaMapper removeMinimalSchema(Schema const &input, Schema const &minimal)
Create a mapper by removing fields from the front of a schema.
A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data...