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

#include <PagedMemory.h>

Classes

struct  node_t
class  const_iterator

Public Types

typedef struct eformat::PagedMemory::node_t node_t
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
 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/include/eformat/PagedMemory.h.

Member Typedef Documentation

◆ node_t [1/3]

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/3]

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 [3/3]

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/3]

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 267 of file Event/eformat/include/eformat/PagedMemory.h.

268 : m_iovec( pages ), m_count( count ), m_size( 0 ) {
269 if ( m_count > MAXPAGES )
270 {
271 // Problem, I cannot index this amount of data
273 }
274 for ( size_t i = 0; i < count; ++i )
275 {
276 m_node[i].page = &pages[i];
277 if ( pages[i].iov_len % 4 != 0 )
278 {
279 // Problem, one of the data blocks is *not* 32-bit aligned
281 }
282 m_node[i].start = m_size;
283 m_size += pages[i].iov_len >> 2;
284 m_node[i].end = m_size;
285 if ( i > 0 ) m_node[i].previous = &m_node[i - 1];
286 else m_node[i].previous = 0;
287 if ( i < ( count - 1 ) ) m_node[i].next = &m_node[i + 1];
288 else m_node[i].next = 0;
289 }
290}
#define EFORMAT_NOT_ALIGNED(base, size)
#define EFORMAT_TOO_BIG_COUNT(count, maxcount)
const struct iovec * pages(void) const

◆ PagedMemory() [2/3]

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.

◆ PagedMemory() [3/3]

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/3]

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 243 of file Event/eformat/include/eformat/PagedMemory.h.

Referenced by main().

◆ begin() [2/3]

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 243 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

243{ return const_iterator( m_node, 0 ); }

◆ begin() [3/3]

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 243 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

243{ return const_iterator( m_node, 0 ); }

◆ count() [1/3]

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 69 of file Event/eformat/include/eformat/PagedMemory.h.

69{ return m_count; }

Referenced by PagedMemory().

◆ count() [2/3]

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 69 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

69{ return m_count; }

◆ count() [3/3]

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 69 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

69{ return m_count; }

◆ end() [1/3]

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 250 of file Event/eformat/include/eformat/PagedMemory.h.

250 {
251 return const_iterator( &m_node[m_count], m_size );
252 }

Referenced by eformat::PagedMemory< TMAXPAGES >::const_iterator::at(), and eformat::PagedMemory< TMAXPAGES >::const_iterator::operator[]().

◆ end() [2/3]

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 250 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

250 {
251 return const_iterator( &m_node[m_count], m_size );
252 }

◆ end() [3/3]

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 250 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

250 {
251 return const_iterator( &m_node[m_count], m_size );
252 }

◆ pages() [1/3]

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 64 of file Event/eformat/include/eformat/PagedMemory.h.

64{ return m_iovec; }

Referenced by PagedMemory().

◆ pages() [2/3]

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 64 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

64{ return m_iovec; }

◆ pages() [3/3]

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 64 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

64{ return m_iovec; }

◆ size() [1/3]

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 74 of file Event/eformat/include/eformat/PagedMemory.h.

74{ return m_size; }

◆ size() [2/3]

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 74 of file InstallArea/x86_64-el9-gcc13-dbg/include/eformat/PagedMemory.h.

74{ return m_size; }

◆ size() [3/3]

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 74 of file InstallArea/x86_64-el9-gcc13-opt/include/eformat/PagedMemory.h.

74{ return m_size; }

Member Data Documentation

◆ MAXPAGES

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

Definition at line 42 of file Event/eformat/include/eformat/PagedMemory.h.

Referenced by PagedMemory().


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