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

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

#include <TPZContBufferedStream.h>

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

Public Member Functions

 TPZContBufferedStream ()
 Creates a buffer. More...
 
 TPZContBufferedStream (const TPZContBufferedStream &readBuffer)
 Copy constructor. More...
 
 ~TPZContBufferedStream ()
 Destroys the object. More...
 
TPZContBufferedStreamoperator= (const TPZContBufferedStream &other)
 Assingment operator. More...
 
virtual TPZContBufferedStreamoperator<< (TPZContBufferedStream &other)
 It reads all data in a buffer, consuming it. More...
 
virtual TPZContBufferedStreamoperator<< (const TPZContBufferedStream &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...
 
void clear ()
 
virtual void Write (const int *p, int howMany=1)
 
virtual void Write (const unsigned int *p, int howMany=1)
 
virtual void Write (const uint64_t *p, int howMany=1)
 
virtual void Write (const int64_t *p, int howMany=1)
 
virtual void Write (const float *p, int howMany=1)
 
virtual void Write (const double *p, int howMany=1)
 
virtual void Write (const unsigned char *p, int howMany=1)
 
virtual void Write (const char *p, int howMany=1)
 
virtual void Write (const std::complex< float > *p, int howMany=1)
 
virtual void Write (const std::complex< double > *p, int howMany=1)
 
virtual void Read (int *p, int howMany=1)
 
virtual void Read (unsigned int *p, int howMany=1)
 
virtual void Read (uint64_t *p, int howMany=1)
 
virtual void Read (int64_t *p, int howMany=1)
 
virtual void Read (float *p, int howMany=1)
 
virtual void Read (double *p, int howMany=1)
 
virtual void Read (unsigned char *p, int howMany=1)
 
virtual void Read (char *p, int howMany=1)
 
virtual void Read (std::complex< float > *p, int howMany=1)
 
virtual void Read (std::complex< double > *p, int howMany=1)
 
size_t Size () const
 
- 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 (long double *p, int howMany=1)
 
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 TPZContBufferedStream.h.

Constructor & Destructor Documentation

◆ TPZContBufferedStream() [1/2]

TPZContBufferedStream::TPZContBufferedStream ( )

Creates a buffer.

Definition at line 10 of file TPZContBufferedStream.cpp.

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

◆ TPZContBufferedStream() [2/2]

TPZContBufferedStream::TPZContBufferedStream ( const TPZContBufferedStream readBuffer)

Copy constructor.

Parameters
[in]readBufferThe buffer to be copied.

Definition at line 19 of file TPZContBufferedStream.cpp.

References operator=().

◆ ~TPZContBufferedStream()

TPZContBufferedStream::~TPZContBufferedStream ( )

Destroys the object.

Definition at line 37 of file TPZContBufferedStream.cpp.

References fBuffer, and operator<<().

Member Function Documentation

◆ clear()

void TPZContBufferedStream::clear ( )

◆ ConstRead()

void TPZContBufferedStream::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 78 of file TPZContBufferedStream.cpp.

References ConstReadFromBuffer().

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

◆ ConstReadFromBuffer()

void TPZContBufferedStream::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 82 of file TPZContBufferedStream.cpp.

References DebugStop, fBuffer, fFirst, fNAllocatedBytes, fSize, PZError, and to_string().

Referenced by ConstRead(), and WriteToBuffer().

◆ GetDataFromBuffer()

void TPZContBufferedStream::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)

Parameters
[in]destArray where data will be stored.

Definition at line 283 of file TPZContBufferedStream.cpp.

References fFirst, and fSize.

◆ operator<<() [1/2]

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

It reads all data in a buffer, consuming it.

Parameters
otherThe other buffer
Returns
Reference to this buffer

Definition at line 42 of file TPZContBufferedStream.cpp.

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

Referenced by ~TPZContBufferedStream().

◆ operator<<() [2/2]

