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