LSSTApplications  11.0-13-gbb96280,12.1+18,12.1+7,12.1-1-g14f38d3+72,12.1-1-g16c0db7+5,12.1-1-g5961e7a+84,12.1-1-ge22e12b+23,12.1-11-g06625e2+4,12.1-11-g0d7f63b+4,12.1-19-gd507bfc,12.1-2-g7dda0ab+38,12.1-2-gc0bc6ab+81,12.1-21-g6ffe579+2,12.1-21-gbdb6c2a+4,12.1-24-g941c398+5,12.1-3-g57f6835+7,12.1-3-gf0736f3,12.1-37-g3ddd237,12.1-4-gf46015e+5,12.1-5-g06c326c+20,12.1-5-g648ee80+3,12.1-5-gc2189d7+4,12.1-6-ga608fc0+1,12.1-7-g3349e2a+5,12.1-7-gfd75620+9,12.1-9-g577b946+5,12.1-9-gc4df26a+10
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 #ifndef SWIG
14 
15 namespace lsst { namespace afw { namespace table {
16 
17 class SchemaMapper;
18 
19 namespace detail {
20 
29 private:
30 
32  struct MakeKeyPair {
33  template <typename T>
34  struct apply {
35  typedef std::pair< Key<T>, Key<T> > type;
36  };
37  };
38 
39 public:
40 
42  typedef boost::mpl::transform<FieldTypes,MakeKeyPair>::type KeyPairTypes;
44  typedef boost::make_variant_over<KeyPairTypes>::type KeyPairVariant;
46  typedef std::vector<KeyPairVariant> KeyPairMap;
47 
49  explicit SchemaMapperImpl(Schema const & input, Schema const & output) : _input(input), _output(output) {}
50 
56  template <typename F>
57  struct VisitorWrapper : public boost::static_visitor<> {
58 
60  template <typename T>
61  void operator()(std::pair< Key<T>, Key<T> > const & pair) const {
62  _func(pair.first, pair.second);
63  }
64 
74  void operator()(KeyPairVariant const & v) const {
75  boost::apply_visitor(*this, v);
76  }
77 
79  template <typename T>
80  explicit VisitorWrapper(T&& func) : _func(std::forward<T>(func)) {}
81 
82  private:
83  F _func;
84  };
85 
86 private:
87 
88  friend class table::SchemaMapper;
89  friend class detail::Access;
90 
94 };
95 
96 }}}} // namespace lsst::afw::table::detail
97 
98 #endif // !SWIG
99 
100 #endif // !AFW_TABLE_DETAIL_SchemaMapperImpl_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:44
A functor-wrapper used in the implementation of SchemaMapper::forEach.
boost::mpl::transform< FieldTypes, MakeKeyPair >::type KeyPairTypes
An MPL sequence of all the allowed pair templates.
A mapping between the keys of two Schemas, used to copy data between them.
Definition: SchemaMapper.h:19
void operator()(std::pair< Key< T >, Key< T > > const &pair) const
Call the wrapped function.
Boost.MPL metafunction that returns a std::pair&lt; Key&lt;T&gt;, Key&lt;T&gt; &gt; given a T.
A private implementation class to hide the messy details of SchemaMapper.
boost::make_variant_over< KeyPairTypes >::type KeyPairVariant
A Boost.Variant type that can hold any one of the allowed pair types.
std::vector< KeyPairVariant > KeyPairMap
A std::vector whose elements can be any of the allowed pair types.
SchemaMapperImpl(Schema const &input, Schema const &output)
Constructor from the given input and output schemas.
void operator()(KeyPairVariant const &v) const
Invoke the visitation.
A class used as a handle to a particular field in a table.
Definition: fwd.h:44
metadata input