NifTK  16.4.1 - 0798f20
CMIC's Translational Medical Imaging Platform
niftkDataStorageListener.h
Go to the documentation of this file.
1 /*=============================================================================
2 
3  NifTK: A software platform for medical image computing.
4 
5  Copyright (c) University College London (UCL). All rights reserved.
6 
7  This software is distributed WITHOUT ANY WARRANTY; without even
8  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
9  PURPOSE.
10 
11  See LICENSE.txt in the top level directory for details.
12 
13 =============================================================================*/
14 
15 #ifndef niftkDataStorageListener_h
16 #define niftkDataStorageListener_h
17 
18 #include "niftkCoreExports.h"
19 
20 #include <itkObject.h>
21 
22 #include <mitkDataNode.h>
23 #include <mitkDataStorage.h>
24 
25 #include "niftkDataNodeFilter.h"
26 
27 namespace niftk
28 {
29 
39 class NIFTKCORE_EXPORT DataStorageListener : public itk::LightObject
40 {
41 
42 public:
43 
44  mitkClassMacroItkParent(DataStorageListener, itk::LightObject)
45  mitkNewMacro1Param(DataStorageListener, const mitk::DataStorage::Pointer)
46 
47 
48  mitk::DataStorage::Pointer GetDataStorage() const;
49 
53  void AddFilter(DataNodeFilter::Pointer filter);
54 
56  void ClearFilters();
57 
59  bool IsBlocked() const;
60 
64  bool SetBlocked(bool blocked);
65 
67  mitk::Message1<mitk::DataNode*> NodeAdded;
68  mitk::Message1<mitk::DataNode*> NodeChanged;
69  mitk::Message1<mitk::DataNode*> NodeRemoved;
70  mitk::Message1<mitk::DataNode*> NodeDeleted;
71 
72 protected:
73 
74  DataStorageListener(const mitk::DataStorage::Pointer);
75  virtual ~DataStorageListener();
76 
77  DataStorageListener(const DataStorageListener&); // Purposefully not implemented.
78  DataStorageListener& operator=(const DataStorageListener&); // Purposefully not implemented.
79 
82  virtual void OnNodeAdded(mitk::DataNode* node);
83 
86  virtual void OnNodeChanged(mitk::DataNode* node);
87 
90  virtual void OnNodeRemoved(mitk::DataNode* node);
91 
94  virtual void OnNodeDeleted(mitk::DataNode* node);
95 
100  bool Pass(const mitk::DataNode* node) const;
101 
102 private:
103 
105  void AddListeners();
106 
108  void RemoveListeners();
109 
112  virtual void NodeAddedProxy(const mitk::DataNode* node);
113 
116  virtual void NodeChangedProxy(const mitk::DataNode* node);
117 
120  virtual void NodeRemovedProxy(const mitk::DataNode* node);
121 
124  virtual void NodeDeletedProxy(const mitk::DataNode* node);
125 
127  mitk::DataStorage::Pointer m_DataStorage;
128 
130  bool m_InDataStorageChanged;
131 
133  std::vector<DataNodeFilter*> m_Filters;
134 
136  bool m_Blocked;
137 };
138 
139 }
140 
141 #endif
mitk::Message1< mitk::DataNode * > NodeDeleted
Definition: niftkDataStorageListener.h:70
mitk::Message1< mitk::DataNode * > NodeRemoved
Definition: niftkDataStorageListener.h:69
mitk::Message1< mitk::DataNode * > NodeChanged
Definition: niftkDataStorageListener.h:68
mitk::Message1< mitk::DataNode * > NodeAdded
GUI independent message callback.
Definition: niftkDataStorageListener.h:67
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glew.h:3751
Definition: niftkExceptionObject.h:21
Base class for objects that Listen to data storage, and want to update a node.
Definition: niftkDataStorageListener.h:39