NeoPZ
|
Class for creating a bidirectional circular buffer. More...
#include <TPZCircBufferedStream.h>
Public Member Functions | |
TPZCircBufferedStream () | |
Creates a bidirectional buffer. More... | |
TPZCircBufferedStream (const TPZStream &readBuffer) | |
Copy constructor. Both buffers will have the same underlying stream, so this must be used with care. More... | |
~TPZCircBufferedStream () | |
Destroys the object. More... | |
TPZCircBufferedStream & | operator= (const TPZCircBufferedStream &other) |
Assingment operator. Both buffers will have the same underlying stream, so this must be used with care. More... | |
virtual TPZCircBufferedStream & | operator<< (TPZCircBufferedStream &other) |
It reads all data in a buffer, consuming it. More... | |
virtual TPZCircBufferedStream & | operator<< (const TPZCircBufferedStream &other) |
It reads all data in a buffer WITHOUT consuming it. More... | |
void | Print () |
Prints buffer info and data. More... | |
void | GetDataFromBuffer (char *dest) const |
Get all buffer data to a char* in a contiguous manner. May be interesting if one needs to this data to be serialized(i.e., for MPI) More... | |
virtual void | Write (const int *p, int howMany) |
virtual void | Write (const unsigned int *p, int howMany) |
virtual void | Write (const uint64_t *p, int howMany) |
virtual void | Write (const int64_t *p, int howMany) |
virtual void | Write (const float *p, int howMany) |
virtual void | Write (const double *p, int howMany) |
virtual void | Write (const unsigned char *p, int howMany) |
virtual void | Write (const char *p, int howMany) |
virtual void | Write (const std::complex< float > *p, int howMany) |
virtual void | Write (const std::complex< double > *p, int howMany) |
virtual void | Read (int *p, int howMany) |
virtual void | Read (unsigned int *p, int howMany) |
virtual void | Read (uint64_t *p, int howMany) |
virtual void | Read (int64_t *p, int howMany) |
virtual void | Read (float *p, int howMany) |
virtual void | Read (double *p, int howMany) |
virtual void | Read (long double *p, int howMany) |
virtual void | Read (unsigned char *p, int howMany) |
virtual void | Read (char *p, int howMany) |
virtual void | Read (std::complex< float > *p, int howMany) |
virtual void | Read (std::complex< double > *p, int howMany) |
Public Member Functions inherited from TPZStream | |
TPZStream () | |
virtual | ~TPZStream () |
virtual void | Write (const bool val) |
virtual void | Write (const long double *p, int howMany=1) |
Writes howMany floating points at pointer location p. More... | |
virtual void | Write (const std::string *p, int howMany=1) |
virtual void | Write (const std::complex< long double > *p, int howMany=1) |
Writes howMany complex-long double at pointer location p. More... | |
void | Write (const TPZFlopCounter *p, int howMany=1) |
virtual void | Read (bool &val) |
virtual void | Read (std::string *p, int howMany=1) |
virtual void | Read (std::complex< long double > *p, int howMany=1) |
Reads howMany complex-long double from pointer location p. More... | |
void | Read (TPZFlopCounter *p, int howMany=1) |
template<class T , typename std::enable_if<(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Write (const TPZVec< T > &vec) |
template<class T , typename std::enable_if<!(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Write (const TPZVec< T > &vec) |
template<class T > | |
void | WritePointers (const TPZVec< TPZAutoPointer< T >> &vec) |
template<class T , typename std::enable_if<(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Write (const std::vector< T > &vec) |
template<class T , typename std::enable_if<!(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Write (const std::vector< T > &vec) |
void | Write (const TPZVec< TPZFlopCounter > &vec) |
template<class T , class U > | |
void | Write (const std::map< T, U > &vec) |
template<class T , typename std::enable_if<(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Write (const std::set< T > &vec) |
template<class T > | |
void | Read (TPZVec< T > &vec) |
template<class T , typename std::enable_if<!(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Read (TPZVec< T > &vec, void *context) |
template<class T , typename std::enable_if<(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Read (TPZVec< T > &vec, void *context) |
template<class T > | |
void | ReadPointers (TPZVec< TPZAutoPointer< T >> &vec) |
void | Read (TPZVec< TPZFlopCounter > &vec) |
template<class T , typename std::enable_if<!(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Read (std::vector< T > &vec, void *context) |
template<class T , typename std::enable_if<(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Read (std::vector< T > &vec, void *context) |
template<int N> | |
void | Read (TPZManVector< REAL, N > &vec) |
template<int N> | |
void | Read (TPZManVector< int64_t, N > &vec) |
template<class T , class U > | |
void | Read (std::map< T, U > &vec) |
template<class T , typename std::enable_if<(std::is_same< std::string, T >::value||is_arithmetic_pz< T >::value), int >::type * = nullptr> | |
void | Read (std::set< T > &vec) |
template<class T > | |
void | WritePointers (const TPZVec< T *> &vec) |
template<class T > | |
void | ReadPointers (TPZVec< T *> &vec) |
template<class T > | |
void | WritePointers (const std::map< int, TPZAutoPointer< T >> &vec) |
template<class T > | |
void | ReadPointers (std::map< int, TPZAutoPointer< T > > &vec) |
template<class T > | |
void | WritePointers (const std::map< int, T *> &vec) |
template<class T > | |
void | ReadPointers (std::map< int, T *> &vec) |
template<class T > | |
void | WritePointers (const std::set< T *> &vec) |
template<class T > | |
void | ReadPointers (std::set< T *> &vec) |
template<class T , int EXP> | |
void | WritePointers (const TPZChunkVector< T *, EXP > &vec) |
template<class T , int EXP> | |
void | ReadPointers (TPZChunkVector< T *, EXP > &vec) |
template<class T , int EXP> | |
void | WritePointers (const TPZAdmChunkVector< T *, EXP > &vec) |
template<class T , int EXP> | |
void | ReadPointers (TPZAdmChunkVector< T *, EXP > &vec) |
template<class T > | |
void | ReadPointers (std::map< int, TPZAutoPointer< T >> &map) |
Protected Member Functions | |
virtual void | ReadFromBuffer (char *dest, const size_t &nBytes) |
Reads from buffer. More... | |
virtual void | ConstRead (char *dest, const size_t &nBytes) const |
Reads from buffer WITHOUT consuming it. Unless it is still reading from its underlying stream. In this situation there is no guarantee. More... | |
virtual void | WriteToBuffer (const char *source, const size_t &nBytes) |
Writes to buffer. More... | |
Private Member Functions | |
virtual void | ConstReadFromBuffer (char *dest, const size_t &nBytes) const |
Reads from buffer WITHOUT consuming it. More... | |
template<class T > | |
void | ReadData (T *p, int howMany) |
template<class T > | |
void | WriteData (const T *p, int howMany) |
Private Attributes | |
char * | fBuffer |
char * | fFirst |
char * | fLast |
size_t | fNAllocatedBytes |
size_t | fSize |
Static Private Attributes | |
static const size_t | MIN_SIZE_INCREMENT |
Class for creating a bidirectional circular buffer.
Definition at line 14 of file TPZCircBufferedStream.h.
TPZCircBufferedStream::TPZCircBufferedStream | ( | ) |
Creates a bidirectional buffer.
Definition at line 7 of file TPZCircBufferedStream.cpp.
References fBuffer, fFirst, fLast, fNAllocatedBytes, fSize, and MIN_SIZE_INCREMENT.
TPZCircBufferedStream::TPZCircBufferedStream | ( | const TPZStream & | readBuffer | ) |
Copy constructor. Both buffers will have the same underlying stream, so this must be used with care.
[in] | readBuffer | The buffer to be copied. |
Definition at line 16 of file TPZCircBufferedStream.cpp.
References operator=().
TPZCircBufferedStream::~TPZCircBufferedStream | ( | ) |
|
protectedvirtual |
Reads from buffer WITHOUT consuming it. Unless it is still reading from its underlying stream. In this situation there is no guarantee.
dest | The destination | |
[in] | nBytes | How many bytes will be read |
Definition at line 85 of file TPZCircBufferedStream.cpp.
References ConstReadFromBuffer().
Referenced by GetDataFromBuffer(), operator<<(), and Print().
|
privatevirtual |
Reads from buffer WITHOUT consuming it.
dest | The destination | |
[in] | nBytes | How many bytes will be read |
Definition at line 89 of file TPZCircBufferedStream.cpp.
References DebugStop, fBuffer, fFirst, fNAllocatedBytes, fSize, PZError, and to_string().
Referenced by ConstRead(), GetDataFromBuffer(), and WriteToBuffer().
|
inline |
Get all buffer data to a char* in a contiguous manner. May be interesting if one needs to this data to be serialized(i.e., for MPI)
[in] | dest | Array where data will be stored. |
Definition at line 72 of file TPZCircBufferedStream.h.
References ConstRead(), ConstReadFromBuffer(), fSize, Read(), TPZStream::Read(), ReadFromBuffer(), TPZStream::Write(), Write(), and WriteToBuffer().
|
virtual |
It reads all data in a buffer, consuming it.
other | The other buffer |
Definition at line 36 of file TPZCircBufferedStream.cpp.
References fSize, ReadFromBuffer(), and WriteToBuffer().
|
virtual |
It reads all data in a buffer WITHOUT consuming it.
[in] | other | The other buffer |
Definition at line 46 of file TPZCircBufferedStream.cpp.
References ConstRead(), fSize, and WriteToBuffer().
TPZCircBufferedStream & TPZCircBufferedStream::operator= | ( | const TPZCircBufferedStream & | other | ) |
Assingment operator. Both buffers will have the same underlying stream, so this must be used with care.
[in] | other | The other buffer |
Definition at line 22 of file TPZCircBufferedStream.cpp.
References fBuffer, fFirst, fLast, fNAllocatedBytes, and fSize.
Referenced by TPZCircBufferedStream().
void TPZCircBufferedStream::Print | ( | ) |
Prints buffer info and data.
Definition at line 154 of file TPZCircBufferedStream.cpp.
References ConstRead(), and fSize.
|
virtual |
Implements TPZStream.
Definition at line 242 of file TPZCircBufferedStream.cpp.
Referenced by GetDataFromBuffer(), and Read().
|
virtual |
Implements TPZStream.
Definition at line 246 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 250 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 254 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 258 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 262 of file TPZCircBufferedStream.cpp.
|
virtual |
Reimplemented from TPZStream.
|
virtual |
Implements TPZStream.
Definition at line 266 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 270 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 274 of file TPZCircBufferedStream.cpp.
|
virtual |
|
private |
Definition at line 177 of file TPZCircBufferedStream.h.
References ReadFromBuffer().
Referenced by WriteData().
|
protectedvirtual |
Reads from buffer.
dest | The destination | |
[in] | nBytes | How many bytes will be read |
Definition at line 55 of file TPZCircBufferedStream.cpp.
References DebugStop, fBuffer, fFirst, fNAllocatedBytes, fSize, PZError, and to_string().
Referenced by GetDataFromBuffer(), operator<<(), and ReadData().
|
virtual |
Implements TPZStream.
Definition at line 166 of file TPZCircBufferedStream.cpp.
Referenced by GetDataFromBuffer(), and Write().
|
virtual |
Implements TPZStream.
Definition at line 170 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 174 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 178 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 182 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 186 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 190 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 194 of file TPZCircBufferedStream.cpp.
|
virtual |
Implements TPZStream.
Definition at line 198 of file TPZCircBufferedStream.cpp.
|
virtual |
|
private |
Definition at line 182 of file TPZCircBufferedStream.h.
References ReadData(), and WriteToBuffer().
|
protectedvirtual |
Writes to buffer.
[in] | source | The source |
[in] | nBytes | How many bytes will be written |
Definition at line 116 of file TPZCircBufferedStream.cpp.
References ConstReadFromBuffer(), fBuffer, fFirst, fLast, fNAllocatedBytes, fSize, and MIN_SIZE_INCREMENT.
Referenced by GetDataFromBuffer(), operator<<(), and WriteData().
|
private |
Definition at line 151 of file TPZCircBufferedStream.h.
Referenced by ConstReadFromBuffer(), operator=(), ReadFromBuffer(), TPZCircBufferedStream(), WriteToBuffer(), and ~TPZCircBufferedStream().
|
private |
Definition at line 153 of file TPZCircBufferedStream.h.
Referenced by ConstReadFromBuffer(), operator=(), ReadFromBuffer(), TPZCircBufferedStream(), and WriteToBuffer().
|
private |
Definition at line 155 of file TPZCircBufferedStream.h.
Referenced by operator=(), TPZCircBufferedStream(), and WriteToBuffer().
|
private |
Definition at line 157 of file TPZCircBufferedStream.h.
Referenced by ConstReadFromBuffer(), operator=(), ReadFromBuffer(), TPZCircBufferedStream(), and WriteToBuffer().
|
private |
Definition at line 159 of file TPZCircBufferedStream.h.
Referenced by ConstReadFromBuffer(), GetDataFromBuffer(), operator<<(), operator=(), Print(), ReadFromBuffer(), TPZCircBufferedStream(), and WriteToBuffer().
|
staticprivate |
Definition at line 173 of file TPZCircBufferedStream.h.
Referenced by TPZCircBufferedStream(), and WriteToBuffer().