Changeset 1460 for XIOS/dev/branch_openmp/src/object_template_impl.hpp
- Timestamp:
- 03/22/18 10:43:20 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
XIOS/dev/branch_openmp/src/object_template_impl.hpp
r1334 r1460 185 185 186 186 template<typename T> 187 std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes() 188 { 189 CContextClient* client = CContext::getCurrent()->client; 187 std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes(CContextClient* client) 188 { 190 189 std::map<int, size_t> minimumSizes; 191 190 … … 215 214 } 216 215 } 217 218 216 return minimumSizes; 219 217 } 218 220 219 221 220 template<typename T> … … 226 225 for (; it != itE; ++it) 227 226 { 228 if (!(it->second)->isEmpty()) sendAttributToServer(*(it->second)); 227 if (it->second->doSend() && !(it->second)->isEmpty()) sendAttributToServer(*(it->second)); 228 } 229 } 230 231 template<typename T> 232 void CObjectTemplate<T>::sendAllAttributesToServer(CContextClient* client) 233 { 234 CAttributeMap& attrMap = *this; 235 CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 236 for (; it != itE; ++it) 237 { 238 if (it->second->doSend() && !(it->second)->isEmpty()) sendAttributToServer(*(it->second), client); 229 239 } 230 240 } … … 238 248 } 239 249 250 template <class T> 251 void CObjectTemplate<T>::sendAttributToServer(const string& id, CContextClient* client) 252 { 253 CAttributeMap & attrMap = *this; 254 CAttribute* attr=attrMap[id]; 255 sendAttributToServer(*attr, client); 256 } 257 240 258 template <class T> 241 259 void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr) 242 260 { 261 // Use correct context client to send message 243 262 CContext* context=CContext::getCurrent(); 244 245 if (!context->hasServer) 263 if (context->hasClient) 246 264 { 247 CContextClient* client=context->client; 248 249 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 250 if (client->isServerLeader()) 251 { 252 CMessage msg; 253 // msg << this->getId(); 254 msg << this->getIdServer(); 255 msg << attr.getName(); 256 msg << attr; 257 const std::list<int>& ranks = client->getRanksServerLeader(); 258 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 259 event.push(*itRank,1,msg); 260 client->sendEvent(event); 261 } 262 else client->sendEvent(event); 265 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 266 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 267 for (int i = 0; i < nbSrvPools; ++i) 268 { 269 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 270 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 271 if (contextClientTmp->isServerLeader()) 272 { 273 CMessage msg; 274 msg<<this->getIdServer(); 275 msg << attr.getName(); 276 msg << attr; 277 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 278 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 279 event.push(*itRank,1,msg); 280 contextClientTmp->sendEvent(event); 281 } 282 else contextClientTmp->sendEvent(event); 283 } 263 284 } 264 285 } 286 287 template <class T> 288 void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr, CContextClient* client) 289 { 290 CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 291 if (client->isServerLeader()) 292 { 293 CMessage msg; 294 msg<<this->getIdServer(); 295 msg << attr.getName(); 296 msg << attr; 297 const std::list<int>& ranks = client->getRanksServerLeader(); 298 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 299 event.push(*itRank,1,msg); 300 client->sendEvent(event); 301 } 302 else client->sendEvent(event); 303 } 304 305 /*! 306 This generic funtion only provides instance for sending, for receving, each 307 child class must define itself. 308 \param [in] id Id of added item 309 \param [in] itemType type of added item 310 */ 311 template<class T> 312 void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType) 313 { 314 CContext* context = CContext::getCurrent(); 315 typedef typename T::EEventId ItemType; 316 if (context->hasClient) 317 { 318 // Use correct context client to send message 319 // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 320 int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 321 for (int i = 0; i < nbSrvPools; ++i) 322 { 323 CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 324 CEventClient event(this->getType(),ItemType(itemType)); 325 if (contextClientTmp->isServerLeader()) 326 { 327 CMessage msg; 328 msg << this->getId(); 329 msg << id; 330 const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 331 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 332 event.push(*itRank,1,msg); 333 contextClientTmp->sendEvent(event); 334 } 335 else contextClientTmp->sendEvent(event); 336 } 337 } 338 } 339 340 template<class T> 341 void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType, CContextClient* client) 342 { 343 typedef typename T::EEventId ItemType; 344 CEventClient event(this->getType(),ItemType(itemType)); 345 if (client->isServerLeader()) 346 { 347 CMessage msg; 348 msg << this->getId(); 349 msg << id; 350 const std::list<int>& ranks = client->getRanksServerLeader(); 351 for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 352 event.push(*itRank,1,msg); 353 client->sendEvent(event); 354 } 355 else client->sendEvent(event); 265 356 } 266 357
Note: See TracChangeset
for help on using the changeset viewer.