TPIE

v1.1rc1-6-g0c97303
tpie::file_accessor::stream_accessor< file_accessor_t > Class Template Reference

Public Member Functions

void open (const std::string &path, bool read, bool write, memory_size_type itemSize, memory_size_type blockSize, memory_size_type maxUserDataSize, cache_hint cacheHint)
 Open file for reading and/or writing. More...
 
void close ()
 
memory_size_type read_block (void *data, stream_size_type blockNumber, memory_size_type itemCount)
 Read the given number of items from the given block into the given buffer. More...
 
void write_block (const void *data, stream_size_type blockNumber, memory_size_type itemCount)
 Write the given number of items from the given buffer into the given block. More...
 
memory_size_type read_user_data (void *data, memory_size_type count)
 Read user data into the given buffer. More...
 
void write_user_data (const void *data, memory_size_type count)
 Write user data to the stream. More...
 
stream_size_type size () const
 Number of items in stream. More...
 
const std::string & path () const
 Path of the file currently open. More...
 
memory_size_type user_data_size () const
 Size (in bytes) of the user data. More...
 
memory_size_type max_user_data_size () const
 Maximum size (in bytes) of the user data. More...
 
stream_size_type byte_size () const
 Size (in bytes) of entire stream as laid out on disk after padding the final block to alignment boundary, including the header and user data. More...
 
void truncate (stream_size_type items)
 

Static Public Member Functions

static memory_size_type memory_usage ()
 Return memory usage of this file accessor. More...
 

Detailed Description

template<typename file_accessor_t>
class tpie::file_accessor::stream_accessor< file_accessor_t >

Definition at line 35 of file stream_accessor.h.

Member Function Documentation

template<typename file_accessor_t >
stream_size_type tpie::file_accessor::stream_accessor< file_accessor_t >::byte_size ( ) const
inline

Size (in bytes) of entire stream as laid out on disk after padding the final block to alignment boundary, including the header and user data.

Definition at line 185 of file stream_accessor.h.

Referenced by tpie::file_stream_base::truncate(), and tpie::file_base::truncate().

185  {
186  return ((m_size + m_blockItems - 1)/m_blockItems) * m_blockSize + header_size();
187  }
template<typename file_accessor_t >
memory_size_type tpie::file_accessor::stream_accessor< file_accessor_t >::max_user_data_size ( ) const
inline

Maximum size (in bytes) of the user data.

Definition at line 178 of file stream_accessor.h.

Referenced by tpie::file_base_crtp< file_stream_base >::max_user_data_size().

178 {return m_maxUserDataSize;}
template<typename file_accessor_t >
static memory_size_type tpie::file_accessor::stream_accessor< file_accessor_t >::memory_usage ( )
inlinestatic

Return memory usage of this file accessor.

Definition at line 158 of file stream_accessor.h.

Referenced by tpie::file< T >::memory_usage(), and tpie::file_stream< item_type >::memory_usage().

158 {return sizeof(stream_accessor<file_accessor_t>);}
template<typename file_accessor_t >
void tpie::file_accessor::stream_accessor< file_accessor_t >::open ( const std::string &  path,
bool  read,
bool  write,
memory_size_type  itemSize,
memory_size_type  blockSize,
memory_size_type  maxUserDataSize,
cache_hint  cacheHint 
)
inline

Open file for reading and/or writing.

template<typename file_accessor_t >
const std::string& tpie::file_accessor::stream_accessor< file_accessor_t >::path ( ) const
inline

Path of the file currently open.

Definition at line 168 of file stream_accessor.h.

Referenced by tpie::file_base_crtp< file_stream_base >::path().

168 {return m_path;}
template<typename file_accessor_t >
memory_size_type tpie::file_accessor::stream_accessor< file_accessor_t >::read_block ( void *  data,
stream_size_type  blockNumber,
memory_size_type  itemCount 
)
inline

Read the given number of items from the given block into the given buffer.

Parameters
dataBuffer in which to store data. Must be able to hold at least sizeof(T)*itemCount bytes.
blockNumberNumber of block in which to begin reading.
itemCountNumber of items to read from beginning of given block. Must be less than m_blockItems.
template<typename file_accessor_t >
memory_size_type tpie::file_accessor::stream_accessor< file_accessor_t >::read_user_data ( void *  data,
memory_size_type  count 
)
inline

Read user data into the given buffer.

Parameters
dataBuffer in which to store user data.
countSize of buffer, in bytes. The method will read at most this number of bytes.
Returns
Number of bytes of user data actually read, in case this is less than count.

Referenced by tpie::file_base_crtp< file_stream_base >::read_user_data().

template<typename file_accessor_t >
stream_size_type tpie::file_accessor::stream_accessor< file_accessor_t >::size ( ) const
inline

Number of items in stream.

Definition at line 163 of file stream_accessor.h.

163 {return m_size;}
template<typename file_accessor_t >
memory_size_type tpie::file_accessor::stream_accessor< file_accessor_t >::user_data_size ( ) const
inline

Size (in bytes) of the user data.

Definition at line 173 of file stream_accessor.h.

Referenced by tpie::file_base_crtp< file_stream_base >::user_data_size().

173 {return m_userDataSize;}
template<typename file_accessor_t >
void tpie::file_accessor::stream_accessor< file_accessor_t >::write_block ( const void *  data,
stream_size_type  blockNumber,
memory_size_type  itemCount 
)
inline

Write the given number of items from the given buffer into the given block.

Parameters
dataBuffer from which to write data. Must hold at least sizeof(T)*itemCount bytes of data.
blockNumberNumber of block in which to write.
itemCountNumber of items to write to beginning of given block. Must be less than m_blockItems.

Referenced by tpie::file_stream_base::flush_block().

template<typename file_accessor_t >
void tpie::file_accessor::stream_accessor< file_accessor_t >::write_user_data ( const void *  data,
memory_size_type  count 
)
inline

Write user data to the stream.

Parameters
dataBuffer from which to write user data.
countNumber of bytes to write. Cannot exceed max_user_data_size().

Referenced by tpie::file_base_crtp< file_stream_base >::write_user_data().


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