source: Sophya/trunk/SophyaPI/PIext/cxxexecutor.cc@ 1289

Last change on this file since 1289 was 1289, checked in by ercodmgr, 25 years ago

prtlevel for cxxexecutor cmv 3/11/00

  • Property svn:executable set to *
File size: 19.8 KB
Line 
1#include "cxxexecutor.h"
2
3#include <typeinfo>
4
5#include "strutilxx.h"
6#include "dvlist.h"
7#include "cxxcmplnk.h"
8
9#include "nomgadapter.h"
10#include "pistdimgapp.h"
11
12
13/* --Methode-- */
14CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */)
15 : mUserCodeFn(""), mUserFctFn("")
16 , mCompOpt(""), mLinkOpt(""), mMyLibs("")
17 , mDefTmp(""), mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(2)
18{
19mIncList.resize(0);
20mCallArgs.resize(0);
21
22// Gestion des fichiers par default dans TmpDir
23NamedObjMgr omg;
24string tmpdir = omg.GetTmpDir();
25if(tmpdir.size()>1) mDefTmp = tmpdir;
26
27// On enregistre les nouvelles commandes
28string hgrp = "CxxExecutorCmd";
29string usage,kw;
30
31kw = "c++exec";
32usage = "c++exec: Execute the following c++ user code\n";
33usage+= "Usage: c++exec c++ user code\n";
34usage+= "Warning: c++ user code can be found in \"TmpDir/"+mDefRoot+".h\"\n";
35usage+= " total generated code can be found in \"TmpDir/"+mDefRoot+".cc\"";
36mpiac->RegisterCommand(kw, usage, this, hgrp);
37
38kw = "c++execfrf";
39usage = "c++execfrf: Execute c++ user_code [user_function_code]\n";
40usage+= "Usage: c++execfrf fileuser.cc [fileuserfct.cc]\n";
41usage+= "Warning: total generated code can be found in \"TmpDir/"+mDefRoot+".cc\"";
42mpiac->RegisterCommand(kw, usage, this, hgrp);
43
44kw = "c++args";
45usage = "c++args: Define user function arguments for c++exec and c++execfrf\n";
46usage+= "Usage: c++args arg1 arg2 arg3 ...\n";
47usage+= " c++args -? : give current arguments\n";
48usage+= " c++args : reset current arguments";
49mpiac->RegisterCommand(kw, usage, this, hgrp);
50
51kw = "c++create";
52usage = "c++create: create a file \"file.cc\" to be used by spiapp\n";
53usage+= "Usage: c++create file.cc func c++ user code...\n";
54mpiac->RegisterCommand(kw, usage, this, hgrp);
55
56kw = "c++createfrf";
57usage = "c++createfrf: create a file \"file.cc\" to be used by spiapp\n";
58usage+= " with a user file code \"fileuser.cc\"\n";
59usage+= " and an optional user function code \"fileuserfct.cc\"\n";
60usage+= "Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]\n";
61mpiac->RegisterCommand(kw, usage, this, hgrp);
62
63kw = "c++compile";
64usage = "c++compile: compile a file (file.cc -> file.so)\n";
65usage+= "Usage: c++compile file\n";
66usage+= "Warning: give \"file\" or \"file.so\" to create \"file.so\" from \"file.cc\"\n";
67usage+= " : to be used before c++link";
68mpiac->RegisterCommand(kw, usage, this, hgrp);
69
70kw = "c++link";
71usage = "c++link: link function \"func\" in file.so to spiapp\n";
72usage+= "Usage: c++link file.so func";
73mpiac->RegisterCommand(kw, usage, this, hgrp);
74
75kw = "c++include";
76usage = "c++include: give personnal includes to be used\n";
77usage+= "Usage: c++include myinc1.h myinc2.h ...\n";
78usage+= " c++include -? : give current include files\n";
79usage+= " c++include : reset current include files\n";
80usage+= "Warning: to be used before c++create... c++exec...";
81mpiac->RegisterCommand(kw, usage, this, hgrp);
82
83kw = "c++compileopt";
84usage = "c++compileopt: give additionnal compile options\n";
85usage+= "Usage: c++compileopt -g -O5 -IMy_Inc_Dir ...\n";
86usage+= " c++compileopt -? : give current compile options\n";
87usage+= " c++compileopt : reset current compile options\n";
88usage+= "Warning: to be used before c++compile";
89mpiac->RegisterCommand(kw, usage, this, hgrp);
90
91kw = "c++linkopt";
92usage = "c++linkopt: give additionnal link options\n";
93usage+= "Usage: c++linkopt -g -O5 ...\n";
94usage+= " c++linkopt -? : give current link options\n";
95usage+= " c++linkopt : reset current link options\n";
96usage+= "Warning: to be used before c++compile";
97mpiac->RegisterCommand(kw, usage, this, hgrp);
98
99kw = "c++mylibs";
100usage = "c++mylibs: give additionnal libraries\n";
101usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...\n";
102usage+= " c++mylibs -? : give current additionnal libraries\n";
103usage+= " c++mylibs : reset current additionnal libraries\n";
104usage+= "Warning: to be used before c++compile";
105mpiac->RegisterCommand(kw, usage, this, hgrp);
106
107
108kw = "c++prtlevel";
109usage = "c++prtlevel: Print level\n";
110usage+= "Usage: c++prtlevel prtlevel\n";
111usage+= " prtlevel=0 : minimum printing\n";
112usage+= " prtlevel=1 : + compiler/linker output\n";
113usage+= " prtlevel=2 : + full infos (default)";
114mpiac->RegisterCommand(kw, usage, this, hgrp);
115
116}
117
118/* --Methode-- */
119CxxExecutor::~CxxExecutor()
120{
121}
122
123/* --Methode-- */
124int CxxExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
125{
126int rc=0;
127if(kw == "c++exec") {
128 if(tokens.size()<1) {
129 cout<<"Usage: c++exec c++ user code"<<endl;
130 return(1);
131 }
132 rc = ExecuteCXX(toks); if(rc) return(1);
133
134} else if(kw == "c++execfrf") {
135 if(tokens.size()<1) {
136 cout<<"Usage: c++execfrf fileuser.cc [fileuserfct.cc]"<<endl;
137 return(1);
138 }
139 rc = FillUserCode(tokens[0]); if(rc) return(1);
140 if(tokens.size()>1) rc = FillUserFctFrF(tokens[1]);
141 else rc = FillUserFctFrF();
142 if(rc) return(1);
143 rc = CrFile(); if(rc) return(1);
144 rc = Compile(); if(rc) return(1);
145 rc = Link(); if(rc) return(1);
146 rc = Call(); if(rc) return(1);
147
148} else if(kw == "c++args") {
149 if(tokens.size()==1) if(tokens[0]=="-?")
150 {cout<<"c++args "<<GetArgs()<<endl; return(0);}
151 FillArgs(tokens);
152
153} else if(kw == "c++create") {
154 if(tokens.size()<3) {
155 cout<<"Usage: c++create file.cc func c++ user code ..."<<endl;
156 return(1);
157 }
158 rc = FillUserCode(toks,2); if(rc) return(1);
159 rc = FillUserFctFrS(); if(rc) return(1);
160 rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
161
162} else if(kw == "c++createfrf") {
163 if(tokens.size()<3) {
164 cout<<"Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]"<<endl;
165 return(1);
166 }
167 rc = FillUserCode(tokens[2]); if(rc) return(1);
168 if(tokens.size()>3) rc = FillUserFctFrF(tokens[3]);
169 else rc = FillUserFctFrF(tokens[3]);
170 if(rc) return(1);
171 rc = CrFile(tokens[0],tokens[1]); if(rc) return(1);
172
173} else if(kw == "c++compile") {
174 if(tokens.size()>=1) rc = Compile(tokens[0]);
175 else rc = Compile();
176 if(rc) return(1);
177
178} else if(kw == "c++link") {
179 if(tokens.size()>=2) rc = Link(tokens[0],tokens[1]);
180 else if(tokens.size()>=1) rc = Link(tokens[0]);
181 else rc = Link();
182 if(rc) return(1);
183
184} else if(kw == "c++include") {
185 if(tokens.size()==1) if(tokens[0]=="-?")
186 {cout<<"c++include "<<GetInclude()<<endl; return(0);}
187 FillInclude(tokens);
188
189} else if(kw == "c++compileopt") {
190 if(tokens.size()==1) if(tokens[0]=="-?")
191 {cout<<"c++compileopt "<<GetCompileOpt()<<endl; return(0);}
192 FillCompileOpt(tokens);
193
194} else if(kw == "c++linkopt") {
195 if(tokens.size()==1) if(tokens[0]=="-?")
196 {cout<<"c++linkopt "<<GetLinkOpt()<<endl; return(0);}
197 FillLinkOpt(tokens);
198
199} else if(kw == "c++mylibs") {
200 if(tokens.size()==1) if(tokens[0]=="-?")
201 {cout<<"c++mylibs "<<GetLinkLibs()<<endl; return(0);}
202 FillLinkLibs(tokens);
203
204} else if(kw == "c++prtlevel") {
205 if(tokens.size()==1) if(tokens[0]=="-?")
206 {cout<<"c++prtlevel prtlevel = "<<mPrtLevel<<endl; return(0);}
207 if(tokens.size()>0) {
208 int lp=atoi(tokens[0].c_str()); if(lp<0) lp=0;
209 mPrtLevel=(uint_2) lp;
210 } else mPrtLevel=2;
211
212}
213
214return(0);
215}
216
217/* --Methode-- */
218int CxxExecutor::ExecuteCXX(string usercode,string userfct)
219{
220int rc=0;
221rc = FillUserCode(usercode,0); if(rc) return(1);
222rc = FillUserFctFrS(userfct); if(rc) return(1);
223rc = CrFile(); if(rc) return(1);
224rc = Compile(); if(rc) return(1);
225rc = Link(); if(rc) return(1);
226rc = Call(); if(rc) return(1);
227return 0;
228}
229
230/* --Methode-- */
231int CxxExecutor::CrFile(string cfilename,string func)
232// Si un nom n'est pas precise alors TmpDir/cxx_spiapp.cc
233{
234if(cfilename.size()<1) cfilename = mDefTmp + mDefRoot + ".cc";
235
236if(func.size()<1) func = mDefFunc;
237
238ofstream os(cfilename.c_str(),ios::out);
239if(!os)
240 {cout<<"CxxExecutor::CrFile: unable to open "<<cfilename<<endl;
241 return 1;}
242
243PutInclude(os);
244os<<endl;
245
246PutIncludeUser(os);
247os<<endl;
248
249os<<"//-------------------------------------------------//"<<endl;
250os<<"//----------------- User Functions ----------------//"<<endl;
251os<<"//-------------------------------------------------//"<<endl;
252if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl;
253os<<endl;
254
255
256os<<"extern \"C\" {"<<endl;
257os<<" int "<<func<<"( vector<string>& args );"<<endl;
258os<<"}"<<endl<<endl;
259os<<"int "<<func<<"( vector<string>& args )"<<endl;
260os<<"{"<<endl;
261os<<"// Some definitions to help using spiapp;"<<endl;
262os<<"NamedObjMgr omg;"<<endl;
263os<<"Services2NObjMgr& srvo = *omg.GetServiceObj();"<<endl;
264os<<endl;
265
266PutObject(os);
267os<<endl;
268
269PutVar(os);
270os<<endl;
271
272os<<"//--------------------------------------------//"<<endl;
273os<<"//----------------- User Code ----------------//"<<endl;
274os<<"//--------------------------------------------//"<<endl;
275if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl;
276os<<endl;
277
278os<<"return 0;"<<endl;
279os<<"}"<<endl;
280
281if(mPrtLevel>1)
282 cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl;
283if(mPrtLevel>1 && mUserCodeFn.size()>0)
284 cout<<" User code was in file "<<mUserCodeFn<<endl;
285if(mPrtLevel>1 && mUserFctFn.size()>0)
286 cout<<" User function code was in file "<<mUserFctFn<<endl;
287return 0;
288}
289
290/* --Methode-- */
291void CxxExecutor::PutInclude(ofstream& os)
292{
293os<<"#include \"machdefs.h\""<<endl
294 <<endl
295
296 <<"//---- System et stdc++ include files"<<endl
297 <<"#include <stdio.h>"<<endl
298 <<"#include <stdlib.h>"<<endl
299 <<"#include <math.h>"<<endl
300 <<"#include <ctype.h>"<<endl
301 <<"#include <string.h>"<<endl
302 <<"#include <iostream.h>"<<endl
303 <<"#include <fstream.h>"<<endl
304 <<"#include <complex>"<<endl
305 <<endl
306
307 <<"#include <typeinfo>"<<endl
308 <<"#include <string>"<<endl
309 <<"#include <vector>"<<endl
310 <<"#include <map>"<<endl
311 <<"#include <functional>"<<endl
312 <<"#include <list>"<<endl
313 <<endl
314
315 <<"//---- Sophya include files"<<endl
316 <<"#include \"systools.h\""<<endl
317 <<"#include \"ntools.h\""<<endl
318 <<"#include \"array.h\""<<endl
319 <<"#include \"histats.h\""<<endl
320 <<endl
321
322 <<"//---- Spiapp include files"<<endl
323 <<"#include \"nobjmgr.h\""<<endl
324 <<"#include \"servnobjm.h\""<<endl
325 <<endl
326
327 <<"#define KeepObj(obj) ___nomobj = #obj; omg.AddObj(obj,___nomobj);"<<endl
328 <<"#define KeepVar(var) ___nomobj = #var; omg.GetVarList().Get(___nomobj) = var ;"<<endl
329 <<endl;
330
331return;
332}
333
334/* --Methode-- */
335void CxxExecutor::PutIncludeUser(ofstream& os)
336{
337if(mIncList.size()<1) return;
338for(uint_4 i=0;i<mIncList.size();i++)
339 os<<"#include \""<<mIncList[i]<<"\""<<endl;
340}
341
342/* --Methode-- */
343void CxxExecutor::PutObject(ofstream& os)
344{
345NamedObjMgr omg;
346NObjMgrAdapter* objmgrad;
347vector<string> objlist;
348string patt = "*";
349omg.GetObjList(patt,objlist);
350int nobjs = objlist.size();
351
352os<<"//-------------- Object List --------------"<<endl;
353os<<"//Number of objects = "<<nobjs<<endl;
354os<<"string ___nomobj;"<<endl<<endl;
355if(nobjs<=0) return;
356
357string dir,nobj,stmp,obtype;
358for(int i=0;i<nobjs;i++) {
359 objmgrad = omg.GetObjAdapter(objlist[i]);
360 omg.ParseObjectName(objlist[i],dir,nobj);
361 obtype = objmgrad->GetDataObjType();
362 stmp = "___" + nobj;
363
364 os<<"___nomobj = \""<<nobj<<"\";"<<endl;
365 os<<obtype<<"* "<<stmp
366 <<" = dynamic_cast< "<<obtype<<" * >(omg.GetObj(___nomobj));"<<endl;
367 os<<"if("<<stmp<<"==NULL) throw NullPtrError"
368 <<"(\"CxxExecutor::PutObject: Non existing object "<<nobj
369 <<"... please update file\");"<<endl;
370 os<<obtype<<"& "<<nobj<<" = (*"<<stmp<<");"<<endl<<endl;
371}
372
373return;
374}
375
376/* --Methode-- */
377void CxxExecutor::PutVar(ofstream& os)
378{
379os<<"//-------------- Variable List --------------"<<endl;
380NamedObjMgr omg;
381DVList& varlist = omg.GetVarList();
382// varlist.Show(); varlist.Print();
383DVList::ValList::const_iterator it;
384for(it=varlist.Begin(); it!=varlist.End(); it++) {
385 string key = (*it).first;
386 if (isalpha(key[0]) ) {
387 os<<"___nomobj = \""<<key<<"\";"<<endl;
388 os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
389 }
390}
391
392return;
393}
394
395/* --Methode-- */
396int CxxExecutor::FillUserCode(string& usercode,uint_4 first)
397// User code is read from input.
398// - first is the first position in the "string" where the code starts
399// - Code is put into file "TmpDir/cxx_spiapp.h".
400{
401mUserCodeFn = "";
402
403// get the string part which is after word "first"
404string code = usercode;
405if(code.size()<=0) {cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
406 return 1;}
407size_t q;
408for(uint_4 i=0;i<=first;i++) {
409 q = code.find_first_not_of(" \t");
410 if(q>=code.size()) {code=""; break;}
411 code = code.substr(q);
412 if(i==first) break;
413 q = code.find_first_of(" \t");
414 if(q>=code.size()) {code=""; break;}
415 code = code.substr(q);
416}
417if(code.size()<=0)
418 {cout<<"CxxExecutor::FillUserCode: no user code after "<<first<<endl;
419 return 1;}
420
421// Fill the file with user code
422mUserCodeFn = mDefTmp + mDefRoot + ".h";
423ofstream os(mUserCodeFn.c_str(),ios::out);
424if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
425 <<mUserCodeFn<<endl; mUserCodeFn = ""; return 1;}
426os<<code<<endl;
427if(mPrtLevel>1)
428 cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
429return 0;
430}
431
432/* --Methode-- */
433int CxxExecutor::FillUserFctFrS(string userfctcode)
434// - Fill user Fonction code from string "userfct"
435// - Code is put into file "TmpDir/cxx_spiapp_fct.h".
436{
437mUserFctFn = "";
438if(userfctcode.size()<1) return 0;
439mUserFctFn = mDefTmp + mDefRoot + "_fct.h";
440ofstream os(mUserFctFn.c_str(),ios::out);
441if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open "
442 <<mUserFctFn<<endl; mUserFctFn = ""; return 1;}
443os<<userfctcode<<endl;
444if(mPrtLevel>1)
445 cout<<"User Function code filled from standard input into "<<mUserFctFn<<endl;
446return 0;
447}
448
449/* --Methode-- */
450int CxxExecutor::FillUserCode(string filename)
451// User code is read from "filename".
452{
453mUserCodeFn = filename;
454if(mPrtLevel>1 && mUserCodeFn.size()>0)
455 cout<<"User code filled from file "<<mUserCodeFn<<endl;
456return 0;
457}
458
459/* --Methode-- */
460int CxxExecutor::FillUserFctFrF(string filefctname)
461// User function code is read from "filefctname".
462{
463mUserFctFn = filefctname;
464if(mPrtLevel>1 && mUserFctFn.size()>0)
465 cout<<"User Function code filled from file "<<mUserFctFn<<endl;
466return 0;
467}
468
469/* --Methode-- */
470int CxxExecutor::Compile(string rootfilename)
471//--------------------------------------------------------//
472// rootfilename = | name | "" ou (default) //
473//--------------------------------------------------------//
474// fichier .cc | name.cc | TmpDir/cxx_spiapp.cc //
475// | ../dir/name.cc | //
476// fichier .o | TmpDir/name.o | TmpDir/cxx_spiapp.o //
477// fichier .so | TmpDir/name.so | TmpDir/cxx_spiapp.so //
478//--------------------------------------------------------//
479{
480if(rootfilename.size()<1) rootfilename = mDefTmp + mDefRoot;
481if(mPrtLevel>1) cout<<"Compile "<<rootfilename<<endl;
482
483int rc;
484CxxCompilerLinker cxx;
485if(mDefTmp.size()>0) cxx.SetTmpDir(mDefTmp);
486if(mPrtLevel>0) cxx.SetVerbose(true);
487 else cxx.SetVerbose(false);
488
489// Compilation
490string fcc = rootfilename + ".cc";
491string fo = "";
492cxx.AddCompileOptions(mCompOpt);
493rc = cxx.Compile(fcc,fo);
494if(mPrtLevel>1) cout << "Compilation rc = "<<rc<< endl;
495if(rc) return 1;
496
497// Fabrication Shared Lib.
498string fso = "";
499cxx.AddLinkOptions(mLinkOpt);
500 string sophlib = "-lPI";
501cxx.AddLinkOptions(sophlib);
502cxx.AddLinkOptions(mMyLibs);
503rc = cxx.BuildSO(fo,fso);
504if(mPrtLevel>1) cout << "Shared Library rc = "<<rc<< endl;
505if(rc) return 2;
506
507return 0;
508}
509
510/* --Methode-- */
511//int CxxExecutor::Compile(string rootfilename)
512// Ne marche pas si TmpDir != ""
513//{
514//if(rootfilename.size()<1) rootfilename = mDefRoot;
515//if(mPrtLevel>1) cout<<"Compile: "<<rootfilename<<endl;
516//int rc = 0;
517//rc = CrMakefile();
518//if(rc) return(1);
519//string make = "";
520//make += "make -f " + mDefRoot + "_Makefile";
521//make += " CXXFLAGS=\"" + mCompOpt + "\"";
522//make += " LDFLAGS=\"" + mLinkOpt + "\"";
523//make += " MYLIBS=\"" + mMyLibs + "\"";
524//make += " " + rootfilename;
525//rc = system(make.c_str());
526//if(rc)
527// {cout<<"CxxExecutor::Compile : \n"<<make<<" Failed"<<endl;
528// return 1000+rc;}
529//return 0;
530//}
531
532/* --Methode-- */
533//int CxxExecutor::CrMakefile(void)
534// Ne marche pas si TmpDir != ""
535//{
536//string makename = mDefTmp + mDefRoot + "_Makefile";
537//ofstream os(makename.c_str(),ios::out);
538//if(!os)
539// {cout<<"CxxExecutor::CrMakefile: unable to open file for Makefile"<<endl;
540// return 1;}
541//---------------------------------------------------------------------
542//os<<"MODULEDECCXXFLAGS := -msg_quiet"<<endl;
543//os<<"include $(DPCBASEREP)/Include/MakefileUser.h"<<endl;
544//os<<"MYLIBS ="<<endl;
545//os<<"LIBS = -L$(SLB) -lPI -lextsophya -lsophya -lm"<<endl;
546//os<<"ifeq ($(MACHEROS),OSF1)"<<endl;
547//os<<"LIBS := $(LIBS) -lfor"<<endl;
548//os<<"endif"<<endl;
549//os<<"ifeq ($(MACHEROS),Linux)"<<endl;
550//os<<"LIBS := $(LIBS) -ldl -lf2c"<<endl;
551//os<<"endif"<<endl;
552//os<<"%.so:%.o"<<endl;
553//os<<"%:%.cc"<<endl;
554//os<<"%:%.o"<<endl;
555//os<<"%.o:%.cc"<<endl;
556//os<<"%.o:%.c"<<endl;
557//os<<"%:%.c"<<endl;
558//os<<endl;
559//os<<".PRECIOUS: %.so"<<endl;
560//os<<endl;
561//os<<"%:%.so"<<endl;
562//os<<"\t"<<"echo $@ \" made (.so) \""<<endl;
563//os<<"%.so:%.o"<<endl;
564//os<<"\t"<<"$(LINK.cc) -shared -o $@ $< $(LIBS) $(MYLIBS)"<<endl;
565//os<<"%.o:%.cc"<<endl;
566//os<<"\t"<<"$(COMPILE.cc) -o $@ $<"<<endl;
567//os<<"%.o:%.c"<<endl;
568//os<<"\t"<<"$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $<"<<endl;
569//---------------------------------------------------------------------
570//return 0;
571//}
572
573/* --Methode-- */
574int CxxExecutor::Link(string libname,string func)
575{
576if(libname.size()<1) libname = mDefTmp + mDefRoot + ".so";
577 else libname = mDefTmp + libname;
578if(func.size()<1) func = mDefFunc;
579
580NamedObjMgr omg;
581PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
582
583string key("linkff2");
584vector<string> arg; arg.push_back(libname); arg.push_back(func);
585string toks = libname + " " + func;
586int rc = mpiac->ExecuteCommand(key,arg,toks);
587if(mPrtLevel>1) cout<<"Link from "<<libname<<" for function "<<func
588 <<" (rc="<<rc<<")"<<endl;
589return 0;
590}
591
592/* --Methode-- */
593int CxxExecutor::Call(string func)
594{
595if(func.size()<1) func = mDefFunc;
596
597NamedObjMgr omg;
598PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
599
600string key("call");
601vector<string> arg; arg.push_back(func);
602string toks = func;
603if(mCallArgs.size()>0)
604 for(uint_4 i=0;i<mCallArgs.size();i++) arg.push_back(mCallArgs[i]);
605mpiac->ExecuteCommand(key,arg,toks);
606return 0;
607}
608
609/* --Methode-- */
610void CxxExecutor::FillArgs(vector<string>& args)
611{
612mCallArgs.resize(0);
613if(args.size()<1) return;
614for(uint_4 i=0;i<args.size();i++) mCallArgs.push_back(args[i]);
615}
616
617void CxxExecutor::FillArgs(string& args)
618{
619mCallArgs.resize(0);
620FillVStringFrString(args,mCallArgs,' ');
621}
622
623string CxxExecutor::GetArgs(void)
624{
625string dum = "";
626if(mCallArgs.size()<1) return dum;
627for(uint_4 i=0;i<mCallArgs.size();i++) dum += mCallArgs[i] + " ";
628return dum;
629}
630
631/* --Methode-- */
632void CxxExecutor::FillInclude(vector<string>& inc)
633{
634mIncList.resize(0);
635if(inc.size()<1) return;
636for(uint_4 i=0;i<inc.size();i++) mIncList.push_back(inc[i]);
637}
638
639void CxxExecutor::FillInclude(string& inc)
640{
641mIncList.resize(0);
642FillVStringFrString(inc,mIncList,' ');
643}
644
645string CxxExecutor::GetInclude(void)
646{
647string dum = "";
648if(mIncList.size()<1) return dum;
649for(uint_4 i=0;i<mIncList.size();i++) dum += mIncList[i] + " ";
650return dum;
651}
652
653/* --Methode-- */
654void CxxExecutor::FillCompileOpt(vector<string>& copt)
655{
656mCompOpt = "";
657if(copt.size()<1) return;
658for(uint_4 i=0;i<copt.size();i++) mCompOpt += copt[i] + " ";
659}
660
661void CxxExecutor::FillCompileOpt(string& copt)
662{
663mCompOpt = copt;
664}
665
666string CxxExecutor::GetCompileOpt(void)
667{
668return mCompOpt;
669}
670
671/* --Methode-- */
672void CxxExecutor::FillLinkOpt(vector<string>& lopt)
673{
674mLinkOpt = "";
675if(lopt.size()<1) return;
676for(uint_4 i=0;i<lopt.size();i++) mLinkOpt += lopt[i] + " ";
677}
678
679void CxxExecutor::FillLinkOpt(string& lopt)
680{
681mLinkOpt = lopt;
682}
683
684string CxxExecutor::GetLinkOpt(void)
685{
686return mLinkOpt;
687}
688
689/* --Methode-- */
690void CxxExecutor::FillLinkLibs(vector<string>& llibs)
691{
692mMyLibs = "";
693if(llibs.size()<1) return;
694for(uint_4 i=0;i<llibs.size();i++) mMyLibs += llibs[i] + " ";
695}
696
697void CxxExecutor::FillLinkLibs(string& llibs)
698{
699mMyLibs = llibs;
700}
701
702string CxxExecutor::GetLinkLibs(void)
703{
704return mMyLibs;
705}
Note: See TracBrowser for help on using the repository browser.