00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef COPYONWRITEPOINTER_H
00016 #define COPYONWRITEPOINTER_H
00017
00018 #include "pandabase.h"
00019
00020 #include "copyOnWriteObject.h"
00021 #include "pointerTo.h"
00022 #include "dcast.h"
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 class EXPCL_PANDA_PUTIL CopyOnWritePointer {
00036 public:
00037 INLINE CopyOnWritePointer(CopyOnWriteObject *object = NULL);
00038 INLINE CopyOnWritePointer(const CopyOnWritePointer ©);
00039 INLINE void operator = (const CopyOnWritePointer ©);
00040 INLINE void operator = (CopyOnWriteObject *object);
00041 INLINE ~CopyOnWritePointer();
00042
00043 INLINE bool operator == (const CopyOnWritePointer &other) const;
00044 INLINE bool operator != (const CopyOnWritePointer &other) const;
00045 INLINE bool operator < (const CopyOnWritePointer &other) const;
00046
00047 #ifdef COW_THREADED
00048 CPT(CopyOnWriteObject) get_read_pointer() const;
00049 PT(CopyOnWriteObject) get_write_pointer();
00050 #else
00051 INLINE const CopyOnWriteObject *get_read_pointer() const;
00052 INLINE CopyOnWriteObject *get_write_pointer();
00053 #endif // COW_THREADED
00054
00055 INLINE CopyOnWriteObject *get_unsafe_pointer();
00056
00057 INLINE bool is_null() const;
00058 INLINE void clear();
00059
00060 INLINE bool test_ref_count_integrity() const;
00061 INLINE bool test_ref_count_nonzero() const;
00062
00063 private:
00064 CopyOnWriteObject *_object;
00065 };
00066
00067
00068
00069
00070
00071
00072
00073 template <class T>
00074 class CopyOnWritePointerTo : public CopyOnWritePointer {
00075 public:
00076
00077
00078 #ifndef CPPPARSER
00079 typedef T To;
00080
00081 INLINE CopyOnWritePointerTo(To *object = NULL);
00082 INLINE CopyOnWritePointerTo(const CopyOnWritePointerTo<T> ©);
00083 INLINE void operator = (const CopyOnWritePointerTo<T> ©);
00084 INLINE void operator = (To *object);
00085
00086 #ifdef COW_THREADED
00087 INLINE CPT(To) get_read_pointer() const;
00088 INLINE PT(To) get_write_pointer();
00089 #else
00090 INLINE const To *get_read_pointer() const;
00091 INLINE To *get_write_pointer();
00092 #endif // COW_THREADED
00093
00094 INLINE To *get_unsafe_pointer();
00095 #endif // CPPPARSER
00096 };
00097
00098 #define COWPT(type) CopyOnWritePointerTo< type >
00099
00100 #include "copyOnWritePointer.I"
00101
00102 #endif