BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
eformat::PagedMemory< TMAXPAGES > Class Template Reference

#include <PagedMemory.h>

Classes

class  const_iterator
 
struct  node_t
 

Public Types

typedef struct eformat::PagedMemory::node_t node_t
 
typedef struct eformat::PagedMemory::node_t node_t
 

Public Member Functions

 PagedMemory (const struct iovec *pages, size_t count)
 
const struct iovec * pages (void) const
 
size_t count (void) const
 
size_t size (void) const
 
const_iterator begin (void) const
 
const_iterator end (void) const
 
 PagedMemory (const struct iovec *pages, size_t count)
 
const struct 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
 

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.

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

Definition at line 39 of file Event/eformat/eformat-00-00-04/eformat/PagedMemory.h.

Member Typedef Documentation

◆ node_t [1/2]

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.

◆ node_t [2/2]

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

◆ PagedMemory() [1/2]

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
pagesThe memory area I would like to read data from
countThe number of pages pointed by the variable pages. This has to be smaller than TMAXPAGES.

Definition at line 274 of file Event/eformat/eformat-00-00-04/eformat/PagedMemory.h.

276 : m_iovec(pages),
277 m_count(count),
278 m_size(0)
279{
280 if (m_count > MAXPAGES) {
281 //Problem, I cannot index this amount of data
283 }
284 for (size_t i=0; i<count; ++i) {
285 m_node[i].page = &pages[i];
286 if (pages[i].iov_len % 4 != 0) {
287 //Problem, one of the data blocks is *not* 32-bit aligned
288 throw EFORMAT_NOT_ALIGNED(pages[i].iov_base, pages[i].iov_len);
289 }
290 m_node[i].start = m_size;
291 m_size += pages[i].iov_len >> 2;
292 m_node[i].end = m_size;
293 if (i > 0) m_node[i].previous = &m_node[i-1];
294 else m_node[i].previous = 0;
295 if (i < (count-1) ) m_node[i].next = &m_node[i+1];
296 else m_node[i].next = 0;
297 }
298}
#define EFORMAT_TOO_BIG_COUNT(count, maxcount)

◆ PagedMemory() [2/2]

template<unsigned int TMAXPAGES = 128>
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
pagesThe memory area I would like to read data from
countThe number of pages pointed by the variable pages. This has to be smaller than TMAXPAGES.

Member Function Documentation

◆ begin() [1/2]

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
itAn updateable iterator you should provide.

Definition at line 249 of file Event/eformat/eformat-00-00-04/eformat/PagedMemory.h.

250 { return const_iterator(m_node, 0); }

Referenced by main().

◆ begin() [2/2]

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
itAn updateable iterator you should provide.

Definition at line 249 of file InstallArea/include/eformat/eformat/PagedMemory.h.

250 { return const_iterator(m_node, 0); }

◆ count() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/PagedMemory.h.

71{ return m_count; }

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

◆ count() [2/2]

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 InstallArea/include/eformat/eformat/PagedMemory.h.

71{ return m_count; }

◆ end() [1/2]

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
itAn updateable iterator you should provide.

Definition at line 257 of file Event/eformat/eformat-00-00-04/eformat/PagedMemory.h.

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

◆ end() [2/2]

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
itAn updateable iterator you should provide.

Definition at line 257 of file InstallArea/include/eformat/eformat/PagedMemory.h.

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

◆ pages() [1/2]

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

Returns the base address of the input IO vector

Definition at line 66 of file Event/eformat/eformat-00-00-04/eformat/PagedMemory.h.

66{ return m_iovec; }

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

◆ pages() [2/2]

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

Returns the base address of the input IO vector

Definition at line 66 of file InstallArea/include/eformat/eformat/PagedMemory.h.

66{ return m_iovec; }

◆ size() [1/2]

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 Event/eformat/eformat-00-00-04/eformat/PagedMemory.h.

76{ return m_size; }

◆ size() [2/2]

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 InstallArea/include/eformat/eformat/PagedMemory.h.

76{ return m_size; }

Member Data Documentation

◆ MAXPAGES

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

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