Changeset 1967 in Sophya for trunk


Ignore:
Timestamp:
Apr 26, 2002, 6:48:22 PM (23 years ago)
Author:
ansari
Message:

Ajout throw TypeMismatchExc ds PPersist_X::SetDataObj() ds les differents classes handler PPersist, a place du return simple, lorsque le type d'objet n'etait pas bon ... Reza 26/4/2002

Location:
trunk
Files:
8 edited

Legend:

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

    r1426 r1967  
    99#include "pexceptions.h"
    1010#include "fiondblock.h"
     11#include "datatype.h"
     12#include <typeinfo>
    1113
    1214////////////////////////////////////////////////////////////////
     
    7173{
    7274NDataBlock<T> * po = dynamic_cast< NDataBlock<T> * >(&o);
    73 if (po == NULL) throw TypeMismatchExc("FIO_NDataBlock<T>::SetDataObj() - Type Mismatch Error");
     75if (po == NULL) {
     76  char buff[160];
     77  sprintf(buff,"FIO_NDataBlock<T><%s>::SetDataObj(%s) - Object type  error ! ",
     78          DataTypeInfo<T>::getTypeName().c_str(), typeid(o).name());
     79  throw TypeMismatchExc(PExcLongMessage(buff));   
     80}
    7481if (ownobj && dobj) delete dobj;
    7582dobj = po; ownobj = false;
  • trunk/SophyaLib/BaseTools/objfio.h

    r754 r1967  
    2727  virtual   AnyDataObj* DataObj() { return(dobj); }
    2828  virtual   void        SetDataObj(AnyDataObj & o)
    29           {  T * po = dynamic_cast< T * >(& o); if (po == NULL) return;
    30           if (ownobj && dobj) delete dobj;  dobj = po; ownobj = false; }   
    31 
     29  { 
     30    T * po = dynamic_cast< T * >(& o);
     31    if (po == NULL)  {
     32      char buff[160];
     33      sprintf(buff,"ObjFileIO<T>::SetDataObj(%s) - Object type  error ! ",
     34              typeid(o).name());
     35      throw TypeMismatchExc(PExcLongMessage(buff));   
     36    }
     37    if (ownobj && dobj) delete dobj;  dobj = po; ownobj = false;
     38  }   
     39 
    3240  inline operator T() { return(*dobj); }
    3341
  • trunk/SophyaLib/BaseTools/sversion.h

    r1958 r1967  
    33
    44#define SOPHYA_VERSION   1.3
    5 #define SOPHYA_REVISION  55
    6 #define SOPHYA_TAG       "V_Jan2002"
     5#define SOPHYA_REVISION  60
     6#define SOPHYA_TAG       "V_Mar2002"
    77
    88#endif
  • trunk/SophyaLib/NTools/cimage.cc

    r1390 r1967  
    88#include "pexceptions.h"
    99#include "cimage.h"
     10#include "datatype.h"
     11#include <typeinfo>
    1012
    1113/*!
     
    115117{
    116118  Image<T> * po = dynamic_cast< Image<T> * >(&o);
    117   if (po == NULL) return;
     119  if (po == NULL) {
     120    char buff[160];
     121    sprintf(buff,"FIO_Image<%s>::SetDataObj(%s) - Object type  error ! ",
     122            DataTypeInfo<T>::getTypeName().c_str(), typeid(o).name());
     123    throw TypeMismatchExc(PExcLongMessage(buff));       
     124  }
    118125  if (ownobj && dobj) delete dobj;
    119126  dobj = po; ownobj = false;
  • trunk/SophyaLib/SkyMap/fiolocalmap.cc

    r1624 r1967  
    44#include "pexceptions.h"
    55#include "fiondblock.h"
     6#include "datatype.h"
     7#include <typeinfo>
    68
    79//*******************************************************************
     
    7274{
    7375  LocalMap<T> * po = dynamic_cast< LocalMap<T> * >(&o);
    74   if (po == NULL) return;
     76  if (po == NULL) {
     77    char buff[160];
     78    sprintf(buff,"FIO_LocalMap<%s>::SetDataObj(%s) - Object type  error ! ",
     79            DataTypeInfo<T>::getTypeName().c_str(), typeid(o).name());
     80    throw TypeMismatchExc(PExcLongMessage(buff));   
     81  }
    7582  if (ownobj && dobj) delete dobj;
    7683  dobj = po; ownobj = false;
  • trunk/SophyaLib/SkyMap/fiospherethetaphi.cc

    r1624 r1967  
    44#include "pexceptions.h"
    55#include "fiondblock.h"
     6#include "datatype.h"
     7#include <typeinfo>
    68
    79///////////////////////////////////////////////////////////
     
    5759{
    5860  SphereThetaPhi<T> * po = dynamic_cast< SphereThetaPhi<T> * >(&o);
    59   if (po == NULL) return;
     61  if (po == NULL) {
     62    char buff[160];
     63    sprintf(buff,"FIO_SphereThetaPhi<%s>::SetDataObj(%s) - Object type  error ! ",
     64            DataTypeInfo<T>::getTypeName().c_str(), typeid(o).name());
     65    throw TypeMismatchExc(PExcLongMessage(buff));   
     66  }
     67
    6068  if (ownobj && dobj) delete dobj;
    6169  dobj = po; ownobj = false;
  • trunk/SophyaLib/SkyMap/spherepos.cc

    r764 r1967  
    22
    33#include "spherepos.h"
     4#include "datatype.h"
     5#include <typeinfo>
    46
    5 static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.cc,v 1.1.1.1 2000-03-02 17:05:39 ansari Exp $";
     7static char *head_spherepos_cc_ = "$Header: /Users/garnier/temp/CVSSophya/SophyaLib/SkyMap/spherepos.cc,v 1.2 2002-04-26 16:48:22 ansari Exp $";
    68
    79
     
    7274{
    7375  SphereCoordSys * po = dynamic_cast<SphereCoordSys *>(&o);
    74   if (po == NULL) return;
     76  if (po == NULL) {
     77    char buff[160];
     78    sprintf(buff,"FIO_SphereCoordSys::SetDataObj(%s) - Object type  error ! ",
     79            typeid(o).name());
     80    throw TypeMismatchExc(PExcLongMessage(buff));   
     81  }
     82
    7583  if (ownobj && dobj) delete dobj; 
    7684  dobj = po; ownobj = false;
  • trunk/SophyaProg/Examples/arr1.icc

    r1650 r1967  
    1 // Fichier arr1.icc
    2 // Exemple d'utilisation de tableaux 
    3 // Appel: runcxx -f arr1.icc
    4 // Creation , remplissage d'une matrice
    5   TMatrix<r_4> ma(7,9);
    6   ma = RegularSequence(0.1, 0.05);   
    7   cout << "\n arr1.icc: ma = " << ma << endl;
    8   float min, max;
    9 // Utilisation des sous-tableaux
    10   ma(Range(2,4), Range(4,7)) = M_PI;
    11   cout << "\n Apres ma(Range(2,4), Range(4,7)) = " << ma << endl;
    12 // Appel de methodes
    13   ma.MinMax(min, max);
    14   cout << " MinMax(ma) : min= " << min << " max= " << max << endl;
    15   TMatrix<r_4> sma = Sin(ma);
    16   cout << "\n test pour runcxx - sma = Sin(ma)= " << sma << endl;
    17   sma.MinMax(min, max);
    18   cout << " MinMax(sma) : min= " << min << " max= " << max << endl;
     1  // We create a integer array SizeX=7, SizeY=5
     2  TArray<int_4> ia(7,5);
     3  // We fill it with a sequence of numbers starting at 10., with step = 2.
     4  ia = RegularSequence(10., 2.);
     5  cout << " ----- Array IA = \n " << ia << endl;
     6  TArray<int_4> ib = ia(Range(0,3), Range(3,4), Range(0));
     7  cout << " ----- Array IB IA(Range(0,3), Range(3,2)) = \n" << ib << endl;
     8  // sub array extraction, Range(2,4) : starting position=2 , End=4
     9  TArray<int_4> ic = ia(Range(2,3),Range(1,3),Range(0));
     10  cout << " ----- Array IC IA(Range(2,3),Range(1,3)) = \n " << ic << endl;
     11  // we set the sub-array to zero, this should reflect in the original array
     12  // sub-arrays share their data with parent array
     13  ic = 0;
     14  cout << " ----- Array IC Apres (=0) = \n " << ic << endl;
     15  cout << " ----- Array IB Apres IC=0 = \n " << ib << endl;
     16  cout << " ----- Array IA Apres IC=0 = \n " << ia << endl;
     17  cout << " >>>>>> Writing in  arrt.ppf <<<<<<< " << endl;
     18  POutPersist pos("arrt.ppf");
     19  // We write  the three arrays in the stream
     20  pos << ia << ib << ic;
    1921
    20 // Vector , matrix multiplication
    21   Vector v1(5);
    22   v1 = 12.;
    23   Vector v2(5);
    24   v2 = 14;
    25   Matrix m = v2*v1.Transpose();
    26   cout << " m= v2*v1.Transpose() : " << m;
    27 // Computing the scalar product   
    28   cout << " v1.v2 = " << (v1.Transpose()*v2).toScalar() << endl;
Note: See TracChangeset for help on using the changeset viewer.