VTK
vtkWeakPointerBase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkWeakPointerBase.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
24 #ifndef vtkWeakPointerBase_h
25 #define vtkWeakPointerBase_h
26 
27 #include "vtkCommonCoreModule.h" // For export macro
28 #include "vtkObjectBase.h"
29 
30 class vtkObjectBaseToWeakPointerBaseFriendship;
31 
33 {
34 public:
36  vtkWeakPointerBase() : Object(0) {}
37 
40 
43 
46 
48 
50  vtkWeakPointerBase& operator=(vtkObjectBase* r);
51  vtkWeakPointerBase& operator=(const vtkWeakPointerBase& r);
53 
55 
57  {
58  // Inline implementation so smart pointer comparisons can be fully
59  // inlined.
60  return this->Object;
61  }
63 
64 private:
65  friend class vtkObjectBaseToWeakPointerBaseFriendship;
66 
67 protected:
68 
69  // Initialize weak pointer to given object.
70  class NoReference {};
72 
73  // Pointer to the actual object.
75 };
76 
77 //----------------------------------------------------------------------------
78 #define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op) \
79  inline bool \
80  operator op (const vtkWeakPointerBase& l, const vtkWeakPointerBase& r) \
81  { \
82  return (static_cast<void*>(l.GetPointer()) op \
83  static_cast<void*>(r.GetPointer())); \
84  } \
85  inline bool \
86  operator op (vtkObjectBase* l, const vtkWeakPointerBase& r) \
87  { \
88  return (static_cast<void*>(l) op static_cast<void*>(r.GetPointer())); \
89  } \
90  inline bool \
91  operator op (const vtkWeakPointerBase& l, vtkObjectBase* r) \
92  { \
93  return (static_cast<void*>(l.GetPointer()) op static_cast<void*>(r)); \
94  }
95 
96 
104 
105 #undef VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR
106 
108 
109 VTKCOMMONCORE_EXPORT ostream& operator << (ostream& os,
110  const vtkWeakPointerBase& p);
112 
113 #endif
114 // VTK-HeaderTest-Exclude: vtkWeakPointerBase.h
vtkObjectBase * Object
#define VTKCOMMONCORE_EXPORT
vtkObjectBase * GetPointer() const
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkWeakPointerBase &p)
Non-templated superclass for vtkWeakPointer.
abstract base class for most VTK objects
Definition: vtkObjectBase.h:59
#define VTK_WEAK_POINTER_BASE_DEFINE_OPERATOR(op)