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/group_template_impl.hpp

    r219 r300  
    11#ifndef __XMLIO_CGroupTemplate_impl__ 
    22#define __XMLIO_CGroupTemplate_impl__ 
     3 
     4#include "xmlioserver_spl.hpp" 
     5#include "event_server.hpp" 
     6#include "object_template_impl.hpp" 
     7#include "group_template.hpp" 
     8#include "context.hpp" 
     9#include "event_client.hpp" 
     10#include "context_client.hpp" 
     11 
    312 
    413namespace xmlioserver 
     
    307316      void CGroupTemplate<U, V, W>::solveRefInheritance(void) 
    308317   { /* Ne rien faire de plus */ } 
    309  
     318    
     319//   template <class U, class V, class W> 
     320//   bool CGroupTemplate<U, V, W>::has(const string& id)  
     321//   { 
     322//       return CObjectFactory::HasObject<V>(id) ; 
     323//   } 
     324 
     325//   template <class U, class V, class W> 
     326//   boost::shared_ptr<V> CGroupTemplate<U, V, W>::get(const string& id)  
     327//   { 
     328//       return CObjectFactory::GetObject<V>(id) ; 
     329//   } 
     330 
     331//   template <class U, class V, class W> 
     332//   boost::shared_ptr<V> CGroupTemplate<U, V, W>::get()  
     333//   { 
     334//       return CObjectFactory::GetObject<V>(this) ; 
     335//   } 
     336    
     337//   template <class U, class V, class W> 
     338//   boost::shared_ptr<V> CGroupTemplate<U, V, W>::create(const string& id)  
     339//   { 
     340//       return CObjectFactory::CreateObject<V>(id) ; 
     341//   } 
    310342   ///-------------------------------------------------------------- 
    311343 
     344   template <class U, class V, class W> 
     345   boost::shared_ptr<U> CGroupTemplate<U, V, W>::createChild(const string& id)  
     346  { 
     347    return CGroupFactory::CreateChild<V>(this->get(), id) ; 
     348  } 
     349   
     350   template <class U, class V, class W> 
     351   boost::shared_ptr<V> CGroupTemplate<U, V, W>::createChildGroup(const string& id)  
     352  { 
     353    return CGroupFactory::CreateGroup<V>(this->get(), id) ; 
     354  } 
     355 
     356 
     357   template <class U, class V, class W> 
     358   void CGroupTemplate<U, V, W>::sendCreateChild(const string& id) 
     359   { 
     360    shared_ptr<CContext> context=CContext::current() ; 
     361     
     362    if (! context->hasServer ) 
     363    { 
     364       CContextClient* client=context->client ; 
     365 
     366       CEventClient event(this->getType(),EVENT_ID_CREATE_CHILD) ;    
     367       if (client->isServerLeader()) 
     368       { 
     369         CMessage msg ; 
     370         msg<<this->getId() ; 
     371         msg<<id ; 
     372         event.push(client->getServerLeader(),1,msg) ; 
     373         client->sendEvent(event) ; 
     374       } 
     375       else client->sendEvent(event) ; 
     376    } 
     377       
     378   } 
     379    
     380   template <class U, class V, class W> 
     381   void CGroupTemplate<U, V, W>::sendCreateChildGroup(const string& id) 
     382   { 
     383    shared_ptr<CContext> context=CContext::current() ; 
     384    if (! context->hasServer ) 
     385    { 
     386       CContextClient* client=context->client ; 
     387 
     388       CEventClient event(this->getType(),EVENT_ID_CREATE_CHILD_GROUP) ;    
     389       if (client->isServerLeader()) 
     390       { 
     391         CMessage msg ; 
     392         msg<<this->getId() ; 
     393         msg<<id ; 
     394         event.push(client->getServerLeader(),1,msg) ; 
     395         client->sendEvent(event) ; 
     396       } 
     397       else client->sendEvent(event) ; 
     398    } 
     399       
     400   } 
     401    
     402   template <class U, class V, class W> 
     403   void CGroupTemplate<U, V, W>::recvCreateChild(CEventServer& event) 
     404   { 
     405       
     406      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     407      string id; 
     408      *buffer>>id ; 
     409      V::get(id)->recvCreateChild(*buffer) ; 
     410   } 
     411    
     412    
     413   template <class U, class V, class W> 
     414   void CGroupTemplate<U, V, W>::recvCreateChild(CBufferIn& buffer) 
     415   { 
     416      string id ; 
     417      buffer>>id ; 
     418      createChild(id) ; 
     419   } 
     420 
     421   template <class U, class V, class W> 
     422   void CGroupTemplate<U, V, W>::recvCreateChildGroup(CEventServer& event) 
     423   { 
     424       
     425      CBufferIn* buffer=event.subEvents.begin()->buffer; 
     426      string id; 
     427      *buffer>>id ; 
     428      V::get(id)->recvCreateChildGroup(*buffer) ; 
     429   } 
     430    
     431    
     432   template <class U, class V, class W> 
     433   void CGroupTemplate<U, V, W>::recvCreateChildGroup(CBufferIn& buffer) 
     434   { 
     435      string id ; 
     436      buffer>>id ; 
     437      createChildGroup(id) ; 
     438   } 
     439    
     440 
     441   template <class U, class V, class W> 
     442   bool CGroupTemplate<U, V, W>::dispatchEvent(CEventServer& event) 
     443   { 
     444      if (CObjectTemplate<V>::dispatchEvent(event)) return true ; 
     445      else 
     446      { 
     447        switch(event.type) 
     448        { 
     449           case EVENT_ID_CREATE_CHILD : 
     450             recvCreateChild(event) ; 
     451             return true ; 
     452             break ; 
     453          
     454           case EVENT_ID_CREATE_CHILD_GROUP : 
     455             recvCreateChildGroup(event) ; 
     456             return true ; 
     457             break ;        
     458          
     459           default : 
     460           return false ; 
     461        } 
     462      } 
     463   } 
     464 
    312465} // namespace xmlioserver 
    313466 
Note: See TracChangeset for help on using the changeset viewer.