Commit fd236cf9 authored by Tomáš Oberhuber's avatar Tomáš Oberhuber Committed by Jakub Klinkovský
Browse files

Refactoring segments printing.

parent 4df14dcb
Loading
Loading
Loading
Loading
+25 −51
Original line number Diff line number Diff line
@@ -49,30 +49,14 @@ std::ostream& printSegments( const Segments& segments, std::ostream& str )
   return str;
}


/**
 * \brief Print segments with related content.
 *
 * \tparam Segments is type of segments.
 * \tparam Fetch is a lambda function for reading related data.
 * \param segments is an instance of segments.
 * \param fetch is an instance of lambda function reading related data. It is supposed to defined as
 *
 * ```
 * auto fetch = [=] __cuda_callable__ ( IndexType globalIdx ) -> ValueType { return data_view[ globalIdx ]; };
 * ```
 *
 * \param str is output stream.
 * \return reference to the output stream.
 *
 * \par Example
 * \include Algorithms/Segments/SegmentsPrintingExample-2.cpp
 * \par Output
 * \include SegmentsPrintingExample-2.out
 */
template< typename Segments,
          typename Fetch >
std::ostream& printSegments( const Segments& segments, Fetch&& fetch, std::ostream& str )
struct SegmentsPrinter
{
   SegmentsPrinter( const Segments& segments, Fetch& fetch )
   : segments( segments ), fetch( fetch ) {}

   std::ostream& print( std::ostream& str ) const
   {
      using IndexType = typename Segments::IndexType;
      using DeviceType = typename Segments::DeviceType;
@@ -99,16 +83,6 @@ std::ostream& printSegments( const Segments& segments, Fetch&& fetch, std::ostre
      return str;
   }


template< typename Segments,
          typename Fetch >
struct SegmentsPrinter
{
   SegmentsPrinter( const Segments& segments, Fetch& fetch )
   : segments( segments ), fetch( fetch ) {}

   std::ostream& print( std::ostream& str ) const { return printSegments( segments, fetch, str ); }

   protected:

   const Segments& segments;