TPZContBufferedStream & TPZContBufferedStream::operator<< ( const TPZContBufferedStream 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 54 of file TPZContBufferedStream.cpp.

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

◆ operator=()

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

Assingment operator.

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

Definition at line 25 of file TPZContBufferedStream.cpp.

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

Referenced by TPZContBufferedStream().

◆ Print()

void TPZContBufferedStream::Print ( )

Prints buffer info and data.

Definition at line 120 of file TPZContBufferedStream.cpp.

References ConstRead(), and fSize.

◆ Read() [1/10]

void TPZContBufferedStream::Read ( int *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 207 of file TPZContBufferedStream.cpp.

Referenced by TPZPersistenceManager::OpenRead(), Read(), TPZPersistenceManager::TranslateNextPointer(), TPZPersistenceManager::TranslatePointers(), TPZYCSandlerDimaggioTranslator::UpdateAttributes(), TPZMaterialTranslator::UpdateAttributes(), TPZPlasticStepPVTranslator< YC_Translator, ER_Translator >::UpdateAttributes(), TPZPlasticStepTranslator< YC_t, TF_t, ER_t >::UpdateAttributes(), TPZMatElastoPlastic2DTranslator< TTranslator, TMEMTranslator >::UpdateAttributes(), TPZElastoPlasticMemTranslator::UpdateAttributes(), TPZPlasticStateTranslator< STATE >::UpdateAttributes(), TPZTensorTranslator< STATE >::UpdateAttributes(), TPZMatElastoPlasticTranslator< TTranslator, TMEMTranslator >::UpdateAttributes(), TPZMatWithMemTranslator< TMEMTranslator >::UpdateAttributes(), TPZNullMaterialTranslator::UpdateAttributes(), TPZElasticResponseTranslator::UpdateAttributes(), TPZYCMohrCoulombPVTranslator::UpdateAttributes(), TPZYCCamClayPVTranslator::UpdateAttributes(), TPZSandlerExtendedTranslator::UpdateAttributes(), TPZSandlerExtendedTranslator::UpdateAttributesV1(), TPZMatWithMemTranslator< TMEMTranslator >::UpdateAttributesV3(), TPZSandlerDimaggioTranslator< SANDLERDIMAGGIOPARENTTRANSLATOR >::UpdateFromV1(), TPZPlasticStateTranslator< STATE >::UpdateFromV1(), TPZElastoPlasticMemTranslator::UpdateFromV1(), TPZSandlerExtendedTranslator::UpdateFromV2(), and TPZMatWithMemTranslator< TMEMTranslator >::UpdateFromV3().

◆ Read() [2/10]

void TPZContBufferedStream::Read ( unsigned int *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 211 of file TPZContBufferedStream.cpp.

◆ Read() [3/10]

void TPZContBufferedStream::Read ( uint64_t *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 215 of file TPZContBufferedStream.cpp.

◆ Read() [4/10]

void TPZContBufferedStream::Read ( int64_t *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 219 of file TPZContBufferedStream.cpp.

◆ Read() [5/10]

void TPZContBufferedStream::Read ( float *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 223 of file TPZContBufferedStream.cpp.

◆ Read() [6/10]

void TPZContBufferedStream::Read ( double *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 227 of file TPZContBufferedStream.cpp.

◆ Read() [7/10]

void TPZContBufferedStream::Read ( unsigned char *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 231 of file TPZContBufferedStream.cpp.

◆ Read() [8/10]

void TPZContBufferedStream::Read ( char *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 235 of file TPZContBufferedStream.cpp.

◆ Read() [9/10]

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

Implements TPZStream.

Definition at line 239 of file TPZContBufferedStream.cpp.

◆ Read() [10/10]

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

Implements TPZStream.

Definition at line 243 of file TPZContBufferedStream.cpp.

References Read().

◆ ReadData()

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

Definition at line 177 of file TPZContBufferedStream.h.

References ReadFromBuffer().

Referenced by WriteData().

◆ ReadFromBuffer()

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

Reads from buffer.

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

Definition at line 63 of file TPZContBufferedStream.cpp.

References DebugStop, fFirst, fSize, PZError, and to_string().

Referenced by operator<<(), and ReadData().

◆ Size()

size_t TPZContBufferedStream::Size ( ) const

Definition at line 293 of file TPZContBufferedStream.cpp.

References fSize.

◆ Write() [1/10]

void TPZContBufferedStream::Write ( const int *  p,
int  howMany = 1 
)
virtual

◆ Write() [2/10]

void TPZContBufferedStream::Write ( const unsigned int *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 135 of file TPZContBufferedStream.cpp.

◆ Write() [3/10]

void TPZContBufferedStream::Write ( const uint64_t *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 139 of file TPZContBufferedStream.cpp.

◆ Write() [4/10]

void TPZContBufferedStream::Write ( const int64_t *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 143 of file TPZContBufferedStream.cpp.

◆ Write() [5/10]

void TPZContBufferedStream::Write ( const float *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 147 of file TPZContBufferedStream.cpp.

◆ Write() [6/10]

void TPZContBufferedStream::Write ( const double *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 151 of file TPZContBufferedStream.cpp.

◆ Write() [7/10]

void TPZContBufferedStream::Write ( const unsigned char *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 155 of file TPZContBufferedStream.cpp.

◆ Write() [8/10]

void TPZContBufferedStream::Write ( const char *  p,
int  howMany = 1 
)
virtual

Implements TPZStream.

Definition at line 159 of file TPZContBufferedStream.cpp.

◆ Write() [9/10]

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

Implements TPZStream.

Definition at line 163 of file TPZContBufferedStream.cpp.

◆ Write() [10/10]

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

Implements TPZStream.

Definition at line 167 of file TPZContBufferedStream.cpp.

References Write().

◆ WriteData()

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

Definition at line 182 of file TPZContBufferedStream.h.

References ReadData(), and WriteToBuffer().

◆ WriteToBuffer()

void TPZContBufferedStream::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 97 of file TPZContBufferedStream.cpp.

References ConstReadFromBuffer(), fBuffer, fFirst, fLast, fNAllocatedBytes, fSize, and MIN_SIZE_INCREMENT.

Referenced by operator<<(), and WriteData().

Member Data Documentation

◆ fBuffer

char* TPZContBufferedStream::fBuffer
private

◆ fFirst

char* TPZContBufferedStream::fFirst
private

◆ fLast

char* TPZContBufferedStream::fLast
private

Definition at line 155 of file TPZContBufferedStream.h.

Referenced by clear(), operator=(), TPZContBufferedStream(), and WriteToBuffer().

◆ fNAllocatedBytes

size_t TPZContBufferedStream::fNAllocatedBytes
private

◆ fSize

size_t TPZContBufferedStream::fSize
private

◆ MIN_SIZE_INCREMENT

const size_t TPZContBufferedStream::MIN_SIZE_INCREMENT
staticprivate

Definition at line 173 of file TPZContBufferedStream.h.

Referenced by TPZContBufferedStream(), and WriteToBuffer().


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