Index: trunk/SophyaPI/PIext/servnobjm.cc
===================================================================
--- trunk/SophyaPI/PIext/servnobjm.cc	(revision 293)
+++ trunk/SophyaPI/PIext/servnobjm.cc	(revision 295)
@@ -3,4 +3,5 @@
 #include <ctype.h>
 
+#include <typeinfo>
 #include <iostream.h>
 #include <string>
@@ -14,5 +15,4 @@
 
 #include "strutil.h"
-#include "datatypes.h"
 
 #include "nobjmgr.h"
@@ -20,20 +20,9 @@
 #include "pistdimgapp.h"
 
-#include "pclassids.h"
 #include "histos.h"
 #include "histos2.h"
 #include "ntuple.h"
 #include "hisprof.h"
-#include "generaldata.h"
-
-#include "cimage.h"
-#include "cvector.h"
-#include "matrix.h"
-
-//  Si le module StarReco++ a ete compile (Pour les StarList, Transfo, etc ...
-#ifdef SANS_EVOLPLANCK 
-#include "stlist.h"
-#include "star.h"
-#endif
+
 
 
@@ -55,66 +44,33 @@
 
 /* --Methode-- */
-void Services2NObjMgr::Nobj_ComputeExpressions(PPersist* obj, string& expx, string& expy, string& expz, 
+void Services2NObjMgr::RegisterClass(AnyDataObj* o, NObjMgrAdapter* oa)
+{
+ObjAdaptList::iterator it;
+for(it = objadaplist.begin(); it != objadaplist.end(); it++) 
+    if (typeid(*o) == typeid(*((*it).obj)))  THROW(dupIdErr);
+
+dataobj_adapter oba;
+oba.obj = o;
+oba.obja = oa;
+objadaplist.push_back(oba);
+}
+
+/* --Methode-- */
+NObjMgrAdapter* Services2NObjMgr::GetAdapter(AnyDataObj* o)
+{
+ObjAdaptList::iterator it;
+for(it = objadaplist.begin(); it != objadaplist.end(); it++) 
+  if (typeid(*o) == typeid(*((*it).obj)))  return((*it).obja->Clone(o));
+return(new NObjMgrAdapter(o));
+}
+
+/* --Methode-- */
+void Services2NObjMgr::Nobj_ComputeExpressions(NObjMgrAdapter* obja, string& expx, string& expy, string& expz, 
                           string& expwt, string& expcut, NTuple* nt, Histo* h1, Histo2D* h2, HProf* hp)
 {
-int cid = obj->ClassId();
-
-string vardec;
-switch (cid) {
-  case ClassId_Vector : 
-    vardec = "double i,val; \n";
-    vardec += "i = _zz61qq_[0];  val = _zz61qq_[1]; \n";
-    break;
-
-  case ClassId_Matrix : 
-    vardec = "double i,j,val; \n";
-    vardec += "i = _zz61qq_[0];  j = _zz61qq_[1];  val = _zz61qq_[2]; \n";
-    break;
-
-  case ClassId_Histo1D : 
-  case ClassId_HProf : 
-    vardec = "double i,x,val,err; \n";
-    vardec += "i = _zz61qq_[0];  x = _zz61qq_[1];  val = _zz61qq_[2];  err = _zz61qq_[3]; \n";
-    break;
-
-  case ClassId_Histo2D : 
-    vardec = "double i,j,x,y,val,err; \n";
-    vardec += "i = _zz61qq_[0];  j = _zz61qq_[1]; \n";  
-    vardec += "x = _zz61qq_[2];  y = _zz61qq_[3]; \n";  
-    vardec += "val = _zz61qq_[4]; err = _zz61qq_[5]; \n";
-    break;
-
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 : 
-  case ClassId_Image + kint_1 : 
-  case ClassId_Image + kr_8 : 
-  case ClassId_Image + kuint_4 : 
-  case ClassId_Image + kuint_2 : 
-  case ClassId_Image + kint_2 : 
-  case ClassId_Image + kint_4 : 
-  case ClassId_Image + kr_4 : 
-    vardec = "double x,y,pix,i,j,val; \n";
-    vardec += "x = i = _zz61qq_[0];  y = j = _zz61qq_[1];  pix = val = _zz61qq_[2]; \n";
-    break;
-
-#ifdef SANS_EVOLPLANCK 
-  case ClassId_StarList : 
-    vardec = "double x,y,flux,fond; \n";
-    vardec += "x = _zz61qq_[0];  y = _zz61qq_[1];  flux = _zz61qq_[2];  fond =  _zz61qq_[3]; \n";
-    break;
-#endif
-
-  case ClassId_NTuple :
-    vardec = ((NTuple*)obj)->VarList_C("_zz61qq_");
-    break;
-
-  case ClassId_GeneralFitData :
-    vardec = ((GeneralFitData*)obj)->VarList_C("_zz61qq_");
-    break;
-
-  default :
-    cerr << "NamedObjMgr_ComputeExpressions() Error , N/A to " << PClassIdToClassName(cid) << endl; 
-    return;
-  }
+if (obja == NULL) return;
+NTupleInterface* objnt = obja->GetNTupleInterface();
+if (objnt == NULL)  return;
+string  vardec = objnt->VarList_C("_zz61qq_");
 
 PlotExprFunc f = LinkExprFunc(vardec, expx, expy, expz, expwt, expcut);
@@ -124,162 +80,26 @@
   }
 
-float x[10], xnt[10];
+double xnt[10];
+float  fxnt[10];
 
 int i,j,k;
-for(i=0; i<10; i++) x[i] = xnt[i] = 0.;
-
-TRY {                                 
-switch (cid) {
-  case ClassId_Vector :
-    { 
-    Vector* vv = (Vector*)obj;
-    for(k=0; k<vv->NElts(); k++) {
-      x[0] = k;   x[1] = (*vv)(k);
-      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-        if (nt) nt->Fill(xnt);
-        if (h1) h1->Add(xnt[0], xnt[3]);
-        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-        }
+for(i=0; i<10; i++) xnt[i] = 0.;
+
+TRY  {
+  double* xn;
+  for(k=0; k<objnt->NbLines(); k++)    {
+    xn = objnt->GetLineD(k);
+    if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
+      if (nt) { 
+         for(i=0; i<4; i++) fxnt[i] = xnt[i]; 
+         nt->Fill(fxnt);
+         }
+      if (h1) h1->Add(xnt[0], xnt[3]);
+      if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
+      if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
       }
     }
-    break;
-
-  case ClassId_Matrix : 
-    {
-    Matrix* mm = (Matrix*)obj;
-    for(j=0; j<mm->NCol(); j++)
-      for(i=0; i<mm->NRows(); i++) {
-      x[0] = i; x[1] = j;  x[2] = (*mm)(i,j);
-      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-        if (nt) nt->Fill(xnt);
-        if (h1) h1->Add(xnt[0], xnt[3]);
-        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-        }
-      }
-    }
-    break;
-
-  case ClassId_Histo1D : 
-  case ClassId_HProf : 
-    {
-    Histo* hh = (Histo*)obj;
-    for(k=0; k<hh->NBins(); k++) {
-      x[0] = k;  x[1] = hh->BinCenter(k);   
-      x[2] = (*hh)(k);  x[3] = hh->Error(k);
-      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-        if (nt) nt->Fill(xnt);
-        if (h1) h1->Add(xnt[0], xnt[3]);
-        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-        }
-      }
-    }
-    break;
-
-  case ClassId_Histo2D : 
-    {
-    Histo2D* hh = (Histo2D*)obj;
-    for(j=0; j<hh->NBinY(); j++)
-      for(i=0; i<hh->NBinX(); i++) {
-      x[0] = i;   x[1] = j; 
-      hh->BinCenter(i,j,x[2],x[3]); 
-      x[4] = (*hh)(i,j);  x[5] = hh->Error(i, j);
-      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-        if (nt) nt->Fill(xnt);
-        if (h1) h1->Add(xnt[0], xnt[3]);
-        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-        }
-      }
-    }
-    break;
-
-
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 : 
-  case ClassId_Image + kint_1 : 
-  case ClassId_Image + kr_8 : 
-  case ClassId_Image + kuint_4 : 
-  case ClassId_Image + kuint_2 : 
-  case ClassId_Image + kint_2 : 
-  case ClassId_Image + kint_4 : 
-  case ClassId_Image + kr_4 :
-    {
-    RzImage* img = (RzImage*)obj; 
-    for(j=0; j<img->YSize(); j++)
-      for(i=0; i<img->XSize(); i++) {
-        x[0] = i;  x[1] = j;  x[2] = img->FValue(i, j);
-        if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-          if (nt) nt->Fill(xnt);
-          if (h1) h1->Add(xnt[0], xnt[3]);
-          if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-          if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-          }
-      }
-    }
-    break;
-
-#ifdef SANS_EVOLPLANCK 
-  case ClassId_StarList : 
-    {
-    StarList* stl = (StarList*)obj;
-    BStar *sti;
-    for(k=0; k<stl->NbStars(); k++) {
-      sti = stl->Star(k);
-      if ( (!sti) || !(sti->Nice(BStar::flagOK)) )  continue;
-      x[0] = sti->PosX();   x[1] = sti->PosY();
-      x[2] = sti->Flux();   x[3] =  sti->Fond();  
-      if (f(x, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-        if (nt) nt->Fill(xnt);
-        if (h1) h1->Add(xnt[0], xnt[3]);
-        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-        }
-      }
-    }
-    break;
-#endif
-
-  case ClassId_NTuple :
-    {
-    NTuple* ntp = (NTuple*)obj;
-    r_4* xn;
-    for(k=0; k<ntp->NEntry(); k++)    {
-      xn = ntp->GetVec(k);
-      if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-        if (nt) nt->Fill(xnt);
-        if (h1) h1->Add(xnt[0], xnt[3]);
-        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-        }
-      }
-    }
-    break;
-
-  case ClassId_GeneralFitData :
-    {
-    GeneralFitData* data = (GeneralFitData*)obj;
-    r_4* xn;
-    int iok = 2*data->NVar()+2;
-    for(k=0; k<data->NData(); k++) {
-      xn = data->GetVecR4(k);
-      if(xn[iok]<0.001) continue;
-      if (f(xn, xnt, xnt+1, xnt+2, xnt+3) != 0) {
-        if (nt) nt->Fill(xnt);
-        if (h1) h1->Add(xnt[0], xnt[3]);
-        if (h2) h2->Add(xnt[0], xnt[1], xnt[3]);
-        if (hp) hp->Add(xnt[0], xnt[1], xnt[3]);
-      }
-    }
-    }
-    break;
-
-  default :
-    cout << "NamedObjMgr_ComputeExpressions() Erreur: N/A to  " << PClassIdToClassName(cid) << endl; 
-    return;
-  }
-} CATCH(merr) {
+ }
+CATCH(merr) {
   fflush(stdout); 
   cout << endl; 
@@ -318,5 +138,5 @@
 // constitution du fichier a compiler
 fputs("#include <math.h> \n", fip);
-fputs("int expf_pia_dl_func(float* _zz61qq_, float* _rx_61qq_, float* _ry_61qq_, float* _rz_61qq_, float* _wt_61qq_) \n{\n", fip);
+fputs("int expf_pia_dl_func(double* _zz61qq_, double* _rx_61qq_, double* _ry_61qq_, double* _rz_61qq_, double* _wt_61qq_) \n{\n", fip);
 fprintf(fip,"%s \n", vardec.c_str());
 fprintf(fip, "if (!(%s)) { *_rx_61qq_ = *_ry_61qq_ = *_rz_61qq_ = *_wt_61qq_ = 0.;  return(0); } \n", cut.c_str());
@@ -465,148 +285,5 @@
 }
 
