2 #ifndef AFW_TABLE_DETAIL_SchemaImpl_h_INCLUDED
3 #define AFW_TABLE_DETAIL_SchemaImpl_h_INCLUDED
10 #include "boost/variant.hpp"
11 #include "boost/mpl/transform.hpp"
13 #include "lsst/daf/base/Citizen.h"
67 typedef boost::mpl::transform<FieldTypes, MakeItem>::type
ItemTypes;
69 typedef boost::make_variant_over<ItemTypes>::type
ItemVariant;
73 typedef std::map<std::string, int>
NameMap;
77 typedef std::map<std::pair<int, int>,
int>
FlagMap;
103 template <
typename F>
105 auto iter = _names.find(name);
106 if (iter == _names.end()) {
107 throw LSST_EXCEPT(pex::exceptions::NotFoundError,
108 (boost::format(
"Field with name '%s' not found") % name).str());
111 visitor(_items[iter->second]);
115 std::set<std::string>
getNames(
bool topOnly)
const;
118 std::set<std::string>
getNames(
bool topOnly, std::string
const& prefix)
const;
120 template <
typename T>
124 template <
typename T>
131 template <
typename T>
138 template <
typename T>
152 : daf::base::Citizen(typeid(this)),
167 template <
typename F>
170 template <
typename T>
187 template <
typename T>
197 template <
typename T>
198 Key<T> addFieldImpl(
int elementSize,
int elementCount,
Field<T> const&
field,
bool doReplace);
213 #endif // !AFW_TABLE_DETAIL_SchemaImpl_h_INCLUDED
std::set< std::string > getNames(bool topOnly) const
Return a set of field names (used to implement Schema::getNames).
void replaceField(Key< T > const &key, Field< T > const &field)
Replace the Field in an existing SchemaItem without changing the Key.
void operator()(SchemaItem< T > const &x) const
Call the wrapped function.
VisitorWrapper(T &&func)
Construct the wrapper.
int getFlagFieldCount() const
The number of Flag fields.
std::vector< ItemVariant > ItemContainer
A std::vector whose elements can be any of the allowed SchemaItem types.
boost::mpl::transform< FieldTypes, MakeItem >::type ItemTypes
An MPL sequence of all the allowed SchemaItem templates.
boost::make_variant_over< ItemTypes >::type ItemVariant
A Boost.Variant type that can hold any one of the allowed SchemaItem types.
std::map< int, int > OffsetMap
A map from standard field offsets to position in the vector, so we can do field lookups.
void findAndApply(std::string const &name, F &&func) const
Find an item by name and run the given functor on it.
A description of a field in a table.
table::Key< std::string > name
Tag types used to declare specialized field types.
void operator()(ItemVariant const &v) const
Invoke the visitation.
A private implementation class to hide the messy details of Schema.
ItemContainer const & getItems() const
Return the vector of SchemaItem variants.
A functor-wrapper used in the implementation of Schema::forEach.
A class used as a handle to a particular field in a table.
Key specialization for Flag.
std::map< std::string, int > NameMap
A map from field names to position in the vector, so we can do name lookups.
int getNonFlagFieldCount() const
The number of non-Flag fields.
int getRecordSize() const
The size of a record in bytes.
SchemaImpl()
Default constructor.
std::map< std::pair< int, int >, int > FlagMap
A map from Flag field offset/bit pairs to position in the vector, so we can do Flag field lookups...
SchemaItem< T > find(std::string const &name) const
Find an item by name (used to implement Schema::find).
int getFieldCount() const
The total number of fields.
int contains(SchemaItem< T > const &item, int flags) const
Key< T > addField(Field< T > const &field, bool doReplace=false)
Add a field to the schema (used to implement Schema::addField).
SchemaItem(Key< T > const &key_, Field< T > const &field_)
A simple pair-like struct for mapping a Field (name and description) with a Key (used for actual data...