TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkfunctor.h
Go to the documentation of this file.
1 #ifndef TTKFUNCTOR_H
2 #define TTKFUNCTOR_H
3 
4 /***************************************************************************
5  * This file is part of the TTK Library Module project
6  * Copyright (C) 2015 - 2025 Greedysky Studio
7 
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation; either version 3 of the License, or
11  * (at your option) any later version.
12 
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public License along
19  * with this program; If not, see <http://www.gnu.org/licenses/>.
20  ***************************************************************************/
21 
22 #include "ttkmoduleexport.h"
23 
28 
29 
33 template <typename IT, typename OT = TTKNullType, typename PT = TTKNullType>
35 {
36 public:
37  using InputType = IT;
38  using OutputType = OT;
39  using OptionType = PT;
40 
41 public:
42  TTKFunctor();
43  virtual ~TTKFunctor();
44 
45 public:
46  OutputType executeUnsafe(const InputType &input);
47  OutputType executeUnsafe(const InputType &input, const OptionType &option);
48 
49  bool execute(const InputType &input, const OptionType &option = OptionType());
50  bool execute(const InputType &input, OutputType &output, const OptionType &option = OptionType());
51 
52 protected:
53  virtual bool executeMain(OutputType &output, const InputType &input, const OptionType &option) = 0;
54 
55 };
56 
57 template <typename IT, typename OT, typename PT>
59 {
60 
61 }
62 
63 template <typename IT, typename OT, typename PT>
65 {
66 
67 }
68 
69 template <typename IT, typename OT, typename PT>
71 {
72  OT output;
73  executeMain(output, input, OptionType());
74  return output;
75 }
76 
77 template <typename IT, typename OT, typename PT>
79 {
80  OT output;
81  executeMain(output, input, option);
82  return output;
83 }
84 
85 template <typename IT, typename OT, typename PT>
86 bool TTKFunctor<IT, OT, PT>::execute(const InputType &input, const OptionType &option)
87 {
88  OT output;
89  return executeMain(output, input, option);
90 }
91 
92 template <typename IT, typename OT, typename PT>
93 bool TTKFunctor<IT, OT, PT>::execute(const InputType &input, OutputType &output, const OptionType &option)
94 {
95  return executeMain(output, input, option);
96 }
97 
98 #endif // TTKFUNCTOR_H
#define TTK_MODULE_EXPORT
virtual ~TTKFunctor()
Definition: ttkfunctor.h:64
PT OptionType
Definition: ttkfunctor.h:39
TTK_MODULE_EXPORT bool execute(const QString &path)
The class of the null type.
Definition: ttkfunctor.h:27
OutputType executeUnsafe(const InputType &input)
Definition: ttkfunctor.h:70
The class of the functor interface.
Definition: ttkfunctor.h:34
OT OutputType
Definition: ttkfunctor.h:38
bool execute(const InputType &input, const OptionType &option=OptionType())
Definition: ttkfunctor.h:86
IT InputType
Definition: ttkfunctor.h:37