17 #include <type_traits> 27 template <
class T>
class Fad;
28 template <
int Num,
class T>
class TFad;
33 #define TPZostream std::ostream 35 template<
class T,
int EXP>
38 template <
class T,
int EXP>
61 virtual void Write(
const int *p,
int howMany = 1) = 0;
63 virtual void Write(
const unsigned int *p,
int howMany = 1) = 0;
65 virtual void Write(
const int64_t *p,
int howMany = 1) = 0;
67 virtual void Write(
const uint64_t *p,
int howMany = 1) = 0;
69 #if defined WIN32 || defined __APPLE__ 72 virtual void Write(
const long *p,
int howMany = 1);
74 virtual void Write(
const long unsigned int *p,
int howMany = 1);
77 virtual void Write(
const float *p,
int howMany = 1) = 0;
79 virtual void Write(
const double *p,
int howMany = 1) = 0;
81 virtual void Write(
const long double *p,
int howMany = 1);
83 virtual void Write(
const unsigned char *p,
int howMany = 1) = 0;
85 virtual void Write(
const char *p,
int howMany = 1) = 0;
87 virtual void Write(
const std::string *p,
int howMany = 1);
89 virtual void Write(
const std::complex< float > *p,
int howMany = 1) = 0;
91 virtual void Write(
const std::complex< double > *p,
int howMany = 1) = 0;
93 virtual void Write(
const std::complex< long double > *p,
int howMany = 1);
115 virtual void Write(
const Fad<std::complex< float > > *p,
int howMany = 1);
117 virtual void Write(
const Fad<std::complex< double > >*p,
int howMany = 1);
119 virtual void Write(
const Fad<std::complex< long double >> *p,
int howMany = 1);
125 virtual void Read(
bool &val);
127 virtual void Read(
int *p,
int howMany = 1) = 0;
129 virtual void Read(
unsigned int *p,
int howMany = 1) = 0;
131 virtual void Read(int64_t *p,
int howMany = 1) = 0;
133 virtual void Read(uint64_t *p,
int howMany = 1) = 0;
135 #if defined WIN32 || defined __APPLE__ 139 virtual void Read(
long *p,
int howMany = 1);
141 virtual void Read(
long unsigned int *p,
int howMany = 1);
144 virtual void Read(
float *p,
int howMany = 1) = 0;
146 virtual void Read(
double *p,
int howMany = 1) = 0;
148 virtual void Read(
long double *p,
int howMany = 1);
150 virtual void Read(
unsigned char *p,
int howMany = 1) = 0;
152 virtual void Read(
char *p,
int howMany = 1) = 0;
154 virtual void Read(std::string *p,
int howMany = 1);
156 virtual void Read(std::complex< float > *p,
int howMany = 1) = 0;
158 virtual void Read(std::complex< double > *p,
int howMany = 1) = 0;
160 virtual void Read(std::complex< long double > *p,
int howMany = 1);
182 virtual void Read(
Fad<std::complex< float >> *p,
int howMany = 1);
184 virtual void Read(
Fad<std::complex< double >> *p,
int howMany = 1);
186 virtual void Read(
Fad<std::complex< long double >> *p,
int howMany = 1);
208 for (c = 0; c < nc; c++) {
209 vec[c].Write(*
this, 0);
217 for (uint64_t i = 0; i < size; ++i) {
224 void Write(
const std::vector<T> &vec) {
225 int nel = vec.size();
227 for (
int c = 0; c < nel; c++){
228 this->
Write(&vec[c]);
234 void Write(
const std::vector<T> &vec) {
235 int c, nc = vec.size();
237 for (c = 0; c < nc; c++)
238 vec[c].
Write(*
this, 0);
245 for (
int iel = 0; iel < nel; iel++) {
246 temp[iel] = vec[iel];
251 template <
class T,
class U>
void Write(
const std::map<T, U> &vec) {
252 int64_t sz = vec.size();
256 typename std::map<T, U>::const_iterator it;
257 for (it = vec.begin(); it != vec.end(); it++) {
258 keyVec[count] = it->first;
259 valVec[count++] = it->second;
267 void Write(
const std::set<T> &vec) {
268 int nel = vec.size();
270 typename std::set<T>::iterator it = vec.begin();
271 while (it != vec.end()) {
289 for (c = 0; c < nc; c++) {
290 vec[c].Read(*
this, context);
300 if (nc) this->
Read(&vec[0], nc);
309 for (uint64_t i = 0; i < size; ++i) {
319 if (nc) this->
Read(&temp[0], nc);
320 for (int64_t ic = 0; ic < nc; ic++) {
327 void Read(std::vector<T> &vec,
void *context) {
331 for (c = 0; c < nc; c++) {
332 vec[c].Read(*
this, context);
338 void Read(std::vector<T> &vec,
void *context) {
342 for (
int i = 0; i < nel; i++) {
352 if (nc) this->
Read(&vec[0], nc);
360 if (nc) this->
Read(&vec[0], nc);
363 template <
class T,
class U>
void Read(std::map<T, U> &vec) {
375 for (i = 0; i < sz; ++i) {
376 vec[keyVec[i]] = valVec[i];
385 for (
int i = 0; i < nel; i++) {
417 template <
class T,
int EXP>
420 template <
class T,
int EXP>
423 template <
class T,
int EXP>
426 template <
class T,
int EXP>
436 this->
Write(&nObjects);
437 for (int64_t i = 0; i < nObjects; i++) {
444 this->
Read(&nObjects);
446 for (int64_t i = 0; i < nObjects; ++i) {
453 uint64_t nObjects = map.size();
454 this->
Write(&nObjects);
455 typedef typename std::map<int, TPZAutoPointer<T>>::const_iterator map_it;
457 for (it = map.begin(); it != map.end(); it++) {
458 this->
Write(&(it->first));
466 this->
Read(&nObjects);
468 for (uint64_t i = 0; i < nObjects; ++i) {
476 uint64_t nObjects = vec.size();
477 this->
Write(&nObjects);
478 typedef typename std::map<int, T *>::const_iterator vec_it;
480 for (it = vec.begin(); it != vec.end(); it++) {
481 this->
Write(&it->first);
488 this->
Read(&nObjects);
490 for (uint64_t i = 0; i < nObjects; ++i) {
497 uint64_t nObjects = _set.size();
498 this->
Write(&nObjects);
499 typedef typename std::set<T *>::const_iterator _set_it;
501 while (it != _set.end()) {
509 this->
Read(&nObjects);
511 for(uint64_t i = 0; i < nObjects; ++i) {
516 template <
class T,
int EXP>
519 this->
Write(&nObjects);
520 for (uint64_t i = 0; i < nObjects; i++) {
525 template <
class T,
int EXP>
528 this->
Read(&nObjects);
530 for (uint64_t i = 0; i < nObjects; ++i) {
535 template <
class T,
int EXP>
538 this->
Write(&nObjects);
539 for (uint64_t i = 0; i < nObjects; i++) {
543 this->
Write(&compactScheme);
548 template <
class T,
int EXP>
551 this->
Read(&nObjects);
553 for (uint64_t i = 0; i < nObjects; ++i) {
557 Read(&compactScheme);
Implements a vector class which allows to use external storage provided by the user. Utility.
virtual void resize(const int64_t newsize)
Templated vector implementation.
void WritePointers(const TPZVec< TPZAutoPointer< T >> &vec)
std::underlying_type< Enumeration >::type as_integer(const Enumeration value)
void Write(const std::vector< T > &vec)
void Read(TPZManVector< REAL, N > &vec)
void Read(TPZVec< T > &vec, void *context)
void Read(TPZManVector< int64_t, N > &vec)
This class implements a simple vector storage scheme for a templated class T. Utility.
int64_t NElements() const
Access method to query the number of elements of the vector.
REAL val(STATE &number)
Returns value of the variable.
Implements a chunk vector with free store administration. Utility.
static TPZSavable * GetInstance(const int64_t &objId)
void Resize(const int64_t newsize)
Increase the size of the chunk vector.
void ReadPointers(TPZVec< TPZAutoPointer< T >> &vec)
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
void Read(TPZVec< T > &vec)
static uint64_t fCurrentVersion
static TPZAutoPointer< TPZSavable > GetAutoPointer(const int64_t &objId)
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
void Read(std::set< T > &vec)
CompactScheme fCompactScheme
Internal variable indicating the type of compacting scheme.
void Resize(const int newsize)
Increase the size of the chunk vector.
virtual void Write(const bool val)
#define DebugStop()
Returns a message to user put a breakpoint in.
void Write(const std::map< T, U > &vec)
Free store vector implementation.
Contains declaration of the TPZAutoPointer class which has Increment and Decrement actions are mutexe...
void Read(std::map< T, U > &vec)
TPZManVector< int > fNFree
Number of free elements within each chunk.
TPZStack< int > fFree
List of indexes of freed elements.
This class implements floating point number associated with a counter of the operations performed wit...
Defines the interface for saving and reading data. Persistency.
int64_t NElements() const
Returns the number of elements of the vector.
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
void Read(TPZVec< TPZFlopCounter > &vec)
void Write(const TPZVec< T > &vec)
void Write(const TPZVec< TPZFlopCounter > &vec)
static void WritePointer(const TPZSavable *obj, TPZStream *stream)
void Read(std::vector< T > &vec, void *context)
virtual void Read(bool &val)
This class implements a reference counter mechanism to administer a dynamically allocated object...
void Write(const std::set< T > &vec)