| 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 | , 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 | // 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";
|
|---|
| 41 | usage+= "Usage: c++exec c++ user code\n";
|
|---|
| 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\"";
|
|---|
| 44 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 45 |
|
|---|
| 46 | kw = "c++execfrf";
|
|---|
| 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\"";
|
|---|
| 50 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 51 |
|
|---|
| 52 | kw = "c++args";
|
|---|
| 53 | usage = "c++args: Define user function arguments for c++exec and c++execfrf\n";
|
|---|
| 54 | usage+= "Usage: c++args arg1 arg2 arg3 ...\n";
|
|---|
| 55 | usage+= " c++args -? : give current arguments\n";
|
|---|
| 56 | usage+= " c++args : reset current arguments";
|
|---|
| 57 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 58 |
|
|---|
| 59 | kw = "c++create";
|
|---|
| 60 | usage = "c++create: create a file \"file.cc\" to be used by spiapp\n";
|
|---|
| 61 | usage+= "Usage: c++create file.cc func c++ user code...\n";
|
|---|
| 62 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 63 |
|
|---|
| 64 | kw = "c++createfrf";
|
|---|
| 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";
|
|---|
| 68 | usage+= "Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]\n";
|
|---|
| 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";
|
|---|
| 84 | usage = "c++include: add personnal includes to be used by executor\n";
|
|---|
| 85 | usage+= "Usage: c++include myinc1.h myinc2.h ...\n";
|
|---|
| 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...";
|
|---|
| 89 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 90 |
|
|---|
| 91 | kw = "c++compileopt";
|
|---|
| 92 | usage = "c++compileopt: add personnal compile options\n";
|
|---|
| 93 | usage+= "Usage: c++compileopt -g -O5 -IMy_Inc_Dir ...\n";
|
|---|
| 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 ...";
|
|---|
| 97 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 98 |
|
|---|
| 99 | kw = "c++linkopt";
|
|---|
| 100 | usage = "c++linkopt: add personnal link options\n";
|
|---|
| 101 | usage+= "Usage: c++linkopt -g -O5 ...\n";
|
|---|
| 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 ...";
|
|---|
| 105 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 106 |
|
|---|
| 107 | kw = "c++mylibs";
|
|---|
| 108 | usage = "c++mylibs: add personnal libraries\n";
|
|---|
| 109 | usage+= "Usage: c++mylibs -LMy_Lib_Dir -lmylib1 -lmylib2 ...\n";
|
|---|
| 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 ...";
|
|---|
| 113 | mpiac->RegisterCommand(kw, usage, this, hgrp);
|
|---|
| 114 |
|
|---|
| 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);
|
|---|
| 124 |
|
|---|
| 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 |
|
|---|
| 133 | }
|
|---|
| 134 |
|
|---|
| 135 | /* --Methode-- */
|
|---|
| 136 | CxxExecutor::~CxxExecutor()
|
|---|
| 137 | {
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | /* --Methode-- */
|
|---|
| 141 | int CxxExecutor::Execute(string& kw, vector<string>& tokens, string& toks)
|
|---|
| 142 | {
|
|---|
| 143 | int rc=0;
|
|---|
| 144 | if(kw == "c++exec") {
|
|---|
| 145 | if(tokens.size()<1) {
|
|---|
| 146 | cout<<"Usage: c++exec c++ user code"<<endl;
|
|---|
| 147 | return(1);
|
|---|
| 148 | }
|
|---|
| 149 | rc = ExecuteCXX(toks); if(rc) return(1);
|
|---|
| 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 | }
|
|---|
| 156 | rc = FillUserCode(tokens[0]); if(rc) return(1);
|
|---|
| 157 | if(tokens.size()>1) rc = FillUserFctFrF(tokens[1]);
|
|---|
| 158 | else rc = FillUserFctFrF();
|
|---|
| 159 | if(rc) return(1);
|
|---|
| 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") {
|
|---|
| 166 | if(tokens.size()==1) if(tokens[0]=="-?")
|
|---|
| 167 | {cout<<"c++args "<<GetArgs()<<endl; return(0);}
|
|---|
| 168 | FillArgs(tokens);
|
|---|
| 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 | }
|
|---|
| 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);
|
|---|
| 178 |
|
|---|
| 179 | } else if(kw == "c++createfrf") {
|
|---|
| 180 | if(tokens.size()<3) {
|
|---|
| 181 | cout<<"Usage: c++createfrf file.cc func fileuser.cc [fileuserfct.cc]"<<endl;
|
|---|
| 182 | return(1);
|
|---|
| 183 | }
|
|---|
| 184 | rc = FillUserCode(tokens[2]); if(rc) return(1);
|
|---|
| 185 | if(tokens.size()>3) rc = FillUserFctFrF(tokens[3]);
|
|---|
| 186 | else rc = FillUserFctFrF(tokens[3]);
|
|---|
| 187 | if(rc) return(1);
|
|---|
| 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") {
|
|---|
| 202 | if(tokens.size()==1) if(tokens[0]=="-?")
|
|---|
| 203 | {cout<<"c++include "<<GetInclude()<<endl; return(0);}
|
|---|
| 204 | FillInclude(tokens);
|
|---|
| 205 |
|
|---|
| 206 | } else if(kw == "c++compileopt") {
|
|---|
| 207 | if(tokens.size()==1) if(tokens[0]=="-?")
|
|---|
| 208 | {cout<<"c++compileopt "<<GetCompileOpt()<<endl; return(0);}
|
|---|
| 209 | FillCompileOpt(tokens);
|
|---|
| 210 |
|
|---|
| 211 | } else if(kw == "c++linkopt") {
|
|---|
| 212 | if(tokens.size()==1) if(tokens[0]=="-?")
|
|---|
| 213 | {cout<<"c++linkopt "<<GetLinkOpt()<<endl; return(0);}
|
|---|
| 214 | FillLinkOpt(tokens);
|
|---|
| 215 |
|
|---|
| 216 | } else if(kw == "c++mylibs") {
|
|---|
| 217 | if(tokens.size()==1) if(tokens[0]=="-?")
|
|---|
| 218 | {cout<<"c++mylibs "<<GetLinkLibs()<<endl; return(0);}
|
|---|
| 219 | FillLinkLibs(tokens);
|
|---|
| 220 |
|
|---|
| 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 |
|
|---|
| 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 |
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | return(0);
|
|---|
| 248 | }
|
|---|
| 249 |
|
|---|
| 250 | /* --Methode-- */
|
|---|
| 251 | int CxxExecutor::ExecuteCXX(string usercode,string userfct)
|
|---|
| 252 | {
|
|---|
| 253 | int rc=0;
|
|---|
| 254 | rc = FillUserCode(usercode,0); if(rc) return(1);
|
|---|
| 255 | rc = FillUserFctFrS(userfct); if(rc) return(1);
|
|---|
| 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-- */
|
|---|
| 264 | int CxxExecutor::CrFile(string cfilename,string func)
|
|---|
| 265 | // Si un nom n'est pas precise alors TmpDir/cxx_spiapp.cc
|
|---|
| 266 | {
|
|---|
| 267 | if(cfilename.size()<1) cfilename = TmpDir() + mDefRoot + ".cc";
|
|---|
| 268 |
|
|---|
| 269 | if(func.size()<1) func = mDefFunc;
|
|---|
| 270 |
|
|---|
| 271 | ofstream os(cfilename.c_str(),ios::out);
|
|---|
| 272 | if(!os)
|
|---|
| 273 | {cout<<"CxxExecutor::CrFile: unable to open "<<cfilename<<endl;
|
|---|
| 274 | return 1;}
|
|---|
| 275 |
|
|---|
| 276 | PutInclude(os);
|
|---|
| 277 | os<<endl;
|
|---|
| 278 |
|
|---|
| 279 | PutIncludeUser(os);
|
|---|
| 280 | os<<endl;
|
|---|
| 281 |
|
|---|
| 282 | os<<"//-------------------------------------------------//"<<endl;
|
|---|
| 283 | os<<"//----------------- User Functions ----------------//"<<endl;
|
|---|
| 284 | os<<"//-------------------------------------------------//"<<endl;
|
|---|
| 285 | if(mUserFctFn.size()>0) os<<"#include \""<<mUserFctFn<<"\""<<endl;
|
|---|
| 286 | os<<endl;
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 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 |
|
|---|
| 305 | os<<"//--------------------------------------------//"<<endl;
|
|---|
| 306 | os<<"//----------------- User Code ----------------//"<<endl;
|
|---|
| 307 | os<<"//--------------------------------------------//"<<endl;
|
|---|
| 308 | if(mUserCodeFn.size()>0) os<<"#include \""<<mUserCodeFn<<"\""<<endl;
|
|---|
| 309 | os<<endl;
|
|---|
| 310 |
|
|---|
| 311 | os<<"return 0;"<<endl;
|
|---|
| 312 | os<<"}"<<endl;
|
|---|
| 313 |
|
|---|
| 314 | if(mPrtLevel>1)
|
|---|
| 315 | cout<<"File "<<cfilename<<" for function "<<func<<" created :"<<endl;
|
|---|
| 316 | if(mPrtLevel>1 && mUserCodeFn.size()>0)
|
|---|
| 317 | cout<<" User code was in file "<<mUserCodeFn<<endl;
|
|---|
| 318 | if(mPrtLevel>1 && mUserFctFn.size()>0)
|
|---|
| 319 | cout<<" User function code was in file "<<mUserFctFn<<endl;
|
|---|
| 320 | return 0;
|
|---|
| 321 | }
|
|---|
| 322 |
|
|---|
| 323 | /* --Methode-- */
|
|---|
| 324 | void CxxExecutor::PutInclude(ofstream& os)
|
|---|
| 325 | {
|
|---|
| 326 | os<<"#include \"machdefs.h\""<<endl<<endl;
|
|---|
| 327 |
|
|---|
| 328 | os<<"//---- System et stdc++ include files"<<endl
|
|---|
| 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 |
|
|---|
| 347 | #ifdef SANS_EVOLPLANCK
|
|---|
| 348 | <<"//---- Peida include files"<<endl
|
|---|
| 349 | <<"#include \"toutpeida.h\""<<endl
|
|---|
| 350 | #else
|
|---|
| 351 | <<"//---- Sophya include files"<<endl
|
|---|
| 352 | <<"#include \"basetools.h\""<<endl
|
|---|
| 353 | <<"#include \"systools.h\""<<endl
|
|---|
| 354 | <<"#include \"sutils.h\""<<endl
|
|---|
| 355 | <<"#include \"ntools.h\""<<endl
|
|---|
| 356 | <<"#include \"array.h\""<<endl
|
|---|
| 357 | <<"#include \"histats.h\""<<endl
|
|---|
| 358 | <<endl
|
|---|
| 359 | #endif
|
|---|
| 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 | <<" long mExcErr = nullPtrErr; \n"
|
|---|
| 439 | <<" cerr << \"CxxExecutor::PutObject: Non existing object "
|
|---|
| 440 | <<" ... please update file \\n \" ;"
|
|---|
| 441 | <<" throw mExcErr ; \n } "<<endl;
|
|---|
| 442 | #else
|
|---|
| 443 | os<<"if("<<stmp<<"==NULL) throw NullPtrError"
|
|---|
| 444 | <<"(\"CxxExecutor::PutObject: Non existing object "<<nobj
|
|---|
| 445 | <<"... please update file\");"<<endl;
|
|---|
| 446 | #endif
|
|---|
| 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;
|
|---|
| 463 | if (isalpha(key[0]) ) {
|
|---|
| 464 | os<<"___nomobj = \""<<key<<"\";"<<endl;
|
|---|
| 465 | os<<"MuTyV & $"<<key<<" = omg.GetVarList().Get(___nomobj);"<<endl;
|
|---|
| 466 | }
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 | return;
|
|---|
| 470 | }
|
|---|
| 471 |
|
|---|
| 472 | /* --Methode-- */
|
|---|
| 473 | int CxxExecutor::FillUserCode(string& usercode,uint_4 first)
|
|---|
| 474 | // User code is read from input.
|
|---|
| 475 | // - first is the first position in the "string" where the code starts
|
|---|
| 476 | // - Code is put into file "TmpDir/cxx_spiapp.h".
|
|---|
| 477 | {
|
|---|
| 478 | mUserCodeFn = "";
|
|---|
| 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
|
|---|
| 499 | mUserCodeFn = TmpDir() + mDefRoot + ".h";
|
|---|
| 500 | ofstream os(mUserCodeFn.c_str(),ios::out);
|
|---|
| 501 | if(!os) {cout<<"CxxExecutor::FillUserCode: unable to open "
|
|---|
| 502 | <<mUserCodeFn<<endl; mUserCodeFn = ""; return 1;}
|
|---|
| 503 | os<<code<<endl;
|
|---|
| 504 | if(mPrtLevel>1)
|
|---|
| 505 | cout<<"User code filled from standard input into "<<mUserCodeFn<<endl;
|
|---|
| 506 | return 0;
|
|---|
| 507 | }
|
|---|
| 508 |
|
|---|
| 509 | /* --Methode-- */
|
|---|
| 510 | int CxxExecutor::FillUserFctFrS(string userfctcode)
|
|---|
| 511 | // - Fill user Fonction code from string "userfct"
|
|---|
| 512 | // - Code is put into file "TmpDir/cxx_spiapp_fct.h".
|
|---|
| 513 | {
|
|---|
| 514 | mUserFctFn = "";
|
|---|
| 515 | if(userfctcode.size()<1) return 0;
|
|---|
| 516 | mUserFctFn = TmpDir() + mDefRoot + "_fct.h";
|
|---|
| 517 | ofstream os(mUserFctFn.c_str(),ios::out);
|
|---|
| 518 | if(!os) {cout<<"CxxExecutor::FillUserFctFrS: unable to open "
|
|---|
| 519 | <<mUserFctFn<<endl; mUserFctFn = ""; return 1;}
|
|---|
| 520 | os<<userfctcode<<endl;
|
|---|
| 521 | if(mPrtLevel>1)
|
|---|
| 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 | {
|
|---|
| 530 | mUserCodeFn = filename;
|
|---|
| 531 | if(mPrtLevel>1 && mUserCodeFn.size()>0)
|
|---|
| 532 | cout<<"User code filled from file "<<mUserCodeFn<<endl;
|
|---|
| 533 | return 0;
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | /* --Methode-- */
|
|---|
| 537 | int CxxExecutor::FillUserFctFrF(string filefctname)
|
|---|
| 538 | // User function code is read from "filefctname".
|
|---|
| 539 | {
|
|---|
| 540 | mUserFctFn = filefctname;
|
|---|
| 541 | if(mPrtLevel>1 && mUserFctFn.size()>0)
|
|---|
| 542 | cout<<"User Function code filled from file "<<mUserFctFn<<endl;
|
|---|
| 543 | return 0;
|
|---|
| 544 | }
|
|---|
| 545 |
|
|---|
| 546 | /* --Methode-- */
|
|---|
| 547 | int CxxExecutor::Compile(string rootfilename)
|
|---|
| 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 | //--------------------------------------------------------//
|
|---|
| 556 | {
|
|---|
| 557 | if(rootfilename.size()<1) rootfilename = TmpDir() + mDefRoot;
|
|---|
| 558 | if(mPrtLevel>1) cout<<"Compile "<<rootfilename<<endl;
|
|---|
| 559 |
|
|---|
| 560 | int rc;
|
|---|
| 561 | #ifdef SANS_EVOLPLANCK
|
|---|
| 562 | CxxCompilerLinker cxx;
|
|---|
| 563 | string sophlib = " -lPIE -lm ";
|
|---|
| 564 | cxx.AddLinkOptions(sophlib);
|
|---|
| 565 | #else
|
|---|
| 566 | CxxCompilerLinker cxx(true,true,true);
|
|---|
| 567 | #endif
|
|---|
| 568 | if(TmpDir().size()>0) cxx.SetTmpDir(TmpDir());
|
|---|
| 569 | if(mPrtLevel>0) cxx.SetVerbose(true);
|
|---|
| 570 | else cxx.SetVerbose(false);
|
|---|
| 571 |
|
|---|
| 572 | // Compilation
|
|---|
| 573 | string fcc = rootfilename + ".cc";
|
|---|
| 574 | string fo = "";
|
|---|
| 575 | cxx.AddCompileOptions(mCompOpt);
|
|---|
| 576 | rc = cxx.Compile(fcc,fo);
|
|---|
| 577 | if(mPrtLevel>1) cout << "Compilation rc = "<<rc<< endl;
|
|---|
| 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);
|
|---|
| 585 | if(mPrtLevel>1) cout << "Shared Library rc = "<<rc<< endl;
|
|---|
| 586 | if(rc) return 2;
|
|---|
| 587 |
|
|---|
| 588 | return 0;
|
|---|
| 589 | }
|
|---|
| 590 |
|
|---|
| 591 | /* --Methode-- */
|
|---|
| 592 | //int CxxExecutor::Compile(string rootfilename)
|
|---|
| 593 | // Ne marche pas si TmpDir != ""
|
|---|
| 594 | //{
|
|---|
| 595 | //if(rootfilename.size()<1) rootfilename = mDefRoot;
|
|---|
| 596 | //if(mPrtLevel>1) cout<<"Compile: "<<rootfilename<<endl;
|
|---|
| 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 | //{
|
|---|
| 617 | //string makename = TmpDir() + mDefRoot + "_Makefile";
|
|---|
| 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;}
|
|---|
| 622 | //---------------------------------------------------------------------
|
|---|
| 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;
|
|---|
| 631 | //os<<"#LIBS := $(LIBS) -ldl -lf2c"<<endl;
|
|---|
| 632 | //os<<"LIBS := $(LIBS) -ldl -lg2c"<<endl;
|
|---|
| 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;
|
|---|
| 651 | //---------------------------------------------------------------------
|
|---|
| 652 | //return 0;
|
|---|
| 653 | //}
|
|---|
| 654 |
|
|---|
| 655 | /* --Methode-- */
|
|---|
| 656 | int CxxExecutor::Link(string libname,string func)
|
|---|
| 657 | {
|
|---|
| 658 | if(libname.size()<1) libname = TmpDir() + mDefRoot + ".so";
|
|---|
| 659 | else libname = TmpDir() + libname;
|
|---|
| 660 | if(func.size()<1) func = mDefFunc;
|
|---|
| 661 |
|
|---|
| 662 | NamedObjMgr omg;
|
|---|
| 663 | PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
|
|---|
| 664 |
|
|---|
| 665 | string key("linkff2");
|
|---|
| 666 | vector<string> arg; arg.push_back(libname); arg.push_back(func);
|
|---|
| 667 | string toks = libname + " " + func;
|
|---|
| 668 | int rc = mpiac->ExecuteCommand(key,arg,toks);
|
|---|
| 669 | if(mPrtLevel>1) cout<<"Link from "<<libname<<" for function "<<func
|
|---|
| 670 | <<" (rc="<<rc<<")"<<endl;
|
|---|
| 671 | return 0;
|
|---|
| 672 | }
|
|---|
| 673 |
|
|---|
| 674 | /* --Methode-- */
|
|---|
| 675 | int CxxExecutor::Call(string func)
|
|---|
| 676 | {
|
|---|
| 677 | if(func.size()<1) func = mDefFunc;
|
|---|
| 678 |
|
|---|
| 679 | NamedObjMgr omg;
|
|---|
| 680 | PIACmd* mpiac = omg.GetImgApp()->CmdInterpreter();
|
|---|
| 681 |
|
|---|
| 682 | string key("call");
|
|---|
| 683 | vector<string> arg; arg.push_back(func);
|
|---|
| 684 | string toks = func;
|
|---|
| 685 | if(mCallArgs.size()>0)
|
|---|
| 686 | for(uint_4 i=0;i<mCallArgs.size();i++) arg.push_back(mCallArgs[i]);
|
|---|
| 687 | mpiac->ExecuteCommand(key,arg,toks);
|
|---|
| 688 | return 0;
|
|---|
| 689 | }
|
|---|
| 690 |
|
|---|
| 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 | }
|
|---|
| 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++) {
|
|---|
| 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")
|
|---|
| 814 | mIncImportList.push_back("skymap.h");
|
|---|
| 815 | else if(mModuleImportList[i]=="SkyT")
|
|---|
| 816 | mIncImportList.push_back("skyt.h");
|
|---|
| 817 | else if(mModuleImportList[i]=="XAstroPack")
|
|---|
| 818 | mIncImportList.push_back("xastropack.h");
|
|---|
| 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 | }
|
|---|