Ignore:
Timestamp:
12/12/19 18:15:14 (5 years ago)
Author:
ymipsl
Message:
  • Preparing coupling functionalities.
  • Make some cleaner things

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/object_template_impl.hpp

    r1761 r1784  
    215215   } 
    216216 
    217  
    218    template<typename T> 
    219    void CObjectTemplate<T>::sendAllAttributesToServer() 
    220    { 
    221      CAttributeMap& attrMap = *this; 
    222      CAttributeMap::const_iterator it = attrMap.begin(), itE = attrMap.end(); 
    223      for (; it != itE; ++it) 
    224      { 
    225        if (it->second->doSend() && !(it->second)->isEmpty()) sendAttributToServer(*(it->second)); 
    226      } 
    227    } 
    228  
    229217   template<typename T> 
    230218   void CObjectTemplate<T>::sendAllAttributesToServer(CContextClient* client) 
     
    239227 
    240228   template <class T> 
    241    void CObjectTemplate<T>::sendAttributToServer(const string& id) 
    242    { 
    243       CAttributeMap & attrMap = *this; 
    244       CAttribute* attr=attrMap[id]; 
    245       sendAttributToServer(*attr); 
    246    } 
    247  
    248    template <class T> 
    249229   void CObjectTemplate<T>::sendAttributToServer(const string& id, CContextClient* client) 
    250230   { 
     
    253233      sendAttributToServer(*attr, client); 
    254234   } 
    255  
    256   template <class T> 
    257   void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr) 
    258   { 
    259      // Use correct context client to send message 
    260     CContext* context=CContext::getCurrent(); 
    261     if (context->hasClient) 
    262     { 
    263       // int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    264       int nbSrvPools = (context->hasServer) ? (context->hasClient ? context->clientPrimServer.size() : 0) : 1; 
    265       for (int i = 0; i < nbSrvPools; ++i) 
    266       { 
    267         CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 
    268         CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 
    269         if (contextClientTmp->isServerLeader()) 
    270         { 
    271           CMessage msg; 
    272           if (context->hasServer)  msg<<this->getIdServer(i); 
    273           else  msg<<this->getIdServer();  
    274  
    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       } 
    284     } 
    285   } 
    286235 
    287236  template <class T> 
     
    309258    \param [in] itemType type of added item 
    310259  */ 
    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   } 
    339260 
    340261  template<class T> 
Note: See TracChangeset for help on using the changeset viewer.