LSSTApplications  20.0.0
LSSTDataManagementBasePackage
SchemaMapperImpl.h
Go to the documentation of this file.
1 // -*- lsst-c++ -*-
2 #ifndef AFW_TABLE_DETAIL_SchemaMapperImpl_h_INCLUDED
3 #define AFW_TABLE_DETAIL_SchemaMapperImpl_h_INCLUDED
4 
5 #include <map>
6 #include <algorithm>
7 
8 #include "boost/variant.hpp"
9 #include "boost/mpl/transform.hpp"
10 
11 #include "lsst/afw/table/Schema.h"
12 
13 namespace lsst {
14 namespace afw {
15 namespace table {
16 
17 class SchemaMapper;
18 
19 namespace detail {
20 
27 class SchemaMapperImpl final {
28 private:
30  struct MakeKeyPair {
31  template <typename T>
32  struct apply {
34  };
35  };
36 
37 public:
44 
46  explicit SchemaMapperImpl(Schema const& input, Schema const& output) : _input(input), _output(output) {}
47 
53  template <typename F>
54  struct VisitorWrapper : public boost::static_visitor<> {
56  template <typename T>
57  void operator()(std::pair<Key<T>, Key<T> > const& pair) const {
58  _func(pair.first, pair.second);
59  }
60 
70  void operator()(KeyPairVariant const& v) const { boost::apply_visitor(*this, v); }
71 
73  template <typename T>
74  explicit VisitorWrapper(T&& func) : _func(std::forward<T>(func)) {}
75 
76  private:
77  F _func;
78  };
79 
80 private:
81  friend class table::SchemaMapper;
82  friend class detail::Access;
83 
84  Schema _input;
85  Schema _output;
86  KeyPairMap _map;
87 };
88 } // namespace detail
89 } // namespace table
90 } // namespace afw
91 } // namespace lsst
92 
93 #endif // !AFW_TABLE_DETAIL_SchemaMapperImpl_h_INCLUDED
lsst::afw::table::detail::SchemaMapperImpl::VisitorWrapper::operator()
void operator()(std::pair< Key< T >, Key< T > > const &pair) const
Call the wrapped function.
Definition: SchemaMapperImpl.h:57
std::pair
std::vector< KeyPairVariant >
lsst::afw
Definition: imageAlgorithm.dox:1
lsst::afw::table::Schema
Defines the fields and offsets for a table.
Definition: Schema.h:50
lsst::afw::table::detail::SchemaMapperImpl::MakeKeyPair::apply
Definition: SchemaMapperImpl.h:32
lsst::afw::table::detail::SchemaMapperImpl::MakeKeyPair::apply::type
std::pair< Key< T >, Key< T > > type
Definition: SchemaMapperImpl.h:33
lsst::afw::table::detail::SchemaMapperImpl::KeyPairMap
std::vector< KeyPairVariant > KeyPairMap
A std::vector whose elements can be any of the allowed pair types.
Definition: SchemaMapperImpl.h:43
lsst::afw::table::detail::SchemaMapperImpl::VisitorWrapper
A functor-wrapper used in the implementation of SchemaMapper::forEach.
Definition: SchemaMapperImpl.h:54
lsst::afw::table::detail::SchemaMapperImpl
A private implementation class to hide the messy details of SchemaMapper.
Definition: SchemaMapperImpl.h:27
lsst::afw::table::detail::SchemaMapperImpl::SchemaMapperImpl
SchemaMapperImpl(Schema const &input, Schema const &output)
Constructor from the given input and output schemas.
Definition: SchemaMapperImpl.h:46
lsst::afw::table::detail::SchemaMapperImpl::KeyPairVariant
boost::make_variant_over< KeyPairTypes >::type KeyPairVariant
A Boost.Variant type that can hold any one of the allowed pair types.
Definition: SchemaMapperImpl.h:41
lsst::afw::table::detail::SchemaMapperImpl::VisitorWrapper::operator()
void operator()(KeyPairVariant const &v) const
Invoke the visitation.
Definition: SchemaMapperImpl.h:70
lsst::afw::table::SchemaMapper
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:21
lsst::afw::table::Key
A class used as a handle to a particular field in a table.
Definition: fwd.h:45
lsst::afw::table::detail::SchemaMapperImpl::KeyPairTypes
boost::mpl::transform< FieldTypes, MakeKeyPair >::type KeyPairTypes
An MPL sequence of all the allowed pair templates.
Definition: SchemaMapperImpl.h:39
lsst
A base class for image defects.
Definition: imageAlgorithm.dox:1
lsst::afw::table::detail::SchemaMapperImpl::VisitorWrapper::VisitorWrapper
VisitorWrapper(T &&func)
Construct the wrappper.
Definition: SchemaMapperImpl.h:74
lsst::afw::table::detail::Access
Definition: Access.h:31
std
STL namespace.
type
table::Key< int > type
Definition: Detector.cc:163
Schema.h