Ignore:
Timestamp:
10/21/11 19:01:35 (13 years ago)
Author:
ymipsl
Message:

reprise en main de la version de H. Ozdoba. Correction de différentes erreurs de conception et bug.
Version NEMO operationnel en client/server, interoperabilita avec OASIS, reconstition de fichiers via netcdf4/HDF5

YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/common/src/xmlio/object_factory_impl.hpp

    r266 r286  
    3131      return (U::AllMapObj[CObjectFactory::CurrContext].find(id) != 
    3232              U::AllMapObj[CObjectFactory::CurrContext].end()); 
     33   } 
     34 
     35   template <typename U> 
     36      bool CObjectFactory::HasObject(const StdString & context, const StdString & id) 
     37   { 
     38      if (U::AllMapObj.find(context) == U::AllMapObj.end()) return false ; 
     39      else return (U::AllMapObj[context].find(id) !=  U::AllMapObj[context].end()); 
    3340   } 
    3441 
     
    7380 
    7481   template <typename U> 
     82      boost::shared_ptr<U> CObjectFactory::GetObject(const StdString & context, const StdString & id) 
     83   { 
     84      if (!CObjectFactory::HasObject<U>(context,id)) 
     85         ERROR("CObjectFactory::GetObject(const StdString & id)", 
     86               << "[ id = " << id << ", U = " << U::GetName() <<", context = "<<context<< " ] " 
     87               << " object is not referenced !"); 
     88      return (U::AllMapObj[CObjectFactory::CurrContext][id]); 
     89   } 
     90 
     91   template <typename U> 
    7592      boost::shared_ptr<U> CObjectFactory::CreateObject(const StdString & id) 
    7693   { 
     
    8097      if (id.size() == 0) 
    8198      { 
    82          boost::shared_ptr<U> value(new U); 
     99         boost::shared_ptr<U> value(new U(CObjectFactory::GenUId<U>())); 
    83100         U::AllVectObj[CObjectFactory::CurrContext].insert 
    84101            (U::AllVectObj[CObjectFactory::CurrContext].end(), value); 
     102         U::AllMapObj[CObjectFactory::CurrContext].insert(std::make_pair(value->getId(), value)); 
    85103         return (value); 
    86104      } 
     
    105123      return (U::AllVectObj[context]); 
    106124   } 
    107  
     125    
     126   template <typename U>  
     127       StdString CObjectFactory::GenUId(void) 
     128       { 
     129          long int seed ; 
     130           
     131          xios_map<StdString,long int>::iterator it ; 
     132          it=U::GenId.find(CObjectFactory::CurrContext); 
     133          if (it==U::GenId.end()) 
     134          { 
     135            seed=0 ; 
     136            U::GenId[CObjectFactory::CurrContext]=seed ; 
     137          } 
     138          else 
     139          { 
     140            seed=it->second ; 
     141            seed++ ; 
     142            it->second=seed ; 
     143          } 
     144           
     145          StdOStringStream oss ; 
     146          oss<<"__"<<U::GetName()<<"_undef_id_"<<seed ; 
     147          return StdString(oss.str()) ; 
     148        } 
     149           
    108150} // namespace xmlioserver 
    109151 
Note: See TracChangeset for help on using the changeset viewer.