Arduino-Storage
External Memory Storage library for Arduino
Storage::Cache Class Reference

#include <Storage.h>

Inheritance diagram for Storage::Cache:
Inheritance graph
Collaboration diagram for Storage::Cache:
Collaboration graph

Public Member Functions

 Cache (Storage &mem, void *buf, size_t size, size_t nmemb=1)
 
uint32_t addr (size_t ix=0)
 
int read (size_t ix=0)
 
int write (size_t ix=0)
 
uint32_t addr ()
 
int read (void *buf, uint32_t offset, size_t size)
 
int write (uint32_t offset, const void *buf, size_t size)
 

Public Attributes

const size_t MSIZE
 
const size_t NMEMB
 
const uint32_t SIZE
 

Protected Attributes

void * m_buf
 
Storagem_mem
 
const uint32_t m_addr
 

Detailed Description

Storage Cache for data; temporary or persistent external storage of data with local memory copy. Allows element access of vectors on external storage.

Definition at line 171 of file Storage.h.

Constructor & Destructor Documentation

Storage::Cache::Cache ( Storage mem,
void *  buf,
size_t  size,
size_t  nmemb = 1 
)
inline

Construct cached block on given storage device with the given local buffer, member size and number of members. Storage is allocated on the device for the total storage of the members. The buffer is assumed to only hold a single member.

Parameters
[in]memstorage device for block.
[in]bufbuffer address.
[in]sizenumber of bytes per member.
[in]nmembnumber of members (default 1).

Definition at line 183 of file Storage.h.

Member Function Documentation

uint32_t Storage::Block::addr ( )
inlineinherited

Returns storage address for the memory block.

Returns
address.

Definition at line 119 of file Storage.h.

uint32_t Storage::Cache::addr ( size_t  ix = 0)
inline

Returns storage address for the indexed storage block.

Parameters
[in]ixmember index (default 0):
Returns
address.

Definition at line 196 of file Storage.h.

int Storage::Block::read ( void *  buf,
uint32_t  offset,
size_t  size 
)
inlineinherited

Read given number of bytes from offset within block to given buffer. Returns number of bytes read or negative error code.

Parameters
[in]bufbuffer pointer.
[in]offsetoffset within block.
[in]sizenumber of bytes to read.
Returns
number of bytes read or negative error code.

Definition at line 132 of file Storage.h.

int Storage::Cache::read ( size_t  ix = 0)
inline

Read indexed storage block to buffer. Default index is the first member. Returns number of bytes read or negative error code.

Parameters
[in]ixmember index (default 0):
Returns
number of bytes read or negative error code.

Definition at line 212 of file Storage.h.

int Storage::Block::write ( uint32_t  offset,
const void *  buf,
size_t  size 
)
inlineinherited

Write given number of bytes from buffer to given offset within block. Returns number of bytes written or negative error code.

Parameters
[in]bufbuffer pointer.
[in]offsetoffset within block.
[in]sizenumber of bytes to write.
Returns
number of bytes written or negative error code.

Definition at line 148 of file Storage.h.

int Storage::Cache::write ( size_t  ix = 0)
inline

Write buffer to indexed storage block. Default index is the first member. Returns number of bytes written or negative error code.

Parameters
[in]ixmember index (default 0):
Returns
number of bytes written or negative error code.

Definition at line 228 of file Storage.h.

Member Data Documentation

const uint32_t Storage::Block::m_addr
protectedinherited

Address on storage device.

Definition at line 163 of file Storage.h.

void* Storage::Cache::m_buf
protected

Buffer for data.

Definition at line 245 of file Storage.h.

Storage& Storage::Block::m_mem
protectedinherited

Storage device from memory block.

Definition at line 160 of file Storage.h.

const size_t Storage::Cache::MSIZE

Size of member.

Definition at line 238 of file Storage.h.

const size_t Storage::Cache::NMEMB

Number of members.

Definition at line 241 of file Storage.h.

const uint32_t Storage::Block::SIZE
inherited

Size of memory block.

Definition at line 156 of file Storage.h.


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