NeoPZ
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
TPZCircBufferedStream Class Reference

Class for creating a bidirectional circular buffer. More...

#include <TPZCircBufferedStream.h>

Inheritance diagram for TPZCircBufferedStream:
[legend]
Collaboration diagram for TPZCircBufferedStream:
[legend]

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...
 
TPZCircBufferedStreamoperator= (const TPZCircBufferedStream &other)
 Assingment operator. Both buffers will have the same underlying stream, so this must be used with care. More...
 
virtual TPZCircBufferedStreamoperator<< (TPZCircBufferedStream &other)
 It reads all data in a buffer, consuming it. More...
 
virtual TPZCircBufferedStreamoperator<< (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
 

Detailed Description

Class for creating a bidirectional circular buffer.

Definition at line 14 of file TPZCircBufferedStream.h.

Constructor & Destructor Documentation

◆ TPZCircBufferedStream() [1/2]

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() [2/2]

TPZCircBufferedStream::TPZCircBufferedStream ( const TPZStream readBuffer)

Copy constructor. Both buffers will have the same underlying stream, so this must be used with care.

Parameters
[in]readBufferThe buffer to be copied.

Definition at line 16 of file TPZCircBufferedStream.cpp.

References operator=().

◆ ~TPZCircBufferedStream()

TPZCircBufferedStream::~TPZCircBufferedStream ( )

Destroys the object.

Definition at line 34 of file TPZCircBufferedStream.cpp.

References fBuffer.

Member Function Documentation

◆ ConstRead()

void TPZCircBufferedStream::ConstRead ( char *  dest,
const size_t &  nBytes 
) const
protectedvirtual

Reads from buffer WITHOUT consuming it. Unless it is still reading from its underlying stream. In this situation there is no guarantee.

Parameters
destThe destination
[in]nBytesHow many bytes will be read

Definition at line 85 of file TPZCircBufferedStream.cpp.

References ConstReadFromBuffer().

Referenced by GetDataFromBuffer(), operator<<(), and Print().

◆ ConstReadFromBuffer()

void TPZCircBufferedStream::ConstReadFromBuffer ( char *  dest,
const size_t &  nBytes 
) const
privatevirtual

Reads from buffer WITHOUT consuming it.

Parameters
destThe destination
[in]nBytesHow 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().

◆ GetDataFromBuffer()

void TPZCircBufferedStream::GetDataFromBuffer ( char *  dest) const
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)

Parameters
[in]destArray 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().

◆ operator<<() [1/2]

TPZCircBufferedStream & TPZCircBufferedStream::operator<< ( TPZCircBufferedStream other)
virtual

It reads all data in a buffer, consuming it.

Parameters
otherThe other buffer
Returns
Reference to this buffer

Definition at line 36 of file TPZCircBufferedStream.cpp.

References fSize, ReadFromBuffer(), and WriteToBuffer().

◆ operator<<() [2/2]

TPZCircBufferedStream & TPZCircBufferedStream::operator<< ( const TPZCircBufferedStream other)
virtual

It reads all data in a buffer WITHOUT consuming it.

Parameters
[in]otherThe other buffer
Returns
Reference to this buffer

Definition at line 46 of file TPZCircBufferedStream.cpp.

References ConstRead(), fSize, and WriteToBuffer().

◆ operator=()

TPZCircBufferedStream & TPZCircBufferedStream::operator= ( const TPZCircBufferedStream other)

Assingment operator. Both buffers will have the same underlying stream, so this must be used with care.

Parameters
[in]otherThe other buffer
Returns
Reference to this buffer

Definition at line 22 of file TPZCircBufferedStream.cpp.

References fBuffer, fFirst, fLast, fNAllocatedBytes, and fSize.

Referenced by TPZCircBufferedStream().

◆ Print()

void TPZCircBufferedStream::Print ( )

Prints buffer info and data.

Definition at line 154 of file TPZCircBufferedStream.cpp.

References ConstRead(), and fSize.

◆ Read() [1/11]

