Changeset 4051 in Sophya


Ignore:
Timestamp:
Feb 25, 2012, 10:40:10 PM (12 years ago)
Author:
ansari
Message:

modifs ds PPersist (classe PIOPersist) pour permettre l'enregistrement automatique (1ere lecture ou ecriture) de PPFWrapperSTLVector<T> (gestionnaire ppersist de std::vector<T> , Reza+cmv 25/02/2012

Location:
trunk/SophyaLib/BaseTools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/basetools.h

    r3612 r4051  
    2222#include "srandgen.h"
    2323#include "datatype.h"
     24#include "ppfwrapstlv.h"
    2425#include "randr48.h"
    2526#include "randfmt.h"
     27#include "randtmt32.h"
     28#include "randtmt64.h"
    2629
    2730#endif
  • trunk/SophyaLib/BaseTools/ppersist.cc

    r3426 r4051  
    167167}
    168168
     169//! Return true if the specified PPersist class is found in the registered class list
     170bool
     171PIOPersist::checkPPClassId(PPersist const & ppo)
     172{
     173  string typ_name = typeid(ppo).name() ;
     174  map<string, uint_8>::iterator i = ppclassNameList->find(typ_name);
     175  if (i == ppclassNameList->end())   return false;
     176  return true;
     177}
    169178
    170179//! Returns the PPersist class name for the specified classId
  • trunk/SophyaLib/BaseTools/ppersist.h

    r2805 r4051  
    4646
    4747    virtual void       Write(POutPersist&) const;
    48     void               Read(PInPersist& s);               // Reads the type tag and the object
     48    virtual void       Read(PInPersist& s);               // Reads the type tag and the object
    4949    void               Write(POutPersist&, string const& tag) const;
    5050    void               ReadAtTag(PInPersist& s, string const& tag);
     
    8585    static uint_8                getPPClassId(string const & typ_name);
    8686    static uint_8                getPPClassId(PPersist const & ppo);
     87    static bool                  checkPPClassId(PPersist const & ppo);
     88
    8789    static string                getDataObjClassName(uint_8 classId);
    8890    static uint_8                getDataObjClassId(string const & typ_name);
  • trunk/SophyaLib/BaseTools/ppfwrapstlv.h

    r2805 r4051  
    6363  inline operator std::vector<T>()  { return(*dobj); }
    6464
     65  virtual void       Write(POutPersist& os) const
     66  {
     67    if (!PIOPersist::checkPPClassId(*this)) {  // on enregistre la classe
     68      PPRegister(PPFWrapperSTLVector< T >);
     69      DObjRegister(PPFWrapperSTLVector< T >, std::vector< T >);
     70    }
     71    PPersist::Write(os);
     72  }
     73  virtual void       Read(PInPersist& os)
     74  {
     75    if (!PIOPersist::checkPPClassId(*this)) {  // on enregistre la classe
     76      PPRegister(PPFWrapperSTLVector< T >);
     77      DObjRegister(PPFWrapperSTLVector< T >, std::vector< T >);
     78    }
     79    PPersist::Read(os);
     80  }
     81
    6582protected :
    6683  virtual void       ReadSelf(PInPersist& is)
     
    7390    // On efface le contenu du vecteur si necessaire - (on peut faire plus efficacement ...)
    7491    if ( dobj->size() > 0) dobj->erase(dobj->begin(), dobj->end());
    75     T el;
    7692    for(uint_8 k=0; k<itab[1]; k++) {
     93      T el;
    7794      is >> el;
    7895      dobj->push_back(el);
Note: See TracChangeset for help on using the changeset viewer.