Index: trunk/SophyaLib/BaseTools/exceptions.cc
===================================================================
--- trunk/SophyaLib/BaseTools/exceptions.cc	(revision 244)
+++ 	(revision )
@@ -1,235 +1,0 @@
-#include "defs.h"
-#include "exceptions.h"
-#include <iostream.h>
-#include <new.h>
-#ifndef __mac__
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include "perrors.h"
-
-#ifdef __mac__
-#include "unixmac.h"
-#include <SIOUX.h>
-#endif
-
-//#define LAL
-
-#ifndef EXC_MSG
-#define EXC_MSG(i) "Exception " << i
-#endif
-
-#define kDynAllocBlock 10
-
-void EAFailHandler(void); 
-
-#ifndef COMPILER_EXCEPTIONS
-
-#ifndef NO_EXCEPTIONS
-
-ExcHndl::ExcHndl(ExcHndl* up)
-: nextHandler(up), 
-  theExc(0), hadExc(0),
-  nObj(0), nObjAlloc(kDynAllocBlock), objects((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))), 
-  nDyn(0), nDynAlloc(kDynAllocBlock), dynObjs((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))),
-  nDynTab(0), nDynTabAlloc(kDynAllocBlock), 
-  dynTabObjs((ExcAwareObject**)malloc(kDynAllocBlock*sizeof(void*))),
-  dynTabSz((size_t*)malloc(kDynAllocBlock*sizeof(size_t)))
-{
- //  cerr << "TRY : " << hex << this << "  <-  " << nextHandler << dec << endl;
-}
-
-ExcHndl::~ExcHndl()
-{
-  free(objects);
-  free(dynObjs);
-  free(dynTabObjs);
-  free(dynTabSz);
- // cerr << "~TRY: " << hex << this << "  <-  " << nextHandler << dec << endl;
-}
-
-void ExcHndl::Add(ExcAwareObject* obj)
-{
-  // on verifie s'il est dans la liste a ignorer
-  int trouve=0;
-  int i;
-  for (i=0; i<nDyn; i++)
-    if (dynObjs[i] == obj) {
-      trouve = true;
-      break;
-    }
-  if (trouve) {   // On le vire de la table des news.
-    nDyn--;
-    for (int j=i; j<nDyn; j++)
-      dynObjs[j] = dynObjs[j+1];
-    return;
-  }
-  
-  // Dans les tableaux ?
-  for (i=0; i<nDynTab; i++)
-    if ((dynTabObjs[i] <= obj) && ((char*)(dynTabObjs[i]) + dynTabSz[i] >= (char*)obj)) {
-      return;
-    }
-
-  // on l'ajoute a la liste des objets
-  nObj++;
-  if (nObj>nObjAlloc) {
-    nObjAlloc += kDynAllocBlock;
-    objects = (ExcAwareObject**) realloc(objects, nObjAlloc*sizeof(void*));
-  }
-
-  objects[nObj-1] = obj;
-}
-
-void ExcHndl::Forget(ExcAwareObject* obj)
-{
-  // on verifie s'il est dans la liste
-  int trouve=0;
-  int i=0;
-  for (i=0; i<nObj; i++)
-    if (objects[i] == obj) {
-      trouve = true;
-      break;
-    }
-  if (trouve) {
-    nObj--;
-    for (int j=i; j<nObj; j++)
-      objects[j] = objects[j+1];
-  }
-}
-
-void ExcHndl::Ignore(ExcAwareObject* obj)
-{
-  // on l'ajoute a la liste des objets
-  nDyn++;
-  if (nDyn>nDynAlloc) {
-    nDynAlloc += kDynAllocBlock;
-    dynObjs = (ExcAwareObject**) realloc(dynObjs, nDynAlloc*sizeof(void*));
-  }
-
-  dynObjs[nDyn-1] = obj;
-}
-
-void ExcHndl::IgnoreTab(ExcAwareObject* obj, size_t sz)
-{
-  // on l'ajoute a la liste des objets
-  nDynTab++;
-  if (nDynTab>nDynTabAlloc) {
-    nDynTabAlloc += kDynAllocBlock;
-    dynTabObjs =(ExcAwareObject**) realloc(dynTabObjs, nDynTabAlloc*sizeof(void*));
-    dynTabSz   = (size_t*) realloc(dynTabSz,   nDynTabAlloc*sizeof(size_t));
-  }
-
-  dynTabObjs[nDynTab-1] = obj;
-  dynTabSz  [nDynTab-1] = sz;
-}
-
-void ExcHndl::DelTab(ExcAwareObject* obj)
-{
-  // on le supprime
-
-  int trouve=0;
-  int i=0;
-  for (i=0; i<nDynTab; i++)
-    if (dynTabObjs[i] == obj) {
-      trouve = true;
-      break;
-    }
-  if (trouve) {
-    nDynTab--;
-    for (int j=i; j<nDynTab; j++) {
-      dynTabObjs[j] = dynTabObjs[j+1];
-      dynTabSz  [j] = dynTabSz  [j+1];
-    }
-  }
-}
-
-
-
-// End Constructor : ne pas se preoccuper des objets qui sont
-// a l'interieur de cet objet.
-void ExcHndl::EndConstructor(void* obj, size_t s)
-{
-  for (int i=0; i<nObj; i++)
-    if ((char*)objects[i] > (char*)obj && (char*)objects[i] < (char*)obj + s) {
-      nObj--;
-      for (int j=i; j<nObj; j++)
-	objects[j] = objects[j+1];
-      i--;
-    }
-}
-
-#undef DEBUG
-
-void ExcHndl::Throw(int i, char* file, int line)
-{
-  if (_ExcAbortAll || (i<0 && _ExcAbortNeg)) {
-    cerr << EXC_MSG(i);
-    if (file) cerr << " file " << file << " line " << line;
-    cerr << endl;
-    abort();
-  } else {
-    #ifdef DEBUG
-    cerr << "caught " << EXC_MSG(i);
-    if (file) cerr << " file " << file << " line " << line;
-    cerr << endl;
-    #endif
-    theExc = i;
-    hadExc = 1;
-    
-    // On detruit tous les objets crees depuis le TRY
-    // ExcAwareObject a un destructeur virtuel...
-    // Le tableau est dans l'ordre de creation. donc i--
-    
-    for (int i=nObj-1; i>=0; i--)
-      objects[i]->~ExcAwareObject();
-    
-    // et maintenant on saute...
-    
-    longjmp(env, 1);
-  }
-}
-
-
-void ExcHndl::NoHandler(int i, char* file, int line)
-{
-  cerr << "No handler : ";
-  cerr << EXC_MSG(i);
-  if (file) cerr << " file " << file << " line " << line;
-  cerr << endl;
-  terminate();
-}
-
-ExcHndl* topExcHndl = 0;
-int      _ExcAbortNeg = 1;
-int      _ExcAbortAll = 0;
-
-#endif
-#endif
-
-
-void EAFailHandler(void)
-{
-        set_new_handler(NULL);
-	cerr << "Allocation exception -- out of memory" << endl;
-        THROW(allocationErr);
-}
-
-void InitFailNewHandler()
-{
-        set_new_handler(EAFailHandler);
-}
-
-
-#ifdef THINK_CPLUS
-void terminate()
-{
-	DebugStr("\pTerminate...");
-	abort();
-}
-#endif
-
-#ifdef x__GNUG__
-void terminate()
-{ abort(); }
-#endif
Index: trunk/SophyaLib/BaseTools/exceptions.h
===================================================================
--- trunk/SophyaLib/BaseTools/exceptions.h	(revision 244)
+++ 	(revision )
@@ -1,1 +1,0 @@
-#include "pexceptions.h"
Index: trunk/SophyaLib/BaseTools/machdefs.h
===================================================================
--- trunk/SophyaLib/BaseTools/machdefs.h	(revision 244)
+++ trunk/SophyaLib/BaseTools/machdefs.h	(revision 245)
@@ -237,5 +237,7 @@
 
 #ifdef __DECCXX
