source: XMLIO_V2/dev/common/src/xmlio/buffer_pair.hpp @ 219

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

Préparation nouvelle arborescence

File size: 3.4 KB
Line 
1#ifndef __XMLIO_CBufferPair__
2#define __XMLIO_CBufferPair__
3
4/// xmlioserver headers ///
5#include "xmlioserver_spl.hpp"
6#include "buffer.hpp"
7#include "circular_buffer.hpp"
8#include "linear_buffer.hpp"
9#include "mpi_manager.hpp"
10
11namespace xmlioserver
12{
13   namespace comm
14   {
15      /// ////////////////////// Déclarations ////////////////////// ///
16      class CBufferPair
17      {
18
19            /// Définition de type ///
20            typedef CLinearBuffer BufferType;
21
22         public :
23
24            /// Construteurs ///
25            CBufferPair(MPIComm com_client_server = CMPIManager::GetCommWorld());
26            CBufferPair(const CBufferPair & buffer_pair);       // Not implemented yet.
27            CBufferPair(const CBufferPair * const buffer_pair); // Not implemented yet.
28
29            template <typename A1, typename A2, typename A3, typename A4>
30               void prepareRequest(const long int & managerId,
31                                   const long int & methodId,
32                                   A1 * arg1 = CLinearBuffer::NULL_ARG,
33                                   A2 * arg2 = CLinearBuffer::NULL_ARG,
34                                   A3 * arg3 = CLinearBuffer::NULL_ARG,
35                                   A4 * arg4 = CLinearBuffer::NULL_ARG);
36            /// Accesseur ///   
37            CLinearBuffer & getCurrentBuffer(void);
38           
39            /// Traitements divers ///
40            int wait(void);
41            void sendCurrentBuffer(void); 
42                       
43            /// Destructeur ///
44            virtual ~CBufferPair(void);
45           
46         protected :
47           
48            /// Test ///
49            bool mustBeSent(void);           
50
51         private :
52
53            /// Propriétés privées ///
54            MPIComm com_client_server;
55            CLinearBuffer first, second;
56            MPIRequest first_request, second_request;
57            int currentBuffer;
58
59      }; // class CBufferPair
60     
61      ///--------------------------------------------------------------
62     
63      template <typename A1, typename A2, typename A3, typename A4>
64         void CBufferPair::prepareRequest(const long int & managerId,
65                                          const long int & methodId,
66                                          A1 * arg1, A2 * arg2, A3 * arg3, A4 * arg4)
67      {       
68         if (this->mustBeSent()) 
69            this->sendCurrentBuffer();
70           
71         CLinearBuffer & cbuffer = this->getCurrentBuffer();
72         StdSize usize = cbuffer.getUnusedSize();         
73         StdSize rsize = cbuffer.getRequestedSize(arg1, arg2, arg3, arg4) ;
74         StdSize msize = cbuffer.getSize();
75         
76         long int nbargs = 0;
77         
78         if (arg1 != NULL) nbargs++;
79         if (arg2 != NULL) nbargs++;
80         if (arg3 != NULL) nbargs++;
81         if (arg4 != NULL) nbargs++;
82         
83         if (rsize > msize)
84            ERROR("CBufferPair::sendRequest(...)", << "Le tampon client est trop petit !");
85                 
86         if (rsize <= usize)
87         {
88            cbuffer.appendRequestInfos(managerId, methodId, nbargs);
89         }
90         else
91         {
92            this->wait();
93            this->prepareRequest(managerId, methodId, arg1, arg2, arg3, arg4);
94         }
95      }
96     
97      ///--------------------------------------------------------------
98     
99     
100   } // namespace comm
101} // namespace xmlioserver
102
103#endif // __XMLIO_CBufferPair__
Note: See TracBrowser for help on using the repository browser.