Slicer  4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
vtkObserverManager.h
Go to the documentation of this file.
1 /*=auto=========================================================================
2 
3  Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
4 
5  See COPYRIGHT.txt
6  or http://www.slicer.org/copyright/copyright.txt for details.
7 
8  Program: 3D Slicer
9  Module: $RCSfile: vtkObserverManager.h,v $
10  Date: $Date: 2006/01/08 04:48:05 $
11  Version: $Revision: 1.45 $
12 
13 =========================================================================auto=*/
14 
15 #ifndef __vtkObserverManager_h
16 #define __vtkObserverManager_h
17 
18 // MRML includes
19 #include "vtkMRML.h"
20 
21 // VTK includes
22 #include <vtkObject.h>
23 
24 // STD includes
25 #include <map>
26 
27 class vtkCallbackCommand;
28 class vtkIntArray;
29 class vtkFloatArray;
30 class vtkUnsignedLongArray;
31 
32 #ifndef vtkObjectPointer
33 #define vtkObjectPointer(xx) (reinterpret_cast <vtkObject **>( (xx) ))
34 #endif
35 
41 class VTK_MRML_EXPORT vtkObserverManager : public vtkObject
42 {
43  public:
44 
46  static vtkObserverManager *New();
47  vtkTypeMacro(vtkObserverManager,vtkObject);
48  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
49 
51  void SetObject(vtkObject **nodePtr, vtkObject *node);
52 
54  void SetAndObserveObject(vtkObject **nodePtr, vtkObject *node, float priority=0.0, bool logWarningIfSameObservationExists=true);
55 
57  void SetAndObserveObjectEvents(vtkObject **nodePtr, vtkObject *node, vtkIntArray *events, vtkFloatArray *priorities=0, bool logWarningIfSameObservationExists=true);
58 
60  void RemoveObjectEvents(vtkObject *nodePtr);
61 
63  void GetObjectEvents(vtkObject *nodePtr, vtkIntArray *events, vtkFloatArray *priorities);
64 
66  void ObserveObject(vtkObject *node, float priority=0.0);
67 
69  void AddObjectEvents(vtkObject *nodePtr, vtkIntArray *events, vtkFloatArray *priorities=0);
70 
76  vtkGetObjectMacro (Owner, vtkObject);
77  void AssignOwner (vtkObject *owner) { this->Owner = owner; };
79  vtkObject* GetObserver();
80 
81  vtkGetObjectMacro (CallbackCommand, vtkCallbackCommand);
82 
85  int GetObservationsCount(vtkObject* nodePtr, unsigned long event = 0);
86 protected:
88  virtual ~vtkObserverManager();
90  void operator=(const vtkObserverManager&);
91 
94  vtkObject *Owner;
95 
98  vtkCallbackCommand *CallbackCommand;
99 
100  std::map< vtkObject*, vtkUnsignedLongArray* > ObserverTags;
101 
102 };
103 
104 #endif
vtkCallbackCommand * CallbackCommand
Holder for callback
void AssignOwner(vtkObject *owner)
Manages adding and deleting of obserevers with events.
std::map< vtkObject *, vtkUnsignedLongArray *> ObserverTags
vtkObject * Owner
The owner of the observer manager (e.g. the vtkMRMLNode)