1 | #include "server.hpp" |
---|
2 | |
---|
3 | namespace xmlioserver { |
---|
4 | namespace comm { |
---|
5 | |
---|
6 | /// ////////////////////// Définitions ////////////////////// /// |
---|
7 | |
---|
8 | CServer::CServer(MPIComm comm_client_server) |
---|
9 | : blist(comm_client_server) |
---|
10 | { /* Ne rien faire de plus */ } |
---|
11 | |
---|
12 | CServer::~CServer(void) |
---|
13 | { /* Ne rien faire de plus */ } |
---|
14 | |
---|
15 | ///-------------------------------------------------------------- |
---|
16 | |
---|
17 | const CBufferList & CServer::getBufferList(void) const |
---|
18 | { |
---|
19 | return (this->blist); |
---|
20 | } |
---|
21 | |
---|
22 | //--------------------------------------------------------------- |
---|
23 | |
---|
24 | void CServer::run(void) |
---|
25 | { |
---|
26 | while (this->blist.recvRequests()) |
---|
27 | { |
---|
28 | long int managerId = 0, methodId = 0, nbargs = 0; |
---|
29 | long int managerId_= 0, methodId_ = 0, nbargs_ = 0; |
---|
30 | std::vector<CLinearBuffer> lbuffer; |
---|
31 | this->blist.getRequests(lbuffer); |
---|
32 | for (StdSize i = 0; i < lbuffer.size(); i++) |
---|
33 | { |
---|
34 | lbuffer[i].getRequestInfos(0, managerId, methodId, nbargs); |
---|
35 | if (((managerId_ != managerId) || (methodId_ != methodId) || (nbargs_ != nbargs)) && (i != 0 )) |
---|
36 | { |
---|
37 | /*std::cout << managerId_ << "<->" << managerId << std::endl |
---|
38 | << methodId_ << "<->" << methodId << std::endl |
---|
39 | << nbargs_ << "<->" << nbargs << std::endl;*/ |
---|
40 | ERROR("CServer::run(void)", << "[" << i << "] Les requêtes ne sont pas synchronisées !"); |
---|
41 | } |
---|
42 | managerId_ = managerId; |
---|
43 | methodId_ = methodId; |
---|
44 | nbargs_ = nbargs; |
---|
45 | } |
---|
46 | |
---|
47 | if (managerId == 0) |
---|
48 | { |
---|
49 | switch(methodId) |
---|
50 | { |
---|
51 | case (0) : |
---|
52 | this->initialize(); |
---|
53 | continue; |
---|
54 | case (1) : |
---|
55 | this->finalize(); |
---|
56 | return; |
---|
57 | default : |
---|
58 | ERROR("CServer::run(void)", |
---|
59 | << "[ managerId = " << managerId << ", " |
---|
60 | << "[ methodId = " << methodId << ", " |
---|
61 | << "[ nbargs = " << nbargs << "] " |
---|
62 | << " Methode inconnue !"); |
---|
63 | } |
---|
64 | } |
---|
65 | if (managerId == 1) |
---|
66 | { |
---|
67 | switch(methodId) |
---|
68 | { |
---|
69 | case (0) : |
---|
70 | this->setContext(lbuffer); |
---|
71 | continue; |
---|
72 | case (1) : |
---|
73 | this->updateCalendar(lbuffer); |
---|
74 | continue; |
---|
75 | default : |
---|
76 | ERROR("CServer::run(void)", |
---|
77 | << "[ managerId = " << managerId << ", " |
---|
78 | << "[ methodId = " << methodId << ", " |
---|
79 | << "[ nbargs = " << nbargs << "] " |
---|
80 | << " Methode inconnue !"); |
---|
81 | } |
---|
82 | } |
---|
83 | if (managerId == 2) |
---|
84 | { |
---|
85 | switch(methodId) |
---|
86 | { |
---|
87 | case (0) : |
---|
88 | this->writeData(lbuffer, 4); |
---|
89 | continue; |
---|
90 | case (1) : |
---|
91 | this->writeData(lbuffer, 8); |
---|
92 | continue; |
---|
93 | default : |
---|
94 | ERROR("CServer::run(void)", |
---|
95 | << "[ managerId = " << managerId << ", " |
---|
96 | << "[ methodId = " << methodId << ", " |
---|
97 | << "[ nbargs = " << nbargs << "] " |
---|
98 | << " Methode inconnue !"); |
---|
99 | } |
---|
100 | } |
---|
101 | ERROR("CServer::run(void)", |
---|
102 | << "[ managerId = " << managerId << ", " |
---|
103 | << "[ methodId = " << methodId << ", " |
---|
104 | << "[ nbargs = " << nbargs << "] " |
---|
105 | << " Methode inconnue !"); |
---|
106 | } |
---|
107 | } |
---|
108 | |
---|
109 | //-------------------------------------------------------------- |
---|
110 | |
---|
111 | void CServer::initialize(void) // manager 0, method 0 |
---|
112 | { |
---|
113 | std::cout << "initialize called " << std::endl; |
---|
114 | } |
---|
115 | |
---|
116 | //-------------------------------------------------------------- |
---|
117 | |
---|
118 | void CServer::finalize(void) // manager 0, method 1 |
---|
119 | { |
---|
120 | std::cout << "finalize called " << std::endl; |
---|
121 | } |
---|
122 | |
---|
123 | |
---|
124 | //-------------------------------------------------------------- |
---|
125 | |
---|
126 | void CServer::setContext(const std::vector<CLinearBuffer> & buffer) // manager 1, method 0 |
---|
127 | { |
---|
128 | std::cout << "setContext called " << std::endl; |
---|
129 | } |
---|
130 | |
---|
131 | //-------------------------------------------------------------- |
---|
132 | |
---|
133 | void CServer::updateCalendar(const std::vector<CLinearBuffer> & buffer) // manager 1, method 1 |
---|
134 | { |
---|
135 | std::cout << "updateCalendar called " << std::endl; |
---|
136 | } |
---|
137 | |
---|
138 | //-------------------------------------------------------------- |
---|
139 | |
---|
140 | void CServer::writeData(const std::vector<CLinearBuffer> & buffer, int prec) // manager 2, method 0 - 1 |
---|
141 | { |
---|
142 | std::cout << "writeData called " << std::endl; |
---|
143 | } |
---|
144 | |
---|
145 | ///-------------------------------------------------------------- |
---|
146 | |
---|
147 | |
---|
148 | } // namespace comm |
---|
149 | } // namespace xmlioserver |
---|