LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
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 #include "boost/type_traits/remove_const.hpp"
11 #include "boost/type_traits/remove_reference.hpp"
12 
13 #include "lsst/afw/table/Schema.h"
14 
15 #ifndef SWIG
16 
17 namespace lsst { namespace afw { namespace table {
18 
19 class SchemaMapper;
20 
21 namespace detail {
22 
31 private:
32 
34  struct MakeKeyPair {
35  template <typename T>
36  struct apply {
37  typedef std::pair< Key<T>, Key<T> > type;
38  };
39  };
40 
41 public:
42 
44  typedef boost::mpl::transform<FieldTypes,MakeKeyPair>::type KeyPairTypes;
46  typedef boost::make_variant_over<KeyPairTypes>::type KeyPairVariant;
48  typedef std::vector<KeyPairVariant> KeyPairMap;
49 
51  explicit SchemaMapperImpl(Schema const & input, Schema const & output) : _input(input), _output(output) {}
52 
58  template <typename F>
59  struct VisitorWrapper : public boost::static_visitor<> {
60 
62  template <typename T>
63  void operator()(std::pair< Key<T>, Key<T> > const & pair) const {
64  _func(pair.first, pair.second);
65  }
66 
76  void operator()(KeyPairVariant const & v) const {
77  boost::apply_visitor(*this, v);
78  }
79 
81  explicit VisitorWrapper(F func) : _func(func) {}
82 
83  private:
84  F _func;
85  };
86 
87 private:
88 
89  friend class table::SchemaMapper;
90  friend class detail::Access;
91 
95 };
96 
97 }}}} // namespace lsst::afw::table::detail
98 
99 #endif // !SWIG
100 
101 #endif // !AFW_TABLE_DETAIL_SchemaMapperImpl_h_INCLUDED
Defines the fields and offsets for a table.
Definition: Schema.h:46
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.