Wireshark  4.3.0
The Wireshark network protocol analyzer
preference_manager.h
Go to the documentation of this file.
1 
10 #ifndef PREFERENCE_MANAGER_H
11 #define PREFERENCE_MANAGER_H
12 
13 #include <config.h>
14 
15 #include <QObject>
16 #include <QMetaObject>
17 #include <QHash>
18 #include <QActionGroup>
19 
21 #include <ui/qt/capture_file.h>
22 
23 class PreferenceFactory;
25 
26 class PreferenceManager : public QObject
27 {
28 public:
29  static PreferenceManager* instance();
30  virtual ~PreferenceManager();
31 
32  void registerType(int pref, PreferenceFactory * factory);
33  void reuseType(int pref, int reuseFor);
34  WiresharkPreference * getPreference(PrefsItem * item);
35 
36 protected:
37  explicit PreferenceManager(QObject * parent = Q_NULLPTR);
38 
39 private:
40  static QMap<int, PreferenceFactory*> & factories();
41 };
42 
43 class PreferenceFactory : public QObject
44 {
45 public:
46  virtual ~PreferenceFactory();
47  virtual WiresharkPreference * create(QObject * parent = Q_NULLPTR) = 0;
48 };
49 
50 #define REGISTER_PREFERENCE_TYPE(pref_id, preference_class) \
51  class preference_class##pref_id##Factory : public PreferenceFactory { \
52  public: \
53  preference_class##pref_id##Factory() \
54  { \
55  PreferenceManager::instance()->registerType(pref_id, this); \
56  } \
57  virtual WiresharkPreference *create(QObject * parent) { \
58  WiresharkPreference * newPrefHandler = new preference_class(parent); \
59  return newPrefHandler; \
60  } \
61  }; \
62  static preference_class##pref_id##Factory global_##preference_class##pref_id##Factory;
63 
64 #endif // PREFERENCE_MANAGER_H
Definition: preference_manager.h:44
Definition: preference_manager.h:27
Definition: pref_models.h:23
Definition: wireshark_preference.h:20