1/*
2 * map_vector_printers.hpp
3 *
4 * Created on: Feb 10, 2019
5 * Author: i-bird
6 */
7
8#ifndef MAP_VECTOR_PRINTERS_HPP_
9#define MAP_VECTOR_PRINTERS_HPP_
10
11
12/*! \brief this class is a functor for "for_each" algorithm
13 *
14 * This class is a functor for "for_each" algorithm. For each
15 * element of the boost::vector the operator() is called.
16 * Is mainly used to print the elements of the vector
17 *
18 * \tparam encap source
19 * \tparam encap dst
20 *
21 */
22template<typename vector_type, unsigned int ... prp>
23struct vector_printer
24{
25 //! element to print
26 size_t & ele;
27
28 //! vector to print
29 vector_type & vt;
30
31 // stringstream
32 std::stringstream & ss;
33
34 typedef typename to_boost_vmpl<prp...>::type vprp;
35
36 /*! \brief constructor
37 *
38 * \param src source encapsulated object
39 * \param dst source encapsulated object
40 *
41 */
42 inline vector_printer(vector_type & vt, size_t & ele, std::stringstream & ss)
43 :vt(vt),ele(ele),ss(ss)
44 {};
45
46 //! It call the copy function for each property
47 template<typename T>
48 inline void operator()(T& t) const
49 {
50 ss << vt.template get<T::value>(ele) << " ";
51 }
52};
53
54
55#endif /* MAP_VECTOR_PRINTERS_HPP_ */
56