ESyS-Particle  4.0.1
packed_multi_message.h
00001 
00002 //                                                         //
00003 // Copyright (c) 2003-2011 by The University of Queensland //
00004 // Earth Systems Science Computational Centre (ESSCC)      //
00005 // http://www.uq.edu.au/esscc                              //
00006 //                                                         //
00007 // Primary Business: Brisbane, Queensland, Australia       //
00008 // Licensed under the Open Software License version 3.0    //
00009 // http://www.opensource.org/licenses/osl-3.0.php          //
00010 //                                                         //
00012 
00013 #ifndef __PACKED_MULTI_MESSAGE_H
00014 #define __PACKED_MULTI_MESSAGE_H
00015 
00016 //--- MPI ---
00017 #include <mpi.h>
00018 
00019 //--- project includes ---
00020 #include "tml/message/multi_message_slab.h"
00021 
00022 //--- STL includes ---
00023 #include <string>
00024 using std::string;
00025 
00026 
00034 class TML_PackedMultiMessage
00035 {
00036  private:
00037   MPI_Comm m_comm;  
00038   char* m_vbuffer;
00039   int m_vbuffersize; 
00040   int *m_position; 
00041   int *m_rpos;     
00042 
00043   int *m_recvcount;
00044   int *m_displ; //<! the diplacements of the slices in the buffer
00045   int m_size;
00046   int m_int_increment,m_dbl_increment; 
00047 
00048  protected:
00049   void grow();
00050   void growTo(int);
00051 
00052  public:
00053   TML_PackedMultiMessage(MPI_Comm,int isize=64);
00054   virtual ~TML_PackedMultiMessage();
00055 
00056   TML_PackedMultiMessageSlab operator[](int);
00057 
00058   char* buffer(){return m_vbuffer;}; // make protected or make TML_Comm friend?
00059   int* offsets(){return m_displ;};
00060   int* sizes(){return m_rpos;};
00061 
00062   void clear();
00063   void begin_pack(int);
00064   void begin_unpack(int);
00065 
00066   void append(int,int);
00067   void append(double,int);
00068   void append(const string&,int);
00069   void append(bool,int);
00070 
00071   int pop_int(int);
00072   double pop_double(int);
00073   string pop_string(int);
00074   bool pop_bool(int);
00075 };
00076 
00077 #endif // __PACKED_MULTI_MESSAGE_H