ESyS-Particle  4.0.1
packed_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_MESSAGE_H
14 #define __PACKED_MESSAGE_H
15 
16 //--- MPI ---
17 #include <mpi.h>
18 
19 //--- project includes ---
20 #include "tml/message/packed_message_interface.h"
21 #include "Foundation/vec3.h" // for append(Vec3), pop_vec3()
22 
23 //--- STL includes ---
24 #include <string>
25 using std::string;
26 
27 
35 {
36  protected:
37  MPI_Comm m_comm;
38  char* m_buffer;
40  int m_pack_pos;
42  int m_int_increment,m_dbl_increment;
43 
44  void grow();
45  void growTo(int);
46 
47  public:
48  TML_Packed_Message(MPI_Comm,unsigned int size=64);
49  virtual ~TML_Packed_Message();
50 
51  char* buffer(){return m_buffer;}; // make protected ?
52  int size(){return m_pack_pos;};
53 
54  virtual void begin_pack(){m_pack_pos=0;};
55  virtual void begin_unpack(){m_unpack_pos=0;};
56  virtual void append(int);
57  virtual void append(double);
58  virtual void append(const string&);
59  virtual void append(const Vec3&);
60  virtual void append(bool);
61 
62  virtual int pop_int();
63  virtual double pop_double();
64  virtual void pop_doubles(double*,int);
65  virtual string pop_string();
66  virtual Vec3 pop_vec3();
67  virtual bool pop_bool();
68 };
69 #endif //__PACKED_MESSAGE_H