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