pqInterfaceTracker.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Kitware Inc.
2 // SPDX-FileCopyrightText: Copyright (c) Sandia Corporation
3 // SPDX-License-Identifier: BSD-3-Clause
4 #ifndef pqInterfaceTracker_h
5 #define pqInterfaceTracker_h
6 
7 #include "pqCoreModule.h"
8 #include <QObject>
9 
10 class vtkObject;
11 
19 class PQCORE_EXPORT pqInterfaceTracker : public QObject
20 {
21  Q_OBJECT
22  typedef QObject Superclass;
23 
24 public:
25  pqInterfaceTracker(QObject* parent = nullptr);
26  ~pqInterfaceTracker() override;
27 
31  QObjectList interfaces() const { return this->Interfaces + this->RegisteredInterfaces; }
32 
37  template <class T>
38  QList<T> interfaces() const
39  {
40  QList<T> list;
41  QObjectList objList = this->interfaces();
42  Q_FOREACH (QObject* object, objList)
43  {
44  if (object && qobject_cast<T>(object))
45  {
46  list.push_back(qobject_cast<T>(object));
47  }
48  }
49  return list;
50  }
51 
56  void addInterface(QObject* iface);
57 
61  void removeInterface(QObject* iface);
62 
66  void initialize();
67 Q_SIGNALS:
72  void interfaceRegistered(QObject* iface);
73 
74 protected:
79  void onPluginLoaded(vtkObject*, unsigned long, void* calldata);
80 
81  QObjectList Interfaces;
82  QObjectList RegisteredInterfaces;
83  unsigned long ObserverID;
84 
85 private:
86  Q_DISABLE_COPY(pqInterfaceTracker)
87 };
88 
89 #endif
QObjectList RegisteredInterfaces
QObjectList interfaces() const
Return all interfaces that have been loaded/registered.
unsigned long ObserverID
#define PQCORE_EXPORT
Definition: pqCoreModule.h:15
QList< T > interfaces() const
Returns all interfaces that have been loaded/registered that are of the requested type...
pqInterfaceTracker is used by ParaView components to locate interface-implementations.