virtmem
virtual memory library for Arduino
virtmem Namespace Reference

contains all code from virtmem More...

Namespaces

 serram_utils
 Contains utilities for serial allocator.
 

Classes

class  BaseVAlloc
 Base class for virtual memory allocators. More...
 
class  BaseVPtr
 This is the base class of VPtr and can be used for typeless pointers. More...
 
struct  DefaultAllocProperties
 This struct contains default parameters for virtual memory pages. More...
 
class  MultiSPIRAMVAllocP
 Virtual allocator that uses multiple SRAM chips (i.e. 23LC series from Microchip) as memory pool. More...
 
class  SDVAllocP
 Virtual memory allocator class that uses SD card as virtual pool. More...
 
class  SerialVAllocP
 Virtual memory allocator that uses external memory via a serial connection as memory pool. More...
 
struct  SPIRamConfig
 This struct is used to configure each SRAM chip used by a MultiSPIRAMVAllocP allocator. More...
 
class  SPIRAMVAllocP
 Virtual memory allocator that uses SPI (serial) RAM (i.e. the 23LC series from Microchip) as memory pool. More...
 
class  StaticVAllocP
 Virtual memory allocator that uses a static array (in regular RAM) as memory pool. More...
 
class  StdioVAllocP
 Virtual memory allocator that uses a regular file (via stdio) as memory pool. More...
 
class  VAlloc
 Base template class for virtual memory allocators. More...
 
class  VPtr
 Virtual pointer class that provides an interface to access virtual much like 'regular pointers'. More...
 
class  VPtrLock
 Creates a lock to some virtual data. More...
 

Typedefs

typedef uint32_t VPtrNum
 Numeric type used to store raw virtual pointer addresses.
 
typedef uint32_t VPtrSize
 Numeric type used to store the size of a virtual memory block.
 
typedef uint16_t VirtPageSize
 Numeric type used to store the size of a virtual memory page.
 
typedef nullptr_t NILL_t
 
typedef SDVAllocP SDVAlloc
 Shortcut to SDVAllocP with default template arguments.
 
typedef SerialVAllocP SerialVAlloc
 Shortcut to SerialVAllocP with default template arguments.
 
typedef SPIRAMVAllocP SPIRAMVAlloc
 Shortcut to SPIRAMVAllocP with default template arguments.
 
typedef StaticVAllocP StaticVAlloc
 Shortcut to StaticVAllocP with default template arguments.
 
typedef StdioVAllocP StdioVAlloc
 Shortcut to StdioVAllocP with default template arguments.
 

Functions

template<typename T >
VPtrLock< T > makeVirtPtrLock (const T &w, VirtPageSize s, bool ro=false)
 Creates a virtual lock (shortcut) More...
 
template<typename C , typename M , typename A >
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. More...
 
template<typename C , typename M , typename NC , typename NM , typename A >
VPtr< NM, A > getMembrPtr (const VPtr< C, A > &c, const M C::*m, const NM NC::*nm)
 Obtains a virtual pointer to a nested data member that is stored in virtual memory. More...
 
Overloads of C library functions for virtual pointers

The following functions are overloads of some common C functions for dealing with memory and strings. They accept virtual pointers or a mix of virtual and regular pointers. Please note that they are defined in the virtmem namespace like any other code from virtmem, hence, they will not "polute" the global namespace unless you want to (i.e. by using the using directive).

template<typename T1 , typename A1 , typename T2 , typename A2 >
VPtr< T1, A1 > memcpy (VPtr< T1, A1 > dest, const VPtr< T2, A2 > src, VPtrSize size)
 
template<typename T , typename A >
VPtr< T, A > memcpy (VPtr< T, A > dest, const void *src, VPtrSize size)
 
template<typename T , typename A >
void * memcpy (void *dest, VPtr< T, A > src, VPtrSize size)
 
template<typename A >
VPtr< char, A > memset (VPtr< char, A > dest, int c, VPtrSize size)
 
template<typename T , typename A >
VPtr< T, A > memset (VPtr< T, A > dest, int c, VPtrSize size)
 