void TPZCircBufferedStream::Read ( int *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 242 of file TPZCircBufferedStream.cpp.

Referenced by GetDataFromBuffer(), and Read().

◆ Read() [2/11]

void TPZCircBufferedStream::Read ( unsigned int *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 246 of file TPZCircBufferedStream.cpp.

◆ Read() [3/11]

void TPZCircBufferedStream::Read ( uint64_t *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 250 of file TPZCircBufferedStream.cpp.

◆ Read() [4/11]

void TPZCircBufferedStream::Read ( int64_t *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 254 of file TPZCircBufferedStream.cpp.

◆ Read() [5/11]

void TPZCircBufferedStream::Read ( float *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 258 of file TPZCircBufferedStream.cpp.

◆ Read() [6/11]

void TPZCircBufferedStream::Read ( double *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 262 of file TPZCircBufferedStream.cpp.

◆ Read() [7/11]

virtual void TPZCircBufferedStream::Read ( long double *  p,
int  howMany 
)
virtual

Reimplemented from TPZStream.

◆ Read() [8/11]

void TPZCircBufferedStream::Read ( unsigned char *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 266 of file TPZCircBufferedStream.cpp.

◆ Read() [9/11]

void TPZCircBufferedStream::Read ( char *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 270 of file TPZCircBufferedStream.cpp.

◆ Read() [10/11]

void TPZCircBufferedStream::Read ( std::complex< float > *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 274 of file TPZCircBufferedStream.cpp.

◆ Read() [11/11]

void TPZCircBufferedStream::Read ( std::complex< double > *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 278 of file TPZCircBufferedStream.cpp.

References Read().

◆ ReadData()

template<typename T >
template void TPZCircBufferedStream::ReadData ( T *  p,
int  howMany 
)
private

Definition at line 177 of file TPZCircBufferedStream.h.

References ReadFromBuffer().

Referenced by WriteData().

◆ ReadFromBuffer()

void TPZCircBufferedStream::ReadFromBuffer ( char *  dest,
const size_t &  nBytes 
)
protectedvirtual

Reads from buffer.

Parameters
destThe destination
[in]nBytesHow 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().

◆ Write() [1/10]

void TPZCircBufferedStream::Write ( const int *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 166 of file TPZCircBufferedStream.cpp.

Referenced by GetDataFromBuffer(), and Write().

◆ Write() [2/10]

void TPZCircBufferedStream::Write ( const unsigned int *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 170 of file TPZCircBufferedStream.cpp.

◆ Write() [3/10]

void TPZCircBufferedStream::Write ( const uint64_t *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 174 of file TPZCircBufferedStream.cpp.

◆ Write() [4/10]

void TPZCircBufferedStream::Write ( const int64_t *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 178 of file TPZCircBufferedStream.cpp.

◆ Write() [5/10]

void TPZCircBufferedStream::Write ( const float *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 182 of file TPZCircBufferedStream.cpp.

◆ Write() [6/10]

void TPZCircBufferedStream::Write ( const double *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 186 of file TPZCircBufferedStream.cpp.

◆ Write() [7/10]

void TPZCircBufferedStream::Write ( const unsigned char *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 190 of file TPZCircBufferedStream.cpp.

◆ Write() [8/10]

void TPZCircBufferedStream::Write ( const char *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 194 of file TPZCircBufferedStream.cpp.

◆ Write() [9/10]

void TPZCircBufferedStream::Write ( const std::complex< float > *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 198 of file TPZCircBufferedStream.cpp.

◆ Write() [10/10]

void TPZCircBufferedStream::Write ( const std::complex< double > *  p,
int  howMany 
)
virtual

Implements TPZStream.

Definition at line 202 of file TPZCircBufferedStream.cpp.

References Write().

◆ WriteData()

template<typename T >
template void TPZCircBufferedStream::WriteData ( const T *  p,
int  howMany 
)
private

Definition at line 182 of file TPZCircBufferedStream.h.

References ReadData(), and WriteToBuffer().

◆ WriteToBuffer()

void TPZCircBufferedStream::WriteToBuffer ( const char *  source,
const size_t &  nBytes 
)
protectedvirtual

Writes to buffer.

Parameters
[in]sourceThe source
[in]nBytesHow 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().

Member Data Documentation

◆ fBuffer

char* TPZCircBufferedStream::fBuffer
private

◆ fFirst

char* TPZCircBufferedStream::fFirst
private

◆ fLast

char* TPZCircBufferedStream::fLast
private

Definition at line 155 of file TPZCircBufferedStream.h.

Referenced by operator=(), TPZCircBufferedStream(), and WriteToBuffer().

◆ fNAllocatedBytes

size_t TPZCircBufferedStream::fNAllocatedBytes
private

◆ fSize

size_t TPZCircBufferedStream::fSize
private

◆ MIN_SIZE_INCREMENT

const size_t TPZCircBufferedStream::MIN_SIZE_INCREMENT
staticprivate

Definition at line 173 of file TPZCircBufferedStream.h.

Referenced by TPZCircBufferedStream(), and WriteToBuffer().


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