Ignore:
Timestamp:
02/13/12 19:35:25 (12 years ago)
Author:
ymipsl
Message:

nouvelle version de developpement de xios

  • nouvelle interface fortran
  • recodage complet de la couche de communication
  • et bien d'autres choses...

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/common/src/object_template_impl.hpp

    r286 r300  
    11#ifndef __XMLIO_CObjectTemplate_impl__ 
    22#define __XMLIO_CObjectTemplate_impl__ 
     3 
     4#include "object_factory.hpp" 
     5#include "context.hpp" 
     6#include "transfert_parameters.hpp" 
     7#include "buffer_in.hpp" 
     8#include "attribute.hpp" 
     9#include "event_client.hpp" 
     10#include "context_client.hpp" 
     11#include "object_template.hpp" 
    312 
    413namespace xmlioserver 
     
    137146   } 
    138147 
    139    ///-------------------------------------------------------------- 
    140  
     148   template <class T> 
     149   void CObjectTemplate<T>::sendAttributToServer(const string& id) 
     150   { 
     151      CAttributeMap & attrMap = *this; 
     152      CAttribute* attr=attrMap[id] ; 
     153      sendAttributToServer(*attr) ; 
     154   } 
     155 
     156   template <class T> 
     157   void CObjectTemplate<T>::sendAttributToServer(tree::CAttribute& attr) 
     158   { 
     159     shared_ptr<CContext> context=CObjectFactory::GetObject<CContext>(CObjectFactory::GetCurrentContextId()) ; 
     160      
     161    if (!context->hasServer) 
     162    { 
     163       CContextClient* client=context->client ; 
     164 
     165       CEventClient event(getType(),EVENT_ID_SEND_ATTRIBUTE) ;    
     166       if (client->isServerLeader()) 
     167       { 
     168         CMessage msg ; 
     169         msg<<this->getId() ; 
     170         msg<<attr.getName() ; 
     171         msg<<attr ; 
     172         event.push(client->getServerLeader(),1,msg) ; 
     173         client->sendEvent(event) ; 
     174       } 
     175       else client->sendEvent(event) ; 
     176    } 
     177       
     178   } 
     179    
     180   template <class T> 
     181   void CObjectTemplate<T>::recvAttributFromClient(CEventServer& event) 
     182   { 
     183       
     184      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     185      string id,attrId; 
     186      *buffer>>id ; 
     187      CAttributeMap & attrMap = *get(id); 
     188      *buffer>>attrId ; 
     189      CAttribute* attr=attrMap[attrId] ; 
     190      info(50)<<"attribut recu "<<attrId<<"  " ; 
     191      if (attr->isEmpty()) info(50)<<"--> empty"<<endl ; 
     192      else info(50) /*<attr->getValue()*/<<endl ; 
     193      *buffer>>*attr ; 
     194       info(50)<<"attribut recu "<<attrId<<"  " ; 
     195      if (attr->isEmpty()) info(50)<<"--> empty"<<endl ; 
     196      else info(50) /*attr->getValue()*/<<endl ; 
     197  } 
     198 
     199   template <class T> 
     200   bool CObjectTemplate<T>::dispatchEvent(CEventServer& event) 
     201   { 
     202      switch(event.type) 
     203      { 
     204         case EVENT_ID_SEND_ATTRIBUTE : 
     205           recvAttributFromClient(event) ; 
     206           return true ; 
     207           break ; 
     208        
     209         default : 
     210         return false ; 
     211//           ERROR("void CObjectTemplate<T>::recvEvent(CEventServer& event)", 
     212//                 <<"Unknown Event") ; 
     213      } 
     214   } 
     215    
     216   template <typename T> 
     217   bool CObjectTemplate<T>::has(const string & id) 
     218   { 
     219     return CObjectFactory::HasObject<T>(id) ; 
     220   } 
     221 
     222   template <typename T> 
     223   boost::shared_ptr<T> CObjectTemplate<T>::get(const string & id) 
     224   { 
     225     return CObjectFactory::GetObject<T>(id) ; 
     226   } 
     227 
     228   template <typename T> 
     229   boost::shared_ptr<T> CObjectTemplate<T>::create(const string & id) 
     230   { 
     231     return CObjectFactory::CreateObject<T>(id) ; 
     232   }   ///-------------------------------------------------------------- 
     233 
     234  template <typename T> 
     235  boost::shared_ptr<T> CObjectTemplate<T>::get(void) 
     236  { 
     237    return CObjectFactory::GetObject<T>((T*)this) ; 
     238  } 
     239   
     240 
     241   
    141242} // namespace xmlioserver 
    142243 
Note: See TracChangeset for help on using the changeset viewer.