source: XMLIO_V2/dev/common/src/xmlio/client.cpp @ 219

Last change on this file since 219 was 219, checked in by hozdoba, 13 years ago

Préparation nouvelle arborescence

File size: 4.5 KB
Line 
1#include "client.hpp"
2
3#include "linear_buffer_impl.hpp"
4
5namespace xmlioserver {
6namespace comm {
7
8   /// ////////////////////// Définitions ////////////////////// ///
9   
10   CClient::CClient(MPIComm comm_client_server)
11      : bpair(comm_client_server)
12   { 
13      this->initialize();
14   } 
15       
16   CClient::~CClient(void)
17   { 
18      this->finalize();
19   } 
20   
21   ///--------------------------------------------------------------
22
23   boost::shared_ptr<CClient> CClient::Client;
24
25   ///--------------------------------------------------------------
26
27   boost::shared_ptr<CClient> CClient::CreateClient(MPIComm comm_client_server)
28   {
29      if (CClient::Client.get() != NULL)
30         CClient::Client = boost::shared_ptr<CClient>(new CClient(comm_client_server));
31      return (CClient::GetClient());
32   }
33
34   ///--------------------------------------------------------------
35
36   boost::shared_ptr<CClient> CClient::GetClient(void)
37   {
38      return (CClient::Client);
39   }
40
41   ///--------------------------------------------------------------
42   
43   const CBufferPair & CClient::getBufferPair(void) const 
44   {
45      return (this->bpair);
46   }   
47   
48   //---------------------------------------------------------------
49
50   void CClient::initialize(void)
51   {
52      this->bpair.prepareRequest(0, 0, CLinearBuffer::NULL_ARG,
53                                       CLinearBuffer::NULL_ARG,
54                                       CLinearBuffer::NULL_ARG,
55                                       CLinearBuffer::NULL_ARG);
56      // Pas d'argument à ajouter.
57   }
58   
59   //---------------------------------------------------------------
60   
61   void CClient::finalize(void)
62   {
63      this->bpair.prepareRequest(0, 1, CLinearBuffer::NULL_ARG,
64                                       CLinearBuffer::NULL_ARG,
65                                       CLinearBuffer::NULL_ARG,
66                                       CLinearBuffer::NULL_ARG);
67      // Pas d'argument à ajouter.
68      this->bpair.sendCurrentBuffer();
69      comm::CMPIManager::Barrier();
70   }
71   
72   //---------------------------------------------------------------
73   
74   void CClient::setContext(const StdString & idContext)
75   {
76      this->bpair.prepareRequest(1, 0, &idContext,
77                                       CLinearBuffer::NULL_ARG,
78                                       CLinearBuffer::NULL_ARG,
79                                       CLinearBuffer::NULL_ARG);
80      this->bpair.getCurrentBuffer().appendString(idContext);
81   }
82   
83   //---------------------------------------------------------------
84   
85   void CClient::updateCalendar(long int timestep)
86   {
87      this->bpair.prepareRequest(1, 1, &timestep,
88                                       CLinearBuffer::NULL_ARG,
89                                       CLinearBuffer::NULL_ARG,
90                                       CLinearBuffer::NULL_ARG);
91      this->bpair.getCurrentBuffer().appendInt(timestep);
92   }
93
94   //---------------------------------------------------------------
95
96   void CClient::setTimestep(const date::CDuration & duration)
97   {
98      StdString durationstr = duration.toString();
99      this->bpair.prepareRequest(1, 2, &durationstr,
100                                       CLinearBuffer::NULL_ARG,
101                                       CLinearBuffer::NULL_ARG,
102                                       CLinearBuffer::NULL_ARG);
103      this->bpair.getCurrentBuffer().appendString(durationstr);
104   }
105   
106   //---------------------------------------------------------------
107   
108   void CClient::sendData
109      (const StdString & fieldId, const StdString & fileId, const ARRAY(float, 1) dataArray)
110   {
111      this->bpair.prepareRequest(2, 0, &fieldId, &fileId, &dataArray,
112                                       CLinearBuffer::NULL_ARG);
113      this->bpair.getCurrentBuffer().appendString(fieldId);
114      this->bpair.getCurrentBuffer().appendString(fileId);
115      this->bpair.getCurrentBuffer().appendFloatArray(dataArray);
116   }
117   
118   //---------------------------------------------------------------
119   
120   void CClient::sendData
121      (const StdString & fieldId, const StdString & fileId, const ARRAY(double, 1) dataArray)
122   {
123      this->bpair.prepareRequest(2, 1, &fieldId, &fileId, &dataArray,
124                                       CLinearBuffer::NULL_ARG);
125      this->bpair.getCurrentBuffer().appendString(fieldId);
126      this->bpair.getCurrentBuffer().appendString(fileId);
127      this->bpair.getCurrentBuffer().appendDoubleArray(dataArray);
128   }
129
130   ///--------------------------------------------------------------
131
132} // namespace comm
133} // namespace xmlioserver
Note: See TracBrowser for help on using the repository browser.