Panda3D
weakPointerToVoid.h
1 // Filename: weakPointerToVoid.h
2 // Created by: drose (27Sep04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef WEAKPOINTERTOVOID_H
16 #define WEAKPOINTERTOVOID_H
17 
18 #include "pandabase.h"
19 #include "pointerToVoid.h"
20 #include "weakPointerCallback.h"
21 
22 ////////////////////////////////////////////////////////////////////
23 // Class : WeakPointerToVoid
24 // Description : This is the specialization of PointerToVoid for weak
25 // pointers. It needs an additional flag to indicate
26 // that the pointer has been deleted.
27 ////////////////////////////////////////////////////////////////////
28 class EXPCL_PANDAEXPRESS WeakPointerToVoid : public PointerToVoid {
29 protected:
30  INLINE WeakPointerToVoid();
31  INLINE ~WeakPointerToVoid();
32 
33 public:
34  INLINE void mark_deleted();
35 
36  INLINE void set_callback(WeakPointerCallback *callback);
37  INLINE WeakPointerCallback *get_callback() const;
38 
39 PUBLISHED:
40  INLINE bool was_deleted() const;
41  INLINE bool is_valid_pointer() const;
42 
43 protected:
44  bool _ptr_was_deleted;
45  WeakPointerCallback *_callback;
46 };
47 
48 #include "weakPointerToVoid.I"
49 
50 #endif
This is the specialization of PointerToVoid for weak pointers.
This is the non-template part of the base class for PointerTo and ConstPointerTo. ...
Definition: pointerToVoid.h:36
Derive from this class and override the callback() method if you want to get an immediate callback fr...