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