KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
stream_serializer.h
Go to the documentation of this file.
1 // | / |
2 // ' / __| _` | __| _ \ __|
3 // . \ | ( | | ( |\__ `
4 // _|\_\_| \__,_|\__|\___/ ____/
5 // Multi-Physics
6 //
7 // License: BSD License
8 // Kratos default license: kratos/license.txt
9 //
10 // Main authors: Pooyan Dadvand
11 //
12 //
13 
14 #if !defined(KRATOS_STREAM_SERIALIZER_H_INCLUDED )
15 #define KRATOS_STREAM_SERIALIZER_H_INCLUDED
16 
17 // System includes
18 #include <string>
19 #include <cstring>
20 #include <iostream>
21 
22 // External includes
23 
24 // Project includes
25 #include "includes/define.h"
26 #include "includes/serializer.h"
27 
28 //This class provides a simpler interface for serialization to a string instead of to a file
29 // Note that you may not override any load or save method of the Serializer. They are not virtual.
30 namespace Kratos
31 {
32  class StreamSerializer : public Serializer
33  {
34  public:
36 
40  : Serializer(new std::stringstream(std::ios::binary|std::ios::in|std::ios::out),rTrace)
41  {}
42 
43  //this constructor generates a standard Serializer AND fills the buffer with the data contained in "data"
46  StreamSerializer(const std::string& data,TraceType const& rTrace=SERIALIZER_NO_TRACE)
47  : Serializer(new std::stringstream(std::ios::binary|std::ios::in|std::ios::out),rTrace)
48  {
49  *(this->pGetBuffer()) << data << std::endl;
50  }
51 
52  //get a string representation of the serialized data
53  std::string GetStringRepresentation() {
54  return ((std::stringstream*)(this->pGetBuffer()))->str();
55  }
56 
57  virtual ~StreamSerializer(){}
58 
59  private:
60 
62  StreamSerializer& operator=(StreamSerializer const& rOther) = delete;
63 
65  StreamSerializer(StreamSerializer const& rOther) = delete;
66  };
67 }
68 #endif // KRATOS_STREAM_SERIALIZER_H_INCLUDED defined
The serialization consists in storing the state of an object into a storage format like data file or ...
Definition: serializer.h:123
TraceType
Definition: serializer.h:129
@ SERIALIZER_NO_TRACE
Definition: serializer.h:129
BufferType * pGetBuffer()
Definition: serializer.h:903
Definition: stream_serializer.h:33
StreamSerializer(TraceType const &rTrace=SERIALIZER_NO_TRACE)
Definition: stream_serializer.h:39
std::string GetStringRepresentation()
Definition: stream_serializer.h:53
virtual ~StreamSerializer()
Definition: stream_serializer.h:57
KRATOS_CLASS_POINTER_DEFINITION(StreamSerializer)
StreamSerializer(const std::string &data, TraceType const &rTrace=SERIALIZER_NO_TRACE)
Definition: stream_serializer.h:46
REF: G. R. Cowper, GAUSSIAN QUADRATURE FORMULAS FOR TRIANGLES.
Definition: mesh_condition.cpp:21
out
Definition: isotropic_damage_automatic_differentiation.py:200
data
Definition: mesh_to_mdpa_converter.py:59
namespace
Definition: array_1d.h:793