+#define HAS_STR_NPOS
 #define ITER_TAG
+#define __CXX_PRAGMA_TEMPLATES__
 #define PRAGMA_TEMPLATES
 #endif
@@ -267,4 +269,6 @@
 #ifdef HAS_STR_NPOS
 #define NPOS string::npos
+#else
+#define NPOS (size_t)-1
 #endif
 
Index: trunk/SophyaLib/BaseTools/ndatablock.cc
===================================================================
--- trunk/SophyaLib/BaseTools/ndatablock.cc	(revision 245)
+++ trunk/SophyaLib/BaseTools/ndatablock.cc	(revision 245)
@@ -0,0 +1,465 @@
+#include "machdefs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <complex>
+#include "pexceptions.h"
+#include "ndatablock.h"
+
+#define DEBUG_NDATABLOCK
+
+#ifdef DEBUG_NDATABLOCK
+  static size_t NallocData = 0;
+  static size_t NallocSRef = 0;
+#endif
+
+// LOGIQUE DE BASE:
+//   - le createur par copie et la surcharge de l operateur = "partage" les donnees
+//   - gestion du partage de reference
+
+//************ Createur, Destructeur, gestion des donnees
+
+template <class T>
+NDataBlock<T>::NDataBlock(size_t n)
+// Createur d'une structure de "n" donnees
+: mSz(0), mSRef(NULL), mIsTemp(false)
+{
+Alloc(n);
+}
+
+template <class T>
+NDataBlock<T>::NDataBlock(size_t n, T* data, Bridge* br)
+// Createur d'une structure de "n" donnees, avec donnees preallouees
+: mSz(0), mSRef(NULL), mIsTemp(false)
+{
+Alloc(n,data,br);
+}
+
+template <class T>
+NDataBlock<T>::NDataBlock()
+// Createur par default
+: mSz(0), mSRef(NULL), mIsTemp(false)
+{
+}
+
+template <class T>
+NDataBlock<T>::NDataBlock(NDataBlock<T>& a)
+// Createur par copie
+// ATTENTION: partage les donnees avec "a"
+// Ecriture: NDataBlock a = b;
+//           NDataBlock a(b)
+: mSz(0), mSRef(NULL), mIsTemp(false)
+{
+Share(a);
+}
+
+template <class T>
+NDataBlock<T>::NDataBlock(NDataBlock<T>& a,bool share)
+// Createur avec choix de partager ou non
+: mSz(0), mSRef(NULL), mIsTemp(false)
+{
+if(share) Share(a); else Clone(a);
+}
+
+template <class T>
+NDataBlock<T>::~NDataBlock()
+// Destructeur
+{
+Delete();
+}
+
+template <class T>
+void NDataBlock<T>::Alloc(size_t n,T* data,Bridge* br)
+// Allocation d'un NOUVEL espace de stoquage
+// Si data==NULL : allocation de l'espace memoire
+//    data!=NULL : partage des donnees avec l'adresse data
+// Si br==NULL   : les donnees nous appartiennent
+//    br!=NULL   : les donnees ne nous appartiennent pas (ex Blitz)
+{
+#ifdef DEBUG_NDATABLOCK
+cout<<"NDataBlock::Alloc("<<n<<") mSRef="<<mSRef<<endl;
+#endif
+if(n==0) throw(SzMismatchError("NDataBlock::Alloc n==0\n"));
+if(mSRef) Delete();
+mSz = n;
+mSRef = new NDREF;
+mSRef->nref = 1;
+if(data) mSRef->data = data; else mSRef->data = new T[n];
+mSRef->bridge = br;
+#ifdef DEBUG_NDATABLOCK
+if(!data) NallocData++; NallocSRef++;
+cout<<"NDataBlock::Alloc("<<n<<") mSRef="<<mSRef
+    <<" mSRef->nref"<<mSRef->nref<<" mSRef->data"<< mSRef->data
+    <<" Total("<<NallocData<<","<<NallocSRef<<")"<<endl;
+#endif
+}
+
+template <class T>
+void NDataBlock<T>::Clone(NDataBlock<T>& a)
+// Clone (copie de donnee) a partir de "a"
+{
+#ifdef DEBUG_NDATABLOCK
+cout<<"NDataBlock::Clone("<<&a<<endl;
+#endif
+if(!a.mSRef) {mSz=0; mSRef=NULL;} // cas ou "a" est cree par defaut
+else if(a.IsTemp()) Share(a);
+else {Alloc(a.mSz); memcpy(Dtata(),a.Dtata(),mSz*sizeof(T));}
+}
+
+template <class T>
+void NDataBlock<T>::Share(NDataBlock<T>& a)
+// Partage des donnees avec "a"
+{
+#ifdef DEBUG_NDATABLOCK
+cout<<"NDataBlock::Share("<<&a<<") a.mSRef="<<a.mSRef<<" mSRef="<<mSRef<<endl;
+#endif
+if(&a==NULL) throw(NullPtrError("NDataBlock::Share  &a==NULL\n"));
+// on ne peut partager si "a" pas alloue
+if(!a.mSRef) throw(NullPtrError("NDataBlock::Share not allocated a\n"));
+if(mSRef) Delete();
+mSz = a.mSz; mSRef = a.mSRef; mSRef->nref++;
+#ifdef DEBUG_NDATABLOCK
+cout<<"...NDataBlock::Share("<<&a<<") mSRef="<<mSRef
+    <<" mSRef->nref"<<mSRef->nref<<" mSRef->data"<< mSRef->data<<endl;
+#endif
+}
+
+template <class T>
+void NDataBlock<T>::Delete(void)
+// Pour detruire les pointeurs en tenant compte des references
+{
+#ifdef DEBUG_NDATABLOCK
+cout<<"NDataBlock::Delete() mSRef="<<mSRef;
+if(mSRef) cout<<" mSRef->nref"<<mSRef->nref<<" mSRef->data"<<mSRef->data;
+cour<<endl;
+#endif
+if(mSRef==NULL) return; // cas du createur par defaut
+mSRef->nref--;
+if(mSRef->nref != 0) {
+#ifdef DEBUG_NDATABLOCK
+  cout<<"...NDataBlock::Delete() pas de desallocation il reste nref="<<mSRef->nref<<endl;
+#endif
+  return;
+}
+#ifdef DEBUG_NDATABLOCK
+if(!mSRef->bridge) NallocData--; NallocSRef--;
+cout<<"...NNDataBlock::Delete() desallocation complete il reste nref="<<mSRef->nref
+    <<" Total("<<NallocData<<","<<NallocSRef<<")"<<endl;
+#endif
+// Si il y a un Bridge les donnees ne n'appartiennent pas, on detruit le Bridge
+if(mSRef->bridge) delete mSRef->bridge; 
+// sinon, les donnees ont ete allouees par nos soins, on libere l'espace memoire
+else delete [] mSRef->data; 
+mSRef->bridge=NULL; mSRef->data=NULL;
+delete mSRef; mSRef=NULL;
+}
+
+template <class T>
+void NDataBlock<T>::ReSize(size_t n)
+// Re-dimension, dans ce cas re-allocation de la place
+{
+Alloc(n);
+}
+
+//**** Impression
+
+template <class T>
+void NDataBlock<T>::Print(size_t i1,size_t n)
+// Impression de n elements a partir de i1
+{
+size_t nr = 0;
+T* p = NULL;
+if(mSRef) {nr = mSRef->nref; p = mSRef->data;}
+cout<<"NDataBlock::Print nel=%ld nref=%d (%p)\n",mSz,nr,p;
+if(i1<0 || i1>=mSz || n<=0 || !p) return;
+size_t i2 = i1+n; if(i2>mSz) i2=mSz;
+size_t im = 1;
+while(i1<i2) {
+  cout<<" "<<(*this)(i1);  i1++;
+  if(im==10) {cout<<"\n"; im=1;} else im++;
+}
+}
+
+//**** Surcharge de = : NDataBlock=NDataBlock; NDataBlock=<T> b; 
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator = (const NDataBlock<T>& a)
+// surcharge avec partage des donnees
+// Ecriture:  NDataBlock a; a = b;
+//            NDataBlock a(10); a = b; (a est re-affecte)
+{
+if(this == &a) return *this;
+if(a.mSz!=mSz) throw(SzMismatchError("NDataBlock::operator=A size mismatch/null\n"));
+Share(a);
+return *this;
+}
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator = (const T v)
+// surcharge avec copie des donnees (pas de partage)
+// "this" est sur-ecrit, attention au partage de reference!
+// NDataBlock a; a = v; ou bien NDataBlock a(10); a = v;
+{
+if(mSz==0) throw(SzMismatchError("NDataBlock::operator=v null size\n"));
+T* p=Begin(), pe=End();
+while (p<pe) *p++ = v;
+return *this;
+}
+
+//**** Surcharge de +=,-=,*=,/= (INPLACE): NDataBlock += <T> b;
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator += (T b)
+{
+if(mSz==0) throw(SzMismatchError("NDataBlock::operator+=v null size\n"));
+T* p=Begin(), pe=End();
+while (p<pe) *p++ += b;
+return *this;
+}
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator -= (T b)
+{
+if(mSz==0) throw(SzMismatchError("NDataBlock::operator-=v null size\n"));
+T* p=Begin(), pe=End();
+while (p<pe) *p++ -= b;
+return *this;
+}
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator *= (T b)
+{
+if(mSz==0) throw(SzMismatchError("NDataBlock::operator*=v null size\n"));
+T* p=Begin(), pe=End();
+while (p<pe) *p++ *= b;
+return *this;
+}
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator /= (T b)
+{
+if(b==(<T>) 0) throw(ParmError("NDataBlock::operator/=v divide by zero\n"));
+if(mSz==0) throw(SzMismatchError("NDataBlock::operator/=v null size\n"));
+T* p=Begin(), pe=End();
+while (p<pe) *p++ /= b;
+return *this;
+}
+
+//**** Surcharge de +=,-=,*=,/= (INPLACE): NDataBlock += NDataBlock;
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator += (const NDataBlock<T>& a)
+{
+if(mSz==0 || mSz!=a.mSz) throw(SzMismatchError("NDataBlock::operator+=A size mismatch/null"));
+T* p=Begin(), pe=End(), pa=a.Begin();
+while (p<pe) *p++ += *pa++; // ca marche meme si *this=a
+return *this;
+}
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator -= (const NDataBlock<T>& a)
+{
+if(mSz==0 || mSz!=a.mSz) throw(SzMismatchError("NDataBlock::operator-=A size mismatch/null"));
+T* p=Begin(), pe=End(), pa=a.Begin();
+while (p<pe) *p++ -= *pa++; // ca marche meme si *this=a
+return *this;
+}
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator *= (const NDataBlock<T>& a)
+{
+if(mSz==0 || mSz!=a.mSz) throw(SzMismatchError("NDataBlock::operator*=A size mismatch/null"));
+T* p=Begin(), pe=End(), pa=a.Begin();
+while (p<pe) *p++ *= *pa++; // ca marche meme si *this=a
+return *this;
+}
+
+template <class T>
+NDataBlock<T>& NDataBlock<T>::operator /= (const NDataBlock<T>& a)
+{
+if(mSz==0 || mSz!=a.mSz) throw(SzMismatchError("NDataBlock::operator/=A size mismatch/null"));
+T* p=Begin(), pe=End(), pa=a.Begin();
+while (p<pe) *p++ /= *pa++;
+return *this;
+}
+
+//**** FIN DES METHODES DE LA CLASSE
+
+//**** Surcharge de +,-,*,/ : NDataBlock = NDataBlock+<T>b; NDataBlock = <T>b+NDataBlock;
+// ATTENTION: re-affectation imposee
+
+template <class T>
+NDataBlock<T> operator + (const NDataBlock<T>& a, T b)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+return (result += b);
+}
+
+template <class T>
+NDataBlock<T> operator + (T b, const NDataBlock<T>& a)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+return (result += b);
+}
+
+template <class T>
+NDataBlock<T> operator - (const NDataBlock<T>& a, T b)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+return (result -= b);
+}
+
+template <class T>
+NDataBlock<T> operator - (T b, const NDataBlock<T>& a)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+T* p=result.Begin(), pe=result.End(), pa=a.Begin();
+while(p<pe) {*p++ = b - *pa++;}
+return result;
+}
+
+template <class T>
+NDataBlock<T> operator * (const NDataBlock<T>& a, T b)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+return (result *= b);
+}
+
+template <class T>
+NDataBlock<T> operator * (T b, const NDataBlock<T>& a)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+return (result *= b);
+}
+
+template <class T>
+NDataBlock<T> operator / (const NDataBlock<T>& a, T b)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+return (result /= b);
+}
+
+template <class T>
+NDataBlock<T> operator / (T b, const NDataBlock<T>& a)
+{
+NDataBlock<T> result(a,false); result.SetTemp(true);
+T* p=result.Begin(), pe=result.End(), pa=a.Begin();
+while(p<pe) {*p++ = b / *pa++;}
+return result;
+}
+
+//**** Surcharge de +,-,*,/ : NDataBlock = NDataBlock+NDataBlock;
+
+template <class T>
+NDataBlock<T> operator + (const NDataBlock<T>& a, const NDataBlock<T>& b)
+{
+if(a.mSz!=b.mSz) throw(SzMismatchError("NDataBlock operator C=A+B size mismatch/null\n"));
+if(b.IsTemp()) {
+  NDataBlock<T> result(b,true); result.SetTemp(true);
+  return result += a;
+} else {
+  NDataBlock<T> result(a,false); result.SetTemp(true);
+  return result += b;
+}
+}
+
+template <class T>
+NDataBlock<T> operator * (const NDataBlock<T>& a, const NDataBlock<T>& b)
+{
+if(a.mSz!=b.mSz) throw(SzMismatchError("NDataBlock operator C=A*B size mismatch/null\n"));
+if(b.IsTemp()) {
+  NDataBlock<T> result(b,true); result.SetTemp(true);
+  return result *= a;
+} else {
+  NDataBlock<T> result(a,false); result.SetTemp(true);
+  return result *= b;
+}
+}
+
+template <class T>
+NDataBlock<T> operator - (const NDataBlock<T>& a, const NDataBlock<T>& b)
+{
+if(a.mSz!=b.mSz) throw(SzMismatchError("NDataBlock operator C=A-B size mismatch/null\n"));
+if(b.IsTemp()) {
+  NDataBlock<T> result(b,true); result.SetTemp(true);
+  T* p=result.Begin(), pe=result.End(), pa=a.Begin();
+  while(p<pe) {*p = *pa++  - *p; p++;}
+  return result;
+} else {
+  NDataBlock<T> result(a,false); result.SetTemp(true);
+  return result -= b;
+}
+}
+
+template <class T>
+NDataBlock<T> operator / (const NDataBlock<T>& a, const NDataBlock<T>& b)
+{
+if(a.mSz!=b.mSz) throw(SzMismatchError("NDataBlock operator C=A/B size mismatch/null\n"));
+if(b.IsTemp()) {
+  NDataBlock<T> result(b,true); result.SetTemp(true);
+  T* p=result.Begin(), pe=result.End(), pa=a.Begin();
+  while(p<pe) {*p = *pa++  / *p; p++;}
+  return result;
+} else {
+  NDataBlock<T> result(a,false); result.SetTemp(true);
+  return result /= b;
+}
+}
+
+
+
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template NDataBlock<uint_1>
+#pragma define_template NDataBlock<uint_2>
+#pragma define_template NDataBlock<int_2>
+#pragma define_template NDataBlock<int_4>
+#pragma define_template NDataBlock<int_8>
+#pragma define_template NDataBlock<uint_2>
+#pragma define_template NDataBlock<uint_4>
+#pragma define_template NDataBlock<uint_8>
+#pragma define_template NDataBlock<r_4>
+#pragma define_template NDataBlock<r_8>
+#pragma define_template NDataBlock<complex<float>>
+#pragma define_template NDataBlock<complex<double>>
+#endif
+
+#ifdef __GNU_TEMPLATES__
+template class NDataBlock<uint_1>;
+template class NDataBlock<uint_2>;
+template class NDataBlock<int_2>;
+template class NDataBlock<int_4>;
+template class NDataBlock<int_8>;
+template class NDataBlock<uint_2>;
+template class NDataBlock<uint_4>;
+template class NDataBlock<uint_8>;
+template class NDataBlock<r_4>;
+template class NDataBlock<r_8>;
+template class NDataBlock<complex<float>>;
+template class NDataBlock<complex<double>>;
+#endif
+
+#if defined(__ANSI_TEMPLATES__) 
+template class NDataBlock<uint_1>;
+template class NDataBlock<uint_2>;
+template class NDataBlock<int_2>;
+template class NDataBlock<int_4>;
+template class NDataBlock<int_8>;
+template class NDataBlock<uint_2>;
+template class NDataBlock<uint_4>;
+template class NDataBlock<uint_8>;
+template class NDataBlock<r_4>;
+template class NDataBlock<r_8>;
+template class NDataBlock<complex<float>>;
+template class NDataBlock<complex<double>>;
+#endif
+
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template template<class uint_1> NDataBlock<uint_1> operator + (const NDataBlock<uint_1>& a, uint_1 b);
+#endif
+
+#ifdef __GNU_TEMPLATES__
+#endif
+
+#if defined(__ANSI_TEMPLATES__) 
+#endif
Index: trunk/SophyaLib/BaseTools/ndatablock.h
===================================================================
--- trunk/SophyaLib/BaseTools/ndatablock.h	(revision 245)
+++ trunk/SophyaLib/BaseTools/ndatablock.h	(revision 245)
@@ -0,0 +1,92 @@
+#ifndef NDATABLOCK_H
+#define NDATABLOCK_H
+
+#include "machdefs.h"
+
+// Classe pour permettre de partager des donnees avec 
+// un autre systeme de gestion de references (ex avec Blitz)
+class Bridge {
+public:
+  Bridge() { } 
+  virtual ~Bridge() { }
+};
+
+
+template <class T>
+class NDataBlock {
+
+public:
+
+  // Creation / destruction
+  NDataBlock(size_t n);
+  NDataBlock(size_t n, T* data, Bridge* br=NULL);
+  NDataBlock();
+  NDataBlock(NDataBlock<T>& a);
+  NDataBlock(NDataBlock<T>& a,bool share);
+  virtual ~NDataBlock();
+
+  // Temporaire?
+  inline bool IsTemp(void)       {return mIsTemp;}
+  inline void SetTemp(bool temp) {mIsTemp=temp;}
+
+  // Gestion taille
+  void Clone(NDataBlock<T>& a);
+  void ReSize(size_t n);
+  
+  // Informations pointeur/data
+  inline T* Data()
+         {if(mSRef) return mSRef->data; else return NULL;}
+  inline size_t  Size() const    {return mSz;}
+  inline T& operator()(size_t i) {return mSRef->data+i;}
+
+  inline T*        Begin()        {return mSRef->data;}
+  inline T const*  Begin() const  {return mSRef->data;}
+  inline T*        End()          {return mSRef->data+mSz;}
+  inline T const*  End() const    {return mSRef->data+mSz;}
+
+  // Impression
+  void Print(size_t i1=0,size_t n=0);
+
+  // Surcharge d operateurs
+  NDataBlock<T>& operator = (const NDataBlock<T>& a);
+  NDataBlock<T>& operator = (T v);
+
+  NDataBlock<T>& operator += (T b);
+  NDataBlock<T>& operator -= (T b);
+  NDataBlock<T>& operator *= (T b);
+  NDataBlock<T>& operator /= (T b);
+
+  NDataBlock<T>& operator += (const NDataBlock<T>& a);
+  NDataBlock<T>& operator -= (const NDataBlock<T>& a);
+  NDataBlock<T>& operator *= (const NDataBlock<T>& a);
+  NDataBlock<T>& operator /= (const NDataBlock<T>& a);
+
+
+protected:
+
+  typedef struct {size_t nref; T* data; Bridge* bridge; } NDREF;
+
+  void Alloc(size_t n,T* data=NULL,Bridge* br=NULL);
+  void Share(NDataBlock<T>& a);
+  void Delete(void);
+
+  size_t   mSz;
+  NDREF*   mSRef;
+  bool     mIsTemp;
+};
+
+
+template<class T> NDataBlock<T> operator + (const NDataBlock<T>& a, T b);
+template<class T> NDataBlock<T> operator + (T b,const NDataBlock<T>& a);
+template<class T> NDataBlock<T> operator - (const NDataBlock<T>& a, T b);
+template<class T> NDataBlock<T> operator - (T b,const NDataBlock<T>& a);
+template<class T> NDataBlock<T> operator * (const NDataBlock<T>& a, T b);
+template<class T> NDataBlock<T> operator * (T b, const NDataBlock<T>& a);
+template<class T> NDataBlock<T> operator / (const NDataBlock<T>& a, T b);
+
+template<class T> NDataBlock<T> operator + (const NDataBlock<T>& a, const NDataBlock<T>& b);
+template<class T> NDataBlock<T> operator - (const NDataBlock<T>& a, const NDataBlock<T>& b);
+template<class T> NDataBlock<T> operator * (const NDataBlock<T>& a, const NDataBlock<T>& b);
+template<class T> NDataBlock<T> operator / (const NDataBlock<T>& a, const NDataBlock<T>& b);
+
+#endif
Index: trunk/SophyaLib/SysTools/psighand.cc
===================================================================
--- trunk/SophyaLib/SysTools/psighand.cc	(revision 244)
+++ trunk/SophyaLib/SysTools/psighand.cc	(revision 245)
@@ -118,5 +118,3 @@
     throw CaughtSignalExc("???");
   }
-
-return;
 }
