PABLO  0.1
PArallel Balanced Linear Octree
 All Classes Functions Variables Pages
Class_Comm_Buffer.cpp
1 #if NOMPI==0
2 #include "Class_Comm_Buffer.hpp"
3 
4 Class_Comm_Buffer::Class_Comm_Buffer(){
5 
6  commBufferSize = 0;
7  commBuffer = NULL;
8  pos = 0;
9  comm = MPI_COMM_WORLD;
10 }
11 
12 Class_Comm_Buffer::Class_Comm_Buffer(MPI_Comm comm_) : comm(comm_){
13 
14  commBufferSize = 0;
15  commBuffer = NULL;
16  pos = 0;
17 }
18 
19 Class_Comm_Buffer::Class_Comm_Buffer(uint32_t size, char value, MPI_Comm comm_) : comm(comm_){
20 
21  commBufferSize = size;
22  commBuffer = new char [size];
23  for(uint32_t i = 0; i < size; ++i)
24  commBuffer[i] = value;
25  pos = 0;
26 }
27 
28 Class_Comm_Buffer::Class_Comm_Buffer(const Class_Comm_Buffer& other) {
29 
30  commBufferSize = other.commBufferSize;
31  // if(commBuffer != NULL){
32  // delete [] commBuffer;
33  // commBuffer = NULL;
34  // }
35  commBuffer = new char [commBufferSize];
36  for(uint32_t i = 0; i < commBufferSize; ++i)
37  commBuffer[i] = other.commBuffer[i];
38  pos = other.pos;
39  comm = other.comm;
40 }
41 
42 Class_Comm_Buffer::~Class_Comm_Buffer() {
43  delete [] commBuffer;
44  commBuffer = NULL;
45 }
46 
47 Class_Comm_Buffer& Class_Comm_Buffer::operator =(const Class_Comm_Buffer& rhs) {
48  if(this != &rhs)
49  {
50  char* new_array = new char[rhs.commBufferSize];
51  copy(rhs.commBuffer,rhs.commBuffer+rhs.commBufferSize,new_array);
52 
53  delete [] commBuffer;
54 
55  commBuffer = new_array;
56  commBufferSize = rhs.commBufferSize;
57  pos = rhs.pos;
58  comm = rhs.comm;
59  }
60  return *this;
61 
62 }
63 #endif
Bundle char container for communications.