Panda3D
 All Classes Functions Variables Enumerations
threadSafePointerToBase.h
1 // Filename: threadSafePointerToBase.h
2 // Created by: drose (28Apr06)
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 THREADSAFEPOINTERTOBASE_H
16 #define THREADSAFEPOINTERTOBASE_H
17 
18 #include "pandabase.h"
19 #include "pointerToVoid.h"
20 #include "referenceCount.h"
21 #include "typedef.h"
22 #include "memoryUsage.h"
23 #include "config_express.h"
24 #include "atomicAdjust.h"
25 
26 ////////////////////////////////////////////////////////////////////
27 // Class : ThreadSafePointerToBase
28 // Description : This is the base class for ThreadSafePointerTo and
29 // ThreadSafeConstPointerTo. Don't try to use it
30 // directly; use either derived class instead.
31 ////////////////////////////////////////////////////////////////////
32 template <class T>
34 public:
35  typedef T To;
36 
37 protected:
38  INLINE ThreadSafePointerToBase(To *ptr);
39  INLINE ThreadSafePointerToBase(const ThreadSafePointerToBase<T> &copy);
40  INLINE ~ThreadSafePointerToBase();
41 
42  INLINE void reassign(To *ptr);
43  INLINE void reassign(const ThreadSafePointerToBase<To> &copy);
44 
45 #ifdef DO_MEMORY_USAGE
46  void update_type(To *ptr);
47 #endif // DO_MEMORY_USAGE
48 
49  // No assignment or retrieval functions are declared in
50  // ThreadSafePointerToBase, because we will have to specialize on const
51  // vs. non-const later.
52 
53 PUBLISHED:
54  INLINE void clear();
55 
56  void output(ostream &out) const;
57 };
58 
59 template<class T>
60 INLINE ostream &operator <<(ostream &out, const ThreadSafePointerToBase<T> &pointer) {
61  pointer.output(out);
62  return out;
63 }
64 
65 #include "threadSafePointerToBase.I"
66 
67 #endif
This is the non-template part of the base class for PointerTo and ConstPointerTo. ...
Definition: pointerToVoid.h:36
void clear()
A convenient way to set the ThreadSafePointerTo object to NULL.
void output(ostream &out) const
A handy function to output ThreadSafePointerTo&#39;s as a hex pointer followed by a reference count...
This is the base class for ThreadSafePointerTo and ThreadSafeConstPointerTo.