LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
lar::dump::VectorDumper< Vector > Struct Template Reference

Manipulator managing the dump of the vector content into a stream. More...

#include "DumpUtils.h"

Public Types

using Vector_t = Vector
 
using This_t = VectorDumper< Vector_t >
 

Public Member Functions

 VectorDumper (Vector_t const &v)
 
 VectorDumper (This_t const &from)=default
 
 VectorDumper (This_t &&from)=default
 
VectorDumperoperator= (This_t const &from)=delete
 
VectorDumperoperator= (This_t &&from)=delete
 
template<typename Stream >
void operator() (Stream &&out) const
 Inserts the content of the stored vector into the specified stream. More...
 
 operator std::string () const
 Converts the content of the stored vector into a string. More...
 

Public Attributes

Vector_t const & v
 A reference to the vector to be printed. More...
 

Detailed Description

template<typename Vector>
struct lar::dump::VectorDumper< Vector >

Manipulator managing the dump of the vector content into a stream.

Template Parameters
Vectorthe type of vector to be dumped

The manipulator is constructed with the object that needs to be dumped. This implementation requires a vector of at least 3D with methods X(), Y() and Z(). The dump is producer by the call operator, in the form

{ vx, vy, vz }

An overloaded insertion operator will call the operator() method of the manipulator to perform the insertion.

This class can be specialised to manage different vector types. For example:

#include <array>
namespace lar {
namespace dump {
// specialization for 3D std::array<>
template <typename T>
struct VectorDumper<std::array<T, 3U>> {
using Vector_t = std::array<T, 3U>;
Vector_t const& a;
VectorDumper(Vector_t const& a): a(a) {}
template <typename Stream>
void operator() (Stream&& out) const
{ out << "{ " << a[0] << "; " << a[1] << "; " << a[2] << " }"; }
}; // struct VectorDumper<array>
} // namespace dump
} // namespace lar

Definition at line 174 of file DumpUtils.h.

Member Typedef Documentation

template<typename Vector>
using lar::dump::VectorDumper< Vector >::This_t = VectorDumper<Vector_t>

Definition at line 176 of file DumpUtils.h.

template<typename Vector>
using lar::dump::VectorDumper< Vector >::Vector_t = Vector

Definition at line 175 of file DumpUtils.h.

Constructor & Destructor Documentation

template<typename Vector>
lar::dump::VectorDumper< Vector >::VectorDumper ( Vector_t const &  v)
inlineexplicit

Definition at line 180 of file DumpUtils.h.

180 : v(v) {}
Vector_t const & v
A reference to the vector to be printed.
Definition: DumpUtils.h:178
template<typename Vector>
lar::dump::VectorDumper< Vector >::VectorDumper ( This_t const &  from)
default
template<typename Vector>
lar::dump::VectorDumper< Vector >::VectorDumper ( This_t &&  from)
default

Member Function Documentation

template<typename Vector>
lar::dump::VectorDumper< Vector >::operator std::string ( ) const
inlineexplicit

Converts the content of the stored vector into a string.

Definition at line 196 of file DumpUtils.h.

197  {
198  std::ostringstream sstr;
199  this->operator()(sstr);
200  return sstr.str();
201  }
void operator()(Stream &&out) const
Inserts the content of the stored vector into the specified stream.
Definition: DumpUtils.h:190
template<typename Vector>
template<typename Stream >
void lar::dump::VectorDumper< Vector >::operator() ( Stream &&  out) const
inline

Inserts the content of the stored vector into the specified stream.

Definition at line 190 of file DumpUtils.h.

191  {
192  out << "{ " << v.X() << "; " << v.Y() << "; " << v.Z() << " }";
193  }
Vector_t const & v
A reference to the vector to be printed.
Definition: DumpUtils.h:178
template<typename Vector>
VectorDumper& lar::dump::VectorDumper< Vector >::operator= ( This_t const &  from)
delete
template<typename Vector>
VectorDumper& lar::dump::VectorDumper< Vector >::operator= ( This_t &&  from)
delete

Member Data Documentation

template<typename Vector>
Vector_t const& lar::dump::VectorDumper< Vector >::v

A reference to the vector to be printed.

Definition at line 178 of file DumpUtils.h.


The documentation for this struct was generated from the following file: