Changeset 804 in Sophya for trunk/SophyaLib/TArray/fioarr.cc


Ignore:
Timestamp:
Apr 3, 2000, 7:36:01 PM (25 years ago)
Author:
ansari
Message:

Amelioation / debugging de la classe TArray<T> - TVector et TMatrix

heritent maintenant de TArray<T> - Classe RCMatrix rendu prive au fichier
sopemtx.cc - linfit.cc integre a sopemtx.cc

Reza 03/04/2000

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/fioarr.cc

    r787 r804  
    33
    44#include "pexceptions.h"
     5#include "fiondblock.h"
    56#include "fioarr.h"
     7#include "tmatrix.h"
     8#include "tvector.h"
    69
    710// --------------------------------------------------------
     
    1316FIO_TArray<T>::FIO_TArray()
    1417{
    15   dobj=new TArray<T>;
    16   ownobj=true;
     18  dobj=NULL;
     19  ownobj=false;
    1720}
    1821
     
    2023FIO_TArray<T>::FIO_TArray(string const & filename)
    2124{
    22   dobj=new TArray<T>;
    23   ownobj=true;
     25  dobj=NULL;
     26  ownobj=false;
    2427  Read(filename);
    2528}
     
    2831FIO_TArray<T>::FIO_TArray(const TArray<T> & obj)
    2932{
    30   dobj = new TArray<T>(obj);
     33  const TVector<T> * tv = dynamic_cast<const TVector<T> *>(&obj);
     34  if (tv != NULL)  dobj = new TVector<T>(*tv, true);
     35  else {
     36  const TMatrix<T> * tm = dynamic_cast<const TMatrix<T> *>(&obj);
     37  if (tm != NULL)  dobj = new TMatrix<T>(*tm, true);
     38  else dobj = new TArray<T>(obj, true);
     39  }
    3140  ownobj=true;
    3241}
     
    6372void FIO_TArray<T>::ReadSelf(PInPersist& is)
    6473{
    65 // On lit les 3 premiers uint_4
    66 //  0: Numero de version,   : NRows,  2 : NCol
     74// On lit les 5 premiers uint_4
     75//  0: Numero de version,  1 : Type (Array, matrix, Vector, ...)  2 != 0 , has Info
     76//          1:Type = 0 TArray , 12=(4+8) TMatrix , 48=(16+32) TVector
    6777  uint_4 itab[5];
    6878  is.Get(itab,5);
    69   if (dobj == NULL) dobj = new TArray<T>;
     79  if (dobj == NULL) {
     80    if (itab[1] == 12)   dobj = new TMatrix<T>;
     81    else if (itab[1] == 48)   dobj = new TVector<T>;
     82    else   dobj = new TArray<T>;
     83  }
    7084// On lit les tailles, etc ...
    7185  is.Get(dobj->ndim_);
     
    7892  is.Get(dobj->marowi_);
    7993  is.Get(dobj->macoli_);
     94  is.Get(dobj->veceli_);
    8095// On lit le datablock
    8196  is >> dobj->DataBlock();
     
    88103{
    89104  if (dobj == NULL)   return;
    90 //  On ecrit 4 uint_4 ....
     105//  On ecrit 5 uint_4 ....
    91106//  0: Numero de version,  1 : Type (Array, matrix, Vector, ...)  2 != 0 , has Info
     107//          1:Type = 0 TArray , 12=(4+8) TMatrix , 48=(16+32) TVector
     108  uint_4 typa = 0;
     109  TVector<T> * tv = dynamic_cast<TVector<T> *>(dobj);
     110  if (tv != NULL)  typa = 48;
     111  else {
     112  TMatrix<T> * tm = dynamic_cast<TMatrix<T> *>(dobj);
     113  if (tm != NULL)  typa = 12;
     114  else  typa = 0;
     115  }
     116
    92117  uint_4 itab[5];
    93118  itab[0] = 1;  // Numero de version a 1
    94   itab[1] = 0;
     119  itab[1] = typa;  // Real object type
    95120  itab[2] = (dobj->mInfo != NULL) ? 1 : 0;
    96121  itab[3] = itab[4] = 0;
    97   os.Put(itab,3);
     122  os.Put(itab,5);
    98123// On ecrit les tailles, etc ...
    99124  os.Put(dobj->ndim_);
     
    106131  os.Put(dobj->marowi_);
    107132  os.Put(dobj->macoli_);
     133  os.Put(dobj->veceli_);
    108134// On ecrit le datablock
    109135  os << dobj->DataBlock();
     
    117143#ifdef __CXX_PRAGMA_TEMPLATES__
    118144// Instances des delegues FileIO (PPersist)
    119 #pragma define_template FIO_TArray<uint_1>
     145// #pragma define_template FIO_TArray<uint_1>
    120146#pragma define_template FIO_TArray<uint_2>
    121 #pragma define_template FIO_TArray<int_2>
     147// #pragma define_template FIO_TArray<int_2>
    122148#pragma define_template FIO_TArray<int_4>
    123149#pragma define_template FIO_TArray<int_8>
    124 #pragma define_template FIO_TArray<uint_4>
    125 #pragma define_template FIO_TArray<uint_8>
     150// #pragma define_template FIO_TArray<uint_4>
     151// #pragma define_template FIO_TArray<uint_8>
    126152#pragma define_template FIO_TArray<r_8>
    127153#pragma define_template FIO_TArray<r_4>
     
    132158#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
    133159// Instances des delegues FileIO (PPersist)
    134 template class FIO_TArray<uint_1>;
     160// template class FIO_TArray<uint_1>;
    135161template class FIO_TArray<uint_2>;
    136 template class FIO_TArray<int_2>;
    137 template class FIO_TArray<int_4>;
     162// template class FIO_TArray<int_2>;
     163// template class FIO_TArray<int_4>;
    138164template class FIO_TArray<int_8>;
    139 template class FIO_TArray<uint_4>;
    140 template class FIO_TArray<uint_8>;
     165// template class FIO_TArray<uint_4>;
     166// template class FIO_TArray<uint_8>;
    141167template class FIO_TArray<r_8>;
    142168template class FIO_TArray<r_4>;
Note: See TracChangeset for help on using the changeset viewer.