Ignore:
Timestamp:
01/10/17 14:36:29 (7 years ago)
Author:
oabramkina
Message:

Intermeadiate version for merging with new server functionalities.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_olga/src/object_template_impl.hpp

    r1009 r1021  
    164164   std::map<int, size_t> CObjectTemplate<T>::getMinimumBufferSizeForAttributes() 
    165165   { 
    166      // CContextClient* client = CContext::getCurrent()->client; 
     166     // Use correct context client to send message 
    167167     CContext* context = CContext::getCurrent(); 
    168  
    169           // Use correct context client to send message 
    170 //     CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    171168     int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    172169     for (int i = 0; i < nbSrvPools; ++i) 
     
    244241 
    245242   template<typename T> 
    246    void CObjectTemplate<T>::sendAllAttributesToServer(const int srvPool) 
     243   void CObjectTemplate<T>::sendAllAttributesToServer(CContextClient* client) 
    247244   { 
    248245     CAttributeMap& attrMap = *this; 
     
    250247     for (; it != itE; ++it) 
    251248     { 
    252        if (!(it->second)->isEmpty()) sendAttributToServer(*(it->second), srvPool); 
     249       if (!(it->second)->isEmpty()) sendAttributToServer(*(it->second), client); 
    253250     } 
    254251   } 
     
    263260 
    264261   template <class T> 
    265    void CObjectTemplate<T>::sendAttributToServer(const string& id, const int srvPool) 
     262   void CObjectTemplate<T>::sendAttributToServer(const string& id, CContextClient* client) 
    266263   { 
    267264      CAttributeMap & attrMap = *this; 
    268265      CAttribute* attr=attrMap[id]; 
    269       sendAttributToServer(*attr, srvPool); 
     266      sendAttributToServer(*attr, client); 
    270267   } 
    271268 
     
    273270  void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr) 
    274271  { 
     272     // Use correct context client to send message 
    275273    CContext* context=CContext::getCurrent(); 
    276  
    277      // Use correct context client to send message 
    278 //    CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
    279274    if (context->hasClient) 
    280275    { 
     
    283278      { 
    284279        CContextClient* contextClientTmp = (context->hasServer) ? context->clientPrimServer[i] : context->client; 
    285         // CContextClient* contextClientTmp=context->contextClientTmp; 
    286  
    287280        CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 
    288281        if (contextClientTmp->isServerLeader()) 
    289282        { 
    290283          CMessage msg; 
    291 //          if (context->hasServer) 
    292 //          { 
    293 //            StdString tmp = this->getIdServer() + "_" +boost::lexical_cast<string>(i); 
    294 //            msg<<tmp; 
    295 //          } 
    296 //          else 
    297             msg<<this->getIdServer(); 
    298  
     284          msg<<this->getIdServer(); 
    299285          msg << attr.getName(); 
    300286          msg << attr; 
     
    331317 
    332318  template <class T> 
    333   void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr, const int srvPool) 
     319  void CObjectTemplate<T>::sendAttributToServer(CAttribute& attr, CContextClient* client) 
    334320  { 
    335     CContext* context=CContext::getCurrent(); 
    336     CContextClient* contextClientTmp = context->clientPrimServer[srvPool]; 
    337321    CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE); 
    338     if (contextClientTmp->isServerLeader()) 
     322    if (client->isServerLeader()) 
    339323    { 
    340324      CMessage msg; 
     
    342326      msg << attr.getName(); 
    343327      msg << attr; 
    344       const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     328      const std::list<int>& ranks = client->getRanksServerLeader(); 
    345329      for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    346330        event.push(*itRank,1,msg); 
    347       contextClientTmp->sendEvent(event); 
     331      client->sendEvent(event); 
    348332    } 
    349     else contextClientTmp->sendEvent(event); 
     333    else client->sendEvent(event); 
    350334  } 
    351  
    352335 
    353336  /*! 
     
    364347    if (context->hasClient) 
    365348    { 
    366        // Use correct context client to send message 
    367 //      CContextClient* contextClientTmp = (0 != context->clientPrimServer) ? context->clientPrimServer : context->client; 
     349      // Use correct context client to send message 
    368350      int nbSrvPools = (context->hasServer) ? context->clientPrimServer.size() : 1; 
    369351      for (int i = 0; i < nbSrvPools; ++i) 
     
    387369 
    388370  template<class T> 
    389   void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType, const int srvPool) 
     371  void CObjectTemplate<T>::sendAddItem(const StdString& id, int itemType, CContextClient* client) 
    390372  { 
    391     CContext* context = CContext::getCurrent(); 
    392373    typedef typename T::EEventId ItemType; 
    393      CContextClient* contextClientTmp = context->clientPrimServer[srvPool]; 
    394374     CEventClient event(this->getType(),ItemType(itemType)); 
    395      if (contextClientTmp->isServerLeader()) 
     375     if (client->isServerLeader()) 
    396376     { 
    397377       CMessage msg; 
    398378       msg << this->getId(); 
    399379       msg << id; 
    400        const std::list<int>& ranks = contextClientTmp->getRanksServerLeader(); 
     380       const std::list<int>& ranks = client->getRanksServerLeader(); 
    401381       for (std::list<int>::const_iterator itRank = ranks.begin(), itRankEnd = ranks.end(); itRank != itRankEnd; ++itRank) 
    402382         event.push(*itRank,1,msg); 
    403        contextClientTmp->sendEvent(event); 
     383       client->sendEvent(event); 
    404384     } 
    405      else contextClientTmp->sendEvent(event); 
     385     else client->sendEvent(event); 
    406386  } 
     387 
    407388 
    408389  template <class T> 
Note: See TracChangeset for help on using the changeset viewer.