VTK  9.5.20251110
vtkMultiProcessStream.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
20#ifndef vtkMultiProcessStream_h
21#define vtkMultiProcessStream_h
22
23#include "vtkObject.h"
24#include "vtkParallelCoreModule.h" // For export macro
25#include <string> // needed for string.
26#include <vector> // needed for vector.
27
28VTK_ABI_NAMESPACE_BEGIN
29class vtkDataArray;
30class vtkStringArray;
31struct vtkMultiProcessStreamPushArray;
32struct vtkMultiProcessStreamPopArray;
33class VTKPARALLELCORE_EXPORT vtkMultiProcessStream
34{
35public:
40
42
47 vtkMultiProcessStream& operator<<(signed char value);
48 vtkMultiProcessStream& operator<<(unsigned char value);
50 vtkMultiProcessStream& operator<<(unsigned short value);
52 vtkMultiProcessStream& operator<<(unsigned int value);
54 vtkMultiProcessStream& operator<<(unsigned long value);
56 vtkMultiProcessStream& operator<<(unsigned long long value);
59 vtkMultiProcessStream& operator<<(const std::string& value);
60 // Without this operator, the compiler would convert
61 // a char* to a bool instead of a std::string.
62 vtkMultiProcessStream& operator<<(const char* value);
65
67
72 vtkMultiProcessStream& operator>>(signed char& value);
73 vtkMultiProcessStream& operator>>(unsigned char& value);
75 vtkMultiProcessStream& operator>>(unsigned short& value);
77 vtkMultiProcessStream& operator>>(unsigned int& value);
79 vtkMultiProcessStream& operator>>(unsigned long& value);
81 vtkMultiProcessStream& operator>>(unsigned long long& value);
84 vtkMultiProcessStream& operator>>(std::string& value);
87
89
92 void Push(char array[], unsigned int size);
93 void Push(signed char array[], unsigned int size);
94 void Push(unsigned char array[], unsigned int size);
95 void Push(short array[], unsigned int size);
96 void Push(unsigned short array[], unsigned int size);
97 void Push(int array[], unsigned int size);
98 void Push(unsigned int array[], unsigned int size);
99 void Push(long array[], unsigned int size);
100 void Push(unsigned long array[], unsigned int size);
101 void Push(long long array[], unsigned int size);
102 void Push(unsigned long long array[], unsigned int size);
103 void Push(float array[], unsigned int size);
104 void Push(double array[], unsigned int size);
105 void Push(vtkDataArray* array);
106 void Push(vtkStringArray* array);
108
110
117 void Pop(char*& array, unsigned int& size);
118 void Pop(signed char*& array, unsigned int& size);
119 void Pop(unsigned char*& array, unsigned int& size);
120 void Pop(short*& array, unsigned int& size);
121 void Pop(unsigned short*& array, unsigned int& size);
122 void Pop(int*& array, unsigned int& size);
123 void Pop(unsigned int*& array, unsigned int& size);
124 void Pop(long*& array, unsigned int& size);
125 void Pop(unsigned long*& array, unsigned int& size);
126 void Pop(long long*& array, unsigned int& size);
127 void Pop(unsigned long long*& array, unsigned int& size);
128 void Pop(float*& array, unsigned int& size);
129 void Pop(double*& array, unsigned int& size);
130 void Pop(vtkDataArray*& array);
131 void Pop(vtkStringArray*& array);
133
137 void Reset();
138
142 int Size();
143
148 int RawSize() { return (this->Size() + 1); }
149
153 bool Empty();
154
156
160 void GetRawData(std::vector<unsigned char>& data) const;
161 void GetRawData(unsigned char*& data, unsigned int& size);
162 void SetRawData(const std::vector<unsigned char>& data);
163 void SetRawData(const unsigned char*, unsigned int size);
164 std::vector<unsigned char> GetRawData() const;
166
167private:
168 class vtkInternals;
169 vtkInternals* Internals;
170 unsigned char Endianness;
171 enum
172 {
173 BigEndian,
174 LittleEndian
175 };
176 friend struct vtkMultiProcessStreamPushArray;
177 friend struct vtkMultiProcessStreamPopArray;
178
179 template <typename T>
180 inline void PushArray(T array[], unsigned int size);
181 template <typename T>
182 inline void PopArray(T*& array, unsigned int& size);
183 template <typename T>
184 inline vtkMultiProcessStream& OperatorPush(T value);
185 template <typename T>
186 inline vtkMultiProcessStream& OperatorPop(T& value);
187};
188
189VTK_ABI_NAMESPACE_END
190#endif
191
192// VTK-HeaderTest-Exclude: vtkMultiProcessStream.h
abstract superclass for arrays of numeric data
stream used to pass data across processes using vtkMultiProcessController.
vtkMultiProcessStream & operator<<(const vtkMultiProcessStream &)
Add-to-stream operators.
vtkMultiProcessStream & operator<<(unsigned long value)
Add-to-stream operators.
vtkMultiProcessStream & operator<<(long value)
Add-to-stream operators.
void Pop(signed char *&array, unsigned int &size)
Remove-array-to-stream methods.
vtkMultiProcessStream & operator<<(int value)
Add-to-stream operators.
vtkMultiProcessStream & operator>>(bool &value)
Remove-from-stream operators.
void SetRawData(const unsigned char *, unsigned int size)
Serialization methods used to save/restore the stream to/from raw data.
vtkMultiProcessStream & operator<<(unsigned int value)
Add-to-stream operators.
void Pop(short *&array, unsigned int &size)
Remove-array-to-stream methods.
void Push(long array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator>>(unsigned int &value)
Remove-from-stream operators.
void Pop(double *&array, unsigned int &size)
Remove-array-to-stream methods.
vtkMultiProcessStream & operator>>(char &value)
Remove-from-stream operators.
std::vector< unsigned char > GetRawData() const
Serialization methods used to save/restore the stream to/from raw data.
void Push(vtkStringArray *array)
Add-array-to-stream methods.
vtkMultiProcessStream & operator<<(short value)
Add-to-stream operators.
vtkMultiProcessStream & operator>>(long long &value)
Remove-from-stream operators.
void Pop(unsigned long long *&array, unsigned int &size)
Remove-array-to-stream methods.
vtkMultiProcessStream & operator=(const vtkMultiProcessStream &)
void SetRawData(const std::vector< unsigned char > &data)
Serialization methods used to save/restore the stream to/from raw data.
bool Empty()
Returns true iff the stream is empty.
vtkMultiProcessStream & operator>>(unsigned char &value)
Remove-from-stream operators.
void Push(float array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator>>(int &value)
Remove-from-stream operators.
void Push(signed char array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator>>(double &value)
Remove-from-stream operators.
vtkMultiProcessStream & operator>>(short &value)
Remove-from-stream operators.
void GetRawData(std::vector< unsigned char > &data) const
Serialization methods used to save/restore the stream to/from raw data.
void Pop(vtkDataArray *&array)
Remove-array-to-stream methods.
void Pop(char *&array, unsigned int &size)
Remove-array-to-stream methods.
void Push(unsigned long array[], unsigned int size)
Add-array-to-stream methods.
void Push(unsigned int array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator<<(const std::string &value)
Add-to-stream operators.
void Pop(unsigned char *&array, unsigned int &size)
Remove-array-to-stream methods.
void Push(int array[], unsigned int size)
Add-array-to-stream methods.
void Push(char array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator>>(signed char &value)
Remove-from-stream operators.
vtkMultiProcessStream & operator>>(unsigned short &value)
Remove-from-stream operators.
void Pop(unsigned short *&array, unsigned int &size)
Remove-array-to-stream methods.
void Pop(long *&array, unsigned int &size)
Remove-array-to-stream methods.
void Reset()
Clears everything in the stream.
void Push(unsigned long long array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator<<(float value)
Add-to-stream operators.
void Push(double array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator>>(unsigned long &value)
Remove-from-stream operators.
vtkMultiProcessStream & operator>>(long &value)
Remove-from-stream operators.
void Push(unsigned short array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator<<(bool value)
Add-to-stream operators.
vtkMultiProcessStream & operator>>(float &value)
Remove-from-stream operators.
void Pop(unsigned long *&array, unsigned int &size)
Remove-array-to-stream methods.
vtkMultiProcessStream & operator<<(signed char value)
Add-to-stream operators.
void Pop(float *&array, unsigned int &size)
Remove-array-to-stream methods.
void Pop(int *&array, unsigned int &size)
Remove-array-to-stream methods.
void Pop(unsigned int *&array, unsigned int &size)
Remove-array-to-stream methods.
vtkMultiProcessStream & operator>>(vtkMultiProcessStream &)
Remove-from-stream operators.
vtkMultiProcessStream & operator<<(unsigned short value)
Add-to-stream operators.
void Pop(long long *&array, unsigned int &size)
Remove-array-to-stream methods.
vtkMultiProcessStream & operator>>(unsigned long long &value)
Remove-from-stream operators.
void Push(vtkDataArray *array)
Add-array-to-stream methods.
void Pop(vtkStringArray *&array)
Remove-array-to-stream methods.
vtkMultiProcessStream & operator<<(const char *value)
Add-to-stream operators.
vtkMultiProcessStream & operator<<(unsigned long long value)
Add-to-stream operators.
vtkMultiProcessStream & operator<<(double value)
Add-to-stream operators.
void GetRawData(unsigned char *&data, unsigned int &size)
Serialization methods used to save/restore the stream to/from raw data.
vtkMultiProcessStream & operator<<(char value)
Add-to-stream operators.
void Push(long long array[], unsigned int size)
Add-array-to-stream methods.
void Push(short array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator<<(long long value)
Add-to-stream operators.
void Push(unsigned char array[], unsigned int size)
Add-array-to-stream methods.
vtkMultiProcessStream & operator>>(std::string &value)
Remove-from-stream operators.
int Size()
Returns the size of the stream.
vtkMultiProcessStream & operator<<(unsigned char value)
Add-to-stream operators.
int RawSize()
Returns the size of the raw data returned by GetRawData.
vtkMultiProcessStream(const vtkMultiProcessStream &)
a vtkAbstractArray subclass for strings