ESyS-Particle
4.0.1
|
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_MESSAGE_H 00014 #define __PACKED_MESSAGE_H 00015 00016 //--- MPI --- 00017 #include <mpi.h> 00018 00019 //--- project includes --- 00020 #include "tml/message/packed_message_interface.h" 00021 #include "Foundation/vec3.h" // for append(Vec3), pop_vec3() 00022 00023 //--- STL includes --- 00024 #include <string> 00025 using std::string; 00026 00027 00034 class TML_Packed_Message : public TML_PackedMessageInterface 00035 { 00036 protected: 00037 MPI_Comm m_comm; 00038 char* m_buffer; 00039 int m_buffersize; 00040 int m_pack_pos; 00041 int m_unpack_pos; 00042 int m_int_increment,m_dbl_increment; 00043 00044 void grow(); 00045 void growTo(int); 00046 00047 public: 00048 TML_Packed_Message(MPI_Comm,unsigned int size=64); 00049 virtual ~TML_Packed_Message(); 00050 00051 char* buffer(){return m_buffer;}; // make protected ? 00052 int size(){return m_pack_pos;}; 00053 00054 virtual void begin_pack(){m_pack_pos=0;}; 00055 virtual void begin_unpack(){m_unpack_pos=0;}; 00056 virtual void append(int); 00057 virtual void append(double); 00058 virtual void append(const string&); 00059 virtual void append(const Vec3&); 00060 virtual void append(bool); 00061 00062 virtual int pop_int(); 00063 virtual double pop_double(); 00064 virtual void pop_doubles(double*,int); 00065 virtual string pop_string(); 00066 virtual Vec3 pop_vec3(); 00067 virtual bool pop_bool(); 00068 }; 00069 #endif //__PACKED_MESSAGE_H