Panda3D
weakPointerToVoid.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file weakPointerToVoid.h
10  * @author drose
11  * @date 2004-09-27
12  */
13 
14 #ifndef WEAKPOINTERTOVOID_H
15 #define WEAKPOINTERTOVOID_H
16 
17 #include "pandabase.h"
18 #include "pointerToVoid.h"
19 #include "weakPointerCallback.h"
20 #include "weakReferenceList.h"
21 
22 /**
23  * This is the specialization of PointerToVoid for weak pointers. It needs an
24  * additional flag to indicate that the pointer has been deleted.
25  */
26 class EXPCL_PANDA_EXPRESS WeakPointerToVoid : public PointerToVoid {
27 protected:
28  constexpr WeakPointerToVoid() noexcept = default;
29 
30 public:
31  INLINE void add_callback(WeakPointerCallback *callback) const;
32  INLINE void remove_callback(WeakPointerCallback *callback) const;
33 
34 PUBLISHED:
35  INLINE bool was_deleted() const;
36  INLINE bool is_valid_pointer() const;
37 
38 protected:
39  mutable WeakReferenceList *_weak_ref = nullptr;
40 };
41 
42 #include "weakPointerToVoid.I"
43 
44 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the specialization of PointerToVoid for weak pointers.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is an object shared by all the weak pointers that point to the same ReferenceCount object.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is the non-template part of the base class for PointerTo and ConstPointerTo.
Definition: pointerToVoid.h:33
Derive from this class and override the callback() method if you want to get an immediate callback fr...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.