Inherits tpie::file_base_crtp< file_base >.
Inherited by tpie::file< T >.
Classes | |
struct | block_t |
This is the type of our block buffers. More... | |
class | stream |
Stream in file. We support multiple streams per file. More... | |
Public Member Functions | |
stream_size_type | size () const throw () |
void | close () |
void | truncate (stream_size_type s) throw (stream_exception) |
Truncate file to given size. More... | |
~file_base () | |
file_base destructor. More... | |
bool | is_readable () const throw () |
Check if we can read from the file. More... | |
bool | is_writable () const throw () |
Check if we can write to the file. More... | |
memory_size_type | block_size () const |
Get the size of a block in bytes. More... | |
memory_size_type | block_items () const |
Get the number of items per block. More... | |
void | read_user_data (TT &data) throw (stream_exception) |
Read the user data associated with the file. More... | |
memory_size_type | read_user_data (void *data, memory_size_type count) |
Read variable length user data associated with the file. More... | |
void | write_user_data (const TT &data) throw (stream_exception) |
Write user data to the stream. More... | |
void | write_user_data (const void *data, memory_size_type count) |
Write variable length user data associated with the file. More... | |
memory_size_type | user_data_size () const |
Get current user data size. More... | |
memory_size_type | max_user_data_size () const |
Get maximum user data size. More... | |
const std::string & | path () const throw () |
The path of the file opened or the empty string. More... | |
void | open (const std::string &path, access_type accessType=access_read_write, memory_size_type userDataSize=0, cache_hint cacheHint=access_sequential) throw (stream_exception) |
Open a file. More... | |
void | open (memory_size_type userDataSize=0, cache_hint cacheHint=access_sequential) throw (stream_exception) |
Open an anonymous temporary file. More... | |
void | open (temp_file &file, access_type accessType=access_read_write, memory_size_type userDataSize=0, cache_hint cacheHint=access_sequential) throw (stream_exception) |
Open a temporary file. More... | |
bool | is_open () const |
Check if file is open. More... | |
stream_size_type | file_size () const throw () |
Get the size of the file measured in items. More... | |
Static Public Member Functions | |
static memory_size_type | block_size (double blockFactor) throw () |
Calculate the block size in bytes used by a stream. More... | |
static double | calculate_block_factor (memory_size_type blockSize) throw () |
Find the block factor that would result in the given block size measured in bytes. More... | |
static memory_size_type | block_memory_usage (double blockFactor) |
Amount of memory used by a single block given the block factor. More... | |
Protected Member Functions | |
void | update_size (stream_size_type size) |
file_base (memory_size_type item_size, double blockFactor=1.0, file_accessor::file_accessor *fileAccessor=NULL) | |
void | create_block () |
void | delete_block () |
block_t * | get_block (stream_size_type block) |
void | free_block (block_t *block) |
void | open_inner (const std::string &path, access_type accessType, memory_size_type userDataSize, cache_hint cacheHint) throw (stream_exception) |
void | read_block (BT &b, stream_size_type block) |
void | get_block_check (stream_size_type block) |
Protected Attributes | |
boost::intrusive::list< block_t > | m_used |
boost::intrusive::list< block_t > | m_free |
memory_size_type | m_blockItems |
memory_size_type | m_blockSize |
bool | m_canRead |
bool | m_canWrite |
bool | m_open |
memory_size_type | m_itemSize |
file_accessor::file_accessor * | m_fileAccessor |
tpie::unique_ptr< temp_file > | m_ownedTempFile |
temp_file * | m_tempFile |
stream_size_type | m_size |
Static Protected Attributes | |
static block_t | m_emptyBlock |
Definition at line 46 of file file_base.h.
tpie::file_base::~file_base | ( | ) |
file_base destructor.
|
inlineinherited |
Get the number of items per block.
Definition at line 105 of file file_base_crtp.h.
|
inlinestaticinherited |
Amount of memory used by a single block given the block factor.
Definition at line 98 of file file_base_crtp.h.
|
inlinestaticinherited |
Calculate the block size in bytes used by a stream.
We have block_size(calculate_block_factor(b)) ~= b.
blockFactor | Factor of the global block size to use. |
Definition at line 78 of file file_base_crtp.h.
|
inlineinherited |
Get the size of a block in bytes.
Definition at line 112 of file file_base_crtp.h.
Referenced by tpie::ami::stream_old< T >::chunk_size(), and tpie::file< T >::stream::memory_usage().
|
inlinestaticinherited |
Find the block factor that would result in the given block size measured in bytes.
We have calculate_block_factor(block_size(f)) ~= f.
blockSize | The sought block size. |
Definition at line 91 of file file_base_crtp.h.
|
inlineinherited |
Get the size of the file measured in items.
If there are streams of this file that have extended the stream length but have not yet flushed these writes, we might report an incorrect size.
Definition at line 268 of file file_base_crtp.h.
|
inlineinherited |
Check if file is open.
Definition at line 256 of file file_base_crtp.h.
Referenced by tpie::file< T >::stream::read(), tpie::file< T >::stream::read_back(), tpie::file< T >::stream::read_mutable(), and tpie::file< T >::stream::write().
|
inlineinherited |
Check if we can read from the file.
Definition at line 56 of file file_base_crtp.h.
|
inlineinherited |
Check if we can write to the file.
Definition at line 65 of file file_base_crtp.h.
Referenced by tpie::file< T >::stream::write().
|
inlineinherited |
Get maximum user data size.
Definition at line 183 of file file_base_crtp.h.
|
inlineinherited |
Open a file.
path | The path of the file to open. |
accessType | The mode of operation. |
userDataSize | The size of the user data we want to store in the file. |
Definition at line 207 of file file_base_crtp.h.
|
inlineinherited |
Open an anonymous temporary file.
The temporary file is deleted when this file is closed.
Definition at line 219 of file file_base_crtp.h.
|
inlineinherited |
Open a temporary file.
The temporary file is not deleted when this file is closed, so several tpie::file objects may use the same temporary file consecutively.
Definition at line 232 of file file_base_crtp.h.
|
inlineinherited |
The path of the file opened or the empty string.
Definition at line 194 of file file_base_crtp.h.
|
inlineinherited |
Read the user data associated with the file.
data | Where to store the user data. |
TT | The type of user data. sizeof(TT) must be less than or equal to the maximum user data size of the stream. TT must be trivially copyable. |
Definition at line 125 of file file_base_crtp.h.
|
inlineinherited |
Read variable length user data associated with the file.
data | The buffer in which to write data. |
count | The size of the buffer. |
Definition at line 138 of file file_base_crtp.h.
|
inline |
Truncate file to given size.
May only be used when no streams are opened to this file.
Definition at line 179 of file file_base.h.
References tpie::file_accessor::stream_accessor_base< file_accessor_t >::byte_size().
|
inlineinherited |
Get current user data size.
Definition at line 175 of file file_base_crtp.h.
|
inlineinherited |
Write user data to the stream.
data | The user data to store in the stream. |
TT | The type of user data. sizeof(TT) must be less than or equal to the maximum user data size of the stream. TT must be trivially copyable. |
Definition at line 152 of file file_base_crtp.h.
|
inlineinherited |
Write variable length user data associated with the file.
Throws a stream_exception if the size of the user data exceeds the maximum user data size of the stream.
data | The buffer from which to read data. |
count | The size of the user data. |
Definition at line 167 of file file_base_crtp.h.