Index: /branches/Reza/SophyaPI/DemoPIApp/Makefile
===================================================================
--- /branches/Reza/SophyaPI/DemoPIApp/Makefile	(revision 3421)
+++ /branches/Reza/SophyaPI/DemoPIApp/Makefile	(revision 3421)
@@ -0,0 +1,36 @@
+MODULEDECCXXFLAGS := -msg_quiet 
+include $(DPCBASEREP)/Include/MakefileUser.h
+LIBS = -L$(SLB) -lPI -lextsophya -lsophya -lm 
+
+ifeq ($(MACHEROS),OSF1)
+LIBS := $(LIBS) -lfor
+endif
+ifeq ($(MACHEROS),Linux)
+LIBS := $(LIBS) -ldl -lf2c
+endif
+
+%.so:$(OBJ)%.o 
+%:%.cc
+%:%.o
+%.o:%.cc
+%.o:%.c
+%:%.c
+
+.PRECIOUS: %.so  
+
+
+%:%.so
+	echo $@ " made (.so) "
+
+%.so:$(OBJ)%.o
+	$(LINK.cc) -shared -o $@ $< $(LIBS)
+
+$(OBJ)%.o:%.cc 
+	$(COMPILE.cc)  -o $@ $<
+
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -c $(CFLAGS)   $(USERFLAGS) -o $@ $< 
+
+dump :
+	echo $(LIBS)
+
Index: /branches/Reza/SophyaPI/DemoPIApp/demo.pic
===================================================================
--- /branches/Reza/SophyaPI/DemoPIApp/demo.pic	(revision 3421)
+++ /branches/Reza/SophyaPI/DemoPIApp/demo.pic	(revision 3421)
@@ -0,0 +1,21 @@
+#   macro de commande piapp -  Exemple de demo
+#  Mode Trace -> On 
+traceon
+#  Suppression de tous les objets existants
+delobjs *
+#  ouverture de fichier PPF
+openppf demo.ppf
+# affichage divers dans une fenetre graphique 2x2
+zone 2 2 
+#  Affichage d'histo 1D
+disp h1d blue
+#  Affichage d'histo 2D
+disp h2d 
+#  Trace de fonction
+func sin(x)/x 0.1 10. 200 gold
+#  Representation en surface d'une matrice
+surf mtx1 colbr32
+#  Trace des points 3d en utilisant une commande a la paw dans une fenetre
+n/plot nt31.z%y%x ! ! win
+#  Trace des points 3d avec des erreurs superpose au dessin precedant
+nt3d nt32 x y  z ex ey ez - - same,fcirclemarker7,red
Index: /branches/Reza/SophyaPI/DemoPIApp/exlink.pic
===================================================================
--- /branches/Reza/SophyaPI/DemoPIApp/exlink.pic	(revision 3421)
+++ /branches/Reza/SophyaPI/DemoPIApp/exlink.pic	(revision 3421)
@@ -0,0 +1,12 @@
+#  Exemple de fichier de commande pour linker et appeler une fonction user
+#  Appel a make pour construire le module
+shell gmake user.so
+#  Link de la fonction user ds user.so
+link user.so user
+#  L'appel a user cree un nouvel NTuple
+call user toto titi 
+print usernt
+#  On affiche quelque chose du NTuple sortant
+zone 1 
+plot2de usernt 5*x y ex ey  1. blue,fcirclemarker5 
+
Index: /branches/Reza/SophyaPI/DemoPIApp/exmod.pic
===================================================================
--- /branches/Reza/SophyaPI/DemoPIApp/exmod.pic	(revision 3421)
+++ /branches/Reza/SophyaPI/DemoPIApp/exmod.pic	(revision 3421)
@@ -0,0 +1,18 @@
+#  Exemple de macro de commandes pour charger un module
+# Mode trace
+traceon
+#  On passe une commande shell pour fabriquer le module
+shell gmake exmodule.so
+# On charge le module
+loadmodule exmodule.so exmodule
+#  Deux nouvelles commandes sont definies maintenant
+excmd1 
+excmd2
+
+#  On fabrique deux vecteurs
+zone 1 2
+newvec v1 20 sin(x)
+newvec v2 10 cos(x*0.2)+sin(x*0.2)
+#  Execution des commandes de exmodule
+excmd1 v1
+excmd2 v1 v2
Index: /branches/Reza/SophyaPI/DemoPIApp/exmodule.cc
===================================================================
--- /branches/Reza/SophyaPI/DemoPIApp/exmodule.cc	(revision 3421)
+++ /branches/Reza/SophyaPI/DemoPIApp/exmodule.cc	(revision 3421)
@@ -0,0 +1,106 @@
+#include "machdefs.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream.h>
+#include <math.h>
+
+#include <typeinfo>
+
+#include <vector>
+#include <string>
+
+#include "piacmd.h"
+#include "nobjmgr.h"
+#include "pistdimgapp.h"
+
+
+//  Exemple de module chargeable ds piapp 
+
+//  Declaration de la fonction d'activation et de desactivation du module
+extern "C" {
+void exmodule_init();
+void exmodule_end();
+}
+
+
+//  Une classe commande-executor, permettant d'enregistrer de 
+//  nouvelles commandes a piapp
+class exmoduleExecutor : public CmdExecutor {
+public:
+                exmoduleExecutor();
+  virtual       ~exmoduleExecutor();
+  // Execute s'occupe de l'execution effective des commandes
+  virtual int   Execute(string& keyw, vector<string>& args, string& toks);
+};
+
+/* --Methode-- */
+exmoduleExecutor::exmoduleExecutor()
+{
+
+PIACmd * mpiac;
+NamedObjMgr omg;
+mpiac = omg.GetImgApp()->CmdInterpreter();
+
+// On enregistre deux nouvelles commandes 
+string hgrp = "ExModuleCmd";
+// commande excmd1
+string kw = "excmd1";
+string usage = "exmd1: Appel Print pour obj1 \n" ;
+usage += "Usage: excmd1 obj1 ";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+// commande excmd2
+kw = "excmd2";
+usage = "exmd2: Appel Print pour obj1 et obj2 \n" ;
+usage += "Usage: excmd2 obj1 obj2";
+mpiac->RegisterCommand(kw, usage, this, hgrp);
+
+}
+
+/* --Methode-- */
+exmoduleExecutor::~exmoduleExecutor()
+{
+}
+
+/* --Methode-- */
+int exmoduleExecutor::Execute(string& kw, vector<string>& tokens, string&)
+{
+
+NamedObjMgr omg;
+if (kw == "excmd1") {
+  if (tokens.size() < 1) {
+    cout << "Usage: excmd1 obj1" << endl;
+    return(0);
+    }
+  omg.PrintObj(tokens[0]);
+  }
+else if (kw == "excmd2") {
+  if (tokens.size() < 2) {
+    cout << "Usage: excmd2 obj1 obj2" << endl;
+    return(0);
+    }
+  omg.PrintObj(tokens[0]);
+  omg.PrintObj(tokens[1]);
+  }
+
+return(0);
+
+}
+
+static exmoduleExecutor * piaerex = NULL;
+/* Nouvelle-Fonction */
+void exmodule_init()
+{
+// Fonction d'initialisation du module
+// Appele par le gestionnaire de modules de piapp (PIACmd::LoadModule())
+if (piaerex) delete piaerex;
+piaerex = new exmoduleExecutor;
+}
+
+/* Nouvelle-Fonction */
+void exmodule_end()
+{
+// Desactivation du module
+if (piaerex) delete piaerex;
+piaerex = NULL;
+}
+
Index: /branches/Reza/SophyaPI/DemoPIApp/user.cc
===================================================================
--- /branches/Reza/SophyaPI/DemoPIApp/user.cc	(revision 3421)
+++ /branches/Reza/SophyaPI/DemoPIApp/user.cc	(revision 3421)
@@ -0,0 +1,46 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <iostream.h>
+#include <string>
+
+#include "nobjmgr.h"
+
+#include "tvector.h"
+#include "histos.h"
+#include "histos2.h"
+#include "ntuple.h"
+
+#include "nbrandom.h"
+
+// ---------- Fonction pour link ds piapp -----------------
+// Exemple de fonction pouvant etre linke a piapp 
+// La fonction doit etre declare extern "C"
+extern "C" {
+  void user(vector<string>& args);
+}
+
+void user(vector<string>& args)
+{
+  // On instancie un objet NamedObjMgr
+  NamedObjMgr omg;
+  cout << " User Function user(...) nargs=" << args.size() << endl;
+
+  // On cree un NTuple et on le remplit
+  float xnt[4];
+  char *ntn[4] = {"x","y","ex","ey"};
+  int nent,i;
+  nent = 100;
+  NTuple* nt = new NTuple(4,ntn);  // Creation NTuple (AVEC new )
+  for(i=0; i<nent; i++) {
+    xnt[0] = i*50./nent; xnt[1] = 0.2*xnt[0]*xnt[0]+(NorRand()*xnt[0]/3.);
+    xnt[2] = 0.; xnt[3] = xnt[0]/3.;
+    nt->Fill(xnt);
+  }
+
+  // On ajoute le ntuple cree a la liste des objets geres par piapp
+  string nom = "usernt";
+  omg.AddObj(nt, nom);
+  return;
+}
+
Index: /branches/Reza/SophyaProg/Examples/Makefile
===================================================================
--- /branches/Reza/SophyaProg/Examples/Makefile	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/Makefile	(revision 3421)
@@ -0,0 +1,59 @@
+MODULECXXREPNAME := Tests
+MODULEDECCXXFLAGS := -msg_quiet
+include $(DPCDEVREP)/Include/Makefile.h
+
+
+ifdef NOSHLIB
+
+LIBF =  $(LIB)libSysTools.a $(LIB)libNTools.a $(LIB)libBlitz.a $(LIB)libFitsIOServer.a $(LIB)libPI.a $(LIB)libPIext.a 
+LIBS = -L$(LIB) -lPIext -lPI -lSysTools -lNTools -lBlitz  -lm
+#LIBS =  -L$(LIB) -lSysTools -lm
+ifeq ($(CXX),cxx)
+# librairie des instances de templates cxx
+LIBS := $(LIBS) -lrt
+endif
+
+else
+
+LIBF =  $(SLB)libsophya.so 
+LIBS = -L$(SLB) -lPI -lextsophya -lsophya -lm 
+ifeq ($(MACHEROS),OSF1)
+LIBS := $(LIBS) -lfor
+endif
+ifeq ($(MACHEROS),Linux)
+LIBS := $(LIBS) -ldl -lf2c
+endif
+
+endif
+
+LDLIBS := $(LIBS) $(LDLIBS) 
+
+%:%.cc
+%:%.o
+%.o:%.cc
+%.o:%.c
+%:%.c
+
+.PRECIOUS: $(EXE)% $(OBJ)%.o
+
+%:$(EXE)%
+	echo $@ " done"
+
+$(EXE)%:$(OBJ)%.o
+	$(LINK.cc)  -o $@ $< $(LIBS)
+
+$(OBJ)%.o:%.cc
+	$(COMPILE.cc)   $(USERFLAGS) -o $@ $<
+
+$(EXE)%:$(OBJ)%.cc
+	$(LINK.cc) $(USERFLAGS)  -o $@ $< $(LIBS) 
+
+$(EXE)%:$(OBJ)%.c
+	$(LINK.c)  $(USERFLAGS) -o $@ $< $(LIBS) 
+
+$(OBJ)%.o:%.c
+	$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $< 
+
+dump :
+	echo $(LIBS)
+
Index: /branches/Reza/SophyaProg/Examples/MyPPF/README
===================================================================
--- /branches/Reza/SophyaProg/Examples/MyPPF/README	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/MyPPF/README	(revision 3421)
@@ -0,0 +1,77 @@
+Example to illustrate how to make a class persistent
+using SOPHYA PPF services 
+-----------------------------------------------
+   (C) LAL-IN2P3/CNRS   (C) DAPNIA-SPP/CEA 
+               R. Ansari , 2007 
+-----------------------------------------------
+
+0/ Content : 
+   - vfs.h : Declaration of the Vfs class Vfs . This is the class 
+             which we want to make persistent using SOPHYA PPF services
+   - vfs.cc : the Vfs class implementation AND its PPF handler ObjFileIO<Vfs>
+   - tvfs.cc : the test main program
+   - makefile : compiles tvfs.cc and vfs.cc and links them to build tvfs
+
+
+1/ The class should inherit from the SOPHYA::AnyDataObj class. 
+   In the example here, we want to make the class Vfs persistent
+class Vfs : public SOPHYA::AnyDataObj {
+ ... 
+}
+
+2/ A PPF handler should be implemented . The PPF handler class 
+should inherit from SOPHYA::PPersist . The pure virtual methods 
+of PPersist class (DataObj() , SetDataObj() , ReadSelf(), WriteSelf()
+has to be implemented. 
+
+class PPFHandlerVfs : public SOPHYA::PPersist {
+public:
+  virtual SOPHYA::AnyDataObj* DataObj();
+  virtual void       SetDataObj(SOPHYA::AnyDataObj &);
+protected: 
+  virtual void       ReadSelf(SOPHYA::PInPersist&);
+  virtual void       WriteSelf(SOPHYA::POutPersist&) const;
+}
+
+
+It is possible to use the template class SOPHYA::ObjFileIO<T>, and 
+specialize it for the tharget class (here SOPHYA::ObjFileIO<Vfs>), 
+by defining the two methods :
+  SOPHYA::ObjFileIO<Vfs>::ReadSelf(SOPHYA::PInPersist&)
+  SOPHYA::ObjFileIO<Vfs>::WriteSelf(SOPHYA::POutPersist&) const
+
+3/ If it is NOT possible to have the target class inherit from AnyDataObj, 
+a wrapper class should be used. The same class can play the role of wrapper
+AND the PPF handler. 
+  (See the PPF handler / wrapper class for STL vectors :
+   SOPHYA::PPFWrapperSTLVector<T> in file BaseTools/ppfwrapstlv.h )
+
+
+4/ Implement the ReadSelf() and WriteSelf() methods of the PPF handler.
+All the I/O services from the following classes can be used : 
+  - PPFBinaryIOStrem , PPFBinaryInputStream , PInPersist
+  - PPFBinaryIOStrem , PPFBinaryOutputStream , POutPersist
+Writing and reading of the embeded objects for which a handler has been registered 
+can simply be performed by : 
+  POutPersist::PutObject()   PInPersist::GetObject()
+
+==> The services associated with nametags (PPFBinaryOutputStream::WriteNameTag() 
+    PPFBinaryInputStream::GotoNameTag() ... ) are NOT intented to be used in 
+    WriteSelf() , ReadSelf()
+
+
+5/ The new PPF handler, as well as the list of classes it can handle has to be
+registered prior to use PPF read/write for the target classes. This must be 
+performed during the initialization phase, for example at the beginning of the 
+main() program. Another possibility is to use a module initializer 
+(See SophyaInitiator class in file BaseTools/sophyainit.h ) 
+and declare a static instance of the class (Note that this works only if 
+the system loader handles correcly the call of constructor 
+for the statically declared objects)
+
+The registration can be performed using the CPP macros defined in BaseTools/ppersist.h
+
+  // First, register the PPF handler ObjFileIO<Vfs> 
+  PPRegister(ObjFileIO<Vfs>);
+  // Register the list of classes which can be handled by ObjFileIO<Vfs> 
+  DObjRegister(ObjFileIO<Vfs>, Vfs);
Index: /branches/Reza/SophyaProg/Examples/MyPPF/makefile
===================================================================
--- /branches/Reza/SophyaProg/Examples/MyPPF/makefile	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/MyPPF/makefile	(revision 3421)
@@ -0,0 +1,18 @@
+include $(SOPHYABASE)/include/sophyamake.inc
+
+all : tvfs
+
+clean :
+	rm -f tvfs tvfs.o vfs.o tvfs.ppf
+
+
+tvfs : tvfs.o vfs.o
+	$(CXXLINK) -o tvfs tvfs.o vfs.o $(SOPHYASLBLIST)
+
+tvfs.o : tvfs.cc
+	$(CXXCOMPILE) -o tvfs.o tvfs.cc
+
+vfs.o : vfs.cc
+	$(CXXCOMPILE) -o vfs.o vfs.cc
+
+
Index: /branches/Reza/SophyaProg/Examples/MyPPF/tvfs.cc
===================================================================
--- /branches/Reza/SophyaProg/Examples/MyPPF/tvfs.cc	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/MyPPF/tvfs.cc	(revision 3421)
@@ -0,0 +1,70 @@
+#include "machdefs.h"
+
+#include <iostream>
+
+#include "pexceptions.h"
+#include "vfs.h"
+
+//------------------------------------------------------
+// An example to illustrate how to make a class 
+//  persistent using the SOPHYA PPF services
+// (C) LAL-IN2P3/CNRS   (C) DAPNIA-SPP/CEA 
+// ----------------------------------------------------
+
+using namespace SOPHYA;   
+
+//--- The main program ----
+
+int main(int narg, char* arg[])
+{
+  
+  cout << " --------- tvfs.cc  test of class Vfs and ObjFileIO<Vfs>  ---------- "
+       << endl;
+  
+  // We have to register the PPersist handler for our class Vfs
+  // This should be performed at initialization
+  // The following two lines (CPP macros) do the job :
+
+  // First, register the PPF handler ObjFileIO<Vfs> 
+  PPRegister(ObjFileIO<Vfs>);
+  // Register the list of classes which can be handled by ObjFileIO<Vfs> 
+  DObjRegister(ObjFileIO<Vfs>, Vfs);
+
+
+  try {
+    Vfs xa(5);
+    xa.Set(0, 0., "Zero");
+    xa.Set(1, 1., "Un");
+    xa.Set(2, 2., "Deux");
+    xa.Set(3, 3., "Trois");
+    xa.Set(4, 4., "Quatre");
+    cout << xa ;
+    {
+    // We save our objet ito a POutPersist flow
+      POutPersist po("tvfs.ppf");
+      po << xa;
+    }
+    {
+    // We try to read in the saved Vfs xa object
+      Vfs xb;
+      cout << " Vfs xb before reading : \n " << xb << endl;
+      PInPersist pi("tvfs.ppf");
+      pi >> xb;
+      cout << " After reading pi >> xb : \n " << xb << endl;
+    }
+    
+  }
+
+  catch (PThrowable & pex) {
+    cerr << " tvfs.cc/Error - Exception catched " << (string)typeid(pex).name()
+	 << " - Msg= " << pex.Msg() << endl;
+  }
+  catch (...) {
+    cerr << " tx.cc/Error - Exception (...) catched " << endl;
+    }
+      
+  cout << " ----------- End of tx.cc  ------------- " << endl;
+
+  return(0);
+ 
+}
Index: /branches/Reza/SophyaProg/Examples/MyPPF/vfs.cc
===================================================================
--- /branches/Reza/SophyaProg/Examples/MyPPF/vfs.cc	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/MyPPF/vfs.cc	(revision 3421)
@@ -0,0 +1,95 @@
+#include "vfs.h"
+#include "pexceptions.h"
+#include "fiondblock.h"  // To use NDataBlock PPF services
+
+/* Vfs class constructor */
+Vfs::Vfs(int sz) 
+    : mFVal(sz)
+{
+  for(int k=0; k<sz; k++)
+    mSVal.push_back("");
+}
+
+void Vfs::Set(int k, r_4 fv, string const  sv)
+{
+  if ((k < 0) || (k>= (int)mFVal.Size())) 
+    throw SOPHYA::RangeCheckError("Vfs::Set() Out of range index!");
+  mFVal(k) = fv;
+  mSVal[k] = sv;  
+}
+
+r_4 Vfs::GetF(int k)
+{
+  if ((k < 0) || (k>= (int)mFVal.Size())) 
+    throw SOPHYA::RangeCheckError("Vfs::GetF() Out of range index!");
+  return mFVal(k);
+}
+
+string Vfs::GetS(int k)
+{
+  if ((k < 0) || (k>= (int)mFVal.Size())) 
+    throw SOPHYA::RangeCheckError("Vfs::GetS() Out of range index!");
+  return mSVal[k];
+}
+
+void Vfs::Print(ostream& os) const
+{
+  os << "Vfs::Print() - Size= " << mFVal.Size() << endl;
+  for(int k=0; k<(int)mFVal.Size(); k++)
+    os << "K=" << k << " FVal= " << mFVal(k) << " SVal=" << mSVal[k] << endl;
+  os << endl;  
+}
+
+//-----------------------------------------------------------------------
+//  The PPF handler : ObjFileIO<T> is in namespace SOPHYA , 
+//  We declare ObjFileIO<Vfs> in the SOPHYA namespace ...
+//  Only, the WriteSelf() and ReadSelf() methods have to be provided
+//-----------------------------------------------------------------------
+
+namespace SOPHYA {
+
+DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
+void ObjFileIO<Vfs>::WriteSelf(POutPersist& s) const
+{
+//  On ecrit 2 uint_4 .... 
+//  0: Numero de version,  2 : reserve
+  uint_4 itab[2];
+  itab[0] = 1;  // Numero de version a 1
+  itab[1] = 0;  // Reserved for future use
+  s.Put(itab, 2); 
+  s << dobj->mFVal;  // We write the float data block 
+// We write now the string vector , as a series of strings 
+  for(int k=0; k<(int)dobj->mFVal.Size(); k++)
+      s.PutStr(dobj->mSVal[k]);
+}
+
+DECL_TEMP_SPEC  /* equivalent a template <> , pour SGI-CC en particulier */
+void ObjFileIO<Vfs>::ReadSelf(PInPersist& s)
+{
+// We read in the same order as the write
+    // First the two integer containing the version numer
+  uint_4 itab[2];
+  s.Get(itab, 2); 
+// next, we read in the float data vector 
+  s >> dobj->mFVal;  
+// We resest the  vector<string> dobj->mSVal
+  dobj->mSVal.clear();
+// We read in the mFVal.Size() and keep them in dobj->mSVal
+  string buff; 
+  for(int k=0; k<(int)dobj->mFVal.Size(); k++) {
+    s.GetStr(buff);  
+    dobj->mSVal.push_back(buff);
+  }  
+}
+
+// We force the instanciation of the template class ObjFileIO<Vfs>
+#ifdef __CXX_PRAGMA_TEMPLATES__
+#pragma define_template ObjFileIO<Vfs>
+#endif
+
+#if defined(ANSI_TEMPLATES) || defined(GNU_TEMPLATES)
+template class ObjFileIO<Vfs>;
+#endif
+
+} // End of namespace SOPHYA 
+
Index: /branches/Reza/SophyaProg/Examples/MyPPF/vfs.h
===================================================================
--- /branches/Reza/SophyaProg/Examples/MyPPF/vfs.h	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/MyPPF/vfs.h	(revision 3421)
@@ -0,0 +1,58 @@
+#ifndef VFS_H_SEEN
+#define VFS_H_SEEN
+
+#include "machdefs.h"
+
+#include <string>
+#include <vector>
+
+#include "ndatablock.h"
+#include "objfio.h"
+
+//------------------------------------------------------
+// An example to illustrate how to make a class 
+//  persistent using the SOPHYA PPF services
+// (C) LAL-IN2P3/CNRS   (C) DAPNIA-SPP/CEA 
+// ----------------------------------------------------
+
+// A simple class to hold pairs(float, string)
+// we want to make this class persistent using SOPHYA PPF services
+
+class Vfs : public SOPHYA::AnyDataObj {
+public:
+// We need a default constructor , if we want to use the ObjFileIO<Vfs> class
+            Vfs(int sz=10);
+  virtual   ~Vfs() { };
+
+// Setting element k
+  void      Set(int k, r_4 fv, string const sv);
+// Accessing float part of element k
+  r_4       GetF(int k);
+// Accessing string part of element k
+  string    GetS(int k);
+// display/print object content
+  void      Print(ostream& os) const ; 
+//  For persistence handling
+  friend class SOPHYA::ObjFileIO<Vfs> ;
+ private:
+	  SOPHYA::NDataBlock<r_4> mFVal;
+	  vector<string> mSVal;	  	  
+};
+
+// For easy printing of Vfs through cout << x ;
+inline ostream& operator << (ostream& s, Vfs const & x)
+  {  x.Print(s);  return(s);  }
+
+/* Writes the object in the POutPersist stream  os */
+inline SOPHYA::POutPersist& operator << (SOPHYA::POutPersist& os, Vfs & obj)
+{ SOPHYA::ObjFileIO<Vfs> fio(&obj);  fio.Write(os);  return(os); }
+/* Reads the object from the PInPersist stream  is */
+inline SOPHYA::PInPersist& operator >> (SOPHYA::PInPersist& is, Vfs & obj)
+{ SOPHYA::ObjFileIO<Vfs> fio(&obj);  fio.Read(is);  return(is); }
+
+
+#endif
+
+
+
+
Index: /branches/Reza/SophyaProg/Examples/README
===================================================================
--- /branches/Reza/SophyaProg/Examples/README	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/README	(revision 3421)
@@ -0,0 +1,37 @@
+#   Programmes exemple pour l'utilisation de Sophya
+
+On suppose que $DPCBASREP/`uname`-$EROSCXX/Exec est ds le path et 
+  .:$DPCBASREP/`uname`-$EROSCXX/ShLibs ds LD_LIBRARY_PATH 
+
+1) ex1.cc 
+   Un programme simple utilisant SOPHYA
+   
+
+2) arr1.icc 
+   Un bout de code C++ utilisant SOPHYA, pouvant etre execute
+   par runcxx :
+   csh> runcxx -f arr1.icc 
+   OU 
+   csh> runcxx -tmpdir /tmp arr1.icc
+
+3) fft.icc et myf_fft.icc
+   Exemple de code C++ utilisant les transforme de Fourier de SOPHYA,
+   pouvant etre execute ds spiapp.
+
+4) sphylm.icc sphylm.h
+   Exemple d'utilisation des cartes 4Pi (SphericalMaps) et des 
+   transforme en harmonique spherique pouvant etre execute ds spiapp.
+
+
+
+   csh> spiapp   
+   (on peut definir la variable d'environnement TMPDIR avant l'appel
+    a spiapp )
+
+   Commandes a taper dans la fenetre de commande de (s)piapp :
+
+      Cmd> delobjs *
+      Cmd> c++execfrf fft.icc myf_fft.h
+      Cmd> delobjs *
+      Cmd> c++execfrf sphylm.icc sphylm.h
+
Index: /branches/Reza/SophyaProg/Examples/arr1.icc
===================================================================
--- /branches/Reza/SophyaProg/Examples/arr1.icc	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/arr1.icc	(revision 3421)
@@ -0,0 +1,19 @@
+// Fichier arr1.icc
+// Exemple d'utilisation de tableaux  
+// Appel: runcxx -f arr1.icc
+// Creation , remplissage d'une matrice
+  TMatrix<r_4> ma(7,9);
+  ma = RegularSequence(0.1, 0.05);   
+  cout << "\n arr1.icc: ma = " << ma << endl;
+  float min, max;
+// Utilisation des sous-tableaux
+  ma(Range(2,4), Range(4,7)) = M_PI;
+  cout << "\n Apres ma(Range(2,4), Range(4,7)) = " << ma << endl;
+// Appel de methodes
+  ma.MinMax(min, max);
+  cout << " MinMax(ma) : min= " << min << " max= " << max << endl;
+  TMatrix<r_4> sma = Sin(ma);
+  cout << "\n test pour runcxx - sma = Sin(ma)= " << sma << endl;
+  sma.MinMax(min, max);
+  cout << " MinMax(sma) : min= " << min << " max= " << max << endl;
+
Index: /branches/Reza/SophyaProg/Examples/ex1.cc
===================================================================
--- /branches/Reza/SophyaProg/Examples/ex1.cc	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/ex1.cc	(revision 3421)
@@ -0,0 +1,77 @@
+#include "dvlist.h"
+#include "ndatablock.h"
+#include "fiondblock.h"
+#include "sophyainit.h"
+
+
+int main(int narg, char* arg[])
+{
+
+  // We handle exception at the high level
+  try {
+  // This macro initialize the library
+  // static objects handle this - However, not all loader call
+  // the constructor for static objects
+  SophyaInit();
+
+  // using a DVList object
+  cout << " Creating and using DVList and NDataBlock<T> " << endl;
+  DVList dvl;
+  dvl["A"] = 12;
+  dvl["bs"] = "hello";
+
+  // Using a datablock object with 66 integers
+  NDataBlock<int_4> idb(66);
+  // We initialize all values with the value 15
+  idb = 15;
+
+  // Using a datablock object with 40 float
+  NDataBlock<r_4> rdb(40);
+  // We initialize all values with the value 3.14
+  rdb = 3.14;
+
+  // Writing (serialiazing) objects into POutPersist streams
+  cout << " Writing objects in POutPersist streams " << endl;
+      {  
+      POutPersist so1("t11.ppf");
+      so1 << dvl;
+      POutPersist so2("t12.ppf");
+      string nom = "idb";
+      so2.PutObject(idb, nom);
+      nom = "rdb";
+      so2.PutObject(rdb, nom);
+      }
+
+  // Reading objects from PInPersist streams
+  cout << " reading objects from PInPersist streams " << endl;
+      {
+      PInPersist si1("t11.ppf");
+      DVList dvlr;
+      si1 >> dvlr;
+      cout << dvlr;     // Print on the standard output
+      PInPersist si2("t12.ppf");
+      string nom = "rdb";
+      NDataBlock<r_4> rrdb;
+      si2.GetObject(rrdb, nom);
+      cout << rrdb;     // Print on the standard output
+      NDataBlock<int_4> ridb;
+      nom = "idb";
+      si2.GetObject(ridb, nom);
+      cout << ridb;     // Print on the standard output
+      si2.GetObject(ridb, nom);      
+      }
+
+  // Opening an non existing file for reading generates an exception
+  cout << " Generating an exception ... " << endl;
+  PInPersist si("zz.zz");
+
+  }
+  catch (PThrowable & exc) {
+    cerr << " Catched Exception " << (string)typeid(exc).name() 
+	 << " - Msg= " << exc.Msg() << endl;
+  }
+  catch (...) {
+    cerr << " some other exception was caught ! " << endl;
+  }
+}
+
Index: /branches/Reza/SophyaProg/Examples/fft.icc
===================================================================
--- /branches/Reza/SophyaProg/Examples/fft.icc	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/fft.icc	(revision 3421)
@@ -0,0 +1,20 @@
+TVector<r_8> in(4048);
+TVector<r_8> noise(4048);
+TVector< complex<r_8> > out;
+in = RegularSequence(0., 0.05);
+noise = RandomSequence(RandomSequence::Gaussian, 0., 4.);
+MathArray<r_8> ma;
+ma.ApplyFunctionInPlace(in, myf);
+in += noise;
+FFTPackServer FFTServ;
+cout << " Calling FFT " << endl;
+FFTServ.FFTForward(in, out); 
+ExecuteCommand("zone 1 2");
+KeepObj(in);
+DisplayObj(in, "");
+// KeepObj(out);
+DisplayObj(out, "red");
+
+
+
+
Index: /branches/Reza/SophyaProg/Examples/myf_fft.h
===================================================================
--- /branches/Reza/SophyaProg/Examples/myf_fft.h	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/myf_fft.h	(revision 3421)
@@ -0,0 +1,7 @@
+inline double myf(double x)
+{
+return(3*sin(0.2*x)+4*cos(x)+5*sin(4*x+0.25) +3.5*cos(9*x+0.45) + 0.05*x);
+}
+
+
+
Index: /branches/Reza/SophyaProg/Examples/sphylm.h
===================================================================
--- /branches/Reza/SophyaProg/Examples/sphylm.h	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/sphylm.h	(revision 3421)
@@ -0,0 +1,2 @@
+#include "skymap.h"
+#include "samba.h"
Index: /branches/Reza/SophyaProg/Examples/sphylm.icc
===================================================================
--- /branches/Reza/SophyaProg/Examples/sphylm.icc	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/sphylm.icc	(revision 3421)
@@ -0,0 +1,46 @@
+// Generate input spectra  a + b* l + c * gaussienne(l, 50, 20)
+int lmax = 92;
+Vector clin(lmax);
+for(int l=0; l<lmax; l++) {
+  double xx = (l-50.)/10.;
+  clin(l) = 1.e-2 -1.e-4*l + 0.1*exp(-xx*xx);
+}
+
+// Compute map from spectra
+SphericalTransformServer<r_8> ylmserver;
+int m = 128;  // HealPix pixelisation parameter
+SphereHEALPix<r_8> map(m);
+ylmserver.GenerateFromCl(map, m,  clin, 0.);
+// Compute power spectrum from map
+Vector clout = ylmserver.DecomposeToCl(map, lmax,  0.);
+
+// Copy the synthetised map
+SphereHEALPix<r_8> mapdip;
+mapdip = map;
+
+// Define the dipole direction
+double thetadipole = 1.2;
+double phidipole = 0.3;
+UnitVector vd(thetadipole, phidipole);
+UnitVector vc(thetadipole, phidipole);
+
+// Add a dipole component to the map
+for(int i=0; i<mapdip.NbPixels(); i++) {  // Boucle sur les pixels
+  double Thetar,Phir;
+  mapdip.PixThetaPhi(i,Thetar,Phir);  // direction du pixel      
+  vc.SetThetaPhi(Thetar,  Phir);      
+  mapdip(i) += 5.*vd.Psc(vc);  // Produit scalaire 
+}
+
+// Compute the new map power spectrum 
+Vector cldip = ylmserver.DecomposeToCl(mapdip, lmax,  0.);
+
+// Display objects (kept automatically through Display)
+ExecuteCommand("zone 1 2");
+DisplayObj(map, " ");
+DisplayObj(mapdip, " ");
+DisplayObj(clin, "win");
+DisplayObj(clout, "same,red,fcirclemarker5,defline");
+KeepObj(cldip);
+
+
Index: /branches/Reza/SophyaProg/Examples/tvm.icc
===================================================================
--- /branches/Reza/SophyaProg/Examples/tvm.icc	(revision 3421)
+++ /branches/Reza/SophyaProg/Examples/tvm.icc	(revision 3421)
@@ -0,0 +1,7 @@
+Vector v1(5);
+v1 = 12.;
+Vector v2(5);
+v2 = 14;
+Matrix m = v2*v1.Transpose();
+cout << m;
+KeepObj(m);
