XIOS  1.0
Xml I/O Server
 Tout Classes Espaces de nommage Fichiers Fonctions Variables Définitions de type Énumérations Valeurs énumérées Amis Macros
event_client.cpp
Aller à la documentation de ce fichier.
1 #include "xios_spl.hpp"
2 #include "event_client.hpp"
3 #include "buffer_out.hpp"
4 #include "message.hpp"
5 #include "type.hpp"
6 #include "mpi.hpp"
7 #include "cxios.hpp"
8 
9 namespace xios
10 {
11  const size_t CEventClient::headerSize = sizeof(int) + sizeof(size_t) + sizeof(int) + sizeof(int) + sizeof(int); // The two last one signify sizeof(classId) and sizeof(typeId)
12 
13 
14  CEventClient::CEventClient(int classId_, int typeId_)
15  {
16  classId = classId_;
17  typeId = typeId_;
18  }
19 
20  void CEventClient::push(int rank, int nbSender, CMessage& msg)
21  {
22  nbSenders.push_back(nbSender);
23  ranks.push_back(rank);
24  messages.push_back(&msg);
25  }
26 
28  {
29  return ranks.empty();
30  }
31 
32  std::list<int> CEventClient::getRanks(void)
33  {
34  return ranks;
35  }
36 
37  std::list<int> CEventClient::getSizes(void)
38  {
39  std::list<CMessage*>::iterator it;
40  std::list<int> sizes;
41 
42  for (it = messages.begin(); it != messages.end(); ++it) sizes.push_back((*it)->size() + headerSize);
43  return sizes;
44  }
45 
46  void CEventClient::send(size_t timeLine, const std::list<int>& sizes, std::list<CBufferOut*>& buffers)
47  {
48  std::list<CBufferOut*>::iterator itBuff = buffers.begin();
49  std::list<int>::const_iterator itSizes = sizes.begin(), itSenders = nbSenders.begin();
50  std::list<CMessage*>::iterator itMsg = messages.begin();
51 
52  if (CXios::checkEventSync) info(100)<<"Send event "<<timeLine<<" classId : "<<classId<<" typeId : "<<typeId<<endl ;
53  for (; itBuff != buffers.end(); ++itBuff, ++itSizes, ++itSenders, ++itMsg)
54  {
55  **itBuff << *itSizes << timeLine << *itSenders << classId << typeId << **itMsg;
56  }
57  }
58 }
static const size_t headerSize
void send(size_t timeLine, const std::list< int > &sizes, std::list< CBufferOut * > &)
CEventClient(int classId, int typeId)
static bool checkEventSync
For debuuging, check if event are coherent and synchrone on client side.
Definition: cxios.hpp:57
CLog info("info")
Definition: log.hpp:55
std::list< int > nbSenders
#define xios(arg)
void push(int rank, int nbSender, CMessage &msg)
std::list< int > getSizes(void)
std::list< CMessage * > messages
std::list< int > getRanks(void)
std::list< int > ranks