Index: trunk/SophyaPI/PIext/cxxexecutor.cc
===================================================================
--- trunk/SophyaPI/PIext/cxxexecutor.cc	(revision 1268)
+++ trunk/SophyaPI/PIext/cxxexecutor.cc	(revision 1269)
@@ -13,5 +13,5 @@
 CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */)
   : mUserCodeFn(""), mUserFctFn(""), mCompOpt(""), mLinkOpt(""), mMyLibs("")
-  , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx")
+  , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(1)
 {
 mIncList.resize(0);
@@ -121,9 +121,5 @@
     return(1);
   }
-  rc = FillUserCode(toks,0); if(rc) return(1);
-  rc = CrFile();   if(rc) return(1);
-  rc = Compile();  if(rc) return(1);
-  rc = Link();     if(rc) return(1);
-  rc = Call();     if(rc) return(1);
+  rc = ExecuteCXX(toks); if(rc) return(1);
 
 } else if(kw == "c++execfrf") {
@@ -132,7 +128,6 @@
     return(1);
   }
-  if(tokens.size()>1) rc = FillUserCode(tokens[0],tokens[1]);
-    else              rc = FillUserCode(tokens[0]);
-  if(rc) return(1);
+  rc = FillUserCode(tokens[0]); if(rc) return(1);
+  if(tokens.size()>1) rc = FillUserFctFrF(tokens[1]);
   rc = CrFile();   if(rc) return(1);
   rc = Compile();  if(rc) return(1);
@@ -158,7 +153,6 @@
     return(1);
   }
-  if(tokens.size()>3) rc = FillUserCode(tokens[2],tokens[3]);
-    else              rc = FillUserCode(tokens[2]);
-  if(rc) return(1);
+  rc = FillUserCode(tokens[2]); if(rc) return(1);
+  if(tokens.size()>3) FillUserFctFrF(tokens[3]);
   rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
 
@@ -199,4 +193,17 @@
 
 /* --Methode-- */
+int  CxxExecutor::ExecuteCXX(string usercode,string userfct)
+{
+int rc=0;
+rc = FillUserCode(usercode,0); if(rc) return(1);
+rc = FillUserFctFrS(userfct);
+rc = CrFile();   if(rc) return(1);
+rc = Compile();  if(rc) return(1);
+rc = Link();     if(rc) return(1);
+rc = Call();     if(rc) return(1);
+return 0;
+}
+
+/* --Methode-- */
 int CxxExecutor::CrFile(string cfilename,string func)
 {
@@ -216,5 +223,5 @@
 
 os<<"//-------------------------------------------------//"<<endl;
-os<<"//------------- Fonctions utilisateur -------------//"<<endl;
+os<<"//----------------- User Functions ----------------//"<<endl;
 os<<"//-------------------------------------------------//"<<endl;
 if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl;
@@ -239,8 +246,7 @@
 
 os<<"//--------------------------------------------//"<<endl;
-os<<"//------------- Code utilisateur -------------//"<<endl;
+os<<"//----------------- User Code ----------------//"<<endl;
 os<<"//--------------------------------------------//"<<endl;
-os<<endl;
-os<<"#include \""<<mUserCodeFn<<"\""<<endl;
+if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl;
 os<<endl;
 
@@ -248,6 +254,10 @@
 os<<"}"<<endl;
 
-cout<<"File "<<cfilename<<" for function "<<func<<" created"<<endl;
-cout<<"User code is in file "<<mUserCodeFn<<" included in "<<cfilename<<endl;
+if(mPrtLevel)
+  cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl;
+if(mPrtLevel && mUserCodeFn.size()>0)
+  cout<<"  User code was in file "<<mUserCodeFn<<endl;
+if(mPrtLevel && mUserFctFn.size()>0)
+  cout<<"  User function code was in file "<<mUserFctFn<<endl;
 return 0;
 }
@@ -364,5 +374,4 @@
 {
 mUserCodeFn = "";
-mUserFctFn  = "";
 
 // get the string part which is after word "first"
@@ -389,16 +398,43 @@
 if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
              <<mUserCodeFn<<endl;  mUserCodeFn = ""; return 1;}
-os<<" "<<code;
-cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
-return 0;
-}
-
-/* --Methode-- */
-int CxxExecutor::FillUserCode(string filename,string filefctname)
-// User code is read from "filename" an optionally from filefctname.
+os<<code<<endl;
+if(mPrtLevel)
+  cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
+return 0;
+}
+
+/* --Methode-- */
+int CxxExecutor::FillUserFctFrS(string userfct)
+// - Fill user Fonction code from string "userfct"
+// It is put into file "TmpDir/cxx_spiapp_fct.h".
+{
+mUserFctFn  = "";
+if(userfct.size()<1) return 0;
+mUserFctFn  = mDefTmp + mDefRoot + "_fct.h";
+ofstream os(mUserFctFn.c_str(),ios::out);
+if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open "
+             <<mUserFctFn<<endl;  mUserFctFn = ""; return 1;}
+os<<userfct<<endl;
+if(mPrtLevel)
+  cout<<"User Function code filled from standard input into "<<mUserFctFn<<endl;
+return 0;
+}
+
+/* --Methode-- */
+int CxxExecutor::FillUserCode(string filename)
+// User code is read from "filename".
 {
 mUserCodeFn = filename;
-mUserFctFn  = filefctname;
-cout<<"User code filled from file "<<filename<<endl;
+if(mPrtLevel && mUserCodeFn.size()>0)
+  cout<<"User code filled from file "<<mUserCodeFn<<endl;
+return 0;
+}
+
+/* --Methode-- */
+int CxxExecutor::FillUserFctFrF(string filefctname="")
+{
+mUserFctFn = filefctname;
+if(mPrtLevel && mUserFctFn.size()>0)
+  cout<<"User Function code filled from file "<<mUserFctFn<<endl;
 return 0;
 }
@@ -408,5 +444,5 @@
 {
 if(rootfilename.size()<1) rootfilename = mDefRoot;
-cout<<"Compile: "<<rootfilename<<endl;
+if(mPrtLevel) cout<<"Compile: "<<rootfilename<<endl;
 int rc = 0;
 rc = CrMakefile();
@@ -477,6 +513,6 @@
 string toks = libname + " " + func;
 int rc = mpiac->ExecuteCommand(key,arg,toks);
-cout<<"Link from "<<libname<<" for function "<<func
-    <<" (rc="<<rc<<")"<<endl;
+if(mPrtLevel) cout<<"Link from "<<libname<<" for function "<<func
+                 <<" (rc="<<rc<<")"<<endl;
 return 0;
 }
