VTK  9.7.1
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 
28 VTK_ABI_NAMESPACE_BEGIN
29 class vtkDataArray;
30 class vtkStringArray;
31 struct vtkMultiProcessStreamPushArray;
32 struct vtkMultiProcessStreamPopArray;
33 class VTKPARALLELCORE_EXPORT vtkMultiProcessStream
34 {
35 public:
40 
42 
46  vtkMultiProcessStream& operator<<(char value);
47  vtkMultiProcessStream& operator<<(signed char value);
48  vtkMultiProcessStream& operator<<(unsigned char value);
49  vtkMultiProcessStream& operator<<(short value);
50  vtkMultiProcessStream& operator<<(unsigned short value);
52  vtkMultiProcessStream& operator<<(unsigned int value);
53  vtkMultiProcessStream& operator<<(long value);
54  vtkMultiProcessStream& operator<<(unsigned long value);
55  vtkMultiProcessStream& operator<<(long long value);
56  vtkMultiProcessStream& operator<<(unsigned long long value);
57  vtkMultiProcessStream& operator<<(float value);
58  vtkMultiProcessStream& operator<<(double 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 
70  vtkMultiProcessStream& operator>>(bool& value);
71  vtkMultiProcessStream& operator>>(char& value);
72  vtkMultiProcessStream& operator>>(signed char& value);
73  vtkMultiProcessStream& operator>>(unsigned char& value);
74  vtkMultiProcessStream& operator>>(short& value);
75  vtkMultiProcessStream& operator>>(unsigned short& value);
76  vtkMultiProcessStream& operator>>(int& value);
77  vtkMultiProcessStream& operator>>(unsigned int& value);
78  vtkMultiProcessStream& operator>>(long& value);
79  vtkMultiProcessStream& operator>>(unsigned long& value);
80  vtkMultiProcessStream& operator>>(long long& value);
81  vtkMultiProcessStream& operator>>(unsigned long long& value);
82  vtkMultiProcessStream& operator>>(float& value);
83  vtkMultiProcessStream& operator>>(double& 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 
167 private:
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 
189 VTK_ABI_NAMESPACE_END
190 #endif
191 
192 // VTK-HeaderTest-Exclude: vtkMultiProcessStream.h
stream used to pass data across processes using vtkMultiProcessController.
a vtkAbstractArray subclass for strings
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
VTKCOMMONCORE_EXPORT ostream & operator<<(ostream &os, const vtkIndent &o)
vtkMultiProcessStream & operator>>(vtkMultiProcessStream &stream, T &value)
int RawSize()
Returns the size of the raw data returned by GetRawData.