Loading...
Searching...
No Matches
vspace::VRef< T > Struct Template Reference

`#include <vspace.h>`

## Public Member Functions

| VRef ()
size_t | offset () const
bool | operator== (VRef< T > other)
bool | operator!= (VRef< T > other)
| operator bool () const
bool | is_null ()
| VRef (void *ptr)
void * | to_ptr () const
T * | as_ptr () const
T & | as_ref () const
T & | operator* () const
T * | operator-> ()
VRef< T > & | operator= (VRef< T > other)
T & | operator[] (size_t index)
template<typename U>
VRef< U > | cast ()
void | free ()

## Static Public Member Functions

static VRef< T > | from_vaddr (internals::vaddr_t vaddr)
static VRef< T > | alloc (size_t n=1)

## Private Member Functions

| VRef (internals::vaddr_t vaddr)

## Private Attributes

internals::vaddr_t | vaddr

## Detailed Description

template<typename T>
struct vspace::VRef< T >

Definition at line 1747 of file vspace.h.

## Constructor & Destructor Documentation

## VRef() [1/3]

template<typename T>

vspace::VRef< T >::VRef | ( | internals::vaddr_t | vaddr | ) |

inline private

Definition at line 1750 of file vspace.h.

: vaddr(vaddr) {
}
vspace::VRef::vaddr
internals::vaddr_t vaddr
Definition vspace.h:1749

## VRef() [2/3]

template<typename T>

vspace::VRef< T >::VRef | ( |  | ) |

inline

Definition at line 1753 of file vspace.h.

: vaddr(internals::VADDR_NULL) {
}
vspace::VRef
Definition vspace.h:1747

## VRef() [3/3]

template<typename T>

vspace::VRef< T >::VRef | ( | void * | ptr | ) |

inline

Definition at line 1773 of file vspace.h.

{
vaddr = internals::allocated_ptr_to_vaddr(ptr);
}
vspace::internals::allocated_ptr_to_vaddr
static vaddr_t allocated_ptr_to_vaddr(void *ptr)
Definition vspace.h:1697

## Member Function Documentation

## alloc()

template<typename T>

VRef< T > vspace::VRef< T >::alloc | ( | size_t | n = 1 | ) |

inline static

Definition at line 1802 of file vspace.h.

{
return VRef<T>(internals::vmem_alloc(n * sizeof(T)));
}
vspace::VRef::VRef
VRef()
Definition vspace.h:1753

## as_ptr()

template<typename T>

T * vspace::VRef< T >::as_ptr | ( |  | ) | const

inline

Definition at line 1779 of file vspace.h.

{
return (T *) to_ptr();
}
vspace::VRef::to_ptr
void * to_ptr() const
Definition vspace.h:1776

## as_ref()

template<typename T>

T & vspace::VRef< T >::as_ref | ( |  | ) | const

inline

Definition at line 1782 of file vspace.h.

{
return *(T *) to_ptr();
}

## cast()

template<typename T>
template<typename U>

VRef< U > vspace::VRef< T >::cast | ( |  | ) |

inline

Definition at line 1799 of file vspace.h.

{
return VRef<U>::from_vaddr(vaddr);
}
vspace::VRef::from_vaddr
static VRef< T > from_vaddr(internals::vaddr_t vaddr)
Definition vspace.h:1755

## free()

template<typename T>

void vspace::VRef< T >::free | ( |  | ) |

inline

Definition at line 1805 of file vspace.h.

{
as_ptr()->~T(); // explicitly call destructor
internals::vmem_free(vaddr);
vaddr = internals::VADDR_NULL;
}
vspace::internals::vmem_free
void vmem_free(vaddr_t vaddr)
Definition vspace.cc:802
vspace::VRef::as_ptr
T * as_ptr() const
Definition vspace.h:1779

## from_vaddr()

template<typename T>

VRef< T > vspace::VRef< T >::from_vaddr | ( | internals::vaddr_t | vaddr | ) |

inline static

Definition at line 1755 of file vspace.h.

{
return VRef(vaddr);
}

## is_null()

template<typename T>

bool vspace::VRef< T >::is_null | ( |  | ) |

inline

Definition at line 1770 of file vspace.h.

{
return vaddr == internals::VADDR_NULL;
}

## offset()

template<typename T>

size_t vspace::VRef< T >::offset | ( |  | ) | const

inline

Definition at line 1758 of file vspace.h.

{
return vaddr;
}

## operator bool()

template<typename T>

vspace::VRef< T >::operator bool | ( |  | ) | const

inline

Definition at line 1767 of file vspace.h.

{
return vaddr != internals::VADDR_NULL;
}

## operator!=()

template<typename T>

bool vspace::VRef< T >::operator!= | ( | VRef< T > | other | ) |

inline

Definition at line 1764 of file vspace.h.

{
return vaddr != other.vaddr;
}

## operator*()

template<typename T>

T & vspace::VRef< T >::operator* | ( |  | ) | const

inline

Definition at line 1785 of file vspace.h.

{
return *(T *) to_ptr();
}

## operator->()

template<typename T>

T * vspace::VRef< T >::operator-> | ( |  | ) |

inline

Definition at line 1788 of file vspace.h.

{
return (T *) to_ptr();
}

## operator=()

template<typename T>

VRef< T > & vspace::VRef< T >::operator= | ( | VRef< T > | other | ) |

inline

Definition at line 1791 of file vspace.h.

{
vaddr = other.vaddr;
return *this;
}

## operator==()

template<typename T>

bool vspace::VRef< T >::operator== | ( | VRef< T > | other | ) |

inline

Definition at line 1761 of file vspace.h.

{
return vaddr == other.vaddr;
}

## operator[]()

template<typename T>

T & vspace::VRef< T >::operator[] | ( | size_t | index | ) |

inline

Definition at line 1795 of file vspace.h.

{
return as_ptr()[index];
}

## to_ptr()

template<typename T>

void * vspace::VRef< T >::to_ptr | ( |  | ) | const

inline

Definition at line 1776 of file vspace.h.

{
return internals::vmem.to_ptr(vaddr);
}

## Field Documentation

## vaddr

template<typename T>

internals::vaddr_t vspace::VRef< T >::vaddr

private

Definition at line 1749 of file vspace.h.

The documentation for this struct was generated from the following file:

- kernel/oswrapper/vspace.h