All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | Public Attributes | List of all members
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 155 of file DumpUtils.h.

Member Typedef Documentation

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

Definition at line 157 of file DumpUtils.h.

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

Definition at line 156 of file DumpUtils.h.

Constructor & Destructor Documentation

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

Definition at line 161 of file DumpUtils.h.

161 : v(v) {}
Vector_t const & v
A reference to the vector to be printed.
Definition: DumpUtils.h:159
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 175 of file DumpUtils.h.

176  { std::ostringstream sstr; this->operator()(sstr); return sstr.str(); }
void operator()(Stream &&out) const
Inserts the content of the stored vector into the specified stream.
Definition: DumpUtils.h:171
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 171 of file DumpUtils.h.

172  { out << "{ " << v.X() << "; " << v.Y() << "; " << v.Z() << " }"; }
Vector_t const & v
A reference to the vector to be printed.
Definition: DumpUtils.h:159
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 159 of file DumpUtils.h.


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