source: Sophya/trunk/SophyaPI/PIext/basexecut.cc@ 3588

Last change on this file since 3588 was 3588, checked in by ansari, 17 years ago

Declaration HelpGroup Expr.Plotting mal placee, Reza 05/03/2009

File size: 53.5 KB
RevLine 
[2615]1#include "sopnamsp.h"
[293]2#include "piacmd.h"
3
4#include <stdio.h>
5#include <stdlib.h>
6#include <math.h>
7
8#include "basexecut.h"
9
10#include "pdlmgr.h"
11#include "ctimer.h"
[2263]12#include "strutilxx.h"
[293]13
14#include "pistdimgapp.h"
15#include "nobjmgr.h"
[326]16#include "servnobjm.h"
[2305]17#include "nomgadapter.h"
[293]18
19#include "histos.h"
20#include "histos2.h"
21#include "hisprof.h"
22#include "ntuple.h"
23#include "generaldata.h"
[2792]24#include "datatable.h"
[769]25
26#include "tvector.h"
[293]27
28
29/* --Methode-- */
30PIABaseExecutor::PIABaseExecutor(PIACmd* piac, NamedObjMgr* omg, PIStdImgApp* app)
31{
32mpiac = piac;
33mObjMgr = omg;
34mImgApp = app;
[312]35dynlink = NULL;
[1276]36dynlink2 = NULL;
[293]37RegisterCommands();
38}
39
40PIABaseExecutor::~PIABaseExecutor()
41{
[1276]42 if (dynlink) delete dynlink;
43 if (dynlink2) delete dynlink2;
[293]44}
45
46
[2755]47
[293]48/* --Methode-- */
[1268]49int PIABaseExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
[293]50{
[333]51Services2NObjMgr* srvo = mObjMgr->GetServiceObj();
[293]52// >>>>> Chargement de modules
[2307]53if (kw == "loadmodule") {
[293]54 if (tokens.size() < 2) { cout << "Usage: loadmodule fnameso modulename" << endl; return(0); }
55 mpiac->LoadModule(tokens[0], tokens[1]);
56 }
[349]57
[293]58// >>>>>>>>>>> Link dynamique de fonctions C++
59else if (kw == "link" ) {
60 if (tokens.size() < 2) { cout << "Usage: link fnameso f1 [f2 f3]" << endl; return(0); }
61 string sph = "";
62 for(int gg=0; gg<5; gg++) tokens.push_back(sph);
63 int rc = LinkUserFuncs(tokens[0], tokens[1], tokens[2], tokens[3]);
64 if (rc == 0) cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl;
65}
[1276]66else if (kw == "linkff2" ) {
67 if (tokens.size() < 2) { cout << "Usage: linkff2 fnameso f1 [f2 f3]" << endl; return(0); }
68 string sph = "";
69 for(int gg=0; gg<5; gg++) tokens.push_back(sph);
70 int rc = LinkUserFuncs2(tokens[0], tokens[1], tokens[2], tokens[3]);
71 if (rc == 0) cout << "PIABaseExecutor: Link2 from " << tokens[0] << " OK " << endl;
72}
[293]73else if (kw == "call" ) {
74 if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl; return(0); }
[1276]75 UsFmap::iterator it;
76 UsFmap::iterator it1 = usfmap.find(tokens[0]);
77 UsFmap::iterator it2 = usfmap2.find(tokens[0]);
78 if ((it1 == usfmap.end()) && (it2 == usfmap2.end()) ) {
[293]79 cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl;
80 return(0);
81 }
[1276]82 if (it1 == usfmap.end()) it = it2;
83 else it = it1;
[293]84 cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl;
85// on est oblige de faire un cast etant donne qu'on
86// utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
87 DlUserProcFunction fuf = (DlUserProcFunction)(*it).second;
[2494]88/*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004
[293]89// On redirige la sortie sur le terminal
90 bool red = mImgApp->HasRedirectedStdOutErr();
91 mImgApp->RedirectStdOutErr(false);
[2494]92 --------DEL */
[1276]93 try {
94 tokens.erase(tokens.begin());
95 fuf(tokens);
[2944]96 return(0);
[1276]97 }
98 catch ( PThrowable & exc ) {
99 cerr << "\n PIABaseExecutor: Call / Catched Exception :"
100 << (string)typeid(exc).name() << " Msg= "
101 << exc.Msg() << endl;
[2944]102 return(-77);
[1276]103 }
104 catch ( ... ) {
105 cerr << "\n PIABaseExecutor: Call / Catched Exception ... "
106 << endl;
[2944]107 return(-79);
[1276]108 }
[2494]109/*DEL----- Plus besoin en multi-thread ? / Reza 06/01/2004
[293]110 mImgApp->RedirectStdOutErr(red);
[2494]111 --------DEL */
[293]112}
113
114else if (kw == "openppf" ) {
[3423]115 if (tokens.size()<1) {
116 cout<<"Usage: openppf [-s] file [objname1 objname2 ...]"<<endl;
117 return(0);
118 }
119 else if (tokens.size()==1) // read all objects at nametags
120 mObjMgr->ReadAll(tokens[0],true);
121 else {
122 if (tokens[0] == "-s") // Read all objects sequentially
123 mObjMgr->ReadAll(tokens[1],false);
124 else mObjMgr->ReadObj(tokens); // read specified objects
125 }
[293]126}
[2132]127else if ((kw == "saveobjs") || (kw == "saveppf")) {
[333]128 if (tokens.size() < 2) { cout << "Usage: saveobjs patt filename " << endl; return(0); }
129 mObjMgr->SaveObjects(tokens[0], tokens[1]);
130}
[2669]131else if (kw == "savelist") {
132 if (tokens.size() < 2) {
133 cout << "Usage: savelist objname1 [objname2 ...] filename "<<endl;
134 return(0);
135 }
136 mObjMgr->SaveListObjects(tokens);
137}
[293]138else if (kw == "saveall" ) {
139 if (tokens.size() < 1) { cout << "Usage: saveall file " << endl; return(0); }
140 mObjMgr->SaveAll(tokens[0]);
141}
142else if (kw == "print" ) {
[2975]143 if (tokens.size() < 1) { cout << "Usage: print nameobj [prtlev]" << endl; return(0); }
144 int lev = 0;
145 if (tokens.size()>1) lev = atoi(tokens[1].c_str());
146 mObjMgr->PrintObj(tokens[0], lev);
[293]147}
[333]148else if ( (kw == "rename" ) || (kw == "mv") ) {
[2132]149 if (tokens.size() < 2) { cout << "Usage: rename/mv nameobj namenew" << endl; return(0); }
[293]150 mObjMgr->RenameObj(tokens[0], tokens[1]);
151}
[333]152else if ( (kw == "del" ) || (kw == "rm") ) {
[1655]153 if (tokens.size() < 1) { cout << "Usage: del nameobj [nameobj2 ...]" << endl; return(0); }
154 if (tokens.size()>0)
155 for(uint_4 i=0;i<tokens.size();i++) mObjMgr->DelObj(tokens[i]);
[293]156}
157else if (kw == "delobjs" ) {
158 if (tokens.size() < 1) { cout << "Usage: delobjs nomobjpattern (*,?) " << endl; return(0); }
159 mObjMgr->DelObjects(tokens[0]);
160}
[333]161else if ( (kw == "listobjs") || (kw == "ls") ) {
[331]162 if (tokens.size() < 1) tokens.push_back("*");
[2519]163 if (tokens.size() < 2) mObjMgr->ListObjs(tokens[0]);
164 else {
165 vector<string> olv;
166 mObjMgr->GetObjList(tokens[0], olv);
167 mpiac->SetVar(tokens[1], olv);
168 }
[331]169}
[2519]170
[333]171// Gestion des repertoires
172else if (kw == "mkdir" ) {
[344]173 if (tokens.size() < 1) { cout << "Usage: mkdir dirname [true]" << endl; return(0); }
174 bool crd = mObjMgr->CreateDir(tokens[0]);
175 if ( crd && (tokens.size() > 1) && (tokens[1] == "true") )
176 mObjMgr->SetKeepOldDirAtt(tokens[0], true);
[333]177 }
178else if (kw == "rmdir" ) {
179 if (tokens.size() < 1) { cout << "Usage: rmdir dirname " << endl; return(0); }
180 mObjMgr->DeleteDir(tokens[0]);
181 }
[2132]182else if (kw == "setdiratt" ) {
183 if (tokens.size() < 2) { cout << "Usage: setdiratt dirname true/false" << endl; return(0); }
184 if (tokens[1] == "true") mObjMgr->SetKeepOldDirAtt(tokens[0], true);
185 else mObjMgr->SetKeepOldDirAtt(tokens[0], false);
186}
[333]187else if (kw == "cd") {
188 if (tokens.size() < 1) tokens.push_back("home");
189 mObjMgr->SetCurrentDir(tokens[0]);
190 }
[345]191else if (kw == "pwd") {
192 string dirn;
193 mObjMgr->GetCurrentDir(dirn);
194 cout << "CurrentDirectory: " << dirn << endl;
195 }
[333]196else if (kw == "listdirs") {
197 if (tokens.size() < 1) tokens.push_back("*");
198 mObjMgr->ListDirs(tokens[0]);
199 }
[293]200
201// >>>>>>>>>>> Creation d'histos 1D-2D
202else if (kw == "newh1d") {
203 if (tokens.size() < 4) { cout << "Usage: newh1d name xmin xmax nbin" << endl; return(0); }
[1091]204 int_4 nbx = 100;
205 r_8 xmin = 0., xmax = 1.;
[293]206 nbx = atoi(tokens[3].c_str());
207 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
208 Histo* h = new Histo(xmin, xmax, nbx);
209 mObjMgr->AddObj(h, tokens[0]);
210 }
211else if (kw == "newh2d") {
212 if (tokens.size() < 7) {
213 cout << "Usage: newh2d name xmin xmax nbinx ymin ymax nbiny" << endl;
214 return(0);
215 }
[1091]216 int_4 nbx = 50, nby = 50;
217 r_8 xmin = 0., xmax = 1.;
218 r_8 ymin = 0., ymax = 1.;
[293]219 nbx = atoi(tokens[3].c_str());
220 nby = atoi(tokens[6].c_str());
221 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
222 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
223 Histo2D* h = new Histo2D(xmin, xmax, nbx, ymin, ymax, nby);
224 mObjMgr->AddObj(h, tokens[0]);
225 }
[1035]226else if (kw == "newprof" || kw == "newprofe") {
[293]227 if (tokens.size() < 4)
[1035]228 { cout << "Usage: newprof[e] name xmin xmax nbin [ymin ymax]" << endl; return(0); }
[1091]229 int_4 nbx = 100;
230 r_8 xmin = 0., xmax = 1., ymin = 1., ymax = -1.;
[293]231 if(tokens.size() > 5)
232 {ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());}
233 nbx = atoi(tokens[3].c_str());
234 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
235 HProf* h = new HProf(xmin, xmax, nbx, ymin, ymax);
[1035]236 if(kw == "newprofe") h->SetErrOpt(false);
[293]237 mObjMgr->AddObj(h, tokens[0]);
238 }
[447]239
240// Creation de NTuple
241else if (kw == "newnt") {
242 if(tokens.size() < 2)
243 {cout<<"Usage: newnt name v1 v2 ... vn / newnt name nvar"<<endl; return(0);}
244 vector<string> varname;
245 int nvar = 0;
246 const char *c = tokens[1].c_str();
247 if(isdigit(c[0])) {
248 nvar = atoi(tokens[1].c_str());
249 if(nvar<=0 || nvar>=10000)
250 {cout<<"newnt name nvar : nvar must be an positive integer<10000"<<endl;
251 return(0);}
252 for(int i=0;i<nvar;i++) {
253 char str[16]; sprintf(str,"%d",i);
254 string dum = "v"; dum += str;
255 varname.push_back(dum.c_str());
256 }
257 } else if( islower(c[0]) || isupper(c[0]) ) {
[1548]258 for(int i=1;i<(int)tokens.size();i++) {
[447]259 varname.push_back(tokens[i].c_str());
260 nvar++;
261 }
262 } else {
263 cout<<"newnt name v1 v2 ... vn : name vi must begin by a letter"<<endl
264 <<"newnt name nvar : nvar must be an positive integer"<<endl;
265 return(0);
266 }
267 char **noms = new char*[nvar];
268 for(int i=0;i<nvar;i++) noms[i] = (char *)varname[i].c_str();
269 NTuple* nt = new NTuple(nvar,noms);
270 delete [] noms;
271 mObjMgr->AddObj(nt,tokens[0]);
272 }
273
[2792]274// Creation de DataTable
275else if (kw == "newdt") {
276 if(tokens.size() < 2)
277 {cout<<"Usage: newdt name v1:t1 v2:t2 ... vn:tn / newdt name nvar"<<endl; return(0);}
278 DataTable* dt = new DataTable();
279 const char *c = tokens[1].c_str();
280 if(isdigit(c[0])) {
281 int n = atoi(tokens[1].c_str());
282 if(n<=0 || n>=10000) {
283 cout<<"newdt name nvar : nvar="<<n<<" must be an positive integer<10000"<<endl;
284 delete dt; return(0);
285 }
286 for(int i=0;i<n;i++) {
287 char str[16]; sprintf(str,"v%d",i);
288 dt->AddDoubleColumn(str);
289 }
290 } else {
291 for(int i=1;i<tokens.size();i++) {
292 string vname = tokens[i];
293 uint_4 p = tokens[i].find(':');
294 if(p<tokens[i].size()) vname = vname.substr(0,p);
295 if(vname.size()<1) {
296 cout<<"Zero size name for variable: tokens["<<i<<"]="<<tokens[i]<<endl;
297 delete dt; return(0);
298 }
299 if (tokens[i].find(":r4")<tokens[i].size()) dt->AddFloatColumn(vname);
300 else if(tokens[i].find(":r8")<tokens[i].size()) dt->AddDoubleColumn(vname);
301 else if(tokens[i].find(":i4")<tokens[i].size()) dt->AddIntegerColumn(vname);
302 else if(tokens[i].find(":i8")<tokens[i].size()) dt->AddLongColumn(vname);
303 else if(tokens[i].find(":s") <tokens[i].size()) dt->AddStringColumn(vname);
304 else dt->AddDoubleColumn(vname);
305 }
306 }
307 mObjMgr->AddObj(dt,tokens[0]);
308}
309
[447]310// Creation de GeneralFitData
[293]311else if (kw == "newgfd") {
312 if (tokens.size() < 3)
313 { cout << "Usage: newgfd nvar nalloc [errx(0/1)]" << endl; return(0); }
314 int nvar, nalloc, errx=0;
315 if (tokens.size() > 3)
316 { errx = atoi(tokens[3].c_str()); if(errx>0) errx=1; else errx = 0;}
317 nvar = atoi(tokens[1].c_str()); nalloc = atoi(tokens[2].c_str());
318 if(nvar>0 && nalloc>0) {
319 GeneralFitData* gfd = new GeneralFitData(nvar,nalloc,errx);
320 mObjMgr->AddObj(gfd, tokens[0]);
321 }
322 }
323
[333]324// Creation/remplissage de vecteur et de matrice
325else if (kw == "newvec") {
326 if (tokens.size() < 2) {
327 cout << "Usage: newvec name size [f(i) dopt] " << endl; return(0);
328 }
329 int n = atoi(tokens[1].c_str());
330 double xmin, xmax;
331 xmin = 0.; xmax = n;
[357]332 if (tokens.size() < 3) {
333 Vector* v = new Vector(n);
334 mObjMgr->AddObj(v, tokens[0]);
335 }
336 else {
337 if (tokens.size() < 4) tokens.push_back("");
338 mObjMgr->GetServiceObj()->PlotFunc(tokens[2], tokens[0], xmin, xmax, n, tokens[3]);
339 }
[333]340 }
341else if (kw == "newmtx") {
342 if (tokens.size() < 3) {
[1917]343 cout << "Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) dopt] " << endl; return(0);
[333]344 }
345 int nx = atoi(tokens[1].c_str());
346 int ny = atoi(tokens[2].c_str());
347 double xmin, xmax, ymin, ymax;
348 xmin = 0.; xmax = nx;
349 ymin = 0.; ymax = ny;
[357]350 if (tokens.size() < 4) {
351 Matrix* mtx = new Matrix(ny,nx);
352 mObjMgr->AddObj(mtx, tokens[0]);
353 }
354 else {
[1971]355 if (tokens.size() < 5) tokens.push_back("next");
[357]356 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[3], tokens[0], xmin, xmax, ymin, ymax,
357 nx, ny, tokens[4]);
358 }
[333]359 }
[2305]360// ----- Vecteur/NTuple <> Lignes/variables interpreteur
361// Creation de vecteur depuis le contenu de la ligne
362else if (kw == "line2vec") {
363 if (tokens.size() < 2) {
364 cout << "Usage: line2vec vecname v0 v1 v2 ... " << endl; return(0);
365 }
366 int vsz = tokens.size()-1;
367 Vector* v = new Vector(vsz);
368 for(int kkv=0; kkv<vsz; kkv++) (*v)(kkv) = atof(tokens[kkv+1].c_str());
369 mObjMgr->AddObj(v, tokens[0]);
370 }
371// Remplissage de NTuple depuis la ligne
372else if (kw == "line2nt") {
373 if (tokens.size() < 2) {
374 cout << "Usage: line2nt ntname col0 col1 ..." << endl; return(0);
375 }
376 AnyDataObj* obj;
377 obj = mObjMgr->GetObj(tokens[0]);
378 if(obj == NULL) {
379 cerr << "line2nt Error , No such object " << tokens[0] << endl;
380 return(0);
381 }
382 NTuple* nt = dynamic_cast<NTuple *>(obj);
383 if(nt == NULL) {
384 cerr << "line2nt Error " << tokens[0] << " not an NTuple ! " << endl;
385 return(0);
386 }
387 if (nt->NbColumns() < 1) {
388 cerr << "line2nt Error: NbColumns < 1" << endl;
389 return(0);
390 }
391 r_4* xnt = new r_4[ nt->NbColumns() ];
392 int kkx;
393 for(kkx=0; kkx<nt->NbColumns(); kkx++) {
394 if (kkx < tokens.size()-1) xnt[kkx] = atof(tokens[kkx+1].c_str());
395 else xnt[kkx] = 0.;
396 }
397 nt->Fill(xnt);
398 delete[] xnt;
399}
400// Contenu du vecteur vers variable interpreteur
401#define MAXNWORDSO2V 32768
402else if (kw == "vec2var") {
403 if (tokens.size() < 2) {
404 cout << "Usage: vec2var vecname varname [loop_param start:end:step] " << endl; return(0);
405 }
406 AnyDataObj* obj;
407 obj = mObjMgr->GetObj(tokens[0]);
408 if(obj == NULL) {
409 cerr << "vec2var Error , No such object " << tokens[0] << endl;
410 return(0);
411 }
412 Vector* v = dynamic_cast<Vector *>(obj);
413 if(v == NULL) {
414 cerr << "vec2var Error " << tokens[0] << " not a Vector ! " << endl;
415 return(0);
416 }
[2419]417 int_8 kks = 0;
418 int_8 kke = v->NElts();
419 int_8 kkp = 1;
[2305]420 if (tokens.size() > 2) Services2NObjMgr::DecodeLoopParameters(tokens[2], kks, kke, kkp);
421 if (kks < 0) kks = 0;
[2419]422 if (kke > (int_8)v->NElts()) kke = v->NElts();
[2305]423 if (kkp < 1) kkp = 1;
424 int nelt = (kke-kks-1)/kkp;
425 if (nelt > MAXNWORDSO2V) {
426 nelt = MAXNWORDSO2V;
427 cout << "vec2var Warning: Only " << nelt
428 << " elements will be converted to string" << endl;
429 kke = kks+nelt*kkp;
430 }
431 string v2str;
432 char buff[64];
433 for(int kkv=kks; kkv<kke; kkv+=kkp) {
434 sprintf(buff, "%lg ", (*v)(kkv));
435 v2str += buff;
436 }
437
[2999]438 mpiac->SetVar(tokens[1], v2str);
[2305]439}
440// Une ligne du NTuple/NTupleInterface -> variable interpreteur
441else if ((kw == "ntline2var") || (kw == "ntcol2var")) {
442 if (tokens.size() < 3) {
443 cout << "Usage: ntline/col2var objname line_number varname" << endl;
444 return(0);
445 }
446 NObjMgrAdapter* oa = mObjMgr->GetObjAdapter(tokens[0]);
447 if(oa == NULL) {
448 cerr << "ntline/col2var Error , No such object " << tokens[0] << endl;
449 return(0);
450 }
451 bool adel = false;
452 NTupleInterface* nti = oa->GetNTupleInterface(adel);
453 if(nti == NULL) {
454 cerr << "ntline/col2var Error: objet" << tokens[0] << " has no NTupleInterface" << endl;
455 return(0);
456 }
[333]457
[2305]458 if (nti->NbColumns() < 1 || nti->NbLines() < 1) {
459 cerr << "ntline/col2var Error: NbColumns or NbLines < 1" << endl;
460 return(0);
461 }
462 string v2str;
463 char buff[64];
464 if (kw == "ntline2var") {
465 int numline = atoi(tokens[1].c_str());
466 if ( (numline >= nti->NbLines()) || (numline < 0) ) {
467 cerr << "ntline2var Error: numline" << tokens[1] << " out of bounds" << endl;
468 return(0);
469 }
470 r_8* dline = nti->GetLineD(numline);
471 for(int kkv=0; kkv<nti->NbColumns(); kkv++) {
472 sprintf(buff, "%lg ", dline[kkv]);
473 v2str += buff;
474 }
475 }
476 else {
477 int numcol = atoi(tokens[1].c_str());
478 if ( (numcol >= nti->NbColumns()) || (numcol < 0) ) {
479 cerr << "ntcol2var Error: numcol" << tokens[1] << " out of bounds" << endl;
480 return(0);
481 }
[2419]482 int_8 kks = 0;
483 int_8 kke = nti->NbLines();
484 int_8 kkp = 1;
[2305]485 if (tokens.size() > 3) Services2NObjMgr::DecodeLoopParameters(tokens[3], kks, kke, kkp);
486 if (kks < 0) kks = 0;
[2419]487 if (kke > (int_8)nti->NbLines()) kke = nti->NbLines();
[2305]488 if (kkp < 1) kkp = 1;
489 int nelt = (kke-kks-1)/kkp;
490 if (nelt > MAXNWORDSO2V) {
491 nelt = MAXNWORDSO2V;
492 cout << "ntcol2var Warning: Only " << nelt
493 << " lines " << " will be converted to string" << endl;
494 kke = kks+nelt*kkp;
495 }
496 r_8* dline;
497 for(int kkl=kks; kkl<kke; kkl+=kkp) {
498 dline = nti->GetLineD(kkl);
499 sprintf(buff, "%lg ", dline[numcol]);
500 v2str += buff;
501 }
502 }
[2999]503 mpiac->SetVar(tokens[2], v2str);
[2305]504 if (adel) delete nti;
505}
[2999]506// Operation sur objets a travers l'adaptateur NObjMgrAdapter::PerformOperation()
507else if (kw == "objaoper") {
508 if (tokens.size() < 2) {
509 cout << "Usage: objaoper objname operation [args ...]" << endl;
510 return(0);
511 }
512 NObjMgrAdapter* oa = mObjMgr->GetObjAdapter(tokens[0]);
513 if(oa == NULL) {
514 cerr << "objaoper Error , No such object " << tokens[0] << endl;
515 return(0);
516 }
517 tokens.erase(tokens.begin());
518 return oa->PerformOperation(tokens);
519}
[2305]520
521// -------------------------------------------------------
[455]522// Copie d'objets
[2176]523else if ( (kw == "copy") || (kw == "cp") ) {
[455]524 if(tokens.size()<2) {
525 cout<<"Usage: copy name_from name_to"<<endl;return(0);
526 }
[463]527 mObjMgr->CopyObj(tokens[0],tokens[1]);
[455]528}
529
530
[293]531// >>>>>>>>>>> Trace de fonctions
532else if ( (kw == "func") ) {
[1938]533 if(tokens.size()<3) {cout<<"Usage: func f(x) xmin xmax [npt opt]"<<endl; return(0);}
534 int np = 100;
535 double xmin=0., xmax=1.;
536 string opt = "", nom = "";
537 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
538 if (tokens.size() > 3) np = atoi(tokens[3].c_str());
[293]539 if (tokens.size() > 4) opt = tokens[4];
[333]540 mObjMgr->GetServiceObj()->PlotFunc(tokens[0], nom, xmin, xmax, np, opt);
[293]541 }
[326]542else if ( (kw == "funcff") ) {
[1938]543 if (tokens.size()<4) {cout<<"Usage: funcff C-filename f(x)-name xmin xmax [npt opt]"<<endl; return(0);}
544 int np = 100;
545 double xmin=0., xmax=1.;
546 string opt = "", nom = "";
547 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
548 if(tokens.size()>4) np = atoi(tokens[4].c_str());
549 if(tokens.size()>5) opt = tokens[5];
[333]550 mObjMgr->GetServiceObj()->PlotFuncFrCFile(tokens[0], tokens[1], nom, xmin, xmax, np, opt);
[326]551 }
[293]552else if ( (kw == "func2d") ) {
553 if (tokens.size() < 7) {
[357]554 cout << "Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [opt]" << endl;
[293]555 return(0);
556 }
557 int npx, npy;
[333]558 double xmin, xmax;
559 double ymin, ymax;
[293]560 npx = npy = 50;
561 xmin = 0.; xmax = 1.;
562 ymin = 0.; ymax = 1.;
563 npx = atoi(tokens[3].c_str());
564 npy = atoi(tokens[6].c_str());
565 xmin = atof(tokens[1].c_str()); xmax = atof(tokens[2].c_str());
566 ymin = atof(tokens[4].c_str()); ymax = atof(tokens[5].c_str());
[357]567 string opt = "";
[293]568 if (tokens.size() > 7) opt = tokens[7];
[333]569 string nom = "";
570 mObjMgr->GetServiceObj()->PlotFunc2D(tokens[0], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
[293]571 }
[326]572else if ( (kw == "func2dff") ) {
573 if (tokens.size() < 8) {
[357]574 cout << "Usage: func2d C-filename F(x,y)-name xmax nptx ymin ymax npty [opt]" << endl;
[326]575 return(0);
576 }
577 int npx, npy;
[333]578 double xmin, xmax;
579 double ymin, ymax;
[326]580 npx = npy = 50;
581 xmin = 0.; xmax = 1.;
582 ymin = 0.; ymax = 1.;
583 npx = atoi(tokens[4].c_str());
584 npy = atoi(tokens[7].c_str());
585 xmin = atof(tokens[2].c_str()); xmax = atof(tokens[3].c_str());
586 ymin = atof(tokens[5].c_str()); ymax = atof(tokens[6].c_str());
[357]587 string opt = "";
[326]588 if (tokens.size() > 8) opt = tokens[8];
[333]589 string nom = "";
590 mObjMgr->GetServiceObj()->PlotFunc2DFrCFile(tokens[0], tokens[1], nom, xmin, xmax, ymin, ymax, npx, npy, opt);
[326]591 }
[293]592
593// >>>>>>>>>>> Trace d'expressions de N_Tuple, StarList, etc ...
594else if (kw == "plot2d" ) {
[357]595 if (tokens.size() < 3) {
596 cout << "Usage: plot2d nameobj expx expy [expcut opt loop_par]" << endl;
[293]597 return(0);
598 }
[357]599 string errx = ""; string erry = "";
600 if (tokens.size() < 4) tokens.push_back("1");
601 while (tokens.size() < 6) tokens.push_back("");
602 srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],errx,erry,tokens[3],tokens[4],tokens[5]);
603 }
604
605else if (kw == "plot2de" ) { // Plot2D avec les erreurs
606 if (tokens.size() < 5) {
607 cout << "Usage: plot2de nameobj expx expy experrx experry [expcut opt loop_par]" << endl;
608 return(0);
[293]609 }
[357]610 if (tokens.size() < 6) tokens.push_back("1");
611 while (tokens.size() < 8) tokens.push_back("");
612 srvo->DisplayPoints2D(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4],
613 tokens[5],tokens[6],tokens[7]);
[293]614 }
615
[3279]616else if ((kw == "plot2dw")||(kw == "plot2dc")) { // Plot2d avec poids
[357]617 if (tokens.size() < 4) {
[3279]618 cout << "Usage: plot2dw/c nomobj expx expy expwt/expcolidx [expcut opt loop_par]" << endl;
[333]619 return(0);
620 }
[357]621 if (tokens.size() < 5) tokens.push_back("1");
622 while (tokens.size() < 7) tokens.push_back("");
[3279]623 bool fgcolidx = false;
624 if (kw == "plot2dc") fgcolidx = true;
625 srvo->DisplayPoints2DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4],
626 fgcolidx, tokens[5], tokens[6]);
[333]627 }
[357]628else if (kw == "plot3d" ) {
629 if (tokens.size() < 4) {
630 cout << "Usage: plot3d nomobj expx expy expz [expcut opt loop_par]" << endl;
[293]631 return(0);
632 }
[357]633 if (tokens.size() < 5) tokens.push_back("1");
634 while (tokens.size() < 7) tokens.push_back("");
635 srvo->DisplayPoints3D(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6]);
[293]636 }
[2999]637else if (kw == "plot3dw" ) {
638 if (tokens.size() < 5) {
639 cout << "Usage: plot3dw nomobj expx expy expz expwt [expcut opt loop_par]" << endl;
640 return(0);
641 }
642 if (tokens.size() < 6) tokens.push_back("1");
643 while (tokens.size() < 8) tokens.push_back("");
644 srvo->DisplayPoints3DW(tokens[0],tokens[1],tokens[2],tokens[3], tokens[4], tokens[5],
645 tokens[6], tokens[7]);
646}
[293]647
648else if (kw == "projh1d" ) {
[357]649 if (tokens.size() < 3) {
650 cout << "Usage: projh1d nomh1 nomobj expx [expwt expcut opt loop_par]" << endl;
[293]651 return(0);
652 }
[357]653 if (tokens.size() < 4) tokens.push_back("1.");
654 if (tokens.size() < 5) tokens.push_back("1");
655 while (tokens.size() < 7) tokens.push_back("");
656 srvo->ProjectH1(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
[293]657 }
658
[357]659
660// Projection dans histogrammes
[293]661else if (kw == "projh2d" ) {
[357]662 if (tokens.size() < 4) {
663 cout << "Usage: projh2d nomh2 nomobj expx expy [expwt expcut opt loop_par]" << endl;
[293]664 return(0);
665 }
[357]666 if (tokens.size() < 5) tokens.push_back("1.");
667 if (tokens.size() < 6) tokens.push_back("1");
668 while (tokens.size() < 8) tokens.push_back("");
669 srvo->ProjectH2(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
670 tokens[6], tokens[7] );
[293]671 }
672
673else if (kw == "projprof" ) {
[357]674 if (tokens.size() < 4) {
675 cout << "Usage: projprof nomprof nomobj expx expy [expwt expcut opt loop_par]" << endl;
[293]676 return(0);
677 }
[357]678 if (tokens.size() < 5) tokens.push_back("1.");
679 if (tokens.size() < 6) tokens.push_back("1");
680 while (tokens.size() < 8) tokens.push_back("");
681 srvo->ProjectHProf(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
[1091]682 tokens[6], tokens[7] );
[357]683 }
[293]684
[357]685// Projection dans vector/matrix
686else if (kw == "fillvec" ) {
687 if (tokens.size() < 4) {
688 cout << "Usage: fillvec nomvec nomobj expx expv [expcut opt loop_par]" << endl;
689 return(0);
690 }
691 if (tokens.size() < 5) tokens.push_back("1");
692 while (tokens.size() < 7) tokens.push_back("");
693 srvo->FillVect(tokens[1], tokens[2], tokens[3], tokens[4], tokens[0], tokens[5], tokens[6] );
[293]694 }
695
[357]696else if (kw == "fillmtx" ) {
697 if (tokens.size() < 5) {
698 cout << "Usage: fillmtx nommtx nomobj expx expy expv [expcut opt loop_par]" << endl;
699 return(0);
700 }
701 if (tokens.size() < 6) tokens.push_back("1");
702 while (tokens.size() < 8) tokens.push_back("");
703 srvo->FillMatx(tokens[1], tokens[2], tokens[3], tokens[4], tokens[5], tokens[0],
704 tokens[6], tokens[7] );
705 }
706
707// Remplissage NTuple,Vecteurs, ... , boucle de NTuple
[447]708else if (kw == "ntfrascii" ) {
709 if(tokens.size() < 2) {
710 cout<<"Usage: ntfrascii nt_name file_name [def_init_val]"<<endl;
711 return(0);
712 }
713 double def_val = 0.;
714 if(tokens.size()>=3) def_val = atof(tokens[2].c_str());
715 srvo->NtFromASCIIFile(tokens[0],tokens[1],def_val);
716 }
717
[2263]718/* Lecture matrice/vecteur depuis fichier ASCII */
719else if ((kw == "mtxfrascii") || (kw == "vecfrascii") ) {
720 if(tokens.size() < 2) {
[2289]721 cout<<"Usage: mtxfrascii/vecfrascii mtx/vec_name file_name [CommLine Separator]"<<endl;
[2263]722 return(0);
723 }
724 TMatrix<r_8> mtx;
725 TVector<r_8> vec;
726 FILE* fip = fopen(tokens[1].c_str(), "r");
727 if (fip == NULL) {
728 cout << "vec/mtxfrascii: can not open file " << tokens[1] << endl;
729 return(0);
730 }
731 fclose(fip);
732 ifstream is(tokens[1].c_str());
733 sa_size_t nr, nc;
[2289]734 char clm = '#';
735 string sep = " \t";
736 if (tokens.size()>2) clm = tokens[2][0];
737 if (tokens.size()>3) sep = tokens[3];
[2263]738 if (kw == "mtxfrascii") {
[2289]739 mtx.ReadASCII(is, nr, nc, clm, sep.c_str());
[2263]740 mObjMgr->AddObj(mtx, tokens[0]);
741 cout << "mtxfrascii: TMatrix<r_8> " << tokens[0] << " read from file "
742 << tokens[1] << endl;
743 }
744 else {
[2289]745 vec.ReadASCII(is, nr, nc, clm, sep.c_str());
[2263]746 mObjMgr->AddObj(vec, tokens[0]);
747 cout << "vecfrascii: TVector<r_8> " << tokens[0] << " read from file "
748 << tokens[1] << endl;
749 }
750}
[2268]751else if (kw == "arrtoascii") {
752 if(tokens.size() < 2) {
753 cout<<"Usage: arrtoascii array_name file_name "<<endl;
754 return(0);
755 }
756
757 AnyDataObj* obj;
758 obj = mObjMgr->GetObj(tokens[0]);
759 if(obj == NULL) {
760 cerr << "arrtoascii Error , No such object " << tokens[0] << endl;
761 return(0);
762 }
763 BaseArray* ba = dynamic_cast<BaseArray *>(obj);
764 if(ba == NULL) {
765 cerr << "arrtoascii Error " << tokens[0] << " not a BaseArray ! " << endl;
766 return(0);
767 }
768 ofstream os(tokens[1].c_str());
769 ba->WriteASCII(os);
770 cout << "arrtoascii: Array " << tokens[0] << " written to file " << tokens[1] << endl;
771}
772
[2263]773
[293]774else if (kw == "fillnt" ) {
[357]775 if (tokens.size() < 5) {
776 cout << "Usage: fillnt nameobj expx expy expz expt [expcut ntname loop_par]" << endl;
[293]777 return(0);
778 }
[357]779 while (tokens.size() < 8) tokens.push_back("");
780 srvo->FillNT(tokens[0],tokens[1],tokens[2], tokens[3], tokens[4], tokens[5], tokens[6], tokens[7] );
[293]781 }
782
[333]783else if (kw == "ntloop" ) {
784 if (tokens.size() < 3) {
[357]785 cout << "Usage: ntloop nameobj fname funcname [ntname loop_par ]" << endl;
[333]786 return(0);
787 }
[357]788 while (tokens.size() < 5) tokens.push_back("");
789 srvo->FillNTFrCFile(tokens[0],tokens[1], tokens[2], tokens[3], tokens[4]);
[333]790 }
791
792else if (kw == "ntexpcfile" ) {
793 if (tokens.size() < 3) {
794 cout << "Usage: ntexpcfile nameobj fname funcname" << endl;
795 return(0);
796 }
797 srvo->PrepareNTExpressionCFile(tokens[0],tokens[1], tokens[2]);
798 }
799
[2922]800else if (kw == "expmeansig" ) {
801 if (tokens.size() < 2) {
802 cout << "Usage: expmeansig nameobj expx [expcut loop_par]" << endl;
803 return(0);
804 }
805 while (tokens.size() < 4) tokens.push_back("");
806 string dummy = "";
807 cout << " expmeansig: computing mean/sigma + min/max for " << tokens[0]
808 << "." << tokens[1] << endl;
809 srvo->ExpressionToVector(tokens[0],tokens[1],tokens[2],dummy,dummy,tokens[3]);
810 }
811
[357]812else if (kw == "exptovec" ) {
813 if (tokens.size() < 3) {
814 cout << "Usage: exptovec nomvec nameobj expx [expcut opt loop_par]" << endl;
[293]815 return(0);
816 }
[357]817 while (tokens.size() < 6) tokens.push_back("");
818 srvo->ExpressionToVector(tokens[1],tokens[2],tokens[3],tokens[0],tokens[4],tokens[5]);
[293]819 }
820
821else if (kw == "fillgd1" ) {
822 if (tokens.size() < 5) {
[357]823 cout << "Usage: fillgd1 nomgfd nomobj expx expy experry [expcut loop_par] " << endl;
[293]824 return(0);
825 }
[357]826 if (tokens.size() < 6) tokens.push_back("1");
827 if (tokens.size() < 7) tokens.push_back("");
[293]828 string expy = "";
[357]829 srvo->FillGFD(tokens[1],tokens[2], expy, tokens[3], tokens[4], tokens[5], tokens[0]);
[293]830 }
831
832else if (kw == "fillgd2" ) {
833 if (tokens.size() < 6) {
[357]834 cout << "Usage: fillgd2 nomgfd nomobj expx expy expz experrz [expcut loop_par]" << endl;
[293]835 return(0);
836 }
[357]837 if (tokens.size() < 7) tokens.push_back("1");
838 if (tokens.size() < 8) tokens.push_back("");
839 srvo->FillGFD(tokens[1],tokens[2],tokens[3], tokens[4], tokens[5], tokens[6], tokens[0], tokens[7]);
[293]840 }
841
[1067]842else if (kw == "gdfrvec" ) {
843 if(tokens.size()<3) {
844 cout<<"Usage: gdfrvec namegfd X Y\n"
845 <<" gdfrvec namegfd X Y"
846 <<" gdfrvec namegfd X Y ! EY\n"
847 <<" gdfrvec namegfd X Y Z\n"
848 <<" gdfrvec namegfd X Y Z EZ"<<endl;
849 return(0);
850 }
851 while(tokens.size()<5) tokens.push_back("!");
852 srvo->FillGFDfrVec(tokens[0],tokens[1],tokens[2],tokens[3],tokens[4]);
853 }
[293]854
[2180]855// >>>>>>>>>>> Calcul d'expression arithmetique
856else if ( (kw == "eval") ) {
857 if(tokens.size()<2)
858 {cout<<"Usage: eval resultvarname arithmetic expression...."<<endl; return(0);}
859 string expval = "";
860 for(unsigned int i=1;i<tokens.size();i++) expval+=tokens[i];
861 string resultvarname = "";
862 if(isalpha(tokens[0][0])) resultvarname=tokens[0];
863 mObjMgr->GetServiceObj()->ExpVal(expval,resultvarname);
864 }
[293]865
866else {
867 cerr << "PIABaseExecutor::Do() Erreur - Commande " << kw << " inconuue ! " << endl;
868 return(-1);
869 }
870
871return(0);
872}
873
[2755]874/* --Methode-- */
875bool PIABaseExecutor::IsThreadable(string const & keyw)
876{
877 if ( (keyw == "fillvec") || (keyw == "fillmtx") ||
878 (keyw == "fillnt") || (keyw == "ntloop") ) return true;
879 else if (keyw.substr(0,4) == "func") return true;
880 else {
881 string skw = keyw.substr(0,5);
882 if ( (skw == "plot2") || (skw == "plot3") || (skw == "projh") ) return true;
883 }
884 return false;
885}
886
[388]887
[293]888/* --Methode-- */
889void PIABaseExecutor::RegisterCommands()
890{
[3551]891string kw, usage, grp, gdesc;
[2781]892//--------- Commandes du groupe modules externes
[3551]893
[2465]894grp = "External Modules";
[3551]895gdesc = "Dynmamic shared library load (DLL) and external (add-on) module management";
[2465]896mpiac->AddHelpGroup(grp, gdesc);
[3551]897
[293]898kw = "loadmodule";
899usage = "To load and initialize modules \n Usage: loadmodule fnameso modulename";
900usage += "\n Related commands: link";
[2465]901mpiac->RegisterCommand(kw, usage, this, grp);
[293]902kw = "link";
903usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]";
904usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
[1276]905usage += "\n Related commands: call loadmodule linkff2";
[2465]906mpiac->RegisterCommand(kw, usage, this, grp);
[1276]907kw = "linkff2";
908usage = "Dynamic linking of compiled user functions (Set 2)\n Usage: linkff2 fnameso f1 [f2 f3]";
909usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names ";
910usage += "\n Related commands: call link loadmodule";
[2465]911mpiac->RegisterCommand(kw, usage, this, grp);
[293]912kw = "call";
913usage = "Dynamically linked user function call \n Usage: call userf [arg1 arg2 ...]";
914usage += "\n User function : f(vector<string>& args)";
915usage += "\n Related commands: link";
[2465]916mpiac->RegisterCommand(kw, usage, this, grp);
[293]917
918kw = "openppf";
[3423]919usage = "Reads all or some objects from a PPF file";
920usage += "\n Usage: (1) openppf filename ";
921usage += "\n Or (2) openppf -s filename (2)";
922usage += "\n Or (3) openppf filename objname1 [ objname2 ...]";
923usage += "\n The first form reads all objects at NameTags,";
924usage += "\n or all objects if the file has no NameTags.";
925usage += "\n The third reads only the objects with the specified nametags";
926usage += "\n Related commands: saveppf saveall savelist";
[330]927mpiac->RegisterCommand(kw, usage, this, "FileIO");
[2132]928kw = "saveppf";
929usage = "Saves objects with names matching a pattern into a\n";
930usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
931usage += "Usage: saveppf nameobjpattern filename";
[2933]932usage += "\n Related commands: saveobjs savelist saveall openppf";
[2132]933mpiac->RegisterCommand(kw, usage, this, "FileIO");
[333]934kw = "saveobjs";
[2132]935usage = "Saves objects with names matching a pattern into a\n";
936usage += " PPF file (pattern: x?y*) - Alias saveppf\n";
[1068]937usage += "Usage: saveobjs nameobjpattern filename";
[2933]938usage += "\n Related commands: saveppf savelist saveall openppf ";
[333]939mpiac->RegisterCommand(kw, usage, this, "FileIO");
[293]940kw = "saveall";
941usage = "Saves all objects into a PPF file \n Usage: saveall filename";
[2933]942usage += "\n Related commands: saveobj savelist openppf";
[2669]943mpiac->RegisterCommand(kw, usage, this, "FileIO");
944kw = "savelist";
945usage = "Saves a list of objects into a PPF file";
946usage = "\n Usage: savelist objname1 [objname2 ...] filename";
[2933]947usage += "\n Related commands: saveobj openppf";
[330]948mpiac->RegisterCommand(kw, usage, this, "FileIO");
[449]949kw = "ntfrascii";
[2792]950usage = "Fills an existing NTuple or DataTable from ASCII table file";
[449]951usage += "\n Usage: ntfrascii nt_name file_name [def_init_val]";
952usage += "\n Related commands: ntloop fillnt ";
953mpiac->RegisterCommand(kw, usage, this, "FileIO");
[2263]954kw = "mtxfrascii";
955usage = "Reads a matrix from an ASCII file (TMatrix<r_8>)";
[2289]956usage += "\n Usage: mtxfrascii mtx_name file_name [CommChar Separator]";
[2268]957usage += "\n Related commands: arrtoascii vecfrascii ntfrascii ";
[2263]958mpiac->RegisterCommand(kw, usage, this, "FileIO");
959kw = "vecfrascii";
[2268]960usage = "Reads a vector from an ASCII file (TVector<r_8>)";
[2263]961usage += "\n Usage: vecfrascii vec_name file_name";
[2289]962usage += "\n Related commands: arrtoascii mtxfrascii ntfrascii [CommChar Separator]";
[2263]963mpiac->RegisterCommand(kw, usage, this, "FileIO");
[2268]964kw = "arrtoascii";
965usage = "Writes an array (TArray<T>) to an ASCII file ";
966usage += "\n Usage: arrtoascii array_name file_name";
967usage += "\n Related commands: mtxfrascii vecfrascii ntfrascii ";
968mpiac->RegisterCommand(kw, usage, this, "FileIO");
[293]969
970kw = "print";
[2975]971usage = "Prints an object \n Usage: print nameobj [prtlev]";
972usage += "\n prtlev = 0,1,2... default: prtlev=0";
[330]973mpiac->RegisterCommand(kw, usage, this, "FileIO");
[293]974
[2781]975//------- Commandes gestion de repertoires et d'objets
[333]976kw = "mkdir";
977usage = "Create a directory";
[344]978usage += "\n Usage: mkdir dirname [true]";
979usage += "\n if second argument==true, the directory's KeepOld attribute is set to true";
[463]980mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]981kw = "rmdir";
982usage = "Removes an empty directory";
983usage += "\n Usage: remove dirname";
[463]984mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]985kw = "setdiratt";
986usage = "Sets directory attributes";
987usage += "\n Usage: setdiratt dirname KeepOldFlag(=true/false)";
988usage += "\n KeepOldFlag=true Object with the same name is moved to old";
989usage += "\n when adding objects";
990mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]991kw = "cd";
992usage = "Change current directory";
993usage += "\n Usage: cd [dirname]";
[463]994mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]995kw = "pwd";
996usage = "Prints current directory";
997usage += "\n Usage: pwd";
[463]998mpiac->RegisterCommand(kw, usage, this, "Object Management");
[333]999kw = "listdirs";
1000usage = "Prints the list of directories";
1001usage += "\n Usage: listdirs [patt=*] \n patt : * , ? ";
[463]1002mpiac->RegisterCommand(kw, usage, this, "Object Management");
[295]1003kw = "listobjs";
[333]1004usage = "Prints the list of objects (Alias: ls)";
[3423]1005usage += "\n Usage: listobjs [patt=*] ";
1006usage += "\n Or listobjs patt VarName ";
[3428]1007usage += "\n Obj. name pattern patt in the form abc?x* or /*/x?y ... ";
[463]1008mpiac->RegisterCommand(kw, usage, this, "Object Management");
[3428]1009kw = "ls";
1010usage = " Alias for listobjs ";
1011usage += "\n Usage: ls [patt=*] [VarName]";
1012mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]1013kw = "rename";
[333]1014usage = "Rename an object (Alias: mv) \n Usage: rename nameobj namenew";
[2132]1015usage += "\n Related commands: mv del delobjs";
[463]1016mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]1017kw = "mv";
1018usage = "Rename an object (Alias: rename) \n Usage: mv nameobj namenew";
1019usage += "\n Related commands: rename del delobjs";
1020mpiac->RegisterCommand(kw, usage, this, "Object Management");
[463]1021kw = "copy";
[2132]1022usage = "Copy objects (Alias cp) \n";
[463]1023usage +=" Usage: copy name_from name_to";
[2132]1024usage += "\n Related commands: cp new...";
[2176]1025mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]1026kw = "cp";
1027usage = "Copy objects (Alias copy) \n";
1028usage +=" Usage: cp name_from name_to";
1029usage += "\n Related commands: copy new...";
[463]1030mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]1031kw = "del";
[1655]1032usage = "Deletes an object (Alias: rm) \n Usage: del nameobj [nameobj2 ...]";
[2132]1033usage += "\n Related commands: rm delobjs rename";
[463]1034mpiac->RegisterCommand(kw, usage, this, "Object Management");
[2132]1035kw = "rm";
1036usage = "Deletes an object (Alias: del) \n Usage: rm nameobj [nameobj2 ...]";
1037usage += "\n Related commands: del delobjs rename";
1038mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]1039kw = "delobjs";
1040usage = "Delete a set of objects with names matching a pattern (x?y*)";
1041usage += "\n Usage: delobjs nameobjpattern \n";
1042usage += "\n Related commands: del rename";
[463]1043mpiac->RegisterCommand(kw, usage, this, "Object Management");
[293]1044
[2781]1045//------- Commandes creation/manipulation d'objets
[293]1046kw = "newh1d";
1047usage = "Creates a 1D histogramm \n Usage: newh1d name xmin xmax nbin";
[2792]1048usage += "\n Related commands: newh2d newprof[e] newdt newnt newgfd ";
[333]1049mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1050kw = "newh2d";
1051usage = "Creates a 2D histogramm \n Usage: newh2d name xmin xmax nbinx ymin ymax nbiny";
[2792]1052usage += "\n Related commands: newh1d newprof[e] newdt newnt newgfd ";
[333]1053mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1054kw = "newprof";
1055usage = "Creates a profile histogramm \n Usage: newprof name xmin xmax nbin [ymin ymax]";
[1035]1056usage += "\n Errors represent the data spread in the X bin ";
[2792]1057usage += "\n Related commands: newh1d newh2d newprofe newdt newnt newgfd ";
[333]1058mpiac->RegisterCommand(kw, usage, this, "Objects");
[1035]1059kw = "newprofe";
1060usage = "Creates a profile histogramm \n Usage: newprofe name xmin xmax nbin [ymin ymax]";
1061usage += "\n Errors represent the error on the data mean in the X bin ";
[2792]1062usage += "\n Related commands: newh1d newh2d newprof newdt newnt newgfd ";
[1035]1063mpiac->RegisterCommand(kw, usage, this, "Objects");
[447]1064kw = "newnt";
1065usage = "Creates a ntuple \n Usage: newnt name v1 v2 v3 .. vn";
1066usage += "\n newnt name nvar";
[2792]1067usage += "\n Related commands: newdt newh1d newh2d newprof[e] newgfd ";
[447]1068mpiac->RegisterCommand(kw, usage, this, "Objects");
[2792]1069kw = "newdt";
1070usage = "Creates a datatable \n Usage: newdt name v1:t1 v2:t2 v3:t3 .. vn:tn";
1071usage += "\n newdt name nvar";
1072usage += "\n vi : variable name";
1073usage += "\n ti : variable type";
1074usage += "\n r8,r4 for 8 and 4 bytes float";
1075usage += "\n i8,i4 for 8 and 4 bytes signed integer";
1076usage += "\n s for string";
1077usage += "\n Related commands: newnt newh1d newh2d newprof[e] newgfd";
1078mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1079kw = "newgfd";
1080usage = "Creates GeneralFit Data object \n Usage: newgfd nvar nalloc [errx(0/1)]";
[2792]1081usage += "\n Related commands: newh1d newh2d newprof[e] newdt newnt ";
[333]1082mpiac->RegisterCommand(kw, usage, this, "Objects");
1083kw = "newvec";
[357]1084usage = "Creates (and optionaly fills) a vector \n Usage: newvec name size [f(i) [dopt] ] ";
[2305]1085usage += "\n Related commands: newmtx line2vec";
[357]1086mpiac->RegisterCommand(kw, usage, this, "Objects");
[333]1087kw = "newmtx";
[357]1088usage = "Creates (and optionaly fills) a matrix \n";
[1917]1089usage +=" Usage: newmtx name sizeX(Col) sizeY(Lines) [f(i,j) [dopt] ] ";
[333]1090usage += "\n Related commands: newvec";
[357]1091mpiac->RegisterCommand(kw, usage, this, "Objects");
[2305]1092kw = "line2vec";
1093usage = "Creates a vector from the line \n";
1094usage += " Usage: line2vec vecname v0 v1 v2 ... \n";
1095usage += " Related commands: newvec line2nt";
1096mpiac->RegisterCommand(kw, usage, this, "Objects");
1097kw = "line2nt";
1098usage = "Fills (append) an NTuple from the line content \n";
1099usage += " Usage: line2nt ntname col0 col1 ... \n";
1100usage += " Related commands: newnt line2vec ntline2var ntcol2var";
1101mpiac->RegisterCommand(kw, usage, this, "Objects");
1102kw = "vec2var";
1103usage = "Vector content to an interpreter variable varname = 'v0 v1 v2 ...' \n";
1104usage += " Usage: line2vec vecname varname [LoopParam start:end[:step] ]\n";
1105usage += " Related commands: line2vec ntline2var";
1106mpiac->RegisterCommand(kw, usage, this, "Objects");
1107kw = "ntline2var";
1108usage = "Object NTupleInterface line to an interpreter variable \n";
1109usage += " Usage: ntline2var objname line_number varname \n";
1110usage += " Related commands: vec2var ntcol2var";
1111mpiac->RegisterCommand(kw, usage, this, "Objects");
1112kw = "ntcol2var";
1113usage = "Object NTupleInterface column to an interpreter variable \n";
1114usage += " Usage: ntline2var objname column_number varname [LoopParam start:end[:step] ] \n";
1115usage += " Related commands: vec2var ntline2var";
1116mpiac->RegisterCommand(kw, usage, this, "Objects");
[2999]1117kw = "objaoper";
1118usage = "Perform an operation through the object adapter NObjMgrAdapter::PerformOperation()\n";
1119usage += " Usage: objaoper objname operation [arg1 ...] \n";
1120usage += " Examples of defined operations : \n";
1121usage += " Matrices: row indx_row , col indx_col \n";
1122usage += " Arrays: slicexy indx_Z , slicexz indx_Y, sliceyz indxX \n";
1123mpiac->RegisterCommand(kw, usage, this, "Objects");
[293]1124
[2781]1125//------- Commandes trace de fonctions
[293]1126kw = "func";
1127usage = "Displays a function y=f(x) (Fills a vector with function values)";
[1938]1128usage += "\n Usage: func f(x) xmin xmax [npt graphic_attributes]";
[326]1129usage += "\n Related commands: funcff func2d func2dff ";
[330]1130mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[326]1131kw = "funcff";
1132usage = "Displays a function y=f(x) from a C-file (Fills a vector with function values)";
[1938]1133usage += "\n Usage: funcff C-FileName FunctionName xmin xmax [npt graphic_attributes]";
[326]1134usage += "\n Related commands: func func2d func2dff ";
[330]1135mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[293]1136kw = "func2d";
1137usage = "Displays a function z=f(x,y) (Fills a matrix with function values)";
1138usage += "\n Usage: func2d f(x,y) xmin xmax nptx ymin ymax npty [graphic_attributes]";
1139usage += "\n Related commands: func";
[330]1140mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[326]1141kw = "func2dff";
1142usage = "Displays a function z=f(x,y) from a C-file (Fills a matrix with function values)";
1143usage += "\n Usage: func2dff C-FileName FunctionName xmin xmax nptx ymin ymax npty [graphic_attributes]";
1144usage += "\n Related commands: func funcff func2d ";
[330]1145mpiac->RegisterCommand(kw, usage, this, "Func Plot");
[293]1146
[2781]1147//------ Commandes trace d'expression
[3588]1148grp = "Expr. Plotting";
1149gdesc = "Compute and plot various (c-syntax) expressions of objects \n";
1150gdesc += "Objects are seen as list of structures (n-tuples)\n";
1151gdesc += "See ObjectExpressions help item for a list of structure\n";
1152gdesc += "fields for the different classes managed by piapp";
1153mpiac->AddHelpGroup(grp, gdesc);
1154
[357]1155kw = "ObjectExpressions";
1156usage = "Any mathematical expression (math.h) with object variables can be used";
1157usage += "\n ------ Object Variable names (double) -------- ";
[2419]1158usage += "\n (_nl is the table line number or the sequential index)";
1159usage += "\n- NTuple: ntuple variable names,_nl";
[3123]1160usage += "\n- Histo1D/HProf: i,x,val,err,nb,_nl";
[2419]1161usage += "\n- Histo2D: i,j,x,y,val,err,_nl";
[3123]1162usage += "\n- HistoErr: i,x,val,err2,nb,_nl";
1163usage += "\n- Histo2DErr: i,j,x,y,val,err2,nb,_nl";
[3491]1164usage += "\n- Vector/Matrix/Image: n,r,c,val,real,imag,mod,phas,_nl";
[2419]1165usage += "\n- TArray: n,x,y,z,t,u,val,real,imag,mod,phas,_nl";
1166usage += "\n- GeneralFitData: x0,ex0 x1,ex1 ... xn,exn y,ey ok ,_nl";
[3491]1167usage += "\n- SphereThetaPhi/SphereHEALPix/SphereECP/LocalMap: ";
[2419]1168usage += "\n- i,k,val,real,imag,mod,phas,teta,phi,_nl";
1169usage += "\n- FITS Binary/ASCII table: fits column names,_nl";
[1548]1170usage += "\n ------ Other parameters -------- ";
[357]1171usage += "\nLoop parameters can be specified as I1[:I2[:DI]] for(int i=I1; i<I2; i+=DI)";
1172usage += "\nThe default Cut() expression in true (=1) for all";
[2999]1173usage += "\n\n Related commands: plot2d plot2de plot2dw plot3d plot3dw";
1174usage += "\n projh1d projh2d projprof fillvec fillmtx ";
1175usage += "\n fillnt fillgd1 fillgd2 ntloop exptovec ... ";
[3551]1176mpiac->RegisterHelp(kw, usage, grp);
1177
1178
[293]1179kw = "plot2d";
1180usage = "Plots (2D) Y=g(Object) vs. X=f(Object) --- Object Variable names (double) :";
[357]1181usage += "\n Usage: plot2d nameobj f_X() g_Y() [f_Cut() graphic_attributes loop_param]";
[2999]1182usage += "\n Related commands: plot2de plot2dw plot3d plot3dw ObjectExpressions ...";
[330]1183mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1184kw = "plot2de";
1185usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with error bars eX/Y=f_ErrX/Y(Object) ";
1186usage += "\n Usage: plot2de nameobj f_X() g_Y() f_ErrX() f_ErrY() [f_Cut() graphic_attributes loop_param]";
1187usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1188mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[333]1189kw = "plot2dw";
1190usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Weight W=h(Object) ";
[357]1191usage += "\n Usage: plot2dw nameobj f_X() g_Y() h_Wt() [Cut() graphic_attributes loop_param]";
[3279]1192usage += "\n Related commands: plot2d plot2dc plot3d ObjectExpressions ...";
1193mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1194kw = "plot2dc";
1195usage = "Plots (2D) Y=g(Object) vs. X=f(Object) with Color ColIndex=h(Object) ";
1196usage += "\n Usage: plot2dc nameobj f_X() g_Y() h_Col() [Cut() graphic_attributes loop_param]";
[357]1197usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
[333]1198mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1199kw = "plot3d";
[2999]1200usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object)";
[357]1201usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() [Cut() graphic_attributes loop_param]";
[2999]1202usage += "\n Related commands: plot2d plot2de plot3dw ObjectExpressions ...";
[330]1203mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[2999]1204kw = "plot3dw";
1205usage = "Plots (3D) Z=h(Object) vs. Y=g(Object) vs. X=f(Object) with Weight W=k(Object) ";
1206usage += "\n Usage: plot3d nameobj f_X() g_Y() h_Z() k_Wt() [Cut() graphic_attributes loop_param]";
1207usage += "\n Related commands: plot2d plot2dw plot3d ObjectExpressions ...";
1208mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1209
1210kw = "projh1d";
1211usage = "Projects X=f(Object) with weight WT=h(Object) into a 1D histogram ";
[357]1212usage += "\n Usage: projh1d nameh1d nameobj f_X() [h_WT()=1. Cut() graphic_attributes loop_param]";
[293]1213usage += "\n Histo1D nameh1d is created if necessary ";
[357]1214usage += "\n Related commands: projh2d projprof ObjectExpressions ...";
[330]1215mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1216kw = "projh2d";
1217usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a 2D histogram ";
[357]1218usage += "\n Usage: projh2d nameh2d nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
[293]1219usage += "\n Histo2D nameh2d is created if necessary ";
[357]1220usage += "\n Related commands: projh1d projprof ObjectExpressions ...";
[330]1221mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1222kw = "projprof";
1223usage = "Projects (X=f(Object),Y=g(Object)) with weight WT=h(Object) into a profile histogram ";
[709]1224usage += "\n Usage: projprof nameprof nameobj f_X() g_Y() [h_WT()=1. Cut() graphic_attributes loop_param]";
[293]1225usage += "\n HProf nameprof is created if necessary ";
[357]1226usage += "\n Related commands: projh1d projh2d ObjectExpressions ...";
[330]1227mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1228kw = "fillvec";
1229usage = "Fills a Vector V((int)(f_X(Object)+0.5)) = h_V(Object) ";
1230usage += "\n Usage: fillvec namevec nameobj f_X() h_V() [Cut() graphic_attributes loop_param]";
1231usage += "\n Related commands: fillmtx fillnt ObjectExpressions ...";
1232mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1233kw = "fillmtx";
1234usage = "Fills a Matrix M(Line=g_Y(Object)+0.5, Col=f_X(Object)+0.5)) = h_V(Object) ";
[3491]1235usage += "\n Usage: fillmtx namevec nameobj f_X() g_Y() h_V() [Cut() graphic_attributes loop_param]";
[357]1236usage += "\n Related commands: fillvec fillnt ObjectExpressions ...";
1237mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1238
1239kw = "fillnt";
1240usage = "Creates and Fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
[357]1241usage += "\n Usage: fillnt nameobj f_X() g_Y() h_Z() k_T() [Cut() nameNt loop_param]";
[333]1242usage += "\n Related commands: ntloop plot2d projh1d projh2d projprof ";
[357]1243usage += "\n Related commands: fillvec fillmtx ntloop exptovec fillgd1 fillgd2 ObjectExpressions ...";
[330]1244mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1245
[333]1246kw = "ntloop";
1247usage = "Loops over an Object NTupleInterface calling a function from a C-file \n";
1248usage += "and optionaly fills an NTuple(x,y,z,t) with (X=f(Object),Y=g(...),Z=h(...),T=k(...))";
[357]1249usage += "\n Usage: ntloop nameobj CFileName FuncName [NtupleName loop_param]";
1250usage += "\n Related commands: fillvec fillmtx fillnt fillgd1 fillgd2 exptovec ObjectExpressions ...";
[333]1251usage += "\n Related commands: ntexpcfile fillnt";
1252mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[357]1253
[333]1254kw = "ntexpcfile";
1255usage = "Creates a C-File with declarations suitable to be used for ntloop";
1256usage += "\n Usage: ntexpcfile nameobj CFileName FuncName ";
1257usage += "\n Related commands: ntloop";
1258mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1259
[2922]1260kw = "expmeansig";
1261usage = "Computes Mean/Sigma (+Min/Max) for an expression X=f(Object)";
1262usage += "\n Usage: expmeansig nameobj f_X() [Cut() loop_param]";
1263usage += "\n Related commands: exptovec ntloop fillnt ObjectExpressions ...";
1264mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
1265
[357]1266kw = "exptovec";
[293]1267usage = "Creates and Fills a Vector with X=f(Object)";
[357]1268usage += "\n Usage: exptovec namevec nameobj f_X() [Cut() graphic_attributes loop_param]";
1269usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
[330]1270mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[2922]1271
[293]1272kw = "fillgd1";
1273usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), ErrY=h(...))";
[357]1274usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_ErrY() [Cut() loop_param]";
1275usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
[330]1276mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1277kw = "fillgd2";
1278usage = "Creates and Fills a GeneralFitData with (X=f(Object), Y=g(...), Z=h(...)) ErrZ=k(...)";
[357]1279usage += "\n Usage: fillgd1 namegfd nameobj f_X() g_Y() h_Z() k_ErrZ() [Cut() loop_param]";
1280usage += "\n Related commands: ntloop fillnt ObjectExpressions ...";
[330]1281mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[1067]1282kw = "gdfrvec";
1283usage = "Fills a GeneralFitData with vectors X,Y,Z,EZ";
1284usage += "\n Usage: gdfrvec namegfd X Y";
1285usage += "\n Usage: gdfrvec namegfd X Y ! EY";
1286usage += "\n Usage: gdfrvec namegfd X Y Z";
1287usage += "\n Usage: gdfrvec namegfd X Y Z EZ";
1288usage += "\n Related commands: fillgd1 fillgd2 ...";
1289mpiac->RegisterCommand(kw, usage, this, "Expr. Plotting");
[293]1290
[2180]1291
1292kw = "eval";
1293usage = "Compute arithmetic expression\n";
1294usage += "\n Usage: eval resultvarname arithmetic expression....";
1295usage += "\n resultvarname: store result in variable resultvarname";
1296usage += "\n - If first character is not alphabetic, just print result";
1297usage += "\n arithmetic expression:";
1298usage += "\n ex: x + sqrt(y)+z +3.14 (x,y,z are variables)";
1299usage += "\n ex: $x + sqrt($y)+$z +3.14 (x,y,z are variables)";
1300usage += "\n ex: 360 * M_PI / 180.";
1301mpiac->RegisterCommand(kw, usage, this, "Expr. Arithmetic");
1302
[293]1303}
1304
1305/* --Methode-- */
1306int PIABaseExecutor::LinkUserFuncs(string& fnameso, string& func1, string& func2, string& func3)
1307// string& func4, string& func5)
1308{
1309string cmd;
1310
1311if (dynlink) delete dynlink; dynlink = NULL;
1312usfmap.clear();
1313
1314dynlink = new PDynLinkMgr(fnameso, true);
1315if (dynlink == NULL) {
1316 string sn = fnameso;
1317 cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur ouverture SO " << sn << endl;
1318 return(2);
1319 }
1320
1321int nok=0;
1322// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1323// DlUserProcFunction f = NULL;
1324DlFunction f = NULL;
1325if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1326// f = (DlUserProcFunction) dlsym(dlhandle, func1.c_str());
1327f = dynlink->GetFunction(func1);
1328if (f) { nok++; usfmap[func1] = f; }
1329else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func1 << endl;
1330
1331if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1332// f = (DlUserProcFunction) dlsym(dlhandle, func2.c_str());
1333f = dynlink->GetFunction(func2);
1334if (f) { nok++; usfmap[func2] = f; }
1335else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func2 << endl;
1336
1337if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1338// f = (DlUserProcFunction) dlsym(dlhandle, func3.c_str());
1339f = dynlink->GetFunction(func3);
1340if (f) { nok++; usfmap[func3] = f; }
1341else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func3 << endl;
1342
1343/* Pb compile g++ 2.7.2
1344if ((func4.length() < 1) || (func4 == "-") || (func4 == ".") ) goto fin;
1345// f = (DlUserProcFunction) dlsym(dlhandle, func4.c_str());
1346f = dynlink->GetFunction(func4);
1347if (f) { nok++; usfmap[func4] = f; }
1348else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func4 << endl;
1349
1350if ((func5.length() < 1) || (func5 == "-") || (func5 == ".") ) goto fin;
1351// f = (DlUserProcFunction) dlsym(dlhandle, func5.c_str());
1352f = dynlink->GetFunction(func5);
1353if (f) { nok++; usfmap[func5] = f; }
1354else cerr << "PIABaseExecutor/LinkUserFuncs_Erreur: Erreur linking " << func5 << endl;
1355*/
1356fin:
1357if (nok < 1) { if (dynlink) delete dynlink; dynlink = NULL; return(3); }
1358else return(0);
1359}
1360
[1276]1361/* --Methode-- */
1362int PIABaseExecutor::LinkUserFuncs2(string& fnameso, string& func1, string& func2, string& func3)
1363{
1364string cmd;
1365
1366if (dynlink2) delete dynlink2; dynlink2 = NULL;
1367usfmap2.clear();
1368
1369dynlink2 = new PDynLinkMgr(fnameso, true);
1370if (dynlink2 == NULL) {
1371 string sn = fnameso;
1372 cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur ouverture SO " << sn << endl;
1373 return(2);
1374 }
1375
1376int nok=0;
1377// on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++)
1378// DlUserProcFunction f = NULL;
1379DlFunction f = NULL;
1380if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin;
1381f = dynlink2->GetFunction(func1);
1382if (f) { nok++; usfmap2[func1] = f; }
1383else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func1 << endl;
1384
1385if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin;
1386f = dynlink2->GetFunction(func2);
1387if (f) { nok++; usfmap2[func2] = f; }
1388else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func2 << endl;
1389
1390if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin;
1391f = dynlink2->GetFunction(func3);
1392if (f) { nok++; usfmap2[func3] = f; }
1393else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func3 << endl;
1394
1395fin:
1396if (nok < 1) { if (dynlink2) delete dynlink2; dynlink2 = NULL; return(3); }
1397else return(0);
1398}
1399
Note: See TracBrowser for help on using the repository browser.