[591] | 1 | #include "xios_spl.hpp" |
---|
[300] | 2 | #include "event_client.hpp" |
---|
| 3 | #include "buffer_out.hpp" |
---|
| 4 | #include "message.hpp" |
---|
| 5 | #include "type.hpp" |
---|
[382] | 6 | #include "mpi.hpp" |
---|
[300] | 7 | |
---|
[335] | 8 | namespace xios |
---|
[300] | 9 | { |
---|
| 10 | CEventClient::CEventClient(int classId_,int typeId_) |
---|
| 11 | { |
---|
| 12 | classId=classId_ ; |
---|
| 13 | typeId=typeId_ ; |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | void CEventClient::push(int rank,int nbSender,CMessage & msg) |
---|
| 17 | { |
---|
| 18 | nbSenders.push_back(nbSender) ; |
---|
| 19 | ranks.push_back(rank) ; |
---|
| 20 | messages.push_back(&msg) ; |
---|
| 21 | } |
---|
| 22 | |
---|
| 23 | bool CEventClient::isEmpty(void) |
---|
| 24 | { |
---|
| 25 | return ranks.empty() ; |
---|
| 26 | } |
---|
| 27 | |
---|
| 28 | list<int> CEventClient::getRanks(void) |
---|
| 29 | { |
---|
| 30 | return ranks ; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | list<int> CEventClient::getSizes(void) |
---|
| 34 | { |
---|
| 35 | list<CMessage*>::iterator it ; |
---|
| 36 | list<int> sizes ; |
---|
| 37 | size_t headerSize=sizeof(int)+sizeof(classId)+sizeof(typeId) ; |
---|
| 38 | |
---|
| 39 | for(it=messages.begin();it!=messages.end();++it) sizes.push_back((*it)->size()+headerSize) ; |
---|
| 40 | return sizes ; |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | void CEventClient::send(list<CBufferOut*>& buffers) |
---|
| 44 | { |
---|
| 45 | list<CBufferOut*>::iterator itBuff ; |
---|
| 46 | list<CMessage*>::iterator itMsg ; |
---|
| 47 | list<int>::iterator itSenders ; |
---|
| 48 | |
---|
| 49 | for(itBuff=buffers.begin(),itMsg=messages.begin(),itSenders=nbSenders.begin();itBuff!=buffers.end();++itBuff,++itMsg,++itSenders) |
---|
| 50 | { |
---|
| 51 | **itBuff<<*itSenders<<classId<<typeId<<**itMsg ; |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | /* |
---|
| 55 | CEventClient::CEventClient(CContextClient& client_,int nbSender_,list<int>& serverList_) |
---|
| 56 | { |
---|
| 57 | client=&client_ ; |
---|
| 58 | nbSender=nbSender_ ; |
---|
| 59 | serverList=serverList_ ; |
---|
| 60 | |
---|
| 61 | client->registerEvent(*this) ; |
---|
| 62 | } |
---|
| 63 | |
---|
| 64 | list<CBufferOut*> CEventClient::newEvent(int classId, int type, list<int> sizes) |
---|
| 65 | { |
---|
| 66 | list<int>::iterator it ; |
---|
| 67 | list<CBufferOut*>::iterator itBuff; |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | CMessage msg; |
---|
| 71 | |
---|
| 72 | msg<<nbSender<<classId<<type ; |
---|
| 73 | |
---|
| 74 | for(it=sizes.begin();it!=sizes.end();it++) *it+=msg.size() ; |
---|
| 75 | list<CBufferOut*> buffers=client->newEvent(*this,sizes) ; |
---|
| 76 | |
---|
| 77 | for(itBuff=buffers.begin();itBuff!=buffers.end();itBuff++) *(*itBuff)<<msg ; |
---|
| 78 | |
---|
| 79 | return buffers ; |
---|
| 80 | |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | void CEventClient::send(void) |
---|
| 84 | { |
---|
| 85 | client->sendEvent(*this) ; |
---|
| 86 | } |
---|
| 87 | |
---|
| 88 | */ |
---|
| 89 | |
---|
| 90 | } |
---|