TTKMusicPlayer  4.2.0.0
TTKMusicPlayer imitates Kugou UI, the music player uses of qmmp core library based on Qt for windows and linux
ttkdispatchmanager.h
Go to the documentation of this file.
1 #ifndef TTKDISPATCHMANAGER_H
2 #define TTKDISPATCHMANAGER_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 <QMutex>
23 #include "ttksingleton.h"
24 
25 class QTimer;
26 
30 class TTK_MODULE_EXPORT TTKDispatchManager : public QObject
31 {
32  Q_OBJECT
35 public:
36  enum class Module
37  {
38  Null = -1,
39  FileRemove
40  };
41 
45  void dispatch(Module type);
46  void dispatch(Module type, void *funcs);
47  void dispatch(Module type, const TTKVariantList &args);
48 
49 public:
53  void dispatch(Module type, const QVariant &arg1);
54  void dispatch(Module type, const QVariant &arg1, const QVariant &arg2);
55  void dispatch(Module type, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3);
56  void dispatch(Module type, const QVariant &arg1, const QVariant &arg2, const QVariant &arg3, const QVariant &arg4);
57 
58 private Q_SLOTS:
62  void activeFunctions();
63 
64 private:
73 
74 private:
76  {
77  int m_times;
80 
81  TTKDispatchItem() noexcept
82  : m_times(0),
83  m_type(TTKDispatchManager::Module::Null)
84  {
85 
86  }
87 
88  inline bool isEmpty() const noexcept
89  {
90  return m_args.isEmpty();
91  }
92 
93  inline bool isValid() const noexcept
94  {
95  return m_times <= 5;
96  }
97  };
98 
99 private:
100  QMutex m_mutex;
101  QTimer *m_timer;
102  QList<TTKDispatchItem*> m_observer;
103 
104 };
105 
106 #endif // TTKDISPATCHMANAGER_H
#define TTK_MODULE_EXPORT
#define TTK_DECLARE_SINGLETON_CLASS(Class)
// Singleton Macro // //
Definition: ttksingleton.h:86
The class of the functions dispatch manager.
QList< TTKDispatchItem * > m_observer
#define TTK_DECLARE_MODULE(Class)
Definition: ttkqtglobal.h:164
TTKDispatchManager::Module m_type
QList< QVariant > TTKVariantList
Definition: ttkqtglobal.h:201
#define const
Definition: zconf.h:233