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