00001 #include "PsOutgoingSynchronisationMessage.h" 00002 00003 #include "PsPackable.h" 00004 #include "assert.h" 00005 #include <typeinfo> 00006 00007 PsOutgoingSynchronisationMessage::PsOutgoingSynchronisationMessage() 00008 { 00009 } 00010 00011 00012 PsOutgoingSynchronisationMessage::~PsOutgoingSynchronisationMessage() 00013 { 00014 } 00015 00016 00017 void PsOutgoingSynchronisationMessage::reinit() 00018 { 00019 // prepare the associated stream for new insertions 00020 //myos->rdbuf()->seekpos (ios::out, ostrstream::beg) ; 00021 #ifdef _USESSTREAM 00022 _myos.seekp (ios::out, ostringstream::beg) ; 00023 #else 00024 _myos.seekp(0,ostrstream::beg) ; 00025 #endif 00026 } 00027 00028 00029 #ifdef _USESSTREAM 00030 ostringstream & PsOutgoingSynchronisationMessage::getOutputStream ( ) 00031 { 00032 _myos.seekp(0, ostringstream::beg); 00033 return _myos ; 00034 } 00035 #else 00036 ostrstream & PsOutgoingSynchronisationMessage::getOutputStream ( ) 00037 { 00038 _myos.seekp(0, ostrstream::beg); 00039 return _myos ; 00040 } 00041 #endif 00042 00043 void PsOutgoingSynchronisationMessage::packOutputStream ( ) 00044 { 00045 #ifdef _DEBUGPVMMESS 00046 cerr<<"PsOutgoingSynchronisationMessage:"<<(void *)this<<":packOutputMessage () "<<endl; 00047 #endif 00048 00049 #ifdef _USESSTREAM 00050 00051 pack ( _myos.str() ) ; 00052 00053 _myos.seekp(0, ostringstream::beg) ; 00054 00055 #else 00056 _myos.freeze( 1 ) ; 00057 00058 int messageSize = _myos.pcount () ; 00059 char * messageToPack = _myos.str() ; 00060 00061 assert ( messageToPack[messageSize - 1] == 0 ) ; 00062 00063 // int ind = myos->tellp(); 00064 // mess[ind] = '\0' ; 00065 00066 pack ( messageSize ) ; 00067 pack ( messageToPack ) ; 00068 00069 _myos.freeze( 0 ) ; 00070 00071 // prepare the associated stream for new insertions 00072 //myos->rdbuf()->seekpos (ios::out, ostrstream::beg) ; 00073 _myos.seekp(0, ostrstream::beg) ; 00074 #endif 00075 } 00076 00077 00078 void PsOutgoingSynchronisationMessage::pack(const PsPackable & val) 00079 { 00080 #ifdef _DEBUGPVMMESS 00081 cerr<<"PsOutgoingSynchronisationMessage:" 00082 <<this 00083 <<":pack(const PsPackable & (" 00084 <<typeid (val).name() 00085 <<") val)"; 00086 #endif 00087 val.pack ( *this ) ; 00088 #ifdef _DEBUGPVMMESS 00089 cerr<< "end"<<endl; 00090 #endif 00091 } 00092 00093 00094 PsOutgoingSynchronisationMessage & PsOutgoingSynchronisationMessage::operator << (char * val) 00095 { 00096 pack ( val ) ; 00097 return *this ; 00098 } 00099
| Documentation generated on Mon Nov 25 15:25:02 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |