Panda3D
threadSafePointerToBase.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 threadSafePointerToBase.h
10  * @author drose
11  * @date 2006-04-28
12  */
13 
14 #ifndef THREADSAFEPOINTERTOBASE_H
15 #define THREADSAFEPOINTERTOBASE_H
16 
17 #include "pandabase.h"
18 #include "pointerToVoid.h"
19 #include "referenceCount.h"
20 #include "typedef.h"
21 #include "memoryUsage.h"
22 #include "config_express.h"
23 #include "atomicAdjust.h"
24 
25 /**
26  * This is the base class for ThreadSafePointerTo and
27  * ThreadSafeConstPointerTo. Don't try to use it directly; use either derived
28  * class instead.
29  */
30 template <class T>
32 public:
33  typedef T To;
34 
35 protected:
36  INLINE ThreadSafePointerToBase(To *ptr);
38  INLINE ~ThreadSafePointerToBase();
39 
40  INLINE void reassign(To *ptr);
41  INLINE void reassign(const ThreadSafePointerToBase<To> &copy);
42 
43  void update_type(To *ptr);
44 
45  // No assignment or retrieval functions are declared in
46  // ThreadSafePointerToBase, because we will have to specialize on const vs.
47  // non-const later.
48 
49 PUBLISHED:
50  INLINE void clear();
51 
52  void output(std::ostream &out) const;
53 };
54 
55 template<class T>
56 INLINE std::ostream &operator <<(std::ostream &out, const ThreadSafePointerToBase<T> &pointer) {
57  pointer.output(out);
58  return out;
59 }
60 
62 
63 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void output(std::ostream &out) const
A handy function to output ThreadSafePointerTo's as a hex pointer followed by a reference count.
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
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void clear()
A convenient way to set the ThreadSafePointerTo object to NULL.
This is the base class for ThreadSafePointerTo and ThreadSafeConstPointerTo.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.