template<typename T1 , typename A1 , typename T2 , typename A2 >
int memcmp (VPtr< T1, A1 > s1, const VPtr< T2, A2 > s2, VPtrSize n)
 
template<typename T , typename A >
int memcmp (VPtr< T, A > s1, const void *s2, VPtrSize n)
 
template<typename T , typename A >
int memcmp (const void *s1, const VPtr< T, A > s2, VPtrSize n)
 
template<typename A1 , typename A2 >
VPtr< char, A1 > strncpy (VPtr< char, A1 > dest, const VPtr< const char, A2 > src, VPtrSize n)
 
template<typename A >
VPtr< char, A > strncpy (VPtr< char, A > dest, const char *src, VPtrSize n)
 
template<typename A >
char * strncpy (char *dest, const VPtr< const char, A > src, VPtrSize n)
 
template<typename A1 , typename A2 >
VPtr< char, A1 > strcpy (VPtr< char, A1 > dest, const VPtr< const char, A2 > src)
 
template<typename A >
VPtr< char, A > strcpy (VPtr< char, A > dest, const char *src)
 
template<typename A >
char * strcpy (char *dest, const VPtr< const char, A > src)
 
template<typename A1 , typename A2 >
int strncmp (VPtr< const char, A1 > dest, VPtr< const char, A2 > src, VPtrSize n)
 
template<typename A >
int strncmp (VPtr< const char, A > dest, const char *src, VPtrSize n)
 
template<typename A >
int strncmp (const char *dest, VPtr< const char, A > src, VPtrSize n)
 
template<typename A1 , typename A2 >
int strcmp (VPtr< const char, A1 > dest, VPtr< const char, A2 > src)
 
template<typename A >
int strcmp (const char *dest, VPtr< const char, A > src)
 
template<typename A >
int strcmp (VPtr< const char, A > dest, const char *src)
 
template<typename A >
int strlen (VPtr< const char, A > str)
 

Variables

const NILL_t NILL = NILL_t()
 Global instance of a NILL_t class. More...
 

Detailed Description

contains all code from virtmem

Function Documentation

template<typename C , typename M , typename A >
VPtr<M, A> virtmem::getMembrPtr ( const VPtr< C, A > &  c,
const M C::*  m 
)
inline

Obtains a virtual pointer to a data member that is stored in virtual memory.

Template Parameters
CType of virtual data (e.g. the structure)
MType of the data member
AType of the virtual memory allocator
Parameters
cThe virtual pointer of the structure (or class) to which the data member belongs
mA pointer to the member (e.g. &MyStruct::x)
See also
section about virtual pointers to data members in manual
template<typename C , typename M , typename NC , typename NM , typename A >
VPtr<NM, A> virtmem::getMembrPtr ( const VPtr< C, A > &  c,
const M C::*  m,
const NM NC::*  nm 
)
inline

Obtains a virtual pointer to a nested data member that is stored in virtual memory.

Template Parameters
CType of virtual data (e.g. the structure)
MType of the data member
NCType of the nested structure
NMType of nested data member
AType of the virtual memory allocator
Parameters
cThe virtual pointer of the structure (or class) to which the data member belongs
mA pointer to the nested structure/class (e.g. &MyStruct::MyOtherStruct)
nmA pointer to the nested data member (e.g. &MyStruct::MyOtherStruct::y)
See also
section about virtual pointers to data members in manual
template<typename T >
VPtrLock<T> virtmem::makeVirtPtrLock ( const T &  w,
VirtPageSize  s,
bool  ro = false 
)

Creates a virtual lock (shortcut)

This function is a shortcut for making a virtual lock: unlike using VPtrLock, you don't need to specify the virtual pointer type as a template parameter. The function parameters are the same as VPtrLock::VPtrLock.

See also
VPtr and Locking virtual data
Examples:
locking.ino.

Variable Documentation

virtmem::NILL = NILL_t()

Global instance of a NILL_t class.

This variable can be used to assign a NULL pointer to both virtual and regular pointers. Example:

using namespace virtmem;
char *a = NILL;
See also
NILL_t