[2615] | 1 | #include "sopnamsp.h"
|
---|
[1224] | 2 | #include "cxxexecutor.h"
|
---|
| 3 |
|
---|
| 4 | #include <typeinfo>
|
---|
| 5 |
|
---|
[1237] | 6 | #include "strutilxx.h"
|
---|
[1224] | 7 | #include "dvlist.h"
|
---|
[1287] | 8 | #include "cxxcmplnk.h"
|
---|
[1224] | 9 |
|
---|
| 10 | #include "nomgadapter.h"
|
---|
| 11 | #include "pistdimgapp.h"
|
---|
| 12 |
|
---|
| 13 |
|
---|
| 14 | /* --Methode-- */
|
---|
| 15 | CxxExecutor::CxxExecutor(PIACmd *mpiac, PIStdImgApp* /* app */)
|
---|
[1287] | 16 | : mUserCodeFn(""), mUserFctFn("")
|
---|
| 17 | , mCompOpt(""), mLinkOpt(""), mMyLibs("")
|
---|
[2287] | 18 | , mDefRoot("cxx_spiapp"), mDefFunc("usercxx"), mPrtLevel(2), mFgPutVar(false)
|
---|
[1224] | 19 | {
|
---|
| 20 | mIncList.resize(0);
|
---|
| 21 | mCallArgs.resize(0);
|
---|
| 22 |
|
---|
[1297] | 23 | mIncImportList.resize(0);
|
---|
| 24 | mModuleImportList.resize(0);
|
---|
| 25 |
|
---|
| 26 | // La liste de tous les modules que l'on peut ajouter
|
---|
| 27 | mModuleImportDefaultList.resize(0);
|
---|
| 28 | mModuleImportDefaultList.push_back("Samba");
|
---|
| 29 | mModuleImportDefaultList.push_back("SkyMap");
|
---|
[1319] | 30 | mModuleImportDefaultList.push_back("SkyT");
|
---|
| 31 | mModuleImportDefaultList.push_back("FitsIOServer");
|
---|
| 32 | mModuleImportDefaultList.push_back("IFFTW");
|
---|
| 33 | mModuleImportDefaultList.push_back("LinAlg");
|
---|
[1646] | 34 | mModuleImportDefaultList.push_back("XAstroPack");
|
---|
[1297] | 35 |
|
---|
[1224] | 36 | // On enregistre les nouvelles commandes
|
---|
| 37 | string hgrp = "CxxExecutorCmd";
|
---|
[3551] | 38 | string gdesc = "Commands for c++ codelt on the fly compilation and execution";
|
---|
| 39 | mpiac->AddHelpGroup(hgrp, gdesc);
|
---|
| 40 |
|
---|
[1224] | 41 | string usage,kw;
|
---|
| 42 |
|
---|
| 43 | kw = "c++exec";
|
---|
| 44 | usage = "c++exec: Execute the following c++ user code\n";
|
---|
[1237] | 45 | usage+= "Usage: c++exec c++ user code\n";
|
---|
[1268] | 46 | usage+= "Warning: c++ user code can be found in \"TmpDir/"+mDefRoot+".h\"\n";
|
---|
| 47 | usage+= " total generated code can be found in \"TmpDir/"+mDefRoot+".cc\"";
|
---|
[1224] | 48 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 49 |
|
---|
| 50 | kw = "c++execfrf";
|
---|
[1268] | 51 | usage = "c++execfrf: Execute c++ user_code [user_function_code]\n";
|
---|
| 52 | usage+= "Usage: c++execfrf fileuser.cc [fileuserfct.cc]\n";
|
---|
| 53 | usage+= "Warning: total generated code can be found in \"TmpDir/"+mDefRoot+".cc\"";
|
---|
[1224] | 54 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 55 |
|
---|
| 56 | kw = "c++args";
|
---|
[1237] | 57 | usage = "c++args: Define user function arguments for c++exec and c++execfrf\n";
|
---|
[1230] | 58 | usage+= "Usage: c++args arg1 arg2 arg3 ...\n";
|
---|
| 59 | usage+= " c++args -? : give current arguments\n";
|
---|
| 60 | usage+= " c++args : reset current arguments";
|
---|
[1224] | 61 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 62 |
|
---|
| 63 | kw = "c++create";
|
---|
[1287] | 64 | usage = "c++create: create a file \"file.cc\" to be used by spiapp\n";
|
---|
[1224] | 65 | usage+= "Usage: c++create file.cc func c++ user code...\n";
|
---|
| 66 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 67 |
|
---|
| 68 | kw = "c++createfrf";
|
---|
[1287] | 69 | usage = "c++createfrf: create a file \"file.cc\" to be used by spiapp\n";
|
---|
| 70 | usage+= " with a user file code \"fileuser.cc\"\n";
|
---|
| 71 | usage+= " and an optional user function code \"fileuserfct.cc\"\n";
|
---|
[1268] | 72 | usage+= "Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]\n";
|
---|
[1224] | 73 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 74 |
|
---|
| 75 | kw = "c++compile";
|
---|
| 76 | usage = "c++compile: compile a file (file.cc -> file.so)\n";
|
---|
| 77 | usage+= "Usage: c++compile file\n";
|
---|
| 78 | usage+= "Warning: give \"file\" or \"file.so\" to create \"file.so\" from \"file.cc\"\n";
|
---|
| 79 | usage+= " : to be used before c++link";
|
---|
| 80 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 81 |
|
---|
| 82 | kw = "c++link";
|
---|
| 83 | usage = "c++link: link function \"func\" in file.so to spiapp\n";
|
---|
| 84 | usage+= "Usage: c++link file.so func";
|
---|
| 85 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 86 |
|
---|
| 87 | kw = "c++include";
|
---|
[1297] | 88 | usage = "c++include: add personnal includes to be used by executor\n";
|
---|
[1224] | 89 | usage+= "Usage: c++include myinc1.h myinc2.h ...\n";
|
---|
[1297] | 90 | usage+= " c++include -? : list current additionnal include files\n";
|
---|
| 91 | usage+= " c++include : reset to no additionnal include files\n";
|
---|
| 92 | usage+= "Warning: to be used before c++create c++compile c++exec...";
|
---|
[1224] | 93 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 94 |
|
---|
| 95 | kw = "c++compileopt";
|
---|
[1297] | 96 | usage = "c++compileopt: add personnal compile options\n";
|
---|
[1224] | 97 | usage+= "Usage: c++compileopt -g -O5 -IMy_Inc_Dir ...\n";
|
---|
[1297] | 98 | usage+= " c++compileopt -? : list current additionnal compile options\n";
|
---|
| 99 | usage+= " c++compileopt : reset to no additionnal compile options\n";
|
---|
| 100 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
[1224] | 101 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 102 |
|
---|
| 103 | kw = "c++linkopt";
|
---|
[1297] | 104 | usage = "c++linkopt: add personnal link options\n";
|
---|
[1230] | 105 | usage+= "Usage: c++linkopt -g -O5 ...\n";
|
---|
[1297] | 106 | usage+= " c++linkopt -? : list current additionnal link options\n";
|
---|
| 107 | usage+= " c++linkopt : reset to no additionnal link options\n";
|
---|
| 108 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
[1224] | 109 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 110 |
|
---|
| 111 | kw = "c++mylibs";
|
---|
[1297] | 112 | usage = "c++mylibs: add personnal libraries\n";
|
---|
[1230] | 113 | usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...\n";
|
---|
[1297] | 114 | usage+= " c++mylibs -? : list current additionnal libraries\n";
|
---|
| 115 | usage+= " c++mylibs : reset to no additionnal libraries\n";
|
---|
| 116 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
[1224] | 117 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 118 |
|
---|
[1297] | 119 | kw = "c++import";
|
---|
| 120 | usage = "c++import: Sophya additionnal modules to be use in C++ executor\n";
|
---|
| 121 | usage+= "Usage: c++import module1 ... : set list of modules to be used by executor\n";
|
---|
| 122 | usage+= " c++import all : set all modules known by executor\n";
|
---|
| 123 | usage+= " c++import : reset to no additionnal module\n";
|
---|
| 124 | usage+= " c++import -? : list modules currently used in executor\n";
|
---|
| 125 | usage+= " c++import -?? : list of available modules for executor\n";
|
---|
| 126 | usage+= "Warning: to be used before c++create c++compile c++exec ...";
|
---|
| 127 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
[1230] | 128 |
|
---|
[2287] | 129 | kw = "c++declareomgvar";
|
---|
| 130 | usage = "c++declareomgvar: Activate/Deactivate ObjectManager variables declaration \n";
|
---|
| 131 | usage+= "Usage: c++declareomgvar [false/true] \n";
|
---|
| 132 | usage+= " if true, the ObjectManager variables are declared as $varname \n";
|
---|
| 133 | usage+= " no arguments: display the current status of the flag (default=false\n";
|
---|
| 134 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 135 |
|
---|
[1289] | 136 | kw = "c++prtlevel";
|
---|
| 137 | usage = "c++prtlevel: Print level\n";
|
---|
| 138 | usage+= "Usage: c++prtlevel prtlevel\n";
|
---|
| 139 | usage+= " prtlevel=0 : minimum printing\n";
|
---|
| 140 | usage+= " prtlevel=1 : + compiler/linker output\n";
|
---|
| 141 | usage+= " prtlevel=2 : + full infos (default)";
|
---|
| 142 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
---|
| 143 |
|
---|
[1224] | 144 | }
|
---|
| 145 |
|
---|
| 146 | /* --Methode-- */
|
---|
| 147 | CxxExecutor::~CxxExecutor()
|
---|
| 148 | {
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | /* --Methode-- */
|
---|
[1268] | 152 | int CxxExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
|
---|
[1224] | 153 | {
|
---|
| 154 | int rc=0;
|
---|
[1268] | 155 | if(kw == "c++exec") {
|
---|
[1224] | 156 | if(tokens.size()<1) {
|
---|
| 157 | cout<<"Usage: c++exec c++ user code"<<endl;
|
---|
| 158 | return(1);
|
---|
| 159 | }
|
---|
[2755] | 160 | // Pour synchronisation d'execution simultanee
|
---|
[2762] | 161 | ZSync zs(mutx_cxxe); zs.NOp();
|
---|
[2755] | 162 |
|
---|
[2944] | 163 | return ( ExecuteCXX(toks) );
|
---|
[1268] | 164 |
|
---|
| 165 | } else if(kw == "c++execfrf") {
|
---|
| 166 | if(tokens.size()<1) {
|
---|
| 167 | cout<<"Usage: c++execfrf fileuser.cc [fileuserfct.cc]"<<endl;
|
---|
| 168 | return(1);
|
---|
| 169 | }
|
---|
[2755] | 170 | // Pour synchronisation d'execution simultanee
|
---|
[2762] | 171 | ZSync zs(mutx_cxxe); zs.NOp();
|
---|
[2755] | 172 |
|
---|
[1269] | 173 | rc = FillUserCode(tokens[0]); if(rc) return(1);
|
---|
| 174 | if(tokens.size()>1) rc = FillUserFctFrF(tokens[1]);
|
---|
[1287] | 175 | else rc = FillUserFctFrF();
|
---|
| 176 | if(rc) return(1);
|
---|
[2944] | 177 | rc = CrFile(); if(rc) return(rc);
|
---|
| 178 | rc = Compile(); if(rc) return(rc);
|
---|
| 179 | rc = Link(); if(rc) return(rc);
|
---|
| 180 | rc = Call();
|
---|
| 181 | return(rc);
|
---|
[1224] | 182 |
|
---|
| 183 | } else if(kw == "c++args") {
|
---|
[1233] | 184 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 185 | {cout<<"c++args "<<GetArgs()<<endl; return(0);}
|
---|
[1230] | 186 | FillArgs(tokens);
|
---|
[1224] | 187 |
|
---|
| 188 | } else if(kw == "c++create") {
|
---|
| 189 | if(tokens.size()<3) {
|
---|
| 190 | cout<<"Usage: c++create file.cc func c++ user code ..."<<endl;
|
---|
| 191 | return(1);
|
---|
| 192 | }
|
---|
[2755] | 193 | // Pour synchronisation d'execution simultanee
|
---|
[2762] | 194 | ZSync zs(mutx_cxxe); zs.NOp();
|
---|
[2755] | 195 |
|
---|
[2944] | 196 | rc = FillUserCode(toks,2); if(rc) return(rc);
|
---|
| 197 | rc = FillUserFctFrS(); if(rc) return(rc);
|
---|
| 198 | rc = CrFile(tokens[0],tokens[1]);
|
---|
| 199 | return(1);
|
---|
[1224] | 200 |
|
---|
| 201 | } else if(kw == "c++createfrf") {
|
---|
| 202 | if(tokens.size()<3) {
|
---|
[1268] | 203 | cout<<"Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]"<<endl;
|
---|
[1224] | 204 | return(1);
|
---|
| 205 | }
|
---|
[2755] | 206 | // Pour synchronisation d'execution simultanee
|
---|
[2762] | 207 | ZSync zs(mutx_cxxe); zs.NOp();
|
---|
[2755] | 208 |
|
---|
[1269] | 209 | rc = FillUserCode(tokens[2]); if(rc) return(1);
|
---|
[1287] | 210 | if(tokens.size()>3) rc = FillUserFctFrF(tokens[3]);
|
---|
| 211 | else rc = FillUserFctFrF(tokens[3]);
|
---|
| 212 | if(rc) return(1);
|
---|
[2944] | 213 | rc = CrFile(tokens[0],tokens[1]);
|
---|
| 214 | return rc;
|
---|
[1224] | 215 |
|
---|
| 216 | } else if(kw == "c++compile") {
|
---|
[2755] | 217 | // Pour synchronisation d'execution simultanee
|
---|
[2762] | 218 | ZSync zs(mutx_cxxe); zs.NOp();
|
---|
[2755] | 219 |
|
---|
[1224] | 220 | if(tokens.size()>=1) rc = Compile(tokens[0]);
|
---|
| 221 | else rc = Compile();
|
---|
[2944] | 222 | return(rc);
|
---|
[1224] | 223 |
|
---|
| 224 | } else if(kw == "c++link") {
|
---|
[2755] | 225 | // Pour synchronisation d'execution simultanee
|
---|
[2762] | 226 | ZSync zs(mutx_cxxe); zs.NOp();
|
---|
[2755] | 227 |
|
---|
[1224] | 228 | if(tokens.size()>=2) rc = Link(tokens[0],tokens[1]);
|
---|
| 229 | else if(tokens.size()>=1) rc = Link(tokens[0]);
|
---|
| 230 | else rc = Link();
|
---|
[2944] | 231 | return(rc);
|
---|
[1224] | 232 |
|
---|
| 233 | } else if(kw == "c++include") {
|
---|
[1233] | 234 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 235 | {cout<<"c++include "<<GetInclude()<<endl; return(0);}
|
---|
[1230] | 236 | FillInclude(tokens);
|
---|
[1224] | 237 |
|
---|
| 238 | } else if(kw == "c++compileopt") {
|
---|
[1233] | 239 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 240 | {cout<<"c++compileopt "<<GetCompileOpt()<<endl; return(0);}
|
---|
[1230] | 241 | FillCompileOpt(tokens);
|
---|
[1224] | 242 |
|
---|
| 243 | } else if(kw == "c++linkopt") {
|
---|
[1233] | 244 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 245 | {cout<<"c++linkopt "<<GetLinkOpt()<<endl; return(0);}
|
---|
[1230] | 246 | FillLinkOpt(tokens);
|
---|
[1224] | 247 |
|
---|
| 248 | } else if(kw == "c++mylibs") {
|
---|
[1233] | 249 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 250 | {cout<<"c++mylibs "<<GetLinkLibs()<<endl; return(0);}
|
---|
[1230] | 251 | FillLinkLibs(tokens);
|
---|
[1289] | 252 |
|
---|
[1297] | 253 | } else if(kw == "c++import") {
|
---|
| 254 | if(tokens.size()==1) {
|
---|
| 255 | if(tokens[0]=="-?")
|
---|
| 256 | {cout<<"c++import "<<GetModuleImport()<<endl; return(0);}
|
---|
| 257 | if(tokens[0]=="-??") {
|
---|
| 258 | cout<<"c++import possibilities :"<<endl;
|
---|
| 259 | if(mModuleImportDefaultList.size()>0) {
|
---|
| 260 | for(uint_4 i=0;i<mModuleImportDefaultList.size();i++)
|
---|
| 261 | cout<<" "<<mModuleImportDefaultList[i];
|
---|
| 262 | cout<<endl;
|
---|
| 263 | }
|
---|
| 264 | return(0);
|
---|
| 265 | }
|
---|
| 266 | }
|
---|
| 267 | FillModuleImport(tokens);
|
---|
[2287] | 268 | } else if(kw == "c++declareomgvar") {
|
---|
| 269 | if (tokens.size() <1) {
|
---|
| 270 | string fgstat = (mFgPutVar) ? "TRUE" : "FALSE" ;
|
---|
| 271 | cout << " c++declareomgvar: Current flag status: " << fgstat << endl;
|
---|
| 272 | }
|
---|
| 273 | else {
|
---|
| 274 | if (tokens[0] == "true") DeclareObjMgrVar(true);
|
---|
| 275 | else if (tokens[0] == "false") DeclareObjMgrVar(false);
|
---|
| 276 | }
|
---|
[1289] | 277 | } else if(kw == "c++prtlevel") {
|
---|
| 278 | if(tokens.size()==1) if(tokens[0]=="-?")
|
---|
| 279 | {cout<<"c++prtlevel prtlevel = "<<mPrtLevel<<endl; return(0);}
|
---|
| 280 | if(tokens.size()>0) {
|
---|
| 281 | int lp=atoi(tokens[0].c_str()); if(lp<0) lp=0;
|
---|
| 282 | mPrtLevel=(uint_2) lp;
|
---|
| 283 | } else mPrtLevel=2;
|
---|
| 284 |
|
---|
[1224] | 285 | }
|
---|
| 286 |
|
---|
| 287 | return(0);
|
---|
| 288 | }
|
---|
| 289 |
|
---|
| 290 | /* --Methode-- */
|
---|
[2755] | 291 | bool CxxExecutor::IsThreadable(string const & kw)
|
---|
| 292 | {
|
---|
| 293 | if ( (kw == "c++exec") || (kw == "c++execfrf") ||
|
---|
| 294 | (kw == "c++create") || (kw == "c++createfrf") ||
|
---|
| 295 | (kw == "c++compile") || (kw == "c++link") ) return true;
|
---|
| 296 | else return false;
|
---|
| 297 | }
|
---|
| 298 |
|
---|
| 299 | /* --Methode-- */
|
---|
[1269] | 300 | int CxxExecutor::ExecuteCXX(string usercode,string userfct)
|
---|
| 301 | {
|
---|
| 302 | int rc=0;
|
---|
[2944] | 303 | rc = FillUserCode(usercode,0); if(rc) return(rc);
|
---|
| 304 | rc = FillUserFctFrS(userfct); if(rc) return(rc);
|
---|
| 305 | rc = CrFile(); if(rc) return(rc);
|
---|
| 306 | rc = Compile(); if(rc) return(rc);
|
---|
| 307 | rc = Link(); if(rc) return(rc);
|
---|
| 308 | rc = Call(); if(rc) return(rc);
|
---|
[1269] | 309 | return 0;
|
---|
| 310 | }
|
---|
| 311 |
|
---|
| 312 | /* --Methode-- */
|
---|
[1268] | 313 | int CxxExecutor::CrFile(string cfilename,string func)
|
---|
[1287] | 314 | // Si un nom n'est pas precise alors TmpDir/cxx_spiapp.cc
|
---|
[1262] | 315 | {
|
---|
[2181] | 316 | if(cfilename.size()<1) cfilename = TmpDir() + mDefRoot + ".cc";
|
---|
[1287] | 317 |
|
---|
[1268] | 318 | if(func.size()<1) func = mDefFunc;
|
---|
[1262] | 319 |
|
---|
[1224] | 320 | ofstream os(cfilename.c_str(),ios::out);
|
---|
[1237] | 321 | if(!os)
|
---|
| 322 | {cout<<"CxxExecutor::CrFile: unable to open "<<cfilename<<endl;
|
---|
| 323 | return 1;}
|
---|
[1224] | 324 |
|
---|
| 325 | PutInclude(os);
|
---|
| 326 | os<<endl;
|
---|
| 327 |
|
---|
| 328 | PutIncludeUser(os);
|
---|
| 329 | os<<endl;
|
---|
| 330 |
|
---|
[1268] | 331 | os<<"//-------------------------------------------------//"<<endl;
|
---|
[1269] | 332 | os<<"//----------------- User Functions ----------------//"<<endl;
|
---|
[1268] | 333 | os<<"//-------------------------------------------------//"<<endl;
|
---|
| 334 | if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl;
|
---|
| 335 | os<<endl;
|
---|
| 336 |
|
---|
| 337 |
|
---|
[1224] | 338 | os<<"extern \"C\" {"<<endl;
|
---|
| 339 | os<<" int "<<func<<"( vector<string>& args );"<<endl;
|
---|
| 340 | os<<"}"<<endl<<endl;
|
---|
| 341 | os<<"int "<<func<<"( vector<string>& args )"<<endl;
|
---|
| 342 | os<<"{"<<endl;
|
---|
| 343 | os<<"// Some definitions to help using spiapp;"<<endl;
|
---|
| 344 | os<<"NamedObjMgr omg;"<<endl;
|
---|
| 345 | os<<"Services2NObjMgr& srvo = *omg.GetServiceObj();"<<endl;
|
---|
| 346 | os<<endl;
|
---|
| 347 |
|
---|
| 348 | PutObject(os);
|
---|
| 349 | os<<endl;
|
---|
| 350 |
|
---|
[2287] | 351 | if (mFgPutVar) PutVar(os);
|
---|
[1224] | 352 | os<<endl;
|
---|
| 353 |
|
---|
[1237] | 354 | os<<"//--------------------------------------------//"<<endl;
|
---|
[1269] | 355 | os<<"//----------------- User Code ----------------//"<<endl;
|
---|
[1237] | 356 | os<<"//--------------------------------------------//"<<endl;
|
---|
[1269] | 357 | if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl;
|
---|
[1224] | 358 | os<<endl;
|
---|
| 359 |
|
---|
| 360 | os<<"return 0;"<<endl;
|
---|
| 361 | os<<"}"<<endl;
|
---|
| 362 |
|
---|
[1289] | 363 | if(mPrtLevel>1)
|
---|
[1269] | 364 | cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl;
|
---|
[1289] | 365 | if(mPrtLevel>1 && mUserCodeFn.size()>0)
|
---|
[1269] | 366 | cout<<" User code was in file "<<mUserCodeFn<<endl;
|
---|
[1289] | 367 | if(mPrtLevel>1 && mUserFctFn.size()>0)
|
---|
[1269] | 368 | cout<<" User function code was in file "<<mUserFctFn<<endl;
|
---|
[1224] | 369 | return 0;
|
---|
| 370 | }
|
---|
| 371 |
|
---|
| 372 | /* --Methode-- */
|
---|
| 373 | void CxxExecutor::PutInclude(ofstream& os)
|
---|
| 374 | {
|
---|
[1297] | 375 | os<<"#include \"machdefs.h\""<<endl<<endl;
|
---|
[1224] | 376 |
|
---|
[1297] | 377 | os<<"//---- System et stdc++ include files"<<endl
|
---|
[1224] | 378 | <<"#include <stdio.h>"<<endl
|
---|
| 379 | <<"#include <stdlib.h>"<<endl
|
---|
| 380 | <<"#include <math.h>"<<endl
|
---|
| 381 | <<"#include <ctype.h>"<<endl
|
---|
| 382 | <<"#include <string.h>"<<endl
|
---|
[2322] | 383 | <<"#include <iostream>"<<endl
|
---|
| 384 | <<"#include <fstream>"<<endl
|
---|
[1224] | 385 | <<"#include <complex>"<<endl
|
---|
| 386 | <<endl
|
---|
| 387 |
|
---|
| 388 | <<"#include <typeinfo>"<<endl
|
---|
| 389 | <<"#include <string>"<<endl
|
---|
| 390 | <<"#include <vector>"<<endl
|
---|
| 391 | <<"#include <map>"<<endl
|
---|
| 392 | <<"#include <functional>"<<endl
|
---|
| 393 | <<"#include <list>"<<endl
|
---|
| 394 | <<endl
|
---|
| 395 |
|
---|
[2123] | 396 | #ifdef SANS_EVOLPLANCK
|
---|
| 397 | <<"//---- Peida include files"<<endl
|
---|
| 398 | <<"#include \"toutpeida.h\""<<endl
|
---|
| 399 | #else
|
---|
[2616] | 400 | // Si on enleve sopnamsp.h (using namespace SOPHYA), il faudra accoler
|
---|
| 401 | // SOPHYA:: à toutes les déclarations automatiques - Reza, 10/09/2004
|
---|
[1224] | 402 | <<"//---- Sophya include files"<<endl
|
---|
[2616] | 403 | <<"#include \"sopnamsp.h\""<<endl // using namespace SOPHYA
|
---|
[1607] | 404 | <<"#include \"basetools.h\""<<endl
|
---|
[1224] | 405 | <<"#include \"systools.h\""<<endl
|
---|
[1607] | 406 | <<"#include \"sutils.h\""<<endl
|
---|
[1224] | 407 | <<"#include \"ntools.h\""<<endl
|
---|
| 408 | <<"#include \"array.h\""<<endl
|
---|
| 409 | <<"#include \"histats.h\""<<endl
|
---|
| 410 | <<endl
|
---|
[2123] | 411 | #endif
|
---|
[1224] | 412 |
|
---|
| 413 | <<"//---- Spiapp include files"<<endl
|
---|
| 414 | <<"#include \"nobjmgr.h\""<<endl
|
---|
| 415 | <<"#include \"servnobjm.h\""<<endl
|
---|
[1297] | 416 | <<endl;
|
---|
[1224] | 417 |
|
---|
[1297] | 418 | os<<"//---- Include files from additionnal modules"<<endl;
|
---|
| 419 | if(mIncImportList.size()>0)
|
---|
| 420 | for(uint_4 i=0;i<mIncImportList.size();i++)
|
---|
| 421 | os<<"#include \""<<mIncImportList[i]<<"\""<<endl;
|
---|
| 422 | os<<endl;
|
---|
| 423 |
|
---|
[1469] | 424 | os<<"//---- function to compare bits on double \n"
|
---|
| 425 | <<"int_8 BitCmp64(double v,int_8 flg) \n"
|
---|
| 426 | <<"{return ((int_8)((v<0.) ? v-0.1 : v+0.1))&flg;} \n"
|
---|
| 427 | <<endl;
|
---|
| 428 |
|
---|
[1319] | 429 | os<<"//---- function for Adding and displaying Objects " << endl;
|
---|
| 430 | os<<"void Keep_Object(AnyDataObj & obj, string const & nom) \n{ \n"
|
---|
| 431 | <<" string name = nom; \n NamedObjMgr om; \n"
|
---|
| 432 | <<" if (om.GetObj(name)) \n"
|
---|
| 433 | <<" cerr << \"KeepObj()/Warning Already kept object \" << endl; \n"
|
---|
| 434 | <<" else om.AddObj(obj, name); \n"
|
---|
| 435 | <<"} \n" << endl;
|
---|
| 436 | os<<"void Display_Object(AnyDataObj & obj, string const & opt, string const & nom) \n { \n"
|
---|
| 437 | <<" string name = nom; \n NamedObjMgr om; \n"
|
---|
| 438 | <<" if (!om.GetObj(name)) \n"
|
---|
| 439 | <<" om.AddObj(obj, name); \n"
|
---|
| 440 | <<" om.DisplayObj(name, opt); \n"
|
---|
| 441 | <<"} \n" << endl;
|
---|
[2287] | 442 | os<<"//---- function for getting and setting ObjectManager variables " << endl;
|
---|
| 443 | os<<"void Set_ObjMgrVar(MuTyV v, string const & nom) \n{ \n"
|
---|
| 444 | <<" NamedObjMgr om; \n"
|
---|
| 445 | <<" om.SetVar(nom, (string)v); \n"
|
---|
| 446 | <<"} \n" << endl;
|
---|
| 447 | os<<"MuTyV Get_ObjMgrVar(const char * nom) \n{ \n"
|
---|
| 448 | <<" string name = nom; NamedObjMgr om; \n"
|
---|
| 449 | <<" MuTyV v = om.GetVar(name); \n"
|
---|
| 450 | <<" return v; \n"
|
---|
| 451 | <<"} \n" << endl;
|
---|
[1319] | 452 |
|
---|
[2287] | 453 | os<<"//---- Macro for Objects and variables saving"<<endl
|
---|
| 454 | <<"#define KeepObj(obj) Keep_Object(obj, #obj)"<<endl
|
---|
| 455 | <<"#define GetOMVar(var) Get_ObjMgrVar( #var )"<<endl
|
---|
| 456 | <<"#define SetOMVar(var) Set_ObjMgrVar(var, #var )"<<endl
|
---|
[1224] | 457 | <<endl;
|
---|
| 458 |
|
---|
[2287] | 459 | os<<"//---- Macro Displaying objects and command execution"<<endl;
|
---|
[3448] | 460 | os<<"#define DispObj(obj, att) Display_Object(obj, att, #obj); \n" << endl;
|
---|
| 461 | os<<"#define ExecCmd(cmd) srvo.ExecuteCommand(cmd); \n" << endl;
|
---|
[1319] | 462 |
|
---|
[1224] | 463 | return;
|
---|
| 464 | }
|
---|
| 465 |
|
---|
| 466 | /* --Methode-- */
|
---|
| 467 | void CxxExecutor::PutIncludeUser(ofstream& os)
|
---|
| 468 | {
|
---|
| 469 | if(mIncList.size()<1) return;
|
---|
| 470 | for(uint_4 i=0;i<mIncList.size();i++)
|
---|
| 471 | os<<"#include \""<<mIncList[i]<<"\""<<endl;
|
---|
| 472 | }
|
---|
| 473 |
|
---|
| 474 | /* --Methode-- */
|
---|
| 475 | void CxxExecutor::PutObject(ofstream& os)
|
---|
| 476 | {
|
---|
| 477 | NamedObjMgr omg;
|
---|
| 478 | NObjMgrAdapter* objmgrad;
|
---|
| 479 | vector<string> objlist;
|
---|
| 480 | string patt = "*";
|
---|
| 481 | omg.GetObjList(patt,objlist);
|
---|
| 482 | int nobjs = objlist.size();
|
---|
| 483 |
|
---|
| 484 | os<<"//-------------- Object List --------------"<<endl;
|
---|
| 485 | os<<"//Number of objects = "<<nobjs<<endl;
|
---|
| 486 | os<<"string ___nomobj;"<<endl<<endl;
|
---|
| 487 | if(nobjs<=0) return;
|
---|
| 488 |
|
---|
| 489 | string dir,nobj,stmp,obtype;
|
---|
| 490 | for(int i=0;i<nobjs;i++) {
|
---|
| 491 | objmgrad = omg.GetObjAdapter(objlist[i]);
|
---|
| 492 | omg.ParseObjectName(objlist[i],dir,nobj);
|
---|
| 493 | obtype = objmgrad->GetDataObjType();
|
---|
| 494 | stmp = "___" + nobj;
|
---|
| 495 |
|
---|
| 496 | os<<"___nomobj = \""<<nobj<<"\";"<<endl;
|
---|
| 497 | os<<obtype<<"* "<<stmp
|
---|
| 498 | <<" = dynamic_cast< "<<obtype<<" * >(omg.GetObj(___nomobj));"<<endl;
|
---|
[1450] | 499 | #ifdef SANS_EVOLPLANCK
|
---|
| 500 | os<<"if("<<stmp<<"==NULL) { \n"
|
---|
[2182] | 501 | <<" long mExcErr = nullPtrErr; \n"
|
---|
[1450] | 502 | <<" cerr << \"CxxExecutor::PutObject: Non existing object "
|
---|
| 503 | <<" ... please update file \\n \" ;"
|
---|
[2181] | 504 | <<" throw mExcErr ; \n } "<<endl;
|
---|
[1450] | 505 | #else
|
---|
[1224] | 506 | os<<"if("<<stmp<<"==NULL) throw NullPtrError"
|
---|
| 507 | <<"(\"CxxExecutor::PutObject: Non existing object "<<nobj
|
---|
| 508 | <<"... please update file\");"<<endl;
|
---|
[1450] | 509 | #endif
|
---|
[1224] | 510 | os<<obtype<<"& "<<nobj<<" = (*"<<stmp<<");"<<endl<<endl;
|
---|
| 511 | }
|
---|
| 512 |
|
---|
| 513 | return;
|
---|
| 514 | }
|
---|
| 515 |
|
---|
| 516 | /* --Methode-- */
|
---|
| 517 | void CxxExecutor::PutVar(ofstream& os)
|
---|
| 518 | {
|
---|
| 519 | os<<"//-------------- Variable List --------------"<<endl;
|
---|
| 520 | NamedObjMgr omg;
|
---|
| 521 | DVList& varlist = omg.GetVarList();
|
---|
| 522 | // varlist.Show(); varlist.Print();
|
---|
| 523 | DVList::ValList::const_iterator it;
|
---|
| 524 | for(it=varlist.Begin(); it!=varlist.End(); it++) {
|
---|
| 525 | string key = (*it).first;
|
---|
[1262] | 526 | if (isalpha(key[0]) ) {
|
---|
| 527 | os<<"___nomobj = \""<<key<<"\";"<<endl;
|
---|
| 528 | os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
|
---|
| 529 | }
|
---|
[1224] | 530 | }
|
---|
| 531 |
|
---|
[1237] | 532 | return;
|
---|
[1224] | 533 | }
|
---|
| 534 |
|
---|
| 535 | /* --Methode-- */
|
---|
[1268] | 536 | int CxxExecutor::FillUserCode(string& usercode,uint_4 first)
|
---|
[1287] | 537 | // User code is read from input.
|
---|
[1268] | 538 | // - first is the first position in the "string" where the code starts
|
---|
[1287] | 539 | // - Code is put into file "TmpDir/cxx_spiapp.h".
|
---|
[1224] | 540 | {
|
---|
[1237] | 541 | mUserCodeFn = "";
|
---|
[1268] | 542 |
|
---|
| 543 | // get the string part which is after word "first"
|
---|
| 544 | string code = usercode;
|
---|
| 545 | if(code.size()<=0) {cout<<"CxxExecutor::FillUserCode: no user code"<<endl;
|
---|
| 546 | return 1;}
|
---|
| 547 | size_t q;
|
---|
| 548 | for(uint_4 i=0;i<=first;i++) {
|
---|
| 549 | q = code.find_first_not_of(" \t");
|
---|
| 550 | if(q>=code.size()) {code=""; break;}
|
---|
| 551 | code = code.substr(q);
|
---|
| 552 | if(i==first) break;
|
---|
| 553 | q = code.find_first_of(" \t");
|
---|
| 554 | if(q>=code.size()) {code=""; break;}
|
---|
| 555 | code = code.substr(q);
|
---|
| 556 | }
|
---|
| 557 | if(code.size()<=0)
|
---|
| 558 | {cout<<"CxxExecutor::FillUserCode: no user code after "<<first<<endl;
|
---|
| 559 | return 1;}
|
---|
| 560 |
|
---|
| 561 | // Fill the file with user code
|
---|
[2181] | 562 | mUserCodeFn = TmpDir() + mDefRoot + ".h";
|
---|
[1237] | 563 | ofstream os(mUserCodeFn.c_str(),ios::out);
|
---|
| 564 | if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
|
---|
| 565 | <<mUserCodeFn<<endl; mUserCodeFn = ""; return 1;}
|
---|
[1269] | 566 | os<<code<<endl;
|
---|
[1289] | 567 | if(mPrtLevel>1)
|
---|
[1269] | 568 | cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
|
---|
[1224] | 569 | return 0;
|
---|
| 570 | }
|
---|
| 571 |
|
---|
| 572 | /* --Methode-- */
|
---|
[1287] | 573 | int CxxExecutor::FillUserFctFrS(string userfctcode)
|
---|
[1269] | 574 | // - Fill user Fonction code from string "userfct"
|
---|
[1287] | 575 | // - Code is put into file "TmpDir/cxx_spiapp_fct.h".
|
---|
[1224] | 576 | {
|
---|
[1269] | 577 | mUserFctFn = "";
|
---|
[1287] | 578 | if(userfctcode.size()<1) return 0;
|
---|
[2181] | 579 | mUserFctFn = TmpDir() + mDefRoot + "_fct.h";
|
---|
[1269] | 580 | ofstream os(mUserFctFn.c_str(),ios::out);
|
---|
| 581 | if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open "
|
---|
| 582 | <<mUserFctFn<<endl; mUserFctFn = ""; return 1;}
|
---|
[1287] | 583 | os<<userfctcode<<endl;
|
---|
[1289] | 584 | if(mPrtLevel>1)
|
---|
[1269] | 585 | cout<<"User Function code filled from standard input into "<<mUserFctFn<<endl;
|
---|
| 586 | return 0;
|
---|
| 587 | }
|
---|
| 588 |
|
---|
| 589 | /* --Methode-- */
|
---|
| 590 | int CxxExecutor::FillUserCode(string filename)
|
---|
| 591 | // User code is read from "filename".
|
---|
| 592 | {
|
---|
[1237] | 593 | mUserCodeFn = filename;
|
---|
[1289] | 594 | if(mPrtLevel>1 && mUserCodeFn.size()>0)
|
---|
[1269] | 595 | cout<<"User code filled from file "<<mUserCodeFn<<endl;
|
---|
[1224] | 596 | return 0;
|
---|
| 597 | }
|
---|
| 598 |
|
---|
| 599 | /* --Methode-- */
|
---|
[1270] | 600 | int CxxExecutor::FillUserFctFrF(string filefctname)
|
---|
[1287] | 601 | // User function code is read from "filefctname".
|
---|
[1269] | 602 | {
|
---|
| 603 | mUserFctFn = filefctname;
|
---|
[1289] | 604 | if(mPrtLevel>1 && mUserFctFn.size()>0)
|
---|
[1269] | 605 | cout<<"User Function code filled from file "<<mUserFctFn<<endl;
|
---|
| 606 | return 0;
|
---|
| 607 | }
|
---|
| 608 |
|
---|
| 609 | /* --Methode-- */
|
---|
[1224] | 610 | int CxxExecutor::Compile(string rootfilename)
|
---|
[1287] | 611 | //--------------------------------------------------------//
|
---|
| 612 | // rootfilename = | name | "" ou (default) //
|
---|
| 613 | //--------------------------------------------------------//
|
---|
| 614 | // fichier .cc | name.cc | TmpDir/cxx_spiapp.cc //
|
---|
| 615 | // | ../dir/name.cc | //
|
---|
| 616 | // fichier .o | TmpDir/name.o | TmpDir/cxx_spiapp.o //
|
---|
| 617 | // fichier .so | TmpDir/name.so | TmpDir/cxx_spiapp.so //
|
---|
| 618 | //--------------------------------------------------------//
|
---|
[1224] | 619 | {
|
---|
[2181] | 620 | if(rootfilename.size()<1) rootfilename = TmpDir() + mDefRoot;
|
---|
[1289] | 621 | if(mPrtLevel>1) cout<<"Compile "<<rootfilename<<endl;
|
---|
[1287] | 622 |
|
---|
| 623 | int rc;
|
---|
[2123] | 624 | #ifdef SANS_EVOLPLANCK
|
---|
[1287] | 625 | CxxCompilerLinker cxx;
|
---|
[2123] | 626 | string sophlib = " -lPIE -lm ";
|
---|
| 627 | cxx.AddLinkOptions(sophlib);
|
---|
| 628 | #else
|
---|
| 629 | CxxCompilerLinker cxx(true,true,true);
|
---|
| 630 | #endif
|
---|
[2181] | 631 | if(TmpDir().size()>0) cxx.SetTmpDir(TmpDir());
|
---|
[1289] | 632 | if(mPrtLevel>0) cxx.SetVerbose(true);
|
---|
| 633 | else cxx.SetVerbose(false);
|
---|
[1287] | 634 |
|
---|
| 635 | // Compilation
|
---|
| 636 | string fcc = rootfilename + ".cc";
|
---|
| 637 | string fo = "";
|
---|
| 638 | cxx.AddCompileOptions(mCompOpt);
|
---|
| 639 | rc = cxx.Compile(fcc,fo);
|
---|
[1289] | 640 | if(mPrtLevel>1) cout << "Compilation rc = "<<rc<< endl;
|
---|
[1287] | 641 | if(rc) return 1;
|
---|
| 642 |
|
---|
| 643 | // Fabrication Shared Lib.
|
---|
| 644 | string fso = "";
|
---|
| 645 | cxx.AddLinkOptions(mLinkOpt);
|
---|
| 646 | cxx.AddLinkOptions(mMyLibs);
|
---|
| 647 | rc = cxx.BuildSO(fo,fso);
|
---|
[1289] | 648 | if(mPrtLevel>1) cout << "Shared Library rc = "<<rc<< endl;
|
---|
[1287] | 649 | if(rc) return 2;
|
---|
| 650 |
|
---|
[1224] | 651 | return 0;
|
---|
| 652 | }
|
---|
| 653 |
|
---|
| 654 | /* --Methode-- */
|
---|
[1287] | 655 | //int CxxExecutor::Compile(string rootfilename)
|
---|
| 656 | // Ne marche pas si TmpDir != ""
|
---|
| 657 | //{
|
---|
| 658 | //if(rootfilename.size()<1) rootfilename = mDefRoot;
|
---|
[1289] | 659 | //if(mPrtLevel>1) cout<<"Compile: "<<rootfilename<<endl;
|
---|
[1287] | 660 | //int rc = 0;
|
---|
| 661 | //rc = CrMakefile();
|
---|
| 662 | //if(rc) return(1);
|
---|
| 663 | //string make = "";
|
---|
| 664 | //make += "make -f " + mDefRoot + "_Makefile";
|
---|
| 665 | //make += " CXXFLAGS=\"" + mCompOpt + "\"";
|
---|
| 666 | //make += " LDFLAGS=\"" + mLinkOpt + "\"";
|
---|
| 667 | //make += " MYLIBS=\"" + mMyLibs + "\"";
|
---|
| 668 | //make += " " + rootfilename;
|
---|
| 669 | //rc = system(make.c_str());
|
---|
| 670 | //if(rc)
|
---|
| 671 | // {cout<<"CxxExecutor::Compile : \n"<<make<<" Failed"<<endl;
|
---|
| 672 | // return 1000+rc;}
|
---|
| 673 | //return 0;
|
---|
| 674 | //}
|
---|
| 675 |
|
---|
| 676 | /* --Methode-- */
|
---|
| 677 | //int CxxExecutor::CrMakefile(void)
|
---|
| 678 | // Ne marche pas si TmpDir != ""
|
---|
| 679 | //{
|
---|
[2181] | 680 | //string makename = TmpDir() + mDefRoot + "_Makefile";
|
---|
[1287] | 681 | //ofstream os(makename.c_str(),ios::out);
|
---|
| 682 | //if(!os)
|
---|
| 683 | // {cout<<"CxxExecutor::CrMakefile: unable to open file for Makefile"<<endl;
|
---|
| 684 | // return 1;}
|
---|
[1224] | 685 | //---------------------------------------------------------------------
|
---|
[1287] | 686 | //os<<"MODULEDECCXXFLAGS := -msg_quiet"<<endl;
|
---|
[2437] | 687 | //os<<"include $(SOPHYABASEREP)/Include/MakefileUser.h"<<endl;
|
---|
[1287] | 688 | //os<<"MYLIBS ="<<endl;
|
---|
| 689 | //os<<"LIBS = -L$(SLB) -lPI -lextsophya -lsophya -lm"<<endl;
|
---|
| 690 | //os<<"ifeq ($(MACHEROS),OSF1)"<<endl;
|
---|
| 691 | //os<<"LIBS := $(LIBS) -lfor"<<endl;
|
---|
| 692 | //os<<"endif"<<endl;
|
---|
| 693 | //os<<"ifeq ($(MACHEROS),Linux)"<<endl;
|
---|
[1473] | 694 | //os<<"#LIBS := $(LIBS) -ldl -lf2c"<<endl;
|
---|
| 695 | //os<<"LIBS := $(LIBS) -ldl -lg2c"<<endl;
|
---|
[1287] | 696 | //os<<"endif"<<endl;
|
---|
| 697 | //os<<"%.so:%.o"<<endl;
|
---|
| 698 | //os<<"%:%.cc"<<endl;
|
---|
| 699 | //os<<"%:%.o"<<endl;
|
---|
| 700 | //os<<"%.o:%.cc"<<endl;
|
---|
| 701 | //os<<"%.o:%.c"<<endl;
|
---|
| 702 | //os<<"%:%.c"<<endl;
|
---|
| 703 | //os<<endl;
|
---|
| 704 | //os<<".PRECIOUS: %.so"<<endl;
|
---|
| 705 | //os<<endl;
|
---|
| 706 | //os<<"%:%.so"<<endl;
|
---|
| 707 | //os<<"\t"<<"echo $@ \" made (.so) \""<<endl;
|
---|
| 708 | //os<<"%.so:%.o"<<endl;
|
---|
| 709 | //os<<"\t"<<"$(LINK.cc) -shared -o $@ $< $(LIBS) $(MYLIBS)"<<endl;
|
---|
| 710 | //os<<"%.o:%.cc"<<endl;
|
---|
| 711 | //os<<"\t"<<"$(COMPILE.cc) -o $@ $<"<<endl;
|
---|
| 712 | //os<<"%.o:%.c"<<endl;
|
---|
| 713 | //os<<"\t"<<"$(COMPILE.c) -c $(CFLAGS) $(USERFLAGS) -o $@ $<"<<endl;
|
---|
[1224] | 714 | //---------------------------------------------------------------------
|
---|
[1287] | 715 | //return 0;
|
---|
| 716 | //}
|
---|
[1224] | 717 |
|
---|
| 718 | /* --Methode-- */
|
---|
| 719 | int CxxExecutor::Link(string libname,string func)
|
---|
| 720 | {
|
---|
[2181] | 721 | if(libname.size()<1) libname = TmpDir() + mDefRoot + ".so";
|
---|
| 722 | else libname = TmpDir() + libname;
|
---|
[1268] | 723 | if(func.size()<1) func = mDefFunc;
|
---|
| 724 |
|
---|
[1224] | 725 | NamedObjMgr omg;
|
---|
| 726 | PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
|
---|
[1287] | 727 |
|
---|
[1276] | 728 | string key("linkff2");
|
---|
[1224] | 729 | vector<string> arg; arg.push_back(libname); arg.push_back(func);
|
---|
[1268] | 730 | string toks = libname + " " + func;
|
---|
| 731 | int rc = mpiac->ExecuteCommand(key,arg,toks);
|
---|
[1289] | 732 | if(mPrtLevel>1) cout<<"Link from "<<libname<<" for function "<<func
|
---|
[1287] | 733 | <<" (rc="<<rc<<")"<<endl;
|
---|
[2944] | 734 | return rc;
|
---|
[1224] | 735 | }
|
---|
| 736 |
|
---|
| 737 | /* --Methode-- */
|
---|
| 738 | int CxxExecutor::Call(string func)
|
---|
| 739 | {
|
---|
[1268] | 740 | if(func.size()<1) func = mDefFunc;
|
---|
| 741 |
|
---|
[1224] | 742 | NamedObjMgr omg;
|
---|
| 743 | PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
|
---|
[1287] | 744 |
|
---|
[1224] | 745 | string key("call");
|
---|
| 746 | vector<string> arg; arg.push_back(func);
|
---|
[1268] | 747 | string toks = func;
|
---|
[1224] | 748 | if(mCallArgs.size()>0)
|
---|
[1237] | 749 | for(uint_4 i=0;i<mCallArgs.size();i++) arg.push_back(mCallArgs[i]);
|
---|
[2944] | 750 | return ( mpiac->ExecuteCommand(key,arg,toks) );
|
---|
[1224] | 751 | }
|
---|
| 752 |
|
---|
[1230] | 753 | /* --Methode-- */
|
---|
| 754 | void CxxExecutor::FillArgs(vector<string>& args)
|
---|
| 755 | {
|
---|
| 756 | mCallArgs.resize(0);
|
---|
| 757 | if(args.size()<1) return;
|
---|
| 758 | for(uint_4 i=0;i<args.size();i++) mCallArgs.push_back(args[i]);
|
---|
| 759 | }
|
---|
| 760 |
|
---|
| 761 | void CxxExecutor::FillArgs(string& args)
|
---|
| 762 | {
|
---|
| 763 | mCallArgs.resize(0);
|
---|
| 764 | FillVStringFrString(args,mCallArgs,' ');
|
---|
| 765 | }
|
---|
| 766 |
|
---|
| 767 | string CxxExecutor::GetArgs(void)
|
---|
| 768 | {
|
---|
| 769 | string dum = "";
|
---|
| 770 | if(mCallArgs.size()<1) return dum;
|
---|
| 771 | for(uint_4 i=0;i<mCallArgs.size();i++) dum += mCallArgs[i] + " ";
|
---|
| 772 | return dum;
|
---|
| 773 | }
|
---|
| 774 |
|
---|
| 775 | /* --Methode-- */
|
---|
| 776 | void CxxExecutor::FillInclude(vector<string>& inc)
|
---|
| 777 | {
|
---|
| 778 | mIncList.resize(0);
|
---|
| 779 | if(inc.size()<1) return;
|
---|
| 780 | for(uint_4 i=0;i<inc.size();i++) mIncList.push_back(inc[i]);
|
---|
| 781 | }
|
---|
| 782 |
|
---|
| 783 | void CxxExecutor::FillInclude(string& inc)
|
---|
| 784 | {
|
---|
| 785 | mIncList.resize(0);
|
---|
| 786 | FillVStringFrString(inc,mIncList,' ');
|
---|
| 787 | }
|
---|
| 788 |
|
---|
| 789 | string CxxExecutor::GetInclude(void)
|
---|
| 790 | {
|
---|
| 791 | string dum = "";
|
---|
| 792 | if(mIncList.size()<1) return dum;
|
---|
| 793 | for(uint_4 i=0;i<mIncList.size();i++) dum += mIncList[i] + " ";
|
---|
| 794 | return dum;
|
---|
| 795 | }
|
---|
| 796 |
|
---|
| 797 | /* --Methode-- */
|
---|
| 798 | void CxxExecutor::FillCompileOpt(vector<string>& copt)
|
---|
| 799 | {
|
---|
| 800 | mCompOpt = "";
|
---|
| 801 | if(copt.size()<1) return;
|
---|
| 802 | for(uint_4 i=0;i<copt.size();i++) mCompOpt += copt[i] + " ";
|
---|
| 803 | }
|
---|
| 804 |
|
---|
| 805 | void CxxExecutor::FillCompileOpt(string& copt)
|
---|
| 806 | {
|
---|
| 807 | mCompOpt = copt;
|
---|
| 808 | }
|
---|
| 809 |
|
---|
| 810 | string CxxExecutor::GetCompileOpt(void)
|
---|
| 811 | {
|
---|
| 812 | return mCompOpt;
|
---|
| 813 | }
|
---|
| 814 |
|
---|
| 815 | /* --Methode-- */
|
---|
| 816 | void CxxExecutor::FillLinkOpt(vector<string>& lopt)
|
---|
| 817 | {
|
---|
| 818 | mLinkOpt = "";
|
---|
| 819 | if(lopt.size()<1) return;
|
---|
| 820 | for(uint_4 i=0;i<lopt.size();i++) mLinkOpt += lopt[i] + " ";
|
---|
| 821 | }
|
---|
| 822 |
|
---|
| 823 | void CxxExecutor::FillLinkOpt(string& lopt)
|
---|
| 824 | {
|
---|
| 825 | mLinkOpt = lopt;
|
---|
| 826 | }
|
---|
| 827 |
|
---|
| 828 | string CxxExecutor::GetLinkOpt(void)
|
---|
| 829 | {
|
---|
| 830 | return mLinkOpt;
|
---|
| 831 | }
|
---|
| 832 |
|
---|
| 833 | /* --Methode-- */
|
---|
| 834 | void CxxExecutor::FillLinkLibs(vector<string>& llibs)
|
---|
| 835 | {
|
---|
| 836 | mMyLibs = "";
|
---|
| 837 | if(llibs.size()<1) return;
|
---|
| 838 | for(uint_4 i=0;i<llibs.size();i++) mMyLibs += llibs[i] + " ";
|
---|
| 839 | }
|
---|
| 840 |
|
---|
| 841 | void CxxExecutor::FillLinkLibs(string& llibs)
|
---|
| 842 | {
|
---|
| 843 | mMyLibs = llibs;
|
---|
| 844 | }
|
---|
| 845 |
|
---|
| 846 | string CxxExecutor::GetLinkLibs(void)
|
---|
| 847 | {
|
---|
| 848 | return mMyLibs;
|
---|
| 849 | }
|
---|
[1297] | 850 |
|
---|
| 851 | /* --Methode-- */
|
---|
| 852 | void CxxExecutor::FillModuleImport(vector<string>& import)
|
---|
| 853 | {
|
---|
| 854 | mModuleImportList.resize(0);
|
---|
| 855 | mIncImportList.resize(0);
|
---|
| 856 | if(import.size()<1) return;
|
---|
| 857 |
|
---|
| 858 | if(import[0]=="all" || import[0]=="All" || import[0]=="ALL") {
|
---|
| 859 | mModuleImportList = mModuleImportDefaultList;
|
---|
| 860 | } else {
|
---|
| 861 | for(uint_4 i=0;i<import.size();i++) mModuleImportList.push_back(import[i]);
|
---|
| 862 | }
|
---|
| 863 |
|
---|
| 864 | // Set additionnal Includes
|
---|
| 865 | if(mModuleImportList.size()>0)
|
---|
| 866 | for(uint_4 i=0;i<mModuleImportList.size();i++) {
|
---|
[1646] | 867 | if( mModuleImportList[i]=="FitsIOServer")
|
---|
| 868 | mIncImportList.push_back("fitsioserver.h");
|
---|
| 869 | else if(mModuleImportList[i]=="IFFTW")
|
---|
| 870 | mIncImportList.push_back("fftwserver.h");
|
---|
| 871 | else if(mModuleImportList[i]=="LinAlg")
|
---|
| 872 | mIncImportList.push_back("intflapack.h");
|
---|
| 873 | else if( mModuleImportList[i]=="Samba")
|
---|
| 874 | {mIncImportList.push_back("skymap.h"); mIncImportList.push_back("samba.h");}
|
---|
| 875 | else if(mModuleImportList[i]=="SkyMap")
|
---|
[1617] | 876 | mIncImportList.push_back("skymap.h");
|
---|
[1646] | 877 | else if(mModuleImportList[i]=="SkyT")
|
---|
| 878 | mIncImportList.push_back("skyt.h");
|
---|
| 879 | else if(mModuleImportList[i]=="XAstroPack")
|
---|
| 880 | mIncImportList.push_back("xastropack.h");
|
---|
[1297] | 881 | }
|
---|
| 882 |
|
---|
| 883 | return;
|
---|
| 884 | }
|
---|
| 885 |
|
---|
| 886 | void CxxExecutor::FillModuleImport(string& import)
|
---|
| 887 | {
|
---|
| 888 | mModuleImportList.resize(0);
|
---|
| 889 | vector<string> vsimport;
|
---|
| 890 | FillVStringFrString(import,vsimport,' ');
|
---|
| 891 | FillModuleImport(vsimport);
|
---|
| 892 | }
|
---|
| 893 |
|
---|
| 894 | string CxxExecutor::GetModuleImport(void)
|
---|
| 895 | {
|
---|
| 896 | string dum = "";
|
---|
| 897 | if(mModuleImportList.size()<1) return dum;
|
---|
| 898 | for(uint_4 i=0;i<mModuleImportList.size();i++) dum += mModuleImportList[i] + " ";
|
---|
| 899 | return dum;
|
---|
| 900 | }
|
---|