DUNE PDELab (git)

collectorstream.hh
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3// SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
4// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
5#ifndef DUNE_COMMON_TEST_COLLECTORSTREAM_HH
6#define DUNE_COMMON_TEST_COLLECTORSTREAM_HH
7
8#include <sstream>
9#include <string>
10#include <functional>
11
12
14
15
16namespace Dune {
17
18
19
31class CollectorStream : public std::ostringstream
32{
33public:
34
41 template<class CallBack,
43 CollectorStream(CallBack&& callBack) :
44 callBack_(callBack)
45 {}
46
47 CollectorStream(const CollectorStream& other) = delete;
48
57 callBack_(other.callBack_)
58 {
59 (*this) << other.str();
60 other.callBack_ = [](std::string){};
61 }
62
70 {
71 callBack_(this->str());
72 }
73
74private:
75 std::function<void(std::string)> callBack_;
76};
77
78
79
80} // namespace Dune
81
82
83#endif // DUNE_COMMON_TEST_COLLECTORSTREAM_HH
Data collector stream.
Definition: collectorstream.hh:32
~CollectorStream()
Destructor.
Definition: collectorstream.hh:69
CollectorStream(CallBack &&callBack)
Create from callback.
Definition: collectorstream.hh:43
CollectorStream(CollectorStream &&other)
Move constructor.
Definition: collectorstream.hh:56
std::enable_if_t< not Impl::disableCopyMoveHelper< This, T... >::value, int > disableCopyMove
Helper to disable constructor as copy and move constructor.
Definition: typeutilities.hh:45
Dune namespace.
Definition: alignedallocator.hh:13
Utilities for type computations, constraining overloads, ...
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 24, 23:30, 2024)