1 #ifndef VIRTMEM_VPTR_UTILS_H
2 #define VIRTMEM_VPTR_UTILS_H
30 void operator&()
const;
33 template <
typename T>
inline operator T*(void)
const {
return 0; }
34 template <
typename C,
typename M>
inline operator M C::*(void)
const {
return 0; }
35 template <
typename T,
typename A>
inline operator VPtr<T, A>(void)
const {
return VPtr<T, A>(); }
36 inline operator BaseVPtr(
void)
const {
return BaseVPtr(); }
37 template <
typename T,
typename A>
inline operator typename VPtr<T, A>::ValueWrapper(
void)
const {
return VPtr<T, A>::ValueWrapper(0); }
43 extern const NILL_t
NILL;
78 typedef typename TV::TPtr Ptr;
96 virtPtr(v), lockSize(s), readOnly(ro) {
lock(); }
103 VPtrLock(
void) : data(0), lockSize(0), readOnly(false) { }
106 virtPtr(other.virtPtr), lockSize(other.lockSize),
107 readOnly(other.readOnly) {
lock(); }
116 #ifdef VIRTMEM_WRAP_CPOINTERS
117 if (virtPtr.isWrapped())
118 data = virtPtr.unwrap();
121 data =
static_cast<Ptr
>(TV::getAlloc()->makeFittingLock(virtPtr.ptr, lockSize, readOnly));
129 virtPtr = v; lockSize = s; readOnly = ro;
138 #ifdef VIRTMEM_WRAP_CPOINTERS
139 if (!virtPtr.isWrapped() && data)
144 TV::getAlloc()->releaseLock(virtPtr.ptr);
178 namespace private_utils {
182 template <
typename C,
typename M> ptrdiff_t getMembrOffset(
const M C::*m)
183 {
return ((
char *)&((
char &)((C *)(0)->*m)) - (
char *)(0)); }
219 #endif // VIRTMEM_VPTR_UTILS_H
contains all code from virtmem
Definition: base_alloc.cpp:22
PtrNum getRawNum(void) const
Returns a numeric representation of this virtual pointer.
Definition: base_vptr.h:153
Ptr operator*(void)
Provides access to the data.
Definition: vptr_utils.h:149
VPtrLock(void)
Default constructor. No locks are created.
Definition: vptr_utils.h:103
void lock(void)
Recreates a virtual data lock after unlock was called.
Definition: vptr_utils.h:114
VPtrLock(const TV &v, VirtPageSize s, bool ro=false)
Constructs a virtual data lock class and creates a lock to the given data.
Definition: vptr_utils.h:95
This header file contains several variables that can be used to customize virtmem.
void setRawNum(PtrNum p)
Sets a virtual pointer from a numeric value.
Definition: base_vptr.h:159
uint16_t VirtPageSize
Numeric type used to store the size of a virtual memory page.
Definition: base_alloc.h:23
VPtr< M, A > getMembrPtr(const VPtr< C, A > &c, const M C::*m)
Obtains a virtual pointer to a data member that is stored in virtual memory.
Definition: vptr_utils.h:196
This header contains the class definition of the VPtr class.
VPtrLock(const VPtrLock &other)
Copy constructor, adds extra lock to data.
Definition: vptr_utils.h:105
VPtrLock< T > makeVirtPtrLock(const T &w, VirtPageSize s, bool ro=false)
Creates a virtual lock (shortcut)
Definition: vptr_utils.h:175
~VPtrLock(void)
Unlocks data if locked.
Definition: vptr_utils.h:104
const NILL_t NILL
Global instance of a NILL_t class.
Definition: utils.cpp:6
void lock(const TV &v, VirtPageSize s, bool ro=false)
Locks data. Parameters are described here.
Definition: vptr_utils.h:127
void unlock(void)
Unlocks data (if locked). Automatically called during destruction.
Definition: vptr_utils.h:136
Creates a lock to some virtual data.
Definition: vptr_utils.h:76
Generalized NULL pointer class.
Virtual pointer class that provides an interface to access virtual much like 'regular pointers'...
Definition: alloc.h:15
VirtPageSize getLockSize(void) const
Returns the actual size locked.
Definition: vptr_utils.h:158
This header file contains several overloads of common C functions that work with virtual pointers...