ParaView
pqInterfaceTracker.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: ParaView
4  Module: $RCSfile$
5 
6  Copyright (c) 2005,2006 Sandia Corporation, Kitware Inc.
7  All rights reserved.
8 
9  ParaView is a free software; you can redistribute it and/or modify it
10  under the terms of the ParaView license version 1.2.
11 
12  See License_v1.2.txt for the full ParaView license.
13  A copy of this license can be obtained by contacting
14  Kitware Inc.
15  28 Corporate Drive
16  Clifton Park, NY 12065
17  USA
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
23 CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 
31 ========================================================================*/
32 #ifndef pqInterfaceTracker_h
33 #define pqInterfaceTracker_h
34 
35 #include "pqCoreModule.h"
36 #include <QObject>
37 
38 class vtkObject;
39 
45 class PQCORE_EXPORT pqInterfaceTracker : public QObject
46 {
47  Q_OBJECT
48  typedef QObject Superclass;
49 public:
50  pqInterfaceTracker(QObject* parent=0);
51  virtual ~pqInterfaceTracker();
52 
54  QObjectList interfaces() const
55  { return this->Interfaces + this->RegisteredInterfaces; }
56 
59  template <class T>
60  QList<T> interfaces() const
61  {
62  QList<T> list;
63  QObjectList objList = this->interfaces();
64  foreach (QObject* object, objList)
65  {
66  if (object && qobject_cast<T>(object))
67  {
68  list.push_back(qobject_cast<T>(object));
69  }
70  }
71  return list;
72  }
73 
76  void addInterface(QObject* iface);
77 
79  void removeInterface(QObject* iface);
80 
82  void initialize();
83 signals:
86  void interfaceRegistered(QObject* iface);
87 
88 protected:
91  void onPluginLoaded(vtkObject*, unsigned long, void* calldata);
92 
93 protected:
94  QObjectList Interfaces;
95  QObjectList RegisteredInterfaces;
96  unsigned long ObserverID;
97 
98 private:
99  Q_DISABLE_COPY(pqInterfaceTracker)
100 
101 };
102 
103 #endif
QObjectList RegisteredInterfaces
QObjectList interfaces() const
Return all interfaces that have been loaded/registered.
unsigned long ObserverID
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.