[190] | 1 | #include "client.hpp" |
---|
| 2 | |
---|
| 3 | #include "linear_buffer_impl.hpp" |
---|
| 4 | |
---|
| 5 | namespace xmlioserver { |
---|
| 6 | namespace comm { |
---|
| 7 | |
---|
| 8 | /// ////////////////////// Définitions ////////////////////// /// |
---|
| 9 | |
---|
| 10 | CClient::CClient(MPIComm comm_client_server) |
---|
| 11 | : bpair(comm_client_server) |
---|
[199] | 12 | { |
---|
| 13 | this->initialize(); |
---|
| 14 | } |
---|
[190] | 15 | |
---|
| 16 | CClient::~CClient(void) |
---|
[199] | 17 | { |
---|
| 18 | this->finalize(); |
---|
| 19 | } |
---|
[190] | 20 | |
---|
| 21 | ///-------------------------------------------------------------- |
---|
[214] | 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 | ///-------------------------------------------------------------- |
---|
[190] | 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. |
---|
[199] | 68 | this->bpair.sendCurrentBuffer(); |
---|
| 69 | comm::CMPIManager::Barrier(); |
---|
[190] | 70 | } |
---|
| 71 | |
---|
| 72 | //--------------------------------------------------------------- |
---|
| 73 | |
---|
| 74 | void CClient::setContext(const StdString & idContext) |
---|
| 75 | { |
---|
[191] | 76 | this->bpair.prepareRequest(1, 0, &idContext, |
---|
[190] | 77 | CLinearBuffer::NULL_ARG, |
---|
| 78 | CLinearBuffer::NULL_ARG, |
---|
| 79 | CLinearBuffer::NULL_ARG); |
---|
[191] | 80 | this->bpair.getCurrentBuffer().appendString(idContext); |
---|
[190] | 81 | } |
---|
| 82 | |
---|
| 83 | //--------------------------------------------------------------- |
---|
| 84 | |
---|
| 85 | void CClient::updateCalendar(long int timestep) |
---|
| 86 | { |
---|
[191] | 87 | this->bpair.prepareRequest(1, 1, ×tep, |
---|
| 88 | CLinearBuffer::NULL_ARG, |
---|
| 89 | CLinearBuffer::NULL_ARG, |
---|
| 90 | CLinearBuffer::NULL_ARG); |
---|
| 91 | this->bpair.getCurrentBuffer().appendInt(timestep); |
---|
[190] | 92 | } |
---|
[214] | 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 | } |
---|
[190] | 105 | |
---|
| 106 | //--------------------------------------------------------------- |
---|
| 107 | |
---|
[214] | 108 | void CClient::sendData |
---|
| 109 | (const StdString & fieldId, const StdString & fileId, const ARRAY(float, 1) dataArray) |
---|
[190] | 110 | { |
---|
[214] | 111 | this->bpair.prepareRequest(2, 0, &fieldId, &fileId, &dataArray, |
---|
[191] | 112 | CLinearBuffer::NULL_ARG); |
---|
| 113 | this->bpair.getCurrentBuffer().appendString(fieldId); |
---|
[214] | 114 | this->bpair.getCurrentBuffer().appendString(fileId); |
---|
[191] | 115 | this->bpair.getCurrentBuffer().appendFloatArray(dataArray); |
---|
[190] | 116 | } |
---|
| 117 | |
---|
| 118 | //--------------------------------------------------------------- |
---|
| 119 | |
---|
[214] | 120 | void CClient::sendData |
---|
| 121 | (const StdString & fieldId, const StdString & fileId, const ARRAY(double, 1) dataArray) |
---|
[190] | 122 | { |
---|
[214] | 123 | this->bpair.prepareRequest(2, 1, &fieldId, &fileId, &dataArray, |
---|
[191] | 124 | CLinearBuffer::NULL_ARG); |
---|
| 125 | this->bpair.getCurrentBuffer().appendString(fieldId); |
---|
[214] | 126 | this->bpair.getCurrentBuffer().appendString(fileId); |
---|
[191] | 127 | this->bpair.getCurrentBuffer().appendDoubleArray(dataArray); |
---|
[190] | 128 | } |
---|
| 129 | |
---|
| 130 | ///-------------------------------------------------------------- |
---|
| 131 | |
---|
| 132 | } // namespace comm |
---|
| 133 | } // namespace xmlioserver |
---|