File indexing completed on 2025-01-05 04:37:30
0001 /* 0002 SPDX-FileCopyrightText: 2008 Joris Guisson <joris.guisson@gmail.com> 0003 SPDX-FileCopyrightText: 2008 Ivan Vasic <ivasic@gmail.com> 0004 0005 SPDX-License-Identifier: GPL-2.0-or-later 0006 */ 0007 #ifndef BTLOGSYSTEMMANAGER_H 0008 #define BTLOGSYSTEMMANAGER_H 0009 0010 #include <QMap> 0011 #include <QObject> 0012 #include <QScopedPointer> 0013 #include <ktorrent_export.h> 0014 #include <util/constants.h> 0015 0016 namespace bt 0017 { 0018 /** 0019 Keeps track of all logging system ID's 0020 */ 0021 class KTORRENT_EXPORT LogSystemManager : public QObject 0022 { 0023 Q_OBJECT 0024 0025 LogSystemManager(); 0026 0027 public: 0028 ~LogSystemManager() override; 0029 0030 /// Register a system 0031 void registerSystem(const QString &name, Uint32 id); 0032 0033 /// Unregister a system 0034 void unregisterSystem(const QString &name); 0035 0036 typedef QMap<QString, Uint32>::iterator iterator; 0037 typedef QMap<QString, Uint32>::const_iterator const_iterator; 0038 0039 iterator begin() 0040 { 0041 return systems.begin(); 0042 } 0043 iterator end() 0044 { 0045 return systems.end(); 0046 } 0047 0048 const_iterator begin() const 0049 { 0050 return systems.cbegin(); 0051 } 0052 const_iterator end() const 0053 { 0054 return systems.cend(); 0055 } 0056 0057 static LogSystemManager &instance(); 0058 0059 /// Get the ID of a system 0060 Uint32 systemID(const QString &name); 0061 0062 Q_SIGNALS: 0063 void registered(const QString &name); 0064 void unregisted(const QString &name); 0065 0066 private: 0067 QMap<QString, Uint32> systems; 0068 static QScopedPointer<LogSystemManager> self; 0069 }; 0070 0071 } 0072 0073 #endif