ug4
|
A Buffer for binary data. More...
#include <binary_buffer.h>
Public Member Functions | |
BinaryBuffer () | |
BinaryBuffer (size_t bufSize) | |
creates a binary buffer and reserves bufSize bytes. More... | |
char * | buffer () |
returns the raw buffer pointer or NULL if the buffer is empty (capacity() == 0) More... | |
size_t | capacity () const |
returns the capacity (reserved memory) of the buffer More... | |
void | clear () |
clears the buffer More... | |
bool | eof () |
returns true if the read-position reached the write-position More... | |
void | read (char *buf, size_t size) |
reads data of the given size (in bytes) More... | |
size_t | read_pos () const |
returns the current read-pos (in bytes) More... | |
void | reserve (size_t newSize) |
resizes the associated buffer to the given size. More... | |
void | set_read_pos (size_t pos) |
sets the read position (in bytes). More... | |
void | set_write_pos (size_t pos) |
sets the write position. More... | |
void | write (const char *buf, size_t size) |
writes data of the given size (in bytes) More... | |
size_t | write_pos () const |
returns the current write-pos (in bytes) More... | |
Private Attributes | |
std::vector< char > | m_data |
size_t | m_readPos |
size_t | m_writePos |
A Buffer for binary data.
The BinaryBuffer allows read and write access, which mimics the behavior of std::iostream. However, in contrary to ug::BinaryStream, this class is not a specialization of std::iostream. This is crucial to achieve maximal performance.
Furthermore BinaryBuffer gives access to its internal buffer, which can be handy in some situations. However, this feature has to be used with extreme care!
ug::BinaryBuffer::BinaryBuffer | ( | ) |
ug::BinaryBuffer::BinaryBuffer | ( | size_t | bufSize | ) |
creates a binary buffer and reserves bufSize bytes.
|
inline |
returns the raw buffer pointer or NULL if the buffer is empty (capacity() == 0)
References ug::GetDataPtr(), and m_data.
Referenced by ug::AddConnectionsBetweenSlaves(), pcl::ProcessCommunicator::broadcast(), pcl::ParallelArchive::BufferBinaryBuffer::buffer(), pcl::InterfaceCommunicator< TLayout >::communicate_and_resume(), ug::CommunicateOnInterfaces(), pcl::ProcessCommunicator::distribute_data(), pcl::ProcessCommunicator::gather(), ug::NewLayoutCreator::issue(), ug::ParallelNodes::issue(), ug::RowSendingScheme< matrix_type >::issue_send(), ug::LoadGridFromLGB(), ug::ComPol_MatCreateOverlap< TMatrix >::post_process(), ug::SaveGridToLGB(), ug::SendGlobalLayout(), ug::SendMatrix(), pcl::TestSizeOfInterfacesInLayoutsMatch(), pcl::InterfaceCommunicator< TLayout >::wait(), and pcl::WriteCombinedParallelFile().
|
inline |
returns the capacity (reserved memory) of the buffer
References m_data.
void ug::BinaryBuffer::clear | ( | ) |
clears the buffer
This method does not free associated memory. It only resets the read and write positions. To free the memory you may create a new instance of ug::BinaryBuffer and assign it by value to your current instance.
References m_readPos, and m_writePos.
Referenced by pcl::ProcessCommunicator::distribute_data(), pcl::MinimalKeyValuePairAcrossAllProcs(), pcl::ReadCombinedParallelFile(), and pcl::InterfaceCommunicator< TLayout >::wait().
|
inline |
returns true if the read-position reached the write-position
References m_readPos, and m_writePos.
Referenced by ug::AddConnectionsBetweenSlaves(), ug::DeserializeGridElements(), ug::DeserializeMultiGridElements(), ug::NewLayoutCreator::process(), ug::ParallelNodes::process(), ug::ReadGridHeader(), and pcl::TestSizeOfInterfacesInLayoutsMatch().
|
inline |
reads data of the given size (in bytes)
This automatically advances the read position.
References m_data, m_readPos, and m_writePos.
Referenced by ug::DeserializeAttachment(), ug::DeserializeGridElements(), ug::DeserializeMultiGridElements(), ug::DeserializeProjectionHandler(), ug::DeserializeSelector(), ug::DeserializeSubsetHandler(), ug::DistributeGrid(), ug::ComPol_AdjustType< TLayout >::extract(), ug::ComPol_BroadcastCoarsenMarks< TLayout >::extract(), ug::ComPol_BroadcastRefineMarks< TLayout >::extract(), ug::ComPol_BoolMarker_AddMarks< TLayout >::extract(), ug::ComPol_BoolMarker_RemoveMarks< TLayout >::extract(), ug::ComPol_InterfaceStatus< TLayout >::extract(), ug::ComPol_Selection< TLayout >::extract(), ug::ComPol_EnableSelectionStateBits< TLayout >::extract(), ug::ComPol_Subset< TLayout >::extract(), ug::ComPol_GatherSurfaceStates< TLayout >::extract(), pcl::SelectionCommPol< TLayout, TSelectorIn, TSelectorOut >::extract(), ug::GetParent(), ug::LoadGridFromLGB(), ug::ReadGridHeader(), ug::ReadSelectionStatesFromStream(), ug::ReadSubsetIndicesFromStream(), and pcl::InterfaceCommunicator< TLayout >::wait().
|
inline |
returns the current read-pos (in bytes)
References m_readPos.
Referenced by ug::ComPol_MatCreateOverlap< TMatrix >::post_process().
void ug::BinaryBuffer::reserve | ( | size_t | newSize | ) |
resizes the associated buffer to the given size.
You can check the number of bytes reserved in the buffer through ug::BinaryBuffer::capacity
References m_data.
Referenced by pcl::ProcessCommunicator::broadcast(), pcl::InterfaceCommunicator< TLayout >::communicate_and_resume(), pcl::ProcessCommunicator::distribute_data(), pcl::ProcessCommunicator::gather(), ug::LoadGridFromLGB(), pcl::ReadCombinedParallelFile(), and pcl::InterfaceCommunicator< TLayout >::wait().
void ug::BinaryBuffer::set_read_pos | ( | size_t | pos | ) |
void ug::BinaryBuffer::set_write_pos | ( | size_t | pos | ) |
sets the write position.
References m_writePos.
Referenced by pcl::ProcessCommunicator::broadcast(), pcl::InterfaceCommunicator< TLayout >::communicate_and_resume(), pcl::ProcessCommunicator::distribute_data(), pcl::ProcessCommunicator::gather(), ug::LoadGridFromLGB(), and pcl::InterfaceCommunicator< TLayout >::wait().
|
inline |
writes data of the given size (in bytes)
This automatically advances the write position.
References m_data, and m_writePos.
Referenced by ug::ComPol_AdjustType< TLayout >::collect(), ug::ComPol_BroadcastCoarsenMarks< TLayout >::collect(), ug::ComPol_BroadcastRefineMarks< TLayout >::collect(), ug::ComPol_BoolMarker_AddMarks< TLayout >::collect(), ug::ComPol_BoolMarker_RemoveMarks< TLayout >::collect(), ug::ComPol_InterfaceStatus< TLayout >::collect(), ug::ComPol_Selection< TLayout >::collect(), ug::ComPol_EnableSelectionStateBits< TLayout >::collect(), ug::ComPol_Subset< TLayout >::collect(), ug::ComPol_GatherSurfaceStates< TLayout >::collect(), pcl::SelectionCommPol< TLayout, TSelectorIn, TSelectorOut >::collect(), ug::DistributeGrid(), pcl::ReadCombinedParallelFile(), ug::SaveGridToLGB(), pcl::InterfaceCommunicator< TLayout >::send_raw(), ug::SerializeAttachment(), ug::SerializeGridElements(), ug::SerializeMultiGridElements(), ug::SerializeProjectionHandler(), ug::SerializeSelector(), ug::SerializeSubsetHandler(), ug::WriteGridHeader(), ug::WriteParent(), ug::WriteSelectionStatesToStream(), and ug::WriteSubsetIndicesToStream().
|
inline |
returns the current write-pos (in bytes)
References m_writePos.
Referenced by ug::AddConnectionsBetweenSlaves(), pcl::ProcessCommunicator::broadcast(), pcl::InterfaceCommunicator< TLayout >::communicate_and_resume(), ug::CommunicateOnInterfaces(), pcl::ProcessCommunicator::gather(), ug::NewLayoutCreator::issue(), ug::ParallelNodes::issue(), ug::RowSendingScheme< matrix_type >::issue_send(), ug::ComPol_MatCreateOverlap< TMatrix >::post_process(), ug::NewLayoutCreator::process(), ug::ParallelNodes::process(), ug::ReceiveGlobalLayout(), ug::ReceiveMatrix(), ug::SaveGridToLGB(), ug::SendGlobalLayout(), ug::SendMatrix(), pcl::ParallelArchive::BufferBinaryBuffer::size(), pcl::TestSizeOfInterfacesInLayoutsMatch(), and pcl::WriteCombinedParallelFile().
|
private |
Referenced by buffer(), capacity(), read(), reserve(), and write().
|
private |
Referenced by clear(), eof(), read(), read_pos(), and set_read_pos().
|
private |
Referenced by clear(), eof(), read(), set_write_pos(), write(), and write_pos().