-/* --Methode-- */
-char* Services2NObjMgr::PClassIdToClassName(int cid)
-{
-switch (cid) {
-  case ClassId_Poly1 : 
-    return("Poly1");
-  case ClassId_Poly2 : 
-    return("Poly2");
-  case ClassId_Matrix : 
-    return("Matrix");
-  case ClassId_Vector : 
-    return("Vector");
-
-  case ClassId_DVList : 
-    return("DVList");
-
-  case ClassId_Histo1D : 
-    return("Histo1D");
-  case ClassId_Histo2D : 
-    return("Histo2D");
-  case ClassId_HProf : 
-    return("HProf");
-  case ClassId_NTuple : 
-    return("NTuple");
-  case ClassId_GeneralFitData : 
-    return("GeneralFitData");
-
-  case ClassId_Image : 
-    return("RzImage");
-  case ClassId_Image + kuint_1 : 
-    return("ImageU1");
-  case ClassId_Image + kint_1 : 
-    return("ImageI1");
-  case ClassId_Image + kuint_2 : 
-    return("ImageU2");
-  case ClassId_Image + kint_2 : 
-    return("ImageI2");
-  case ClassId_Image + kuint_4 : 
-    return("ImageU4");
-  case ClassId_Image + kint_4 : 
-    return("ImageI4");
-  case ClassId_Image + kr_4 : 
-    return("ImageR4");
-  case ClassId_Image + kr_8 : 
-    return("ImageR8");
-
-  case ClassId_ZFidu : 
-    return("ZFidu");
-
-#ifdef SANS_EVOLPLANCK 
-  case ClassId_StarList : 
-    return("StarList");
-  case ClassId_Transfo : 
-    return("Transfo");
-  case ClassId_PSF : 
-    return("PSF");
-
-  case ClassId_Star + BStar_Type : 
-    return("BStar");
-  case ClassId_Star + RzStar_Type : 
-    return("RzStar");
-  case ClassId_Star + PSFStar_Type : 
-    return("PSFStar");
-  case ClassId_Star + MCStar_Type : 
-    return("MCStar");
-  case ClassId_Star + CircRFixStar_Type : 
-    return("CircRFixStar");
-  case ClassId_Star + PSFDHStar_Type : 
-    return("PSFDHStar");
-  case ClassId_Star + PSFSEStar_Type : 
-    return("PSFSEStar");
-  case ClassId_Star + MCDHStar_Type : 
-    return("MCDHStar");
-#endif
-
-// - Ajout objet PPF
-  default:
-    return("Unknown");
-  }
-}  
-
-/* --Methode-- */
-char* Services2NObjMgr::PClassIdToShortClassName(int cid)
-{
-switch (cid) {
-  case ClassId_Poly1 : 
-  case ClassId_Poly2 : 
-    return("Poly");
-  case ClassId_Matrix : 
-    return("Mtx");
-  case ClassId_Vector : 
-    return("Vec");
-  case ClassId_DVList : 
-    return("Dvl");
-
-  case ClassId_Histo1D : 
-    return("H1D");
-  case ClassId_Histo2D : 
-    return("H2D");
-  case ClassId_HProf : 
-    return("HPF");
-  case ClassId_NTuple : 
-    return("NT");
-  case ClassId_GeneralFitData : 
-    return("GFD");
-
-  case ClassId_Image : 
-  case ClassId_Image + kuint_1 : 
-  case ClassId_Image + kint_1 : 
-  case ClassId_Image + kuint_2 : 
-  case ClassId_Image + kint_2 : 
-  case ClassId_Image + kuint_4 : 
-  case ClassId_Image + kint_4 : 
-  case ClassId_Image + kr_4 : 
-  case ClassId_Image + kr_8 : 
-    return("Img");
-
-  case ClassId_ZFidu : 
-    return("Fidu");
-
-#ifdef SANS_EVOLPLANCK 
-  case ClassId_StarList : 
-    return("Stl");
-  case ClassId_Transfo : 
-    return("Tr");
-  case ClassId_PSF : 
-    return("PSF");
-
-  case ClassId_Star + BStar_Type : 
-  case ClassId_Star + RzStar_Type : 
-  case ClassId_Star + PSFStar_Type : 
-  case ClassId_Star + MCStar_Type : 
-  case ClassId_Star + CircRFixStar_Type : 
-  case ClassId_Star + PSFDHStar_Type : 
-  case ClassId_Star + PSFSEStar_Type : 
-  case ClassId_Star + MCDHStar_Type : 
-    return("Star");
-#endif
-
-// - Ajout objet PPF
-  default:
-    return("U");
-  }
-}  
+
 
 // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
