Changeset 2698 in Sophya for trunk/SophyaLib/BaseTools


Ignore:
Timestamp:
Apr 27, 2005, 1:41:51 PM (20 years ago)
Author:
ansari
Message:

1/ Simplification de la classe gestionnairee PPersist ObjFile<T> (objfio.h)
2/ Ajout DECL_TEMP_SPEC ds ppftpointerio.h
3/ Nom specifique pour methode SegDBInterface::GetSegment() const devenu
SegDBInterface::GetCstSegment() const pour eviter l'appel a la methode non const
et adapatation classes derivees (segdatablock.h et swsegdb.h)
4/ Ajout SkipToNextObjet() ds PInPersist::ReadObject() (ppersist.cc) et protection contre pointeur NULL -> new DVList pour la lecture PPersist de DVList

Reza - 27 Avril 2005

Location:
trunk/SophyaLib/BaseTools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/BaseTools/dvlist.cc

    r2615 r2698  
    537537bool ok=true;
    538538buf[0] = '\0';
    539 dobj->Clear();
     539if (dobj == NULL) dobj = new DVList;
     540else dobj->Clear();
    540541
    541542//  itab -  0 : Version,  1 : NVar,  2  : Comment length, 3 reserved
  • trunk/SophyaLib/BaseTools/objfio.h

    r2477 r2698  
    1919
    2020public :
    21             ObjFileIO() { dobj=new T; ownobj=true; }
    22             ObjFileIO(string const & filename)
    23                         { dobj=new T; ownobj=true; Read(filename); }
    24             ObjFileIO(const T & obj) { dobj = new T(obj); ownobj=true; }
     21            ObjFileIO() { dobj=NULL; ownobj=true; }
    2522            ObjFileIO(T * obj) { dobj = obj; ownobj=false; }
    2623  virtual   ~ObjFileIO() { if (ownobj && dobj) delete dobj; }
     
    3936  }   
    4037 
    41   inline operator T() { return(*dobj); }
     38  inline operator T&() { return(*dobj); }
    4239
    4340protected :
  • trunk/SophyaLib/BaseTools/ppersist.cc

    r2657 r2698  
    281281{
    282282  PInPersist inf(fn);
     283  inf.SkipToNextObject();
    283284  Read(inf);
    284285}
     
    438439PInPersist::ReadObject()
    439440{
     441  SkipToNextObject();
    440442  return(GetPPObject());
    441443}
  • trunk/SophyaLib/BaseTools/ppfswapper.h

    r2695 r2698  
    2727  PPFDataSwapper(PInPersist & is) { ppfos = NULL; ppfis = &is;}
    2828  PPFDataSwapper(PInPersist & is, POutPersist & os) { ppfos = &os; ppfis = &is;}
     29
     30  inline PInPersist & InStream() { return *ppfis; }
     31  inline PInPersist & OutStream() { return *ppfos; }
     32  inline void SetInStream(PInPersist & is) { ppfis = &is; }
     33  inline void SetOutStream(POutPersist & os) { ppfos = &os; }
     34
     35  // Operateur = , on recopie les pointeurs des streams
     36  inline PPFDataSwapper& operator = (PPFDataSwapper const & a)
     37  { ppfis = a.ppfis;  ppfos = a.ppfos; return *this; }
     38
    2939  virtual int_8 WriteToSwap(const T * d, size_t sz, int_8 idx, int_8 oswp=0, bool osw=false)
    3040  {
  • trunk/SophyaLib/BaseTools/ppftpointerio.h

    r2695 r2698  
    4444};
    4545
     46DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    4647class PPF_TPointer_IO<int_1> {
    4748public:
     
    4950  static void Read(PInPersist & is, int_1 * arr, size_t n);
    5051};
     52DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    5153class PPF_TPointer_IO<uint_1> {
    5254public:
     
    5557};
    5658
     59DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    5760class PPF_TPointer_IO<int_2> {
    5861public:
     
    6063  static void Read(PInPersist & is, int_2 * arr, size_t n);
    6164};
     65DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    6266class PPF_TPointer_IO<uint_2> {
    6367public:
     
    6670};
    6771
     72DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    6873class PPF_TPointer_IO<int_4> {
    6974public:
     
    7176  static void Read(PInPersist & is, int_4 * arr, size_t n);
    7277};
     78DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    7379class PPF_TPointer_IO<uint_4> {
    7480public:
     
    7783};
    7884
     85DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    7986class PPF_TPointer_IO<int_8> {
    8087public:
     
    8289  static void Read(PInPersist & is, int_8 * arr, size_t n);
    8390};
     91DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    8492class PPF_TPointer_IO<uint_8> {
    8593public:
     
    8896};
    8997
     98DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    9099class PPF_TPointer_IO<r_4> {
    91100public:
     
    93102  static void Read(PInPersist & is, r_4 * arr, size_t n);
    94103};
     104DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    95105class PPF_TPointer_IO<r_8> {
    96106public:
     
    99109};
    100110
     111DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    101112class PPF_TPointer_IO< complex<r_4> > {
    102113public:
     
    104115  static void Read(PInPersist & is, complex<r_4> * arr, size_t n);
    105116};
     117DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
    106118class PPF_TPointer_IO< complex<r_8> > {
    107119public:
  • trunk/SophyaLib/BaseTools/segdatablock.h

    r2692 r2698  
    4343  //! Return the current size of the segmented data structure
    4444  inline size_t Size() const    { return  SegmentSize()*NbSegments(); }
    45   //! Return pointer to data segment \b k
    46   virtual T* GetSegment(size_t k) = 0;         
    47   virtual T const * GetSegment(size_t k) const = 0;
     45  //! Return the pointer to data segment \b k
     46  virtual T* GetSegment(size_t k) = 0;   
     47  //! Return the const (read-only) pointer to data segment \b k     
     48  virtual T const * GetCstSegment(size_t k) const = 0;
    4849};
    4950
     
    141142      if (cpval) {
    142143        T * dst = GetSegment(k);
    143         const T * src = a.GetSegment(k);
     144        const T * src = a.GetCstSegment(k);
    144145        memcpy(dst, src, mSRef->segsize*sizeof(T));
    145146      }
     
    155156  inline size_t Size() const    { return mSRef->segsize*mSRef->dseg.size(); }
    156157
    157   //! Return pointer to data segment \b k
     158  //! Return the pointer to data segment \b k     
    158159  virtual T* GetSegment(size_t k)              { return mSRef->dseg[k]; }
    159   virtual T const * GetSegment(size_t k) const { return mSRef->dseg[k]; }
     160  //! Return the const (read-only) pointer to data segment \b k     
     161  virtual T const * GetCstSegment(size_t k) const { return mSRef->dseg[k]; }
    160162
    161163  //! Return the segment index for  element \b i
  • trunk/SophyaLib/BaseTools/swsegdb.h

    r2695 r2698  
    9999  //! Return the current size of the segmented data structure
    100100  inline size_t Size() const    { return  mSRef->swp.size()*mSRef->segsize; }
    101   //! Return pointer to data segment \b k
     101  //! Return the pointer to data segment \b k
    102102  virtual T* GetSegment(size_t k)
    103103  {
     
    106106    return mSRef->buff;
    107107  }
    108          
    109   virtual T const * GetSegment(size_t k) const
     108  //! Return the const (read-only) pointer to data segment \b k         
     109  virtual T const * GetCstSegment(size_t k) const
    110110  {
    111111    getSeg(k);
Note: See TracChangeset for help on using the changeset viewer.