| 364 | //------------------------------------------------------------------------------ |
| 365 | template <typename T> |
| 366 | void vtkMultiProcessStream::PopArray(T*& array, unsigned int& size) |
| 367 | { |
| 368 | assert("pre: stream data must be the right type" && |
| 369 | this->Internals->Data.front() == vtkTypeTraits<T>::VTKTypeID()); |
| 370 | this->Internals->Data.pop_front(); |
| 371 | |
| 372 | if (array == nullptr) |
| 373 | { |
| 374 | // Get the size of the array |
| 375 | this->Internals->Pop(reinterpret_cast<unsigned char*>(&size), sizeof(unsigned int)); |
| 376 | |
| 377 | // Allocate array |
| 378 | array = new T[size]; |
| 379 | assert("ERROR: cannot allocate array" && (array != nullptr)); |
| 380 | } |
| 381 | else |
| 382 | { |
| 383 | unsigned int sz; |
| 384 | |
| 385 | // Get the size of the array |
| 386 | this->Internals->Pop(reinterpret_cast<unsigned char*>(&sz), sizeof(unsigned int)); |
| 387 | assert("ERROR: input array size does not match size of data" && (sz == size)); |
| 388 | } |
| 389 | |
| 390 | // Pop the array data |
| 391 | this->Internals->Pop(reinterpret_cast<unsigned char*>(array), sizeof(T) * size); |
| 392 | } |
| 393 | |
| 394 | //------------------------------------------------------------------------------ |
| 395 | void vtkMultiProcessStream::Pop(char*& array, unsigned int& size) |