Messagelib

compositememento.h
1/*
2 SPDX-FileCopyrightText: 2023 Daniel Vrátil <dvratil@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#pragma once
8
9#include "cryptobodypartmemento.h"
10
11#include <memory>
12#include <type_traits>
13
14namespace MimeTreeParser
15{
16
17class CompositeMemento : public CryptoBodyPartMemento
18{
20public:
21 explicit CompositeMemento() = default;
22 ~CompositeMemento() override;
23
24 bool start() override;
25 void exec() override;
26
27 void addMemento(CryptoBodyPartMemento *memento);
28
29 [[nodiscard]] QList<CryptoBodyPartMemento *> mementos() const
30 {
31 return mMementos;
32 }
33
34 [[nodiscard]] auto size() const
35 {
36 return mMementos.size();
37 }
38
39 template<typename T>
40 T *memento() const
41 {
42 auto it = std::find_if(mMementos.begin(), mMementos.end(), [](auto *memento) {
43 return qobject_cast<std::decay_t<T> *>(memento) != nullptr;
44 });
45 if (it != mMementos.cend()) {
46 return static_cast<T *>(*it);
47 }
48
49 return nullptr;
50 }
51
52private:
53 void subMementoFinished();
55 int mRunningMementos = 0;
56};
57
58} // namespace
iterator begin()
const_iterator cend() const const
iterator end()
qsizetype size() const const
Q_OBJECTQ_OBJECT
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:50:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.