[2615] | 1 | #include "sopnamsp.h"
|
---|
[293] | 2 | #include "piacmd.h"
|
---|
[165] | 3 | #include <stdio.h>
|
---|
| 4 | #include <stdlib.h>
|
---|
[349] | 5 | #include <ctype.h>
|
---|
[165] | 6 | #include <math.h>
|
---|
| 7 |
|
---|
| 8 |
|
---|
[293] | 9 | #include "pdlmgr.h"
|
---|
[165] | 10 | #include "ctimer.h"
|
---|
[2214] | 11 | #include "strutil.h"
|
---|
[2215] | 12 | #include "strutilxx.h"
|
---|
[293] | 13 | // #include "dlftypes.h"
|
---|
[2307] | 14 | #include "srandgen.h"
|
---|
[165] | 15 |
|
---|
[293] | 16 | #include "pistdimgapp.h"
|
---|
[165] | 17 | #include "nobjmgr.h"
|
---|
[2781] | 18 |
|
---|
| 19 | // Les differentes classes CommandExecutor
|
---|
| 20 | #include "basexecut.h"
|
---|
| 21 | #include "graphexecut.h"
|
---|
[361] | 22 | #include "piafitting.h"
|
---|
[463] | 23 | #include "pawexecut.h"
|
---|
[1224] | 24 | #include "cxxexecutor.h"
|
---|
[1251] | 25 | #include "cxxexecwin.h"
|
---|
[1828] | 26 | #include "contmodex.h"
|
---|
[1920] | 27 | #include "flowmodex.h"
|
---|
[165] | 28 |
|
---|
[293] | 29 | #include PISTDWDG_H
|
---|
| 30 | #include PILIST_H
|
---|
[165] | 31 |
|
---|
[293] | 32 | // ------------------------------------------------------------
|
---|
[349] | 33 | // Gestion d'une fenetre d'aide interactive
|
---|
| 34 | // Classe PIAHelpWind
|
---|
[293] | 35 | // ------------------------------------------------------------
|
---|
[165] | 36 |
|
---|
[2474] | 37 | #define HGRPMSGOFFSET 100000
|
---|
| 38 |
|
---|
[293] | 39 | class PIAHelpWind : public PIWindow {
|
---|
| 40 | public :
|
---|
| 41 | PIAHelpWind(PIStdImgApp* par, PIACmd* piacmd);
|
---|
| 42 | virtual ~PIAHelpWind();
|
---|
[330] | 43 | virtual void Show();
|
---|
[293] | 44 | virtual void Process(PIMessage msg, PIMsgHandler* sender, void* data=NULL);
|
---|
[330] | 45 | inline void AddHelpGroup(const char * hgrp, int gid)
|
---|
[2474] | 46 | { hgrpom->AppendItem(hgrp, HGRPMSGOFFSET+gid); }
|
---|
[2465] | 47 | inline void AddHelpGroup(string const & hgrp, int gid)
|
---|
[2474] | 48 | { hgrpom->AppendItem(hgrp.c_str(), HGRPMSGOFFSET+gid); }
|
---|
[330] | 49 | inline void ClearHelpList()
|
---|
| 50 | { mNitem=0; hitemlist->DeleteAllItems(); }
|
---|
[293] | 51 | inline void AddHelpItem(const char * hitem)
|
---|
[330] | 52 | { mNitem++; hitemlist->AppendItem(hitem, 100+mNitem); }
|
---|
[2465] | 53 | inline void SetHelpTextLabel(string const & htxt, string const & hlab)
|
---|
| 54 | { mTxt->SetText(htxt); mLab->SetLabel(hlab); }
|
---|
| 55 |
|
---|
[293] | 56 | protected :
|
---|
| 57 | PIStdImgApp* dap;
|
---|
| 58 | PIACmd* piac;
|
---|
| 59 | int mNitem;
|
---|
| 60 | PIList* hitemlist;
|
---|
[330] | 61 | PIOptMenu* hgrpom;
|
---|
[293] | 62 | PIButton * mBut;
|
---|
| 63 | PILabel * mLab;
|
---|
| 64 | PIText* mTxt;
|
---|
| 65 | };
|
---|
[165] | 66 |
|
---|
[293] | 67 | /* --Methode-- */
|
---|
| 68 | PIAHelpWind::PIAHelpWind(PIStdImgApp *par, PIACmd* piacmd)
|
---|
| 69 | : PIWindow((PIMsgHandler *)par, "Help-PIApp", PIWK_normal, 400, 300, 100, 350)
|
---|
| 70 | {
|
---|
| 71 | dap = par;
|
---|
| 72 | piac = piacmd;
|
---|
| 73 | mNitem = 0;
|
---|
[330] | 74 | SetMsg(77);
|
---|
[165] | 75 |
|
---|
[293] | 76 | int bsx, bsy;
|
---|
| 77 | int tsx, tsy;
|
---|
| 78 | int spx, spy;
|
---|
| 79 | PIApplicationPrefCompSize(bsx, bsy);
|
---|
| 80 | spx = bsx/6; spy = bsy/6;
|
---|
| 81 | tsx = 10*bsx+2*spx; tsy = 7*bsy+3*spy;
|
---|
| 82 | SetSize(tsx,tsy);
|
---|
[330] | 83 | hgrpom = new PIOptMenu(this, "hgrpoptmen", bsx*2.0, bsy, spx/2, spy);
|
---|
| 84 | hgrpom->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 85 | hitemlist = new PIList(this, "hitemlist", bsx*2.0, tsy-3*spy-bsy, spx/2, 2*spy+bsy);
|
---|
[293] | 86 | hitemlist->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 87 | // hitemlist->SetBorderWidth(2);
|
---|
[324] | 88 | mTxt = new PIText(this, "helptext", true, true, bsx*8.0, 6*bsy, bsx*2.0+1.5*spx, spy);
|
---|
| 89 | // mTxt->SetMutiLineMode(true);
|
---|
[293] | 90 | mTxt->SetTextEditable(false);
|
---|
| 91 | mTxt->SetText("");
|
---|
| 92 | mTxt->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 93 | mLab = new PILabel(this, "helpitem", bsx*4, bsy, bsx*2.5+2*spx, tsy-spy-bsy);
|
---|
| 94 | mLab->SetBorderWidth(1);
|
---|
| 95 | mLab->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 96 | mLab->SetLabel("");
|
---|
[330] | 97 | mBut = new PIButton(this, "Close", 70, bsx, bsy, tsx-bsx*1.5-spx, tsy-spy-bsy);
|
---|
[293] | 98 | mBut->SetBinding(PIBK_elastic,PIBK_elastic, PIBK_elastic,PIBK_elastic);
|
---|
| 99 | }
|
---|
[165] | 100 |
|
---|
| 101 | /* --Methode-- */
|
---|
[293] | 102 | PIAHelpWind::~PIAHelpWind()
|
---|
| 103 | {
|
---|
[330] | 104 | delete hgrpom;
|
---|
[293] | 105 | delete hitemlist;
|
---|
| 106 | delete mTxt;
|
---|
| 107 | delete mLab;
|
---|
| 108 | delete mBut;
|
---|
| 109 | }
|
---|
| 110 |
|
---|
| 111 | /* --Methode-- */
|
---|
| 112 | void PIAHelpWind::Process(PIMessage msg, PIMsgHandler* sender, void* /*data*/)
|
---|
| 113 | {
|
---|
| 114 | PIMessage um = UserMsg(msg);
|
---|
[330] | 115 | if (((um == 77) && (ModMsg(msg) == PIMsg_Close)) || (um == 70) ) {
|
---|
[293] | 116 | Hide();
|
---|
| 117 | return;
|
---|
| 118 | }
|
---|
[2474] | 119 | else if ( (um >= HGRPMSGOFFSET) && (sender == hgrpom)) { // Selection de groupe de Help
|
---|
[330] | 120 | mTxt->SetText("");
|
---|
| 121 | mLab->SetLabel("");
|
---|
[2474] | 122 | piac->UpdateHelpList(this, um-HGRPMSGOFFSET);
|
---|
[330] | 123 | }
|
---|
| 124 | else if ( (um > 100) && (sender == hitemlist) && (ModMsg(msg) == PIMsg_Select) ) {
|
---|
[293] | 125 | string s = hitemlist->GetSelectionStr();
|
---|
| 126 | mTxt->SetText(piac->GetUsage(s));
|
---|
| 127 | mLab->SetLabel(s);
|
---|
| 128 | }
|
---|
| 129 | }
|
---|
| 130 |
|
---|
[330] | 131 | /* --Methode-- */
|
---|
| 132 | void PIAHelpWind::Show()
|
---|
| 133 | {
|
---|
[2474] | 134 | hgrpom->SetValue(HGRPMSGOFFSET); // Groupe All
|
---|
[330] | 135 | mTxt->SetText("");
|
---|
| 136 | mLab->SetLabel("");
|
---|
| 137 | piac->UpdateHelpList(this, 0);
|
---|
| 138 | PIWindow::Show();
|
---|
| 139 | }
|
---|
[293] | 140 |
|
---|
[349] | 141 |
|
---|
| 142 | // ------------------------------------------------------------
|
---|
| 143 | // Classe PIACmd
|
---|
| 144 | // ------------------------------------------------------------
|
---|
| 145 |
|
---|
[2463] | 146 | // static PIACmd* curpiacmd = NULL;
|
---|
[293] | 147 | /* --Methode-- */
|
---|
[2490] | 148 | PIACmd::PIACmd(PIStdImgApp* app)
|
---|
[2463] | 149 | : Commander()
|
---|
[165] | 150 | {
|
---|
[2490] | 151 | mObjMgr = new NamedObjMgr;
|
---|
[165] | 152 | mImgApp = app;
|
---|
[293] | 153 | helpwin = new PIAHelpWind(app, this);
|
---|
[2465] | 154 | helpwin_initdone = false;
|
---|
[293] | 155 |
|
---|
[2305] | 156 | string grp = "PIACmd";
|
---|
[2465] | 157 | string gdesc = "piapp interpreter (class PIACmd) additional builtin commands";
|
---|
| 158 | AddHelpGroup(grp, gdesc);
|
---|
| 159 |
|
---|
[2672] | 160 | string kw = "exitpiapp";
|
---|
[2463] | 161 | string usage = "To end the piapp session ";
|
---|
[2419] | 162 | RegisterCommand(kw, usage, NULL, grp);
|
---|
[2463] | 163 | kw = "helpwindow";
|
---|
| 164 | usage = "To display the Help window ";
|
---|
[2419] | 165 | RegisterCommand(kw, usage, NULL, grp);
|
---|
[2677] | 166 | kw = "stop";
|
---|
| 167 | usage = "To stop (break) interpreter (PIACmd/Commander) execution";
|
---|
[2672] | 168 | RegisterCommand(kw, usage, NULL, grp);
|
---|
[2203] | 169 |
|
---|
[2490] | 170 | basexec = new PIABaseExecutor(this, mObjMgr, app);
|
---|
[2781] | 171 | graphexec = new PIAGraphicExecutor(this, mObjMgr, app);
|
---|
[361] | 172 | fitexec = new PIAFitter(this, app);
|
---|
[463] | 173 | pawexec = new PAWExecutor(this, app);
|
---|
[1251] | 174 | CxxExecutor * cxxe = new CxxExecutor(this, app);
|
---|
| 175 | cxxexec = cxxe;
|
---|
[1828] | 176 |
|
---|
| 177 | ContModExecutor *cntxx = new ContModExecutor(this, app);//_OP_
|
---|
| 178 | cntexec = cntxx; //_OP_
|
---|
[1920] | 179 | FlowModExecutor *flwxx = new FlowModExecutor(this, app);//_OP_
|
---|
| 180 | flwexec = flwxx; //_OP_
|
---|
[1828] | 181 |
|
---|
[1251] | 182 | cxxoptwin = new CxxOptionWind(app, cxxe);
|
---|
| 183 | cxxexwin = new CxxExecWind(app, cxxe);
|
---|
| 184 |
|
---|
[2465] | 185 | InitializeHelpWindowMenu();
|
---|
[2486] | 186 | // <ZThread> Thread control attributes
|
---|
| 187 | fg_thrstop = false;
|
---|
| 188 | fg_threxe = false;
|
---|
[165] | 189 | }
|
---|
| 190 |
|
---|
| 191 | /* --Methode-- */
|
---|
| 192 | PIACmd::~PIACmd()
|
---|
| 193 | {
|
---|
[2490] | 194 | delete mObjMgr;
|
---|
[293] | 195 | delete helpwin;
|
---|
[1251] | 196 | delete cxxexwin;
|
---|
| 197 | delete cxxoptwin;
|
---|
[361] | 198 | delete basexec;
|
---|
[2781] | 199 | delete graphexec;
|
---|
[361] | 200 | delete fitexec;
|
---|
[463] | 201 | delete pawexec;
|
---|
[1224] | 202 | delete cxxexec;
|
---|
[165] | 203 | }
|
---|
| 204 |
|
---|
| 205 |
|
---|
[293] | 206 | /* --Methode-- */
|
---|
[2486] | 207 | void PIACmd::AddInputLine(string const & line)
|
---|
| 208 | {
|
---|
[2677] | 209 | if (line == "stop") {
|
---|
[2672] | 210 | StopExecution();
|
---|
| 211 | return;
|
---|
| 212 | }
|
---|
[2486] | 213 | mutx_inps.lock();
|
---|
[2536] | 214 | inputlines.push(line); // Ajout d'un element en fin de queue
|
---|
[2486] | 215 | mutx_inps.unlock();
|
---|
| 216 | mutx_inps.broadcast();
|
---|
| 217 | }
|
---|
| 218 |
|
---|
| 219 | /* --Methode-- */
|
---|
| 220 | void PIACmd::StopThread()
|
---|
| 221 | {
|
---|
| 222 | fg_thrstop = true;
|
---|
| 223 | mutx_inps.broadcast();
|
---|
| 224 | }
|
---|
| 225 |
|
---|
| 226 | /* --Methode-- */
|
---|
| 227 | void PIACmd::run()
|
---|
| 228 | {
|
---|
| 229 | while (!fg_thrstop) {
|
---|
| 230 | mutx_inps.lock();
|
---|
| 231 | while (inputlines.empty()) {
|
---|
| 232 | fg_threxe = false;
|
---|
| 233 | mutx_inps.wait();
|
---|
| 234 | }
|
---|
[2536] | 235 | string line = inputlines.front(); // On recupere l'element de tete
|
---|
| 236 | inputlines.pop(); // On supprime l'element de tete
|
---|
[2486] | 237 | fg_threxe = true;
|
---|
| 238 | mutx_inps.unlock();
|
---|
[2606] | 239 | try {
|
---|
| 240 | Interpret(line);
|
---|
| 241 | }
|
---|
| 242 | catch (PThrowable& pex) { // Catching SOPHYA exceptions
|
---|
| 243 | cerr << "PIACmd::run() SOPHYA exception in call to Interpret(" << line << ")\n"
|
---|
| 244 | << (string)typeid(pex).name() << " Msg= " << pex.Msg() << endl;
|
---|
| 245 | }
|
---|
| 246 | catch (std::exception& sex) {
|
---|
| 247 | cerr << "PIACmd::run() std::exception in call to Interpret(" << line << ")\n"
|
---|
| 248 | << (string)typeid(sex).name() << " Msg= " << sex.what() << endl;
|
---|
| 249 | }
|
---|
| 250 | catch (...) {
|
---|
| 251 | cerr << "PIACmd::run() unknown exception (...) in call to Interpret("
|
---|
| 252 | << line << ")" << endl;
|
---|
| 253 | }
|
---|
[2486] | 254 | }
|
---|
| 255 | }
|
---|
| 256 |
|
---|
| 257 | /* --Methode-- */
|
---|
[2465] | 258 | bool PIACmd::CheckHelpGrp(string& grp, int& gid, string& desc)
|
---|
[330] | 259 | {
|
---|
[2465] | 260 | bool fgnewgrp = Commander::CheckHelpGrp(grp, gid, desc);
|
---|
| 261 | if (helpwin_initdone && fgnewgrp) helpwin->AddHelpGroup(grp.c_str(), gid);
|
---|
| 262 | return fgnewgrp;
|
---|
[330] | 263 | }
|
---|
| 264 |
|
---|
| 265 | /* --Methode-- */
|
---|
| 266 | void PIACmd::UpdateHelpList(PIAHelpWind* hw, int gid)
|
---|
| 267 | {
|
---|
| 268 | helpwin->ClearHelpList();
|
---|
[2465] | 269 | if (gid == 0) {
|
---|
| 270 | string htxt = "All registered commands";
|
---|
| 271 | string hlab = "All (HelpGroup)";
|
---|
| 272 | helpwin->SetHelpTextLabel(htxt, hlab);
|
---|
| 273 | }
|
---|
| 274 | else {
|
---|
| 275 | CmdHGroup::iterator ith;
|
---|
| 276 | for(ith = cmdhgrp.begin(); ith != cmdhgrp.end(); ith++) {
|
---|
| 277 | if ((*ith).second.gid == gid) {
|
---|
| 278 | string hlab = (*ith).first;
|
---|
| 279 | hlab += " (HelpGroup)";
|
---|
| 280 | helpwin->SetHelpTextLabel((*ith).second.desc, hlab);
|
---|
| 281 | break;
|
---|
| 282 | }
|
---|
| 283 | }
|
---|
| 284 | }
|
---|
[330] | 285 | CmdExmap::iterator it;
|
---|
| 286 | for(it = helpexmap.begin(); it != helpexmap.end(); it++) {
|
---|
| 287 | if ( (gid != 0) && ((*it).second.group != gid) ) continue;
|
---|
| 288 | helpwin->AddHelpItem((*it).first.c_str());
|
---|
| 289 | }
|
---|
| 290 | for(it = cmdexmap.begin(); it != cmdexmap.end(); it++) {
|
---|
| 291 | if ( (gid != 0) && ((*it).second.group != gid) ) continue;
|
---|
| 292 | helpwin->AddHelpItem((*it).first.c_str());
|
---|
| 293 | }
|
---|
| 294 | }
|
---|
| 295 |
|
---|
[2465] | 296 | /* --Methode-- */
|
---|
| 297 | void PIACmd::InitializeHelpWindowMenu()
|
---|
| 298 | {
|
---|
| 299 | helpwin->AddHelpGroup("All", 0);
|
---|
| 300 | CmdHGroup::iterator it;
|
---|
| 301 | for(it = cmdhgrp.begin(); it != cmdhgrp.end(); it++)
|
---|
| 302 | helpwin->AddHelpGroup((*it).first, (*it).second.gid);
|
---|
| 303 | helpwin_initdone = true;
|
---|
| 304 | }
|
---|
[165] | 305 |
|
---|
[357] | 306 | /* Fonction */
|
---|
[368] | 307 | static string GetStringFrStdin(PIACmd* piac)
|
---|
[357] | 308 | {
|
---|
[368] | 309 | PIStdImgApp* piapp = piac->GetImgApp();
|
---|
| 310 | if (piapp) {
|
---|
| 311 | PIBaseWdg* wdg = piapp->CurrentBaseWdg();
|
---|
| 312 | if (wdg) wdg->Refresh();
|
---|
| 313 | }
|
---|
[357] | 314 | char buff[128];
|
---|
| 315 | fgets(buff, 128, stdin);
|
---|
| 316 | buff[127] = '\0';
|
---|
| 317 | return((string)buff);
|
---|
| 318 | }
|
---|
| 319 |
|
---|
[2999] | 320 | /* --Methode-- */
|
---|
| 321 | bool PIACmd::GetVarApp(string const & vn, string & vv)
|
---|
| 322 | {
|
---|
| 323 | vv = "";
|
---|
| 324 | if (mObjMgr == NULL) return false;
|
---|
| 325 | vector<string> opts;
|
---|
| 326 | SplitStringToVString(vn, opts, '.');
|
---|
| 327 | string nom = opts[0];
|
---|
| 328 | opts.erase(opts.begin());
|
---|
| 329 | NObjMgrAdapter* obja = mObjMgr->GetObjAdapter(nom);
|
---|
| 330 | if (obja == NULL) return false;
|
---|
| 331 | vv = obja->GetInfoString(opts);
|
---|
| 332 | return true;
|
---|
| 333 | }
|
---|
[165] | 334 |
|
---|
[1262] | 335 | /* --Methode-- */
|
---|
| 336 | int PIACmd::ExecuteCommandLine(string & kw, vector<string> & tokens, string & toks)
|
---|
| 337 | {
|
---|
| 338 | int rc = 0;
|
---|
| 339 | NamedObjMgr omg;
|
---|
[349] | 340 |
|
---|
[165] | 341 | // >>>>>>>>>>> Commande d'interpreteur
|
---|
[2812] | 342 | if ( (kw == "helpwindow") && (mImgApp)) {
|
---|
| 343 | ZSync zs(mImgApp->getMutex());
|
---|
[2465] | 344 | ShowHelpWindow();
|
---|
[2812] | 345 | zs.NOp();
|
---|
[2465] | 346 | return 0;
|
---|
| 347 | }
|
---|
[2307] | 348 | // ----> Sortie d'application
|
---|
[2812] | 349 | else if ((kw == "exitpiapp") && (mImgApp)) {
|
---|
[2307] | 350 | mImgApp->Stop();
|
---|
[2465] | 351 | return 0;
|
---|
[2307] | 352 | }
|
---|
[2463] | 353 | else return Commander::ExecuteCommandLine(kw, tokens, toks);
|
---|
[2465] | 354 | return 0;
|
---|
[165] | 355 | }
|
---|
| 356 |
|
---|
[333] | 357 |
|
---|
[165] | 358 | /* --Methode-- */
|
---|
[293] | 359 | void PIACmd::ShowHelpWindow()
|
---|
[165] | 360 | {
|
---|
[2812] | 361 | helpwin->Show();
|
---|
[165] | 362 | }
|
---|
[357] | 363 |
|
---|
[463] | 364 | /* --Methode-- */
|
---|
[1251] | 365 | void PIACmd::ShowCxxOptionWindow()
|
---|
| 366 | {
|
---|
[2812] | 367 | cxxoptwin->Show();
|
---|
[1251] | 368 | }
|
---|
| 369 |
|
---|
| 370 | /* --Methode-- */
|
---|
| 371 | void PIACmd::ShowCxxExecWindow()
|
---|
| 372 | {
|
---|
[2812] | 373 | cxxexwin->Show();
|
---|
[1251] | 374 | }
|
---|
| 375 |
|
---|
[2463] | 376 | /* --Methode-- */
|
---|
| 377 | void PIACmd::SetCurrentPrompt(const char* pr)
|
---|
[2377] | 378 | {
|
---|
[2463] | 379 | Commander::SetCurrentPrompt(pr);
|
---|
[2489] | 380 | if (mImgApp) {
|
---|
[2755] | 381 | ZSync zs(mImgApp->getMutex()); zs.NOp();
|
---|
[2489] | 382 | mImgApp->GetConsole()->SetPrompt(pr);
|
---|
| 383 | }
|
---|
[2377] | 384 | }
|
---|
| 385 |
|
---|
[1251] | 386 | /* --Methode-- */
|
---|
[2463] | 387 | void PIACmd::ShowMessage(const char * msg, int att)
|
---|
[463] | 388 | {
|
---|
[2489] | 389 | /*
|
---|
| 390 | Il faut faire quelque chose pour gerer correctement ca en multithread
|
---|
[2463] | 391 | char va = (att == 0) ? 0 : PIVA_Magenta;
|
---|
[2489] | 392 | if (mImgApp) {
|
---|
[2755] | 393 | ZSync(mImgApp->getMutex()); zs.NOp();
|
---|
[2489] | 394 | mImgApp->GetConsole()->AddStr(msg, va);
|
---|
| 395 | }
|
---|
| 396 | */
|
---|
| 397 | Commander::ShowMessage(msg, att);
|
---|
[2263] | 398 | }
|
---|
[3366] | 399 |
|
---|
| 400 |
|
---|
| 401 | /* --Methode-- */
|
---|
| 402 | SOpExObj::SOpExObj(PIStdImgApp* app)
|
---|
| 403 | {
|
---|
| 404 | mImgApp = app;
|
---|
| 405 | fg_thrstop = false;
|
---|
| 406 | fg_threxe = false;
|
---|
| 407 | }
|
---|
| 408 |
|
---|
| 409 | /* --Methode-- */
|
---|
| 410 | SOpExObj::~SOpExObj()
|
---|
| 411 | {
|
---|
| 412 | }
|
---|
| 413 |
|
---|
| 414 | /* --Methode-- */
|
---|
| 415 | void SOpExObj::AddOpe(string const & line)
|
---|
| 416 | {
|
---|
| 417 | mutx_inps.lock();
|
---|
| 418 | inputlines.push(line); // Ajout d'un element en fin de queue
|
---|
| 419 | mutx_inps.unlock();
|
---|
| 420 | mutx_inps.broadcast();
|
---|
| 421 | }
|
---|
| 422 |
|
---|
| 423 | /* --Methode-- */
|
---|
| 424 | void SOpExObj::run()
|
---|
| 425 | {
|
---|
| 426 | NamedObjMgr omg;
|
---|
| 427 | while (!fg_thrstop) {
|
---|
| 428 | mutx_inps.lock();
|
---|
| 429 | while (inputlines.empty()) {
|
---|
| 430 | fg_threxe = false;
|
---|
| 431 | mutx_inps.wait();
|
---|
| 432 | }
|
---|
| 433 | string cmd = inputlines.front().substr(0,3); // On recupere l'element de tete
|
---|
| 434 | string nom = inputlines.front().substr(4); // On recupere l'element de tete
|
---|
| 435 | inputlines.pop(); // On supprime l'element de tete
|
---|
| 436 | fg_threxe = true;
|
---|
| 437 | mutx_inps.unlock();
|
---|
| 438 | try {
|
---|
[3374] | 439 | if (cmd == "UPD") { // UpdateObjMgrWindow()
|
---|
| 440 | int did = atoi(nom.c_str());
|
---|
| 441 | omg.UpdateObjMgrWindow(did);
|
---|
| 442 | }
|
---|
| 443 | else if (cmd == "SCO") { // set cobj
|
---|
[3366] | 444 | string ss = "set cobj ";
|
---|
| 445 | ss += nom;
|
---|
| 446 | cout << " Defining cobj : " << ss << endl;
|
---|
| 447 | mImgApp->CmdInterpreter()->AddInputLine(ss);
|
---|
| 448 | }
|
---|
| 449 | else if (cmd == "DIS") { // display obj
|
---|
| 450 | omg.DisplayObj(nom);
|
---|
| 451 | }
|
---|
| 452 | else if (cmd == "PRT") { // print obj
|
---|
| 453 | omg.PrintObj(nom);
|
---|
| 454 | }
|
---|
| 455 | else if (cmd == "DEL") { // delete obj
|
---|
| 456 | omg.DelObj(nom);
|
---|
| 457 | }
|
---|
| 458 | else if (cmd == "SAV") { // saveppf obj
|
---|
| 459 | if (mImgApp->mPpfout) omg.SaveObj(nom, *(mImgApp->mPpfout), false);
|
---|
| 460 | }
|
---|
| 461 | else cerr << "SOpExObj::run() ERROR CMD= " << cmd << endl;
|
---|
| 462 | }
|
---|
| 463 | catch (PThrowable& pex) { // Catching SOPHYA exceptions
|
---|
| 464 | cerr << "SOpExObj::run() SOPHYA exception CMD=" << cmd << " NOM=" << nom << "\n"
|
---|
| 465 | << (string)typeid(pex).name() << " Msg= " << pex.Msg() << endl;
|
---|
| 466 | }
|
---|
| 467 | catch (std::exception& sex) {
|
---|
| 468 | cerr << "SOpExObj::run() std::exception CMD=" << cmd << " NOM=" << nom << "\n"
|
---|
| 469 | << (string)typeid(sex).name() << " Msg= " << sex.what() << endl;
|
---|
| 470 | }
|
---|
| 471 | catch (...) {
|
---|
| 472 | cerr << "SOpExObj::run() unknown exception (...) CMD="
|
---|
| 473 | << cmd << " NOM=" << nom << endl;
|
---|
| 474 | }
|
---|
| 475 | }
|
---|
| 476 | }
|
---|