1 | // This may look like C code, but it is really -*- C++ -*-
|
---|
2 | // Classe CxxExecutor : Dynamic C++ compile/execution in piapp
|
---|
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>
|
---|
12 | #include <iostream>
|
---|
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();
|
---|
24 |
|
---|
25 | virtual int Execute(string& keyw,vector<string>& args, string& toks);
|
---|
26 | virtual bool IsThreadable(string const & keyw);
|
---|
27 |
|
---|
28 | inline void SetPrtLevel(uint_2 lp=2) {mPrtLevel = lp;}
|
---|
29 |
|
---|
30 | int ExecuteCXX(string usercode,string userfct="");
|
---|
31 |
|
---|
32 | // if true , declare ObjMgr variables as $varname
|
---|
33 | inline void DeclareObjMgrVar(bool fg=false) { mFgPutVar=fg; }
|
---|
34 |
|
---|
35 | int CrFile(string cfilename="",string func="");
|
---|
36 | void PutInclude(ofstream& os);
|
---|
37 | void PutIncludeUser(ofstream& os);
|
---|
38 | void PutObject(ofstream& os);
|
---|
39 | void PutVar(ofstream& os);
|
---|
40 |
|
---|
41 | int FillUserCode(string& usercode,uint_4 first);
|
---|
42 | int FillUserCode(string filename);
|
---|
43 |
|
---|
44 | int FillUserFctFrS(string userfctcode="");
|
---|
45 | int FillUserFctFrF(string filefctname="");
|
---|
46 |
|
---|
47 | int Compile(string rootfilename="");
|
---|
48 | /* int CrMakefile(void); */
|
---|
49 |
|
---|
50 | int Link(string libname="",string func="");
|
---|
51 | int Call(string func="");
|
---|
52 |
|
---|
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 |
|
---|
73 | void FillModuleImport(vector<string>& import);
|
---|
74 | void FillModuleImport(string& import);
|
---|
75 | string GetModuleImport(void);
|
---|
76 |
|
---|
77 | private:
|
---|
78 | string mUserCodeFn;
|
---|
79 | string mUserFctFn;
|
---|
80 | string mCompOpt;
|
---|
81 | string mLinkOpt;
|
---|
82 | string mMyLibs;
|
---|
83 | vector<string> mIncList;
|
---|
84 | vector<string> mCallArgs;
|
---|
85 |
|
---|
86 | // Import des modules
|
---|
87 | vector<string> mIncImportList;
|
---|
88 | vector<string> mModuleImportList;
|
---|
89 | vector<string> mModuleImportDefaultList;
|
---|
90 |
|
---|
91 |
|
---|
92 | // string mDefTmp; remplace par la methode TmpDir() - Reza 4/9/02
|
---|
93 | inline string const& TmpDir() { NamedObjMgr omg; return omg.GetTmpDir(); }
|
---|
94 | string mDefRoot;
|
---|
95 | string mDefFunc;
|
---|
96 |
|
---|
97 | uint_2 mPrtLevel;
|
---|
98 | bool mFgPutVar; // if true , declare ObjMgr variables as $varname, default=false
|
---|
99 |
|
---|
100 | // Mutex de controle de thread pour dynamic-link
|
---|
101 | ZMutex mutx_cxxe;
|
---|
102 |
|
---|
103 | };
|
---|
104 |
|
---|
105 | #endif
|
---|