eformat::PagedMemory< TMAXPAGES > Class Template Reference

#include <PagedMemory.h>

List of all members.

Public Types

typedef eformat::PagedMemory::node_t node_t

Public Member Functions

 PagedMemory (const struct iovec *pages, size_t count)
iovec * pages (void) const
size_t count (void) const
size_t size (void) const
const_iterator begin (void) const
const_iterator end (void) const

Static Public Attributes

static const unsigned int MAXPAGES = TMAXPAGES

Private Attributes

iovec * m_iovec
 my iovec set of pages
size_t m_count
 how many pages do I have in the list above
node_t m_node [TMAXPAGES]
 index
size_t m_size
 the number of words I have in this Memory

Classes

class  const_iterator
struct  node_t


Detailed Description

template<unsigned int TMAXPAGES = 128>
class eformat::PagedMemory< TMAXPAGES >

A list of nodes. To gain speed, the PagedMemory uses an internal page index. The default maximum size of this index is 128. The user can instanciate bigger PagedMemory objects by increasing the default template parameter size to a more suitable value.

Attention: PagedMemory's with different index sizes cannot interact directly.

Definition at line 39 of file PagedMemory.h.


Member Typedef Documentation

template<unsigned int TMAXPAGES = 128>
typedef struct eformat::PagedMemory::node_t eformat::PagedMemory< TMAXPAGES >::node_t

Define a private type that is used to index the access to this type of eformat::Memory. The performance of this iterator is dependent on the distance from the current offset and on the page sizes. Try to use the iterator for small scale reach and readjust if necessary.


Constructor & Destructor Documentation

template<unsigned int TMAXPAGES>
eformat::PagedMemory< TMAXPAGES >::PagedMemory ( const struct iovec *  pages,
size_t  count 
)

Simpler constructor: starts from an existing set of base addresses and sizes. Please note that for reasons of simplicity, the data in all memory blocks have to be 32-bit aligned. Otherwise, the implementation should be DC::Buffer, where this has all been thought about.

Also note that this class is intended for reading data and optimized for such. If you just want to manipulate fragments you are better doing it your self or using the writing part of the library.

Parameters:
pages The memory area I would like to read data from
count The number of pages pointed by the variable pages. This has to be smaller than TMAXPAGES.

Definition at line 275 of file PagedMemory.h.

References EFORMAT_NOT_ALIGNED, EFORMAT_TOO_BIG_COUNT, genRecEmupikp::i, and next.

00276   : m_iovec(pages),
00277     m_count(count),
00278     m_size(0)
00279 {
00280   if (m_count > MAXPAGES) {
00281     //Problem, I cannot index this amount of data
00282     throw EFORMAT_TOO_BIG_COUNT(count, MAXPAGES);
00283   }
00284   for (size_t i=0; i<count; ++i) {
00285     m_node[i].page = &pages[i];
00286     if (pages[i].iov_len % 4 != 0) {
00287       //Problem, one of the data blocks is *not* 32-bit aligned
00288       throw EFORMAT_NOT_ALIGNED(pages[i].iov_base, pages[i].iov_len);
00289     }
00290     m_node[i].start = m_size;
00291     m_size += pages[i].iov_len >> 2;
00292     m_node[i].end = m_size;
00293     if (i > 0) m_node[i].previous = &m_node[i-1];
00294     else m_node[i].previous = 0;
00295     if (i < (count-1) ) m_node[i].next = &m_node[i+1];
00296     else m_node[i].next = 0;
00297   }
00298 }


Member Function Documentation

template<unsigned int TMAXPAGES = 128>
const_iterator eformat::PagedMemory< TMAXPAGES >::begin ( void   )  const [inline]

Returns a const iterator to the begin of this list

Parameters:
it An updateable iterator you should provide.

Definition at line 249 of file PagedMemory.h.

References eformat::PagedMemory< TMAXPAGES >::m_node.

00250     { return const_iterator(m_node, 0); }

template<unsigned int TMAXPAGES = 128>
size_t eformat::PagedMemory< TMAXPAGES >::count ( void   )  const [inline]

Returns the number of blocks in this IO vector

Definition at line 71 of file PagedMemory.h.

References eformat::PagedMemory< TMAXPAGES >::m_count.

00071 { return m_count; }

template<unsigned int TMAXPAGES = 128>
const_iterator eformat::PagedMemory< TMAXPAGES >::end ( void   )  const [inline]

Returns a const iterator to the end of this list

Parameters:
it An updateable iterator you should provide.

Definition at line 257 of file PagedMemory.h.

References eformat::PagedMemory< TMAXPAGES >::m_count, eformat::PagedMemory< TMAXPAGES >::m_node, and eformat::PagedMemory< TMAXPAGES >::m_size.

Referenced by eformat::PagedMemory< TMAXPAGES >::const_iterator::at().

00258     { return const_iterator(&m_node[m_count], m_size); }

template<unsigned int TMAXPAGES = 128>
struct iovec* eformat::PagedMemory< TMAXPAGES >::pages ( void   )  const [inline]

Returns the base address of the input IO vector

Definition at line 66 of file PagedMemory.h.

References eformat::PagedMemory< TMAXPAGES >::m_iovec.

00066 { return m_iovec; }

template<unsigned int TMAXPAGES = 128>
size_t eformat::PagedMemory< TMAXPAGES >::size ( void   )  const [inline]

Returns the size in bytes words for this PagedMemory.

Definition at line 76 of file PagedMemory.h.

References eformat::PagedMemory< TMAXPAGES >::m_size.

00076 { return m_size; }


Member Data Documentation

template<unsigned int TMAXPAGES = 128>
size_t eformat::PagedMemory< TMAXPAGES >::m_count [private]

how many pages do I have in the list above

Definition at line 263 of file PagedMemory.h.

Referenced by eformat::PagedMemory< TMAXPAGES >::count(), and eformat::PagedMemory< TMAXPAGES >::end().

template<unsigned int TMAXPAGES = 128>
struct iovec* eformat::PagedMemory< TMAXPAGES >::m_iovec [private]

my iovec set of pages

Definition at line 262 of file PagedMemory.h.

Referenced by eformat::PagedMemory< TMAXPAGES >::pages().

template<unsigned int TMAXPAGES = 128>
node_t eformat::PagedMemory< TMAXPAGES >::m_node[TMAXPAGES] [private]

index

Definition at line 264 of file PagedMemory.h.

Referenced by eformat::PagedMemory< TMAXPAGES >::begin(), and eformat::PagedMemory< TMAXPAGES >::end().

template<unsigned int TMAXPAGES = 128>
size_t eformat::PagedMemory< TMAXPAGES >::m_size [private]

the number of words I have in this Memory

Definition at line 265 of file PagedMemory.h.

Referenced by eformat::PagedMemory< TMAXPAGES >::end(), and eformat::PagedMemory< TMAXPAGES >::size().

template<unsigned int TMAXPAGES = 128>
const unsigned int eformat::PagedMemory< TMAXPAGES >::MAXPAGES = TMAXPAGES [static]

Definition at line 43 of file PagedMemory.h.


Generated on Tue Nov 29 23:36:29 2016 for BOSS_7.0.2 by  doxygen 1.4.7