LSSTApplications  11.0-13-gbb96280,12.1.rc1,12.1.rc1+1,12.1.rc1+2,12.1.rc1+5,12.1.rc1+8,12.1.rc1-1-g06d7636+1,12.1.rc1-1-g253890b+5,12.1.rc1-1-g3d31b68+7,12.1.rc1-1-g3db6b75+1,12.1.rc1-1-g5c1385a+3,12.1.rc1-1-g83b2247,12.1.rc1-1-g90cb4cf+6,12.1.rc1-1-g91da24b+3,12.1.rc1-2-g3521f8a,12.1.rc1-2-g39433dd+4,12.1.rc1-2-g486411b+2,12.1.rc1-2-g4c2be76,12.1.rc1-2-gc9c0491,12.1.rc1-2-gda2cd4f+6,12.1.rc1-3-g3391c73+2,12.1.rc1-3-g8c1bd6c+1,12.1.rc1-3-gcf4b6cb+2,12.1.rc1-4-g057223e+1,12.1.rc1-4-g19ed13b+2,12.1.rc1-4-g30492a7
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.
SchemaMapperImpl(Schema const &input, Schema const &output)
Constructor from the given input and output schemas.
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
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.
void operator()(KeyPairVariant const &v) const
Invoke the visitation.
std::vector< KeyPairVariant > KeyPairMap
A std::vector whose elements can be any of the allowed pair types.
boost::make_variant_over< KeyPairTypes >::type KeyPairVariant
A Boost.Variant type that can hold any one of the allowed pair types.
A class used as a handle to a particular field in a table.
Definition: fwd.h:44
void operator()(std::pair< Key< T >, Key< T > > const &pair) const
Call the wrapped function.