LSSTApplications  10.0-2-g4f67435,11.0.rc2+1,11.0.rc2+12,11.0.rc2+3,11.0.rc2+4,11.0.rc2+5,11.0.rc2+6,11.0.rc2+7,11.0.rc2+8
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.
void operator()(std::pair< Key< T >, Key< T > > const &pair) const
Call the wrapped function.
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.
boost::make_variant_over< KeyPairTypes >::type KeyPairVariant
A Boost.Variant type that can hold any one of the allowed pair types.
SchemaMapperImpl(Schema const &input, Schema const &output)
Constructor from the given input and output schemas.
std::vector< KeyPairVariant > KeyPairMap
A std::vector whose elements can be any of the allowed pair types.
A class used as a handle to a particular field in a table.
Definition: fwd.h:44
boost::mpl::transform< FieldTypes, MakeKeyPair >::type KeyPairTypes
An MPL sequence of all the allowed pair templates.
void operator()(KeyPairVariant const &v) const
Invoke the visitation.