Changeset 1276 in Sophya for trunk/SophyaPI/PIext/basexecut.cc
- Timestamp:
- Nov 2, 2000, 11:18:50 AM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SophyaPI/PIext/basexecut.cc
r1268 r1276 34 34 mImgApp = app; 35 35 dynlink = NULL; 36 dynlink2 = NULL; 36 37 RegisterCommands(); 37 38 } … … 39 40 PIABaseExecutor::~PIABaseExecutor() 40 41 { 42 if (dynlink) delete dynlink; 43 if (dynlink2) delete dynlink2; 41 44 } 42 45 … … 124 127 if (rc == 0) cout << "PIABaseExecutor: Link from " << tokens[0] << " OK " << endl; 125 128 } 129 else if (kw == "linkff2" ) { 130 if (tokens.size() < 2) { cout << "Usage: linkff2 fnameso f1 [f2 f3]" << endl; return(0); } 131 string sph = ""; 132 for(int gg=0; gg<5; gg++) tokens.push_back(sph); 133 int rc = LinkUserFuncs2(tokens[0], tokens[1], tokens[2], tokens[3]); 134 if (rc == 0) cout << "PIABaseExecutor: Link2 from " << tokens[0] << " OK " << endl; 135 } 126 136 else if (kw == "call" ) { 127 137 if (tokens.size() < 1) { cout << "Usage: call userf [arg1 arg2 ...]" << endl; return(0); } 128 UsFmap::iterator it = usfmap.find(tokens[0]); 129 if (it == usfmap.end()) { 138 UsFmap::iterator it; 139 UsFmap::iterator it1 = usfmap.find(tokens[0]); 140 UsFmap::iterator it2 = usfmap2.find(tokens[0]); 141 if ((it1 == usfmap.end()) && (it2 == usfmap2.end()) ) { 130 142 cerr << "PIABaseExecutor: No User Function " << tokens[0] << endl; 131 143 return(0); 132 144 } 145 if (it1 == usfmap.end()) it = it2; 146 else it = it1; 133 147 cout << "PIABaseExecutor: Call " << tokens[0] << "( ... )" << endl; 134 148 // on est oblige de faire un cast etant donne qu'on … … 138 152 bool red = mImgApp->HasRedirectedStdOutErr(); 139 153 mImgApp->RedirectStdOutErr(false); 154 #ifdef SANS_EVOLPLANCK 140 155 TRY { 141 156 tokens.erase(tokens.begin()); … … 143 158 } CATCH(merr) { 144 159 fflush(stdout); 160 string es = PeidaExc(merr); 161 cerr << "\n PIABaseExecutor: Call UserFunc Exception :" << merr << es; 145 162 cout << endl; 146 cerr << endl; 147 //CMV_A_FAIRE string es = PeidaExc(merr); 148 //CMV_A_FAIRE cerr << "PIABaseExecutor: Call UserFunc Exception :" << merr << es; 149 } 163 } 164 #else 165 try { 166 tokens.erase(tokens.begin()); 167 fuf(tokens); 168 } 169 catch ( PThrowable & exc ) { 170 cerr << "\n PIABaseExecutor: Call / Catched Exception :" 171 << (string)typeid(exc).name() << " Msg= " 172 << exc.Msg() << endl; 173 cout << endl; 174 } 175 catch ( ... ) { 176 cerr << "\n PIABaseExecutor: Call / Catched Exception ... " 177 << endl; 178 cout << endl; 179 } 180 #endif 150 181 mImgApp->RedirectStdOutErr(red); 151 182 } … … 677 708 usage = "Dynamic linking of compiled user functions \n Usage: link fnameso f1 [f2 f3]"; 678 709 usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names "; 679 usage += "\n Related commands: call loadmodule"; 710 usage += "\n Related commands: call loadmodule linkff2"; 711 mpiac->RegisterCommand(kw, usage, this, "External Modules"); 712 kw = "linkff2"; 713 usage = "Dynamic linking of compiled user functions (Set 2)\n Usage: linkff2 fnameso f1 [f2 f3]"; 714 usage += "\n fnameso: Shared-object file name, f1,f2,f3 : User function names "; 715 usage += "\n Related commands: call link loadmodule"; 680 716 mpiac->RegisterCommand(kw, usage, this, "External Modules"); 681 717 kw = "call"; … … 1098 1134 } 1099 1135 1136 /* --Methode-- */ 1137 int PIABaseExecutor::LinkUserFuncs2(string& fnameso, string& func1, string& func2, string& func3) 1138 { 1139 string cmd; 1140 1141 if (dynlink2) delete dynlink2; dynlink2 = NULL; 1142 usfmap2.clear(); 1143 1144 dynlink2 = new PDynLinkMgr(fnameso, true); 1145 if (dynlink2 == NULL) { 1146 string sn = fnameso; 1147 cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur ouverture SO " << sn << endl; 1148 return(2); 1149 } 1150 1151 int nok=0; 1152 // on utilise donc des DlFunction (Reza 20/08/98) voir commentaire ds .h (pb g++) 1153 // DlUserProcFunction f = NULL; 1154 DlFunction f = NULL; 1155 if ((func1.length() < 1) || (func1 == "-") || (func1 == ".") ) goto fin; 1156 f = dynlink2->GetFunction(func1); 1157 if (f) { nok++; usfmap2[func1] = f; } 1158 else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func1 << endl; 1159 1160 if ((func2.length() < 1) || (func2 == "-") || (func2 == ".") ) goto fin; 1161 f = dynlink2->GetFunction(func2); 1162 if (f) { nok++; usfmap2[func2] = f; } 1163 else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func2 << endl; 1164 1165 if ((func3.length() < 1) || (func3 == "-") || (func3 == ".") ) goto fin; 1166 f = dynlink2->GetFunction(func3); 1167 if (f) { nok++; usfmap2[func3] = f; } 1168 else cerr << "PIABaseExecutor/LinkUserFuncs2_Erreur: Erreur linking " << func3 << endl; 1169 1170 fin: 1171 if (nok < 1) { if (dynlink2) delete dynlink2; dynlink2 = NULL; return(3); } 1172 else return(0); 1173 } 1174 1100 1175 /* Nouvelle-Fonction */ 1101 1176 void RegisterPIGraphicsHelp(PIACmd* piac)
Note:
See TracChangeset
for help on using the changeset viewer.