| [1224] | 1 | // This may look like C code, but it is really -*- C++ -*- | 
|---|
| [1237] | 2 | // Classe CxxExecutor  : Dynamic C++ compile/execution in piapp | 
|---|
| [1224] | 3 | // (c) DAPNIA (CEA)                 LAL (IN2P3/CNRS) | 
|---|
|  | 4 | //                           C. Magneville  10/2000 | 
|---|
|  | 5 |  | 
|---|
|  | 6 | #ifndef CXXEXECUTOR_H_SEEN | 
|---|
|  | 7 | #define CXXEXECUTOR_H_SEEN | 
|---|
|  | 8 |  | 
|---|
|  | 9 | #include "machdefs.h" | 
|---|
|  | 10 | #include <stdio.h> | 
|---|
|  | 11 | #include <stdlib.h> | 
|---|
| [2322] | 12 | #include <iostream> | 
|---|
| [1224] | 13 |  | 
|---|
|  | 14 | #include <vector> | 
|---|
|  | 15 | #include <string> | 
|---|
|  | 16 |  | 
|---|
|  | 17 | #include "piacmd.h" | 
|---|
|  | 18 | #include "nobjmgr.h" | 
|---|
|  | 19 |  | 
|---|
|  | 20 | class CxxExecutor : public CmdExecutor { | 
|---|
|  | 21 | public: | 
|---|
|  | 22 | CxxExecutor(PIACmd* piac, PIStdImgApp* app); | 
|---|
|  | 23 | virtual ~CxxExecutor(); | 
|---|
| [1230] | 24 |  | 
|---|
| [1268] | 25 | virtual int Execute(string& keyw,vector<string>& args, string& toks); | 
|---|
| [2755] | 26 | virtual bool  IsThreadable(string const & keyw); | 
|---|
| [1224] | 27 |  | 
|---|
| [1289] | 28 | inline void SetPrtLevel(uint_2 lp=2) {mPrtLevel = lp;} | 
|---|
| [1269] | 29 |  | 
|---|
|  | 30 | int  ExecuteCXX(string usercode,string userfct=""); | 
|---|
|  | 31 |  | 
|---|
| [2287] | 32 | // if true , declare ObjMgr variables as $varname | 
|---|
|  | 33 | inline void DeclareObjMgrVar(bool fg=false) { mFgPutVar=fg; } | 
|---|
|  | 34 |  | 
|---|
| [1268] | 35 | int  CrFile(string cfilename="",string func=""); | 
|---|
| [1224] | 36 | void PutInclude(ofstream& os); | 
|---|
|  | 37 | void PutIncludeUser(ofstream& os); | 
|---|
|  | 38 | void PutObject(ofstream& os); | 
|---|
|  | 39 | void PutVar(ofstream& os); | 
|---|
|  | 40 |  | 
|---|
| [1268] | 41 | int  FillUserCode(string& usercode,uint_4 first); | 
|---|
| [1269] | 42 | int  FillUserCode(string filename); | 
|---|
| [1230] | 43 |  | 
|---|
| [1287] | 44 | int  FillUserFctFrS(string userfctcode=""); | 
|---|
| [1269] | 45 | int  FillUserFctFrF(string filefctname=""); | 
|---|
|  | 46 |  | 
|---|
| [1268] | 47 | int  Compile(string rootfilename=""); | 
|---|
| [1287] | 48 | /* int CrMakefile(void); */ | 
|---|
| [1230] | 49 |  | 
|---|
| [1268] | 50 | int  Link(string libname="",string func=""); | 
|---|
|  | 51 | int  Call(string func=""); | 
|---|
| [1224] | 52 |  | 
|---|
| [1230] | 53 | void   FillArgs(vector<string>& args); | 
|---|
|  | 54 | void   FillArgs(string& args); | 
|---|
|  | 55 | string GetArgs(void); | 
|---|
|  | 56 |  | 
|---|
|  | 57 | void   FillInclude(vector<string>& inc); | 
|---|
|  | 58 | void   FillInclude(string& inc); | 
|---|
|  | 59 | string GetInclude(void); | 
|---|
|  | 60 |  | 
|---|
|  | 61 | void   FillCompileOpt(vector<string>& copt); | 
|---|
|  | 62 | void   FillCompileOpt(string& copt); | 
|---|
|  | 63 | string GetCompileOpt(void); | 
|---|
|  | 64 |  | 
|---|
|  | 65 | void   FillLinkOpt(vector<string>& lopt); | 
|---|
|  | 66 | void   FillLinkOpt(string& lopt); | 
|---|
|  | 67 | string GetLinkOpt(void); | 
|---|
|  | 68 |  | 
|---|
|  | 69 | void   FillLinkLibs(vector<string>& llibs); | 
|---|
|  | 70 | void   FillLinkLibs(string& llibs); | 
|---|
|  | 71 | string GetLinkLibs(void); | 
|---|
|  | 72 |  | 
|---|
| [1297] | 73 | void FillModuleImport(vector<string>& import); | 
|---|
|  | 74 | void FillModuleImport(string& import); | 
|---|
|  | 75 | string GetModuleImport(void); | 
|---|
|  | 76 |  | 
|---|
| [1224] | 77 | private: | 
|---|
| [1237] | 78 | string mUserCodeFn; | 
|---|
| [1268] | 79 | string mUserFctFn; | 
|---|
| [1224] | 80 | string mCompOpt; | 
|---|
|  | 81 | string mLinkOpt; | 
|---|
|  | 82 | string mMyLibs; | 
|---|
|  | 83 | vector<string> mIncList; | 
|---|
|  | 84 | vector<string> mCallArgs; | 
|---|
| [1268] | 85 |  | 
|---|
| [1297] | 86 | // Import des modules | 
|---|
|  | 87 | vector<string> mIncImportList; | 
|---|
|  | 88 | vector<string> mModuleImportList; | 
|---|
|  | 89 | vector<string> mModuleImportDefaultList; | 
|---|
|  | 90 |  | 
|---|
|  | 91 |  | 
|---|
| [2181] | 92 | //  string mDefTmp; remplace par la methode TmpDir() - Reza 4/9/02 | 
|---|
|  | 93 | inline string const& TmpDir() { NamedObjMgr omg; return omg.GetTmpDir(); } | 
|---|
| [1268] | 94 | string mDefRoot; | 
|---|
|  | 95 | string mDefFunc; | 
|---|
| [1269] | 96 |  | 
|---|
|  | 97 | uint_2 mPrtLevel; | 
|---|
| [2287] | 98 | bool   mFgPutVar;  // if true , declare ObjMgr variables as $varname, default=false | 
|---|
| [2755] | 99 |  | 
|---|
|  | 100 | // Mutex de controle de thread pour dynamic-link | 
|---|
|  | 101 | ZMutex mutx_cxxe; | 
|---|
|  | 102 |  | 
|---|
| [1224] | 103 | }; | 
|---|
|  | 104 |  | 
|---|
|  | 105 | #endif | 
|---|