ESyS-Particle  4.0.1
packed_multi_message.h
1 
2 // //
3 // Copyright (c) 2003-2011 by The University of Queensland //
4 // Earth Systems Science Computational Centre (ESSCC) //
5 // http://www.uq.edu.au/esscc //
6 // //
7 // Primary Business: Brisbane, Queensland, Australia //
8 // Licensed under the Open Software License version 3.0 //
9 // http://www.opensource.org/licenses/osl-3.0.php //
10 // //
12 
13 #ifndef __PACKED_MULTI_MESSAGE_H
14 #define __PACKED_MULTI_MESSAGE_H
15 
16 //--- MPI ---
17 #include <mpi.h>
18 
19 //--- project includes ---
20 #include "tml/message/multi_message_slab.h"
21 
22 //--- STL includes ---
23 #include <string>
24 using std::string;
25 
26 
35 {
36  private:
37  MPI_Comm m_comm;
38  char* m_vbuffer;
39  int m_vbuffersize;
40  int *m_position;
41  int *m_rpos;
42 
43  int *m_recvcount;
44  int *m_displ; //<! the diplacements of the slices in the buffer
45  int m_size;
46  int m_int_increment,m_dbl_increment;
47 
48  protected:
49  void grow();
50  void growTo(int);
51 
52  public:
53  TML_PackedMultiMessage(MPI_Comm,int isize=64);
54  virtual ~TML_PackedMultiMessage();
55 
57 
58  char* buffer(){return m_vbuffer;}; // make protected or make TML_Comm friend?
59  int* offsets(){return m_displ;};
60  int* sizes(){return m_rpos;};
61 
62  void clear();
63  void begin_pack(int);
64  void begin_unpack(int);
65 
66  void append(int,int);
67  void append(double,int);
68  void append(const string&,int);
69  void append(bool,int);
70 
71  int pop_int(int);
72  double pop_double(int);
73  string pop_string(int);
74  bool pop_bool(int);
75 };
76 
77 #endif // __PACKED_MULTI_MESSAGE_H