#include <bbtkInterpreterVirtual.h>
Classes | |
struct | CommandInfoType |
The structure storing the informations on a command. More... | |
Public Types | |
enum | ExitStatus { Interpreter_OK, Interpreter_ERROR, Interpreter_QUIT, Interpreter_BREAK } |
typedef InterpreterVirtual | Self |
typedef boost::shared_ptr< Self > | Pointer |
typedef boost::weak_ptr< Self > | WeakPointer |
typedef Object | Superclass |
Public Member Functions | |
std::string | GetObjectName () const |
std::string | GetObjectInfo () const |
size_t | GetObjectSize () const |
size_t | GetObjectInternalSize () const |
size_t | GetObjectRecursiveSize () const |
ExitStatus | InterpretFile (const std::string &filename, bool source=false) |
Runs the interpretation of a file. | |
ExitStatus | InterpretBuffer (std::stringstream *buffer) |
Runs the interpretation of a buffer and deletes it ! | |
ExitStatus | InterpretLine (const std::string &line) |
Runs the interpretation of a command. | |
ExitStatus | InterpretCurrentStreams () |
Runs the interpretation of the currently open streams. | |
void | CommandLineInterpreter () |
Launches a command line interpreter (with a prompt). | |
void | SetCommandLine (bool v=true) |
Sets the bool that indicates wether we are in command line context. | |
void | SetThrow (bool b) |
void | SetUser (InterpreterUser *c) |
Sets the user of the interpreter (if any). | |
InterpreterUser * | GetUser () |
Gets the InterpreterUser of this. | |
const InterpreterUser * | GetUser () const |
Gets the InterpreterUser of this (const). | |
long | GetUseCount () |
Static Public Member Functions | |
static Pointer | New () |
static void | InsertInObjectList (Pointer) |
static void | RemoveFromObjectList (WeakPointer) |
static void | InsertInPackageList (Pointer) |
static void | ReleasePackages () |
static void | PrintObjectListInfo (const std::string &name) |
static void | PrintObjectInfo (const Pointer &o) |
static long | GetObjectsCount () |
Protected Types | |
enum | CommandCodeType { cBreak, cClear, cNew, cDelete, cConnect, cExec, cPackage, cEndPackage, cDefine, cEndDefine, cInput, cOutput, cSet, cConfig, cReset, cAuthor, cCategory, cDescription, cHelp, cMessage, cInclude, cQuit, cLoad, cUnload, cGraph, cPrint, cIndex, cKind, cNewGUI, cWorkspace, cDebug } |
The enumeration of command codes == Command name. More... | |
typedef std::map< std::string, CommandInfoType > | CommandDictType |
The type of dictionnary of commands. | |
Protected Member Functions | |
void | DoInterpretLine (const std::string &line) |
Interprets a line. | |
void | GetLineFromPrompt (std::string &line) |
Reads a line from prompt. | |
void | SplitLine (const std::string &line, std::vector< std::string > &words) |
Splits a line into words. | |
void | InterpretCommand (const std::vector< std::string > &words, CommandInfoType &info) |
Executes the right action depending on the command name. | |
void | SwitchToFile (const std::string &filename, bool source=false) |
Switch to the interpretation of a file. | |
void | SwitchToStream (std::stringstream *stream) |
Switch to the interpretation of a stringstream. | |
void | CloseCurrentFile () |
Closes the currently open file. | |
void | CloseAllFiles () |
Closes all open files. | |
virtual void | commandReset () |
Resets all. | |
virtual void | commandHelp (const std::string &words) |
Displays help (entry point of any help). | |
virtual void | commandHelp (const std::vector< std::string > &words) |
Displays help on all the commands. | |
virtual void | commandGraph (const std::vector< std::string > &words) |
virtual void | commandConfig () const |
Displays the Configuration. | |
void | commandIndex (const std::string &filename, const std::string &type="Initials") |
void | FindCommandsWithPrefix (char *buf, int n, std::vector< std::string > &commands) |
virtual void | commandNewGUI (const std::string &box, const std::string &instanceName) |
virtual void | commandDebug (const std::string &arg) |
virtual void | commandNew (const std::string &boxType, const std::string &boxName) |
virtual void | commandDelete (const std::string &boxName) |
virtual void | commandConnection (const std::string &nodeFrom, const std::string &outputLabel, const std::string &nodeTo, const std::string &inputLabel) |
virtual void | commandPackage (const std::string &packageName) |
virtual void | commandEndPackage () |
virtual void | commandDefine (const std::string &name, const std::string &pack, const std::string &scriptfilename) |
virtual void | commandEndDefine () |
virtual void | commandKind (const std::string &kind) |
virtual void | commandPrint (const std::string &value) |
virtual void | commandExec (const std::string &word) |
virtual void | commandInput (const std::string &name, const std::string &box, const std::string &input, const std::string &help) |
virtual void | commandOutput (const std::string &name, const std::string &box, const std::string &output, const std::string &help) |
virtual void | commandSet (const std::string &box, const std::string &input, const std::string &value) |
virtual void | commandAuthor (const std::string &author) |
virtual void | commandCategory (const std::string &categorytype) |
virtual void | commandDescription (const std::string &description) |
virtual void | commandClear () |
virtual void | commandInclude (const std::string &word, bool ok) |
virtual void | commandLoad (const std::string &packageName) |
virtual void | commandUnload (const std::string &packageName) |
virtual void | commandBreak () |
virtual void | commandQuit () |
virtual void | commandMessage () |
virtual void | commandMessage (const std::string &kind, const std::string &levelstr) |
virtual void | SetCurrentFileName (const std::string &fullPathScriptName) |
InterpreterVirtual () | |
Constructor. | |
void | Init () |
~InterpreterVirtual () | |
The break signal. | |
virtual void | CatchInterpreterException (const InterpreterException &e) |
virtual void | CatchBbtkException (const bbtk::Exception &e) |
virtual void | CatchStdException (const std::exception &e) |
virtual void | CatchUnknownException () |
void | LockThis () |
void | UnLockThis () |
template<class U > | |
boost::shared_ptr< U > | GetThisPointer () const |
Static Protected Member Functions | |
template<class U > | |
static boost::shared_ptr< U > | MakePointer (U *s, bool lock=false) |
template<class U , class D > | |
static boost::shared_ptr< U > | MakePointer (U *s, const D &del, bool lock=false) |
Protected Attributes | |
std::vector< std::string > | mFileName |
Vector of names of open files with full path (as open). | |
std::vector< int > | mLine |
Stores the current line number in each open file. | |
bool | mThrow |
bool | mCommandLine |
Are we in a command line context ? | |
std::vector< std::string > | mFileNameHistory |
bbtk::InterpreterUser * | mUser |
The user of the interpreter (0 if none). | |
CommandDictType | mCommandDict |
The dictionnary of commands. | |
Private Member Functions | |
void | LoadScript (std::string fullPathScriptName, std::string includeScriptName) |
Private Attributes | |
std::vector< std::istream * > | mFile |
Vector of open files / buffers (can be stringstream). | |
std::vector< std::string > | mIncludeFileName |
Vector of names of open files as given to the include command. | |
bool | mInsideComment |
Are we inside a commented-out zone ? | |
ExitStatus | mStatus |
The current interpreter status. | |
std::deque< char * > | mHistory |
The history of commands. | |
int | bufferNb |
Friends | |
struct | Object::Deleter |
Definition at line 136 of file bbtkInterpreterVirtual.h.
typedef std::map<std::string,CommandInfoType> bbtk::InterpreterVirtual::CommandDictType [protected] |
typedef boost::shared_ptr<Self> bbtk::InterpreterVirtual::Pointer |
Reimplemented from bbtk::Object.
Reimplemented in bbtk::Interpreter.
Definition at line 138 of file bbtkInterpreterVirtual.h.
Definition at line 138 of file bbtkInterpreterVirtual.h.
typedef boost::weak_ptr<Self> bbtk::InterpreterVirtual::WeakPointer |
Reimplemented from bbtk::Object.
Reimplemented in bbtk::Interpreter.
Definition at line 138 of file bbtkInterpreterVirtual.h.
enum bbtk::InterpreterVirtual::CommandCodeType [protected] |
The enumeration of command codes == Command name.
Definition at line 198 of file bbtkInterpreterVirtual.h.
00199 { 00200 cBreak, // LG 12/12/08 : Stops the current script execution (if not exec frozen) - used in tutorial + debugging 00201 cClear, // LG 12/12/08 : Clears the current complex black box (e.g. workspace) - used in tours 00202 cNew, 00203 cDelete, 00204 cConnect, 00205 cExec, 00206 cPackage, 00207 cEndPackage, 00208 cDefine, 00209 cEndDefine, 00210 cInput, 00211 cOutput, 00212 cSet, 00213 cConfig, // JPR 00214 cReset, // EED 00215 cAuthor, 00216 cCategory, // JPR 00217 cDescription, 00218 cHelp, 00219 cMessage, 00220 cInclude, 00221 cQuit, 00222 cLoad, 00223 cUnload, 00224 cGraph, 00225 cPrint, 00226 cIndex, 00227 cKind, // LG 00228 cNewGUI, // LG 00229 cWorkspace, // LG 00230 cDebug // LG 00231 } CommandCodeType;
Definition at line 143 of file bbtkInterpreterVirtual.h.
00144 { 00145 Interpreter_OK, 00146 Interpreter_ERROR, 00147 Interpreter_QUIT, 00148 Interpreter_BREAK, 00149 }
bbtk::InterpreterVirtual::InterpreterVirtual | ( | ) | [protected] |
Constructor.
Definition at line 63 of file bbtkInterpreterVirtual.cxx.
References Init().
Referenced by New().
00064 { 00065 Init(); 00066 }
bbtk::InterpreterVirtual::~InterpreterVirtual | ( | ) | [protected] |
The break signal.
Definition at line 352 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage.
00353 { 00354 bbtkDebugMessage("object",2,"==> ~Interpreter()" <<std::endl); 00355 }
void bbtk::InterpreterVirtual::CatchBbtkException | ( | const bbtk::Exception & | e | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 420 of file bbtkInterpreterVirtual.cxx.
References CloseAllFiles(), bbtk::Exception::GetErrorMessage(), Interpreter_ERROR, mFile, mFileName, mLine, mStatus, and mThrow.
00421 { 00422 //EED Borrame if (GetExecuter()->GetNoErrorMode()) 00423 //EED Borrame { 00424 //EED Borrame std::string file("?"); 00425 //EED Borrame int line = 0; 00426 //EED Borrame if (mFileName.size()) { 00427 //EED Borrame file = mFileName.back(); 00428 //EED Borrame line = mLine.back(); 00429 //EED Borrame } 00430 //EED Borrame bbtkWarning("ERROR '"<<e.GetErrorMessage() 00431 //EED Borrame <<"' ("<<file<<":"<<line<<") skipped"); 00432 //EED Borrame return; 00433 //EED Borrame } 00434 00435 mStatus = Interpreter_ERROR; 00436 if (mThrow) 00437 { 00438 bool in_script = false; 00439 std::string file(""); 00440 int line = 0; 00441 if (mFileName.size()) 00442 { 00443 std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back()); 00444 if (fs!=0) in_script = true; 00445 file = mFileName.back(); 00446 line = mLine.back(); 00447 } 00448 if (e.GetErrorMessage()!="break") 00449 CloseAllFiles(); 00450 throw InterpreterException(e,in_script,file,line); 00451 } else { 00452 std::stringstream mess; 00453 mess << "* ERROR : "<<e.GetErrorMessage()<<std::endl; 00454 if (mFileName.size()) 00455 { 00456 mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl; 00457 mess << "* LINE : "<<mLine.back()<<std::endl; 00458 } 00459 CloseAllFiles(); 00460 std::cerr << mess.str(); 00461 } // if 00462 }
void bbtk::InterpreterVirtual::CatchInterpreterException | ( | const InterpreterException & | e | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 388 of file bbtkInterpreterVirtual.cxx.
References CloseAllFiles(), bbtk::Exception::GetErrorMessage(), bbtk::InterpreterException::GetScriptFile(), bbtk::InterpreterException::GetScriptLine(), Interpreter_ERROR, bbtk::InterpreterException::IsInScriptFile(), mStatus, and mThrow.
00389 { 00390 //EED Borrame if (GetExecuter()->GetNoErrorMode()) 00391 //EED Borrame { 00392 //EED Borrame bbtkWarning("ERROR :"<<e.GetErrorMessage() 00393 //EED Borrame <<" ("<<e.GetScriptFile()<<":"<<e.GetScriptLine() 00394 //EED Borrame <<" skipped"); 00395 //EED Borrame return; 00396 //EED Borrame } 00397 if (mThrow) 00398 { 00399 if (e.GetErrorMessage()!="break") 00400 { 00401 mStatus = Interpreter_ERROR; 00402 CloseAllFiles(); 00403 } 00404 throw InterpreterException(e); 00405 } else { 00406 std::stringstream mess; 00407 mess << "* ERROR : "<<e.GetErrorMessage()<<std::endl; 00408 if (e.IsInScriptFile()) 00409 { 00410 mess << "* FILE : \""<<e.GetScriptFile()<<"\""<<std::endl; 00411 mess << "* LINE : "<<e.GetScriptLine()<<std::endl; 00412 } 00413 CloseAllFiles(); 00414 std::cerr << mess.str(); 00415 } // if 00416 }
void bbtk::InterpreterVirtual::CatchStdException | ( | const std::exception & | e | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 466 of file bbtkInterpreterVirtual.cxx.
References CloseAllFiles(), Interpreter_ERROR, mFile, mFileName, mLine, mStatus, and mThrow.
00467 { 00468 //EED Borrame if (GetExecuter()->GetNoErrorMode()) 00469 //EED Borrame { 00470 //EED Borrame std::string file("?"); 00471 //EED Borrame int line = 0; 00472 //EED Borrame if (mFileName.size()) { 00473 //EED Borrame file = mFileName.back(); 00474 //EED Borrame line = mLine.back(); 00475 //EED Borrame } 00476 //EED Borrame bbtkWarning("ERROR '"<<e.what() 00477 //EED Borrame <<"' ("<<file<<":"<<line<<") skipped"); 00478 //EED Borrame return; 00479 //EED Borrame } 00480 00481 mStatus = Interpreter_ERROR; 00482 if (mThrow) 00483 { 00484 bool in_script = false; 00485 std::string file(""); 00486 int line = 0; 00487 if (mFileName.size()) { 00488 std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back()); 00489 if (fs!=0) in_script = true; 00490 file = mFileName.back(); 00491 line = mLine.back(); 00492 } 00493 CloseAllFiles(); 00494 throw InterpreterException(e.what(),in_script,file,line); 00495 } else { 00496 std::stringstream mess; 00497 mess << "* ERROR : "<<e.what()<<std::endl; 00498 if (mFileName.size()) 00499 { 00500 mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl; 00501 mess << "* LINE : "<<mLine.back()<<std::endl; 00502 } 00503 CloseAllFiles(); 00504 std::cerr << mess.str(); 00505 } 00506 }
void bbtk::InterpreterVirtual::CatchUnknownException | ( | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 511 of file bbtkInterpreterVirtual.cxx.
References CloseAllFiles(), Interpreter_ERROR, mFile, mFileName, mLine, mStatus, and mThrow.
00512 { 00513 //EED Borrame if (GetExecuter()->GetNoErrorMode()) 00514 //EED Borrame { 00515 //EED Borrame std::string file("?"); 00516 //EED Borrame int line = 0; 00517 //EED Borrame if (mFileName.size()) { 00518 //EED Borrame file = mFileName.back(); 00519 //EED Borrame line = mLine.back(); 00520 //EED Borrame } 00521 //EED Borrame bbtkWarning("UNDEFINED ERROR " 00522 //EED Borrame <<"("<<file<<":"<<line<<") skipped"); 00523 //EED Borrame return; 00524 //EED Borrame } 00525 mStatus = Interpreter_ERROR; 00526 if (mThrow) 00527 { 00528 bool in_script = false; 00529 std::string file(""); 00530 int line = 0; 00531 if (mFileName.size()) { 00532 std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back()); 00533 if (fs!=0) in_script = true; 00534 file = mFileName.back(); 00535 line = mLine.back(); 00536 } 00537 CloseAllFiles(); 00538 throw InterpreterException("Unknown exception caught", 00539 in_script,file,line); 00540 } 00541 else 00542 { 00543 std::stringstream mess; 00544 mess << "* UNDEFINED ERROR (not a bbtk nor a std exception)" 00545 << std::endl; 00546 if (mFileName.size()) { 00547 mess << "* FILE : \""<<mFileName.back()<<"\""<<std::endl; 00548 mess << "* LINE : "<<mLine.back()<<std::endl; 00549 } 00550 CloseAllFiles(); 00551 std::cerr << mess.str(); 00552 } 00553 }
void bbtk::InterpreterVirtual::CloseAllFiles | ( | ) | [protected] |
Closes all open files.
Definition at line 1646 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, CloseCurrentFile(), and mFile.
Referenced by CatchBbtkException(), CatchInterpreterException(), CatchStdException(), CatchUnknownException(), and bbtk::Interpreter::commandReset().
01647 { 01648 bbtkDebugMessage("interpreter",9,"==> InterpreterVirtual::CloseAllFiles()" 01649 <<std::endl); 01650 01651 while (mFile.size() != 0) 01652 { 01653 CloseCurrentFile(); 01654 } 01655 bbtkDebugMessage("interpreter",9,"<== InterpreterVirtual::CloseAllFiles()" 01656 <<std::endl); 01657 }
void bbtk::InterpreterVirtual::CloseCurrentFile | ( | ) | [protected] |
Closes the currently open file.
Definition at line 1615 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, mFile, mFileName, mIncludeFileName, and mLine.
Referenced by CloseAllFiles(), and InterpretCurrentStreams().
01616 { 01617 bbtkDebugMessage("interpreter",9,"==> InterpreterVirtual::CloseCurrentFile()" 01618 <<std::endl); 01619 01620 if (mFile.size()==0) 01621 { 01622 bbtkDebugMessage("interpreter",9," -> no file left open"<<std::endl); 01623 return; 01624 } 01625 01626 bbtkDebugMessage("interpreter",9," Closing file '"<<mFileName.back()<<"'"<<std::endl); 01627 01628 std::ifstream* file = dynamic_cast<std::ifstream*>(mFile.back()); 01629 if (file!=0) file->close(); 01630 01631 delete mFile.back(); 01632 mFile.pop_back(); 01633 mFileName.pop_back(); 01634 mIncludeFileName.pop_back(); 01635 mLine.pop_back(); 01636 01637 bbtkDebugMessage("interpreter",9," Remains " 01638 <<mFile.size() 01639 <<" open"<<std::endl); 01640 bbtkDebugMessage("interpreter",9,"<== InterpreterVirtual::CloseCurrentFile()" 01641 <<std::endl); 01642 }
void bbtk::InterpreterVirtual::commandAuthor | ( | const std::string & | author | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 748 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandBreak | ( | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 780 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandCategory | ( | const std::string & | categorytype | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 752 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandClear | ( | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 763 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandConfig | ( | ) | const [protected, virtual] |
Displays the Configuration.
Reimplemented in bbtk::Interpreter.
Definition at line 1706 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandConnection | ( | const std::string & | nodeFrom, | |
const std::string & | outputLabel, | |||
const std::string & | nodeTo, | |||
const std::string & | inputLabel | |||
) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 702 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandDebug | ( | const std::string & | arg | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 2035 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandDefine | ( | const std::string & | name, | |
const std::string & | pack, | |||
const std::string & | scriptfilename | |||
) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 714 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandDelete | ( | const std::string & | boxName | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 698 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandDescription | ( | const std::string & | description | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 758 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandEndDefine | ( | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 718 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandEndPackage | ( | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 710 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandExec | ( | const std::string & | word | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 731 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandGraph | ( | const std::vector< std::string > & | words | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 2013 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandHelp | ( | const std::vector< std::string > & | words | ) | [protected, virtual] |
Displays help on all the commands.
Reimplemented in bbtk::Interpreter.
Definition at line 1695 of file bbtkInterpreterVirtual.cxx.
void bbtk::InterpreterVirtual::commandHelp | ( | const std::string & | words | ) | [protected, virtual] |
Displays help (entry point of any help).
Reimplemented in bbtk::Interpreter.
Definition at line 1699 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine(), and InterpretCommand().
void bbtk::InterpreterVirtual::commandInclude | ( | const std::string & | word, | |
bool | ok | |||
) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 767 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandIndex | ( | const std::string & | filename, | |
const std::string & | type = "Initials" | |||
) | [protected] |
Reimplemented in bbtk::Interpreter.
Definition at line 2020 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandInput | ( | const std::string & | name, | |
const std::string & | box, | |||
const std::string & | input, | |||
const std::string & | help | |||
) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 736 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandKind | ( | const std::string & | kind | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 722 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::CommandLineInterpreter | ( | ) |
Launches a command line interpreter (with a prompt).
Definition at line 1951 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugDecTab, bbtkDebugMessageInc, DoInterpretLine(), GetLineFromPrompt(), mCommandLine, mInsideComment, and bbtk::Exception::Print().
01952 { 01953 bbtkDebugMessageInc("interpreter",9, 01954 "InterpreterVirtual::CommandLineInterpreter()"<<std::endl); 01955 01956 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT 01957 // Initialise the tty in non canonical mode with no echo 01958 // oter remembers the previous settings to restore them after 01959 struct termios ter,oter; 01960 tcgetattr(0,&ter); 01961 oter=ter; 01962 ter.c_lflag &= ~ECHO; 01963 ter.c_lflag &= ~ICANON; 01964 ter.c_cc[VMIN]=1; 01965 ter.c_cc[VTIME]=0; 01966 tcsetattr(0,TCSANOW,&ter); 01967 #endif 01968 01969 mCommandLine = true; 01970 bool again = true; 01971 // bool insideComment = false; // for multiline comment 01972 mInsideComment = false; 01973 do 01974 { 01975 try 01976 { 01977 std::string line; 01978 GetLineFromPrompt(line); 01979 DoInterpretLine(line); //, insideComment); 01980 } 01981 /* 01982 catch (QuitException e) 01983 { 01984 bbtkMessage("interpreter",1,"Interpreter : Quit"<<std::endl); 01985 again = false; 01986 } 01987 */ 01988 catch (bbtk::Exception e) 01989 { 01990 e.Print(); 01991 } 01992 catch (std::exception& e) 01993 { 01994 std::cerr << "* ERROR :: "<<e.what()<<" (not in bbtk)"<<std::endl; 01995 } 01996 catch (...) 01997 { 01998 std::cerr << "* UNDEFINED ERROR (not a bbtk nor a std exception)"<<std::endl; 01999 } 02000 } 02001 while (again); 02002 02003 #ifdef BBTK_USE_TERMIOS_BASED_PROMPT 02004 tcsetattr(0,TCSANOW,&oter); 02005 #endif 02006 02007 std::cout << "Good bye !" << std::endl; 02008 02009 bbtkDebugDecTab("interpreter",9); 02010 }
void bbtk::InterpreterVirtual::commandLoad | ( | const std::string & | packageName | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 772 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandMessage | ( | const std::string & | kind, | |
const std::string & | levelstr | |||
) | [protected, virtual] |
void bbtk::InterpreterVirtual::commandMessage | ( | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 788 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandNew | ( | const std::string & | boxType, | |
const std::string & | boxName | |||
) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 694 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandNewGUI | ( | const std::string & | box, | |
const std::string & | instanceName | |||
) | [protected, virtual] |
Creates and connects the piece of pipeline which defines a GUI for the box box. Define it as a complex box type with name instanceName+"Type" The instance is called instanceName and connected to the existing pipeline
Reimplemented in bbtk::Interpreter.
Definition at line 2027 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandOutput | ( | const std::string & | name, | |
const std::string & | box, | |||
const std::string & | output, | |||
const std::string & | help | |||
) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 740 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandPackage | ( | const std::string & | packageName | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 706 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandPrint | ( | const std::string & | value | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 726 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandQuit | ( | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 784 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandReset | ( | ) | [protected, virtual] |
Resets all.
Reimplemented in bbtk::Interpreter.
Definition at line 1168 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandSet | ( | const std::string & | box, | |
const std::string & | input, | |||
const std::string & | value | |||
) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 744 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::commandUnload | ( | const std::string & | packageName | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 776 of file bbtkInterpreterVirtual.cxx.
Referenced by DoInterpretLine().
void bbtk::InterpreterVirtual::DoInterpretLine | ( | const std::string & | line | ) | [protected] |
Interprets a line.
Definition at line 799 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugDecTab, bbtkDebugMessage, bbtkInternalError, bbtkMessage, cAuthor, cBreak, cCategory, cClear, cConfig, cConnect, cDebug, cDefine, cDelete, cDescription, cEndDefine, cEndPackage, cExec, cGraph, cHelp, cInclude, cIndex, cInput, cKind, cLoad, cMessage, cNew, cNewGUI, bbtk::InterpreterVirtual::CommandInfoType::code, commandAuthor(), commandBreak(), commandCategory(), commandClear(), commandConfig(), commandConnection(), commandDebug(), commandDefine(), commandDelete(), commandDescription(), commandEndDefine(), commandEndPackage(), commandExec(), commandGraph(), commandHelp(), commandInclude(), commandIndex(), commandInput(), commandKind(), commandLoad(), commandMessage(), commandNew(), commandNewGUI(), commandOutput(), commandPackage(), commandPrint(), commandQuit(), commandReset(), commandSet(), commandUnload(), cOutput, cPackage, cPrint, cQuit, cReset, cSet, cUnload, InterpretCommand(), bbtk::InterpreterVirtual::CommandInfoType::keyword, mFile, mFileName, mInsideComment, mLine, bbtk::Utilities::SplitAroundFirstDot(), and SplitLine().
Referenced by CommandLineInterpreter(), InterpretCurrentStreams(), and InterpretLine().
00800 { 00801 00802 bbtkDebugMessage("interpreter",6,"==> InterpreterVirtual::DoInterpretLine(\"" 00803 <<line<<"\")"<<std::endl); 00804 std::vector<std::string> words; 00805 SplitLine(line,words); 00806 00807 00808 00809 // Empty line 00810 if (words.size()<1) 00811 { 00812 bbtkDebugDecTab("interpreter",9); 00813 return; 00814 } 00815 00816 // Single line comment : # or // 00817 if ( words[0][0]=='#' || (words[0][0]=='/' && words[0][1]=='/') ) 00818 { 00819 bbtkDebugDecTab("interpreter",9); 00820 bbtkMessage("interpreter",9,"Comment"<<std::endl); 00821 return; 00822 } 00823 00824 // Multi line comment ( /* ... */ ) -delimiters on different lines !- 00825 00826 if (words[0][0]=='/' && words[0][1]=='*') 00827 { 00828 bbtkDebugDecTab("interpreter",9); 00829 bbtkMessage("interpreter",9,"In multiline comment"<<std::endl); 00830 mInsideComment = true; 00831 return; 00832 } 00833 00834 if (words[0][0]=='*' && words[0][1]=='/') 00835 { 00836 bbtkDebugDecTab("interpreter",9); 00837 bbtkMessage("interpreter",9,"Out multiline comment"<<std::endl); 00838 if ( !mInsideComment ) { 00839 bbtkDebugDecTab("interpreter",9); 00840 bbtkMessage("interpreter",9,"Comment mismatch : '*/' with no matching '/*'"<<std::endl); 00841 } 00842 mInsideComment = false; 00843 return; 00844 } 00845 00846 if (mInsideComment) 00847 { 00848 bbtkDebugDecTab("interpreter",9); 00849 bbtkMessage("interpreter",9,"Multiline Comment"<<std::endl); 00850 return; 00851 } 00852 00853 00854 // Command 00855 CommandInfoType command; 00856 InterpretCommand(words,command); 00857 //std::cout<<"JCP bbtkInterpreter command.keyword ="<<command.keyword<<std::endl; 00858 bbtkDebugMessage("interpreter",9, 00859 "Command='"<<command.keyword 00860 <<"' code="<<command.code<<std::endl); 00861 00862 std::string left,right,left2,right2; 00863 std::string filename; 00864 00865 // message command 00866 if (command.code==cMessage) 00867 { 00868 if (words.size()<3) 00869 { 00870 commandMessage(); 00871 //EED Borrame mVirtualExecuter->HelpMessages(); 00872 } 00873 else 00874 { 00875 commandMessage(words[1],words[2]); 00876 //EED Borrame sscanf(words[2].c_str(),"%d",&level); 00877 //EED Borrame mVirtualExecuter->SetMessageLevel(words[1],level); 00878 } 00879 return; 00880 } 00881 else 00882 { 00883 bbtkMessage("echo",2,line<<std::endl); 00884 } 00885 00886 // break and quit commands 00887 if ((command.code==cBreak) || (command.code==cQuit)) 00888 { 00889 bool in_script = false; 00890 std::string file(""); 00891 int line = 0; 00892 00893 if (mFileName.size()) 00894 { 00895 std::ifstream* fs = dynamic_cast<std::ifstream*>(mFile.back()); 00896 if (fs!=0) in_script = true; 00897 file = mFileName.back(); 00898 line = mLine.back(); 00899 } 00900 if (command.code==cBreak) 00901 { 00902 /* 00903 std::cout << "BreakException(" 00904 <<in_script<<"," 00905 <<file<<"," 00906 <<line<<")"<<std::endl; 00907 */ 00908 commandBreak(); 00909 //EED Borrame bbtkError("break");//,in_script,file,line); 00910 // throw BreakException(in_script,file,line); 00911 } 00912 else 00913 { 00914 commandQuit(); 00915 //EED Borrame bbtkError("quit");//,in_script,file,line); 00916 //throw QuitException(in_script,file,line); 00917 } 00918 return; 00919 } 00920 //std::cout<<" mVirtualExecuter->Create(words[1],words[2]); "<<line<<std::endl; 00921 // other cammands 00922 00923 00924 switch (command.code) 00925 { 00926 case cNew : 00927 commandNew(words[1],words[2]); 00928 //EED Borrame mVirtualExecuter->Create(words[1],words[2]); 00929 break; 00930 00931 case cDelete : 00932 commandDelete(words[1]); 00933 //EED Borrame mVirtualExecuter->Destroy(words[1]); 00934 break; 00935 00936 case cConnect : 00937 Utilities::SplitAroundFirstDot(words[1],left,right); 00938 Utilities::SplitAroundFirstDot(words[2],left2,right2); 00939 commandConnection(left,right,left2,right2); 00940 //EED Borrame mVirtualExecuter->Connect(left,right,left2,right2); 00941 break; 00942 00943 case cPackage : 00944 commandPackage(words[1]); 00945 //EED Borrame mVirtualExecuter->BeginPackage(words[1]); 00946 break; 00947 00948 case cEndPackage : 00949 commandEndPackage(); 00950 //EED Borrame mVirtualExecuter->EndPackage(); 00951 break; 00952 00953 case cDefine : 00954 if (mFileName.size()>0) 00955 { 00956 //??? commandDefine(????); 00957 filename = mFileName.back(); //mIncludeFileName.back(); //Utilities::get_file_name(mFileName.back()); 00958 } 00959 if (words.size()==2) 00960 { 00961 std::string packTmp = ""; 00962 commandDefine(words[1],packTmp,filename); 00963 //EED Borrame mVirtualExecuter->Define(words[1],"",filename); 00964 } 00965 else 00966 { 00967 commandDefine(words[1],words[2],filename); 00968 //EED Borrame mVirtualExecuter->Define(words[1],words[2],filename); 00969 } 00970 break; 00971 00972 case cEndDefine : 00973 commandEndDefine(); 00974 //EED Borrame mVirtualExecuter->EndDefine(); 00975 break; 00976 00977 case cKind : 00978 commandKind(words[1]); 00979 //EED Borrame mVirtualExecuter->Kind(words[1]); 00980 break; 00981 00982 case cPrint : 00983 commandPrint(words[1]); 00984 //EED Borrame mVirtualExecuter->Print(words[1]); 00985 break; 00986 00987 case cExec : 00988 commandExec(words[1]); 00989 //EED Borrame if (words[1]=="freeze") 00990 //EED Borrame { 00991 //EED Borrame mVirtualExecuter->SetNoExecMode(true); 00992 //EED Borrame mThrow = false; 00993 //EED Borrame } 00994 //EED Borrame else if (words[1]=="freeze_no_error") 00995 //EED Borrame { 00996 //EED Borrame mVirtualExecuter->SetNoExecMode(true); 00997 //EED Borrame mVirtualExecuter->SetNoErrorMode(true); 00998 //EED Borrame mThrow = false; 00999 //EED Borrame } 01000 //EED Borrame else if (words[1]=="unfreeze") 01001 //EED Borrame { 01002 //EED Borrame mVirtualExecuter->SetNoExecMode(false); 01003 //EED Borrame mVirtualExecuter->SetNoErrorMode(false); 01004 //EED Borrame } 01005 //EED Borrame else 01006 //EED Borrame { 01007 //EED Borrame mVirtualExecuter->Execute(words[1]); 01008 //EED Borrame } 01009 01010 break; 01011 01012 case cInput : 01013 Utilities::SplitAroundFirstDot(words[2],left,right); 01014 commandInput(words[1],left,right,words[3]); 01015 //EED Borrame mVirtualExecuter->DefineInput(words[1],left,right,words[3]); 01016 break; 01017 01018 case cOutput : 01019 Utilities::SplitAroundFirstDot(words[2],left,right); 01020 commandOutput(words[1],left,right,words[3]); 01021 //EED Borrame mVirtualExecuter->DefineOutput(words[1],left,right,words[3]); 01022 break; 01023 01024 case cSet : 01025 Utilities::SplitAroundFirstDot(words[1],left,right); 01026 commandSet(left,right,words[2]); 01027 //EED Borrame mVirtualExecuter->Set(left,right,words[2]); 01028 break; 01029 01030 case cAuthor : 01031 commandAuthor(words[1]); 01032 //EED Borrame mVirtualExecuter->Author(words[1]); 01033 break; 01034 01035 case cNewGUI : 01036 commandNewGUI(words[1],words[2]); 01037 break; 01038 01039 case cCategory : 01040 commandCategory(words[1]); 01041 //EED Borrame mVirtualExecuter->Category(words[1]); 01042 break; 01043 01044 case cIndex : 01045 if (words.size()==1) 01046 commandIndex("tmp_index.html"); 01047 else if (words.size()==2) 01048 commandIndex(words[1]); 01049 else if (words.size()==3) 01050 commandIndex(words[1],words[2]); 01051 break; 01052 01053 case cDescription : 01054 commandDescription(words[1]); 01055 //EED Borrame mVirtualExecuter->Description(words[1]); 01056 break; 01057 01058 case cHelp : 01059 commandHelp(words); 01060 break; 01061 01062 01063 case cGraph : 01064 commandGraph(words); 01065 break; 01066 01067 case cConfig : 01068 commandConfig(); 01069 break; 01070 01071 case cReset : 01072 commandReset(); 01073 break; 01074 01075 case cClear : 01076 commandClear(); 01077 //EED Borrame mVirtualExecuter->Clear(); 01078 break; 01079 01080 case cInclude : 01081 commandInclude( words[1] , (words.size()==3) ); 01082 //EED Borrame // if 'source' was given (words.size()==3) then tell to set the 01083 //EED Borrame // source file name of the current complex box with the full file name included 01084 //EED Borrame if (mCommandLine) 01085 //EED Borrame { 01086 //EED Borrame InterpretFile(words[1],(words.size()==3)); 01087 //EED Borrame } else{ 01088 //EED Borrame SwitchToFile(words[1],(words.size()==3) ); 01089 //EED Borrame } 01090 break; 01091 01092 case cLoad: 01093 commandLoad( words[1] ); 01094 //EED Borrame GetExecuter()->LoadPackage(words[1]); 01095 break; 01096 01097 case cUnload: 01098 commandUnload( words[1] ); 01099 //EED Borrame GetExecuter()->UnLoadPackage(words[1]); 01100 break; 01101 01102 case cDebug : 01103 if (words.size()==2) commandDebug(words[1]); 01104 else commandDebug(""); 01105 break; 01106 01107 /* obsolete 01108 case cWorkspace : 01109 if (words.size() == 2) 01110 { 01111 if (words[1]=="freeze") mVirtualExecuter->SetNoExecMode(true); 01112 else if (words[1]=="unfreeze") mVirtualExecuter->SetNoExecMode(false); 01113 } 01114 else 01115 { 01116 mVirtualExecuter->SetWorkspaceName(words[2]); 01117 } 01118 break; 01119 */ 01120 default: 01121 bbtkInternalError("should not reach here !!!"); 01122 } 01123 01124 bbtkDebugMessage("interpreter",6,"<== InterpreterVirtual::DoInterpretLine(\"" 01125 <<line<<"\")"<<std::endl); 01126 01127 }
void bbtk::InterpreterVirtual::FindCommandsWithPrefix | ( | char * | buf, | |
int | n, | |||
std::vector< std::string > & | commands | |||
) | [protected] |
Fills the vector commands with the commands which have the first n chars of buf for prefix TODO : skip initial spaces in buf and also return the position of first non blank char in buf
Definition at line 1718 of file bbtkInterpreterVirtual.cxx.
References bbtk::i, and mCommandDict.
01721 { 01722 CommandDictType::const_iterator i; 01723 for (i=mCommandDict.begin(); i!=mCommandDict.end(); ++i) 01724 { 01725 if ((i->first).find(buf,0,n) == 0) 01726 commands.push_back(i->first); 01727 } 01728 }
void bbtk::InterpreterVirtual::GetLineFromPrompt | ( | std::string & | line | ) | [protected] |
Reads a line from prompt.
Definition at line 1918 of file bbtkInterpreterVirtual.cxx.
Referenced by CommandLineInterpreter().
01919 { 01920 s.clear(); 01921 01922 putchar('>'); 01923 putchar(' '); 01924 01925 do 01926 { 01927 char c = getchar(); 01928 if (c=='\n') 01929 { 01930 putchar('\n'); 01931 break; 01932 } 01933 if (c=='\t') 01934 { 01935 // putchar('T'); 01936 continue; 01937 } 01938 // putchar(c); 01939 s += c; 01940 } 01941 while (true); 01942 01943 }
std::string bbtk::InterpreterVirtual::GetObjectInfo | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Reimplemented in bbtk::Interpreter.
Definition at line 2058 of file bbtkInterpreterVirtual.cxx.
02059 { 02060 std::stringstream i; 02061 return i.str(); 02062 }
size_t bbtk::InterpreterVirtual::GetObjectInternalSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Reimplemented in bbtk::Interpreter.
Definition at line 2074 of file bbtkInterpreterVirtual.cxx.
Referenced by GetObjectRecursiveSize(), and GetObjectSize().
02075 { 02076 size_t s = sizeof(InterpreterVirtual); 02077 return s; 02078 }
std::string bbtk::InterpreterVirtual::GetObjectName | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Reimplemented in bbtk::Interpreter.
Definition at line 2051 of file bbtkInterpreterVirtual.cxx.
size_t bbtk::InterpreterVirtual::GetObjectRecursiveSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Reimplemented in bbtk::Interpreter.
Definition at line 2081 of file bbtkInterpreterVirtual.cxx.
References GetObjectInternalSize(), and bbtk::Object::GetObjectRecursiveSize().
02082 { 02083 size_t s = Superclass::GetObjectRecursiveSize(); 02084 s += InterpreterVirtual::GetObjectInternalSize(); 02085 return s; 02086 }
static long bbtk::Object::GetObjectsCount | ( | ) | [inline, static, inherited] |
Definition at line 75 of file bbtkObject.h.
Referenced by bbtk::StaticInitTime::~StaticInitTime().
00075 { return mgObjectList.size(); }
size_t bbtk::InterpreterVirtual::GetObjectSize | ( | ) | const [virtual] |
Reimplemented from bbtk::Object.
Reimplemented in bbtk::Interpreter.
Definition at line 2066 of file bbtkInterpreterVirtual.cxx.
References GetObjectInternalSize(), and bbtk::Object::GetObjectSize().
02067 { 02068 size_t s = Superclass::GetObjectSize(); 02069 s += InterpreterVirtual::GetObjectInternalSize(); 02070 return s; 02071 }
boost::shared_ptr<U> bbtk::Object::GetThisPointer | ( | ) | const [inline, protected, inherited] |
Definition at line 92 of file bbtkObject.h.
00093 { 00094 return boost::dynamic_pointer_cast<U>(mThisPointer.lock()); 00095 }
long bbtk::Object::GetUseCount | ( | ) | [inline, inherited] |
const InterpreterUser* bbtk::InterpreterVirtual::GetUser | ( | ) | const [inline] |
Gets the InterpreterUser of this (const).
Definition at line 180 of file bbtkInterpreterVirtual.h.
00180 { return mUser; }
InterpreterUser* bbtk::InterpreterVirtual::GetUser | ( | ) | [inline] |
Gets the InterpreterUser of this.
Definition at line 178 of file bbtkInterpreterVirtual.h.
00178 { return mUser; }
void bbtk::InterpreterVirtual::Init | ( | ) | [protected] |
Definition at line 71 of file bbtkInterpreterVirtual.cxx.
References bbtk::InterpreterVirtual::CommandInfoType::argmax, bbtk::InterpreterVirtual::CommandInfoType::argmin, bbtkDebugMessageInc, bufferNb, cAuthor, cBreak, cCategory, cClear, cConfig, cConnect, cDebug, cDefine, cDelete, cDescription, cEndDefine, cEndPackage, cExec, cGraph, cHelp, cInclude, cIndex, cInput, cKind, cLoad, cMessage, cNew, cNewGUI, bbtk::InterpreterVirtual::CommandInfoType::code, cOutput, cPackage, cPrint, cQuit, cReset, cSet, cUnload, bbtk::InterpreterVirtual::CommandInfoType::help, bbtk::InterpreterVirtual::CommandInfoType::keyword, mCommandDict, mCommandLine, mThrow, mUser, bbtk::MessageManager::RegisterMessageType(), and bbtk::InterpreterVirtual::CommandInfoType::syntax.
Referenced by bbtk::Interpreter::Init(), bbtk::Interpreter::Interpreter(), and InterpreterVirtual().
00072 { 00073 mUser = 0; 00074 mCommandLine = false; 00075 mThrow = false; 00076 bufferNb = 0; 00077 bbtk::MessageManager::RegisterMessageType("echo","Level>0 : Prints the output of the 'print' commands of the user.\n\tLevel>1 : Prints the command being interpreted",1); 00078 bbtk::MessageManager::RegisterMessageType("Interpreter","Messages of the interpreter",0); 00079 bbtkDebugMessageInc("Interpreter",9,"InterpreterVirtual::Interpreter()" <<std::endl); 00080 00081 // For the time being, comment out previous line, and 00082 // uncomment next line to check Transcriptor 00083 00084 //mVirtualExecuter = new bbtk::Transcriptor("GeneratedProgram.txt"); 00085 00086 // Builds the commands dict 00087 CommandInfoType info; 00088 00089 info.keyword = "new"; 00090 info.argmin = 2; 00091 info.argmax = 2; 00092 info.code = cNew; 00093 info.syntax = "new <type> <name>"; 00094 info.help = "Creates a new black box of type <type> with name <name>"; 00095 mCommandDict[info.keyword] = info; 00096 00097 info.keyword = "delete"; 00098 info.argmin = 1; 00099 info.argmax = 1; 00100 info.code = cDelete; 00101 info.syntax = "delete <box>"; 00102 info.help = "Deletes the black box of name <box>"; 00103 mCommandDict[info.keyword] = info; 00104 00105 info.keyword = "clear"; 00106 info.argmin = 0; 00107 info.argmax = 0; 00108 info.code = cClear; 00109 info.syntax = "clear"; 00110 info.help = "Clears the currently defined complex box (deletes all its boxes and connections)"; 00111 mCommandDict[info.keyword] = info; 00112 00113 info.keyword = "break"; 00114 info.argmin = 0; 00115 info.argmax = 0; 00116 info.code = cBreak; 00117 info.syntax = "break"; 00118 info.help = "Breaks the current execution"; 00119 mCommandDict[info.keyword] = info; 00120 00121 info.keyword = "newgui"; 00122 info.argmin = 2; 00123 info.argmax = 2; 00124 info.code = cNewGUI; 00125 info.syntax = "newgui <box> <name>"; 00126 info.help = "Automatically creates a graphical user interface with name <name> for the black box <box> and connects it to the box inputs"; 00127 mCommandDict[info.keyword] = info; 00128 00129 info.keyword = "connect"; 00130 info.argmin = 2; 00131 info.argmax = 2; 00132 info.code = cConnect; 00133 info.syntax = "connect <box1.output> <box2.input>"; 00134 info.help = "Connects the ouput <output> of black box <box1> to the input <input> of black box <box2>"; 00135 mCommandDict[info.keyword] = info; 00136 00137 info.keyword = "print"; 00138 info.argmin = 1; 00139 info.argmax = 1; 00140 info.code = cPrint; 00141 info.syntax = "print <string>"; 00142 info.help = "Prints the string. Substitutes any token of the form '$box.output$' by the string adaptation of the output of the box (requires the right adaptor). No carriage return is issued at the end, use '\\n' to add carriage returns. The level of 'echo' messages must be greater than 1 (see the command 'message')."; 00143 mCommandDict[info.keyword] = info; 00144 00145 info.keyword = "exec"; 00146 info.argmin = 1; 00147 info.argmax = 2; 00148 info.code = cExec; 00149 info.syntax = "exec <box | 'freeze' | 'unfreeze' | 'freeze_no_error' >"; 00150 info.help = "Executes the black box of name <box> (and connected boxes if needed). If the special keyword 'freeze' is given then freezes any further execution command. 'unfreeze' reverts to normal execution mode. 'freeze_no_error' is like freeze but also skips any error."; 00151 mCommandDict[info.keyword] = info; 00152 00153 info.keyword = "package"; 00154 info.argmin = 1; 00155 info.argmax = 1; 00156 info.code = cPackage; 00157 info.syntax = "package <name>"; 00158 info.help = "Begins the definition of a package."; 00159 mCommandDict[info.keyword] = info; 00160 00161 info.keyword = "endpackage"; 00162 info.argmin = 0; 00163 info.argmax = 0; 00164 info.code = cEndPackage; 00165 info.syntax = "endpackage"; 00166 info.help = "Ends the definition of a package."; 00167 mCommandDict[info.keyword] = info; 00168 00169 info.keyword = "define"; 00170 info.argmin = 1; 00171 info.argmax = 2; 00172 info.code = cDefine; 00173 info.syntax = "define <type> [<package>]"; 00174 info.help = "Begins the definition of a new type of complex black box called <type>. If <package> is provided will create it in the given package."; 00175 mCommandDict[info.keyword] = info; 00176 00177 info.keyword = "endefine"; 00178 info.argmin = 0; 00179 info.argmax = 0; 00180 info.code = cEndDefine; 00181 info.syntax = "endefine"; 00182 info.help = "Ends the definition of a new type of complex black box"; 00183 mCommandDict[info.keyword] = info; 00184 00185 info.keyword = "kind"; 00186 info.argmin = 1; 00187 info.argmax = 1; 00188 info.code = cKind; 00189 info.syntax = "kind <ADAPTOR|DEFAULT_ADAPTOR|GUI|DEFAULT_GUI>"; 00190 info.help = "Sets the kind of the currently defined complex black box"; 00191 mCommandDict[info.keyword] = info; 00192 00193 info.keyword = "input"; 00194 info.argmin = 3; 00195 info.argmax = 3; 00196 info.code = cInput; 00197 info.syntax = "input <name> <box.input> <help>"; 00198 info.help = "Defines the input <name> of the current working black box as being an alias for the input <input> of the black box <box>. <help> defines the help string for the newly created input"; 00199 mCommandDict[info.keyword] = info; 00200 00201 info.keyword = "output"; 00202 info.argmin = 3; 00203 info.argmax = 3; 00204 info.code = cOutput; 00205 info.syntax = "output <name> <box.output> <help>"; 00206 info.help = "Defines the output <name> of the current working black box as being an alias for the output <output> of the black box <box>. <help> defines the help string for the newly created output"; 00207 mCommandDict[info.keyword] = info; 00208 00209 info.keyword = "set"; 00210 info.argmin = 2; 00211 info.argmax = 2; 00212 info.code = cSet; 00213 info.syntax = "set <box.input> <value>"; 00214 info.help = "Sets the value of the input <input> of the black box <box> to <value>. There must exist a string to the value type adaptor"; 00215 mCommandDict[info.keyword] = info; 00216 00217 info.keyword = "config"; // JPR 00218 info.argmin = 0; 00219 info.argmax = 0; 00220 info.code = cConfig; 00221 info.syntax = "config"; 00222 info.help = "Prints the value of all configuration parameters"; 00223 mCommandDict[info.keyword] = info; 00224 00225 info.keyword = "index"; // LG 00226 info.argmin = 0; 00227 info.argmax = 2; 00228 info.code = cIndex; 00229 00230 info.syntax = "index [<filename> ['Initials'(default)|'Packages'|'Categories'|'Adaptors']]"; 00231 info.help = "Creates an html index of known boxes. If filename is provided then save it to the file 'filename'. The default index entries are the initial letters of the names of the boxes. If 'Packages' or 'Categories' is provided then the entries are either the packages names or the categories. If 'Adaptors' is provided then an alphabetical index of all adaptors is created."; 00232 mCommandDict[info.keyword] = info; 00233 00234 info.keyword = "reset"; 00235 info.argmin = 0; 00236 info.argmax = 0; 00237 info.code = cReset; 00238 info.syntax = "reset"; 00239 info.help = "Deletes all boxes and unloads all packages (reset to start state)"; 00240 mCommandDict[info.keyword] = info; 00241 00242 info.keyword = "author"; 00243 info.argmin = 1; 00244 info.argmax = 1; 00245 info.code = cAuthor; 00246 info.syntax = "author <string>"; 00247 info.help = "Adds the string <string> to the author information of the black box being defined"; 00248 mCommandDict[info.keyword] = info; 00249 00250 info.keyword = "category"; //JP 00251 info.argmin = 1; 00252 info.argmax = 1; 00253 info.code = cCategory; 00254 info.syntax = "category <list of items, separated by ;>"; 00255 info.help = "Adds the string <string> to the category information of the black box being defined"; 00256 mCommandDict[info.keyword] = info; 00257 00258 info.keyword = "description"; 00259 info.argmin = 1; 00260 info.argmax = 1; 00261 info.code = cDescription; 00262 info.syntax = "description <string>"; 00263 info.help = "Adds the string <string> to the descriptive information of the black box being defined"; 00264 mCommandDict[info.keyword] = info; 00265 00266 info.keyword = "help"; 00267 info.argmin = 0; 00268 info.argmax = 2; 00269 info.code = cHelp; 00270 info.syntax = "help"; 00271 info.syntax = "\n (1) help \n (2) help <command name> \n (3) help packages [all]\n (4) help <package name> [all]\n (5) help <black box type> \n (6) help <black box name>"; 00272 info.help = "Effect :\n (1) Lists all available commands;\n (2) Prints help on a particular command; \n (3) Lists the packages loaded and their black boxes.\n Add 'all' to list adaptors; \n (4) Prints short help on the black boxes of a package.\n Add 'all' to include adaptors; \n (5) Prints full help on a black box type; \n (6) Prints information on the inputs, outputs and connections of a black box instance."; 00273 mCommandDict[info.keyword] = info; 00274 00275 info.keyword = "message"; 00276 info.argmin = 0; 00277 info.argmax = 2; 00278 info.code = cMessage; 00279 info.syntax = "message <kind> <level>"; 00280 info.help = "Sets the level of the kind of messages <kind> to <level>.\n If kind='All' then sets the level for all kinds. If no kind nor level is passed then prints info on available kinds of messages and their current level."; 00281 mCommandDict[info.keyword] = info; 00282 00283 info.keyword = "include"; 00284 info.argmin = 1; 00285 info.argmax = 2; 00286 info.code = cInclude; 00287 info.syntax = "include <filename> [source]"; 00288 info.help = "Includes the file <filename>.\n 'source' : If the keyword 'source' is provided then informs the interpreter that the included file is the source of the current box definition (Advanced; used to get the right 'Include' field in html doc of packages 'appli' scripts)."; 00289 mCommandDict[info.keyword] = info; 00290 00291 info.keyword = "quit"; 00292 info.argmin = 0; 00293 info.argmax = 0; 00294 info.code = cQuit; 00295 info.syntax = "quit"; 00296 info.help = "Quits the program (during script execution it stops the complete execution)"; 00297 mCommandDict[info.keyword] = info; 00298 00299 info.keyword = "load"; 00300 info.argmin = 1; 00301 info.argmax = 1; 00302 info.code = cLoad; 00303 info.syntax = "load <packagename>"; 00304 info.help = "Loads the black box package <packagename>"; 00305 mCommandDict[info.keyword] = info; 00306 00307 info.keyword = "unload"; 00308 info.argmin = 1; 00309 info.argmax = 1; 00310 info.code = cUnload; 00311 info.syntax = "unload <packagename>"; 00312 info.help = "Unloads the black box package <packagename>"; 00313 mCommandDict[info.keyword] = info; 00314 00315 info.keyword = "graph"; 00316 info.argmin = 0; 00317 info.argmax = 6; 00318 info.code = cGraph; 00319 info.syntax = "graph [ BlackBoxName [ Detail 0..1 [ Level 0..99999 [ Output html file [ Custom header [ Custom title ]]]]]] \n graph [ BlackBoxNameType [ Detail 0..1 [ Level 0..99999 [ Output html file [ Custom header [ Custom title ]]]]]]"; 00320 info.help = "Shows a graphical view of a bbtk pipeline.\n- BlackBoxName : name of the box to view. Default '.' : current box.\n- BlackBoxNameType : name of the type of box to view, ex : 'workspace')"; 00321 mCommandDict[info.keyword] = info; 00322 00323 info.keyword = "debug"; 00324 info.argmin = 0; 00325 info.argmax = 1; 00326 info.code = cDebug; 00327 info.syntax = "debug [expr|-C|-D]"; 00328 info.help = "Prints debug info on living bbtk objects containing the string 'expr' (default expr=''). -C checks the factory integrity. -D turns on objects debug info after main ends"; 00329 mCommandDict[info.keyword] = info; 00330 00331 /* 00332 info.keyword = "workspace"; 00333 info.argmin = 1; 00334 info.argmax = 2; 00335 info.code = cWorkspace; 00336 info.syntax = "workspace < ( freeze | unfreeze ) | ( rename <newname> ) >"; 00337 info.help = "Configures the workspace.\n 'freeze' allows to block execution commands while keeping definition commands active. 'unfreeze' turns back the worspace in 'normal' mode.\n 'rename' allow to set a new name to the workspace."; 00338 mCommandDict[info.keyword] = info; 00339 */ 00340 00341 00342 00343 }
void bbtk::Object::InsertInObjectList | ( | Pointer | p | ) | [static, inherited] |
Definition at line 59 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::mgObjectList.
Referenced by bbtk::Object::MakePointer().
00060 { 00061 bbtkDebugMessage("object",9,"##> Object::InsertInObjectList(\"" 00062 <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl); 00063 boost::weak_ptr<Object> w(p); 00064 mgObjectList.insert(w); 00065 }
void bbtk::Object::InsertInPackageList | ( | Pointer | p | ) | [static, inherited] |
Definition at line 69 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::mgPackageList.
00070 { 00071 bbtkDebugMessage("object",9,"##> Object::InsertInPackageList(\"" 00072 <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl); 00073 boost::weak_ptr<Object> w(p); 00074 mgPackageList.insert(w); 00075 }
InterpreterVirtual::ExitStatus bbtk::InterpreterVirtual::InterpretBuffer | ( | std::stringstream * | buffer | ) |
Runs the interpretation of a buffer and deletes it !
Definition at line 609 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, CATCH_MACRO, InterpretCurrentStreams(), Interpreter_OK, mCommandLine, mInsideComment, mStatus, and SwitchToStream().
00610 { 00611 bbtkDebugMessage("interpreter",4,"==> InterpreterVirtual::InterpretBuffer()"<<std::endl); 00612 00613 bool exm = mCommandLine; 00614 mCommandLine = false; 00615 00616 try 00617 { 00618 mStatus = Interpreter_OK; 00619 SwitchToStream(buffer); 00620 mInsideComment = false; 00621 InterpretCurrentStreams(); 00622 } 00623 CATCH_MACRO; 00624 00625 // CloseAllFiles(); 00626 bbtkDebugMessage("interpreter",4,"<== InterpreterVirtual::InterpretBuffer()"<<std::endl); 00627 00628 00629 mCommandLine = exm; 00630 return mStatus; 00631 }
void bbtk::InterpreterVirtual::InterpretCommand | ( | const std::vector< std::string > & | words, | |
CommandInfoType & | info | |||
) | [protected] |
Executes the right action depending on the command name.
Definition at line 1663 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, bbtkError, commandHelp(), and mCommandDict.
Referenced by DoInterpretLine().
01665 { 01666 01667 bbtkDebugMessage("interpreter",9,"==> InterpreterVirtual::InterpretCommand(...)"<<std::endl); 01668 01669 // searches the command keyword 01670 CommandDictType::iterator c; 01671 c = mCommandDict.find(words[0]); 01672 if ( c == mCommandDict.end() ) { 01673 bbtkError(words[0]<<" : unknown command"); 01674 } 01675 01676 // tests the number of args 01677 if ( ( ((int)words.size())-1 < c->second.argmin ) || 01678 ( ((int)words.size())-1 > c->second.argmax ) ) 01679 { 01680 01681 //EED HelpCommand(words[0]); 01682 commandHelp(words[0]); 01683 bbtkError(words[0]<<" : wrong number of arguments"); 01684 } 01685 //std::cout<<"InterpreterVirtual::InterpretCommand( const std::vector<std::string>& words,"<<std::endl; 01686 info = c->second; 01687 bbtkDebugMessage("interpreter",9,"<== InterpreterVirtual::InterpretCommand(...)"<<std::endl); 01688 01689 }
InterpreterVirtual::ExitStatus bbtk::InterpreterVirtual::InterpretCurrentStreams | ( | ) |
Runs the interpretation of the currently open streams.
Interprets the currently open streams.
Definition at line 636 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, CATCH_MACRO, CloseCurrentFile(), DoInterpretLine(), mFile, mLine, and mStatus.
Referenced by InterpretBuffer(), and InterpretFile().
00637 { 00638 bbtkDebugMessage("interpreter",4, 00639 "==> InterpreterVirtual::InterpretCurrentStreams()"<<std::endl); 00640 00641 while (mFile.size()>0) 00642 { 00643 while (!mFile.back()->eof()) { 00644 mLine.back()++; 00645 char buf[500]; 00646 mFile.back()->getline(buf,500); 00647 std::string str(buf); 00648 //size 0 JCP 21-09-2009 00649 int size=str.length(); 00650 if(size != 0){ 00651 if ( str[ size-1 ]==13 ) 00652 { 00653 str.erase(size-1,1); 00654 } 00655 try 00656 { 00657 DoInterpretLine(str); 00658 } 00659 CATCH_MACRO; 00660 } 00661 00662 } 00663 CloseCurrentFile(); 00664 } 00665 bbtkDebugMessage("interpreter",4, 00666 "<== InterpreterVirtual::InterpretCurrentStreams()"<<std::endl); 00667 00668 return mStatus; 00669 }
InterpreterVirtual::ExitStatus bbtk::InterpreterVirtual::InterpretFile | ( | const std::string & | filename, | |
bool | source = false | |||
) |
Runs the interpretation of a file.
Definition at line 579 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, CATCH_MACRO, InterpretCurrentStreams(), Interpreter_OK, mCommandLine, mInsideComment, mStatus, and SwitchToFile().
Referenced by bbtk::Interpreter::commandInclude().
00580 { 00581 bbtkDebugMessage("interpreter",4,"==> InterpreterVirtual::InterpretFile(\""<<filename<<"\")"<<std::endl); 00582 00583 bool exm = mCommandLine; 00584 mCommandLine = false; 00585 00586 try 00587 { 00588 mStatus = Interpreter_OK; 00589 SwitchToFile(filename,source); 00590 mInsideComment = false; 00591 InterpretCurrentStreams(); 00592 } 00593 CATCH_MACRO; 00594 00595 bbtkDebugMessage("interpreter",4, 00596 "<== InterpreterVirtual::InterpretFile(\"" 00597 <<filename<<"\")"<<std::endl); 00598 00599 00600 mCommandLine = exm; 00601 00602 return mStatus; 00603 }
InterpreterVirtual::ExitStatus bbtk::InterpreterVirtual::InterpretLine | ( | const std::string & | line | ) |
Runs the interpretation of a command.
Definition at line 674 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, CATCH_MACRO, DoInterpretLine(), Interpreter_OK, mInsideComment, and mStatus.
00675 { 00676 bbtkDebugMessage("interpreter",5,"==> InterpreterVirtual::InterpretLine('"<<line<<"')"<<std::endl); 00677 00678 try 00679 { 00680 mStatus = Interpreter_OK; 00681 mInsideComment = false; 00682 //std::cout<<"JCP bbtkInterpreter.cxx InterpreterVirtual::InterpretLine("<<std::endl; 00683 DoInterpretLine(line ); 00684 } 00685 CATCH_MACRO; 00686 00687 00688 bbtkDebugMessage("interpreter",5,"<== InterpreterVirtual::InterpretLine('"<<line<<"')"<<std::endl); 00689 00690 return mStatus; 00691 }
void bbtk::InterpreterVirtual::LoadScript | ( | std::string | fullPathScriptName, | |
std::string | includeScriptName | |||
) | [private] |
Opens the file fullPathScriptName includeScriptName is the name as given to the include command
Definition at line 1575 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, bbtkError, bbtkMessage, INVALID_FILE_SEPARATOR, mFile, mFileName, mFileNameHistory, mIncludeFileName, mLine, bbtk::Utilities::replace(), and VALID_FILE_SEPARATOR.
Referenced by SwitchToFile().
01577 { 01578 bbtkDebugMessage("interpreter",4,"==> InterpreterVirtual::LoadScript(" 01579 <<fullPathScriptName<<")" 01580 <<std::endl); 01581 01582 Utilities::replace( fullPathScriptName , 01583 INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); 01584 01585 if (find(mFileNameHistory.begin(), 01586 mFileNameHistory.end(), 01587 fullPathScriptName)!=mFileNameHistory.end()) 01588 { 01589 return; 01590 } 01591 01592 std::ifstream* s; 01593 s = new std::ifstream; 01594 s->open(fullPathScriptName.c_str()); 01595 if (!s->good()) 01596 { 01597 bbtkError("Could not open file ["<<fullPathScriptName<<"]"); 01598 return; 01599 } 01600 01601 bbtkMessage("interpreter",1," -->[" << fullPathScriptName 01602 << "] found" << std::endl); 01603 01604 mFile.push_back(s); 01605 mFileName.push_back(fullPathScriptName); 01606 mFileNameHistory.push_back(fullPathScriptName); 01607 mIncludeFileName.push_back(includeScriptName); 01608 mLine.push_back(0); 01609 01610 return; 01611 }
void bbtk::Object::LockThis | ( | ) | [inline, protected, inherited] |
static boost::shared_ptr<U> bbtk::Object::MakePointer | ( | U * | s, | |
const D & | del, | |||
bool | lock = false | |||
) | [inline, static, protected, inherited] |
Definition at line 115 of file bbtkObject.h.
References bbtk::Object::InsertInObjectList().
00118 { 00119 if (s->mThisPointer.lock()) 00120 { 00121 boost::shared_ptr<U> p = s->GetThisPointer<U>(); 00122 if (!lock) s->mThisPointerLocked.reset(); 00123 return p; 00124 } 00125 boost::shared_ptr<U> p = boost::shared_ptr<U>(s,del); 00126 static_cast<D*> 00127 (p._internal_get_deleter(typeid(D))) 00128 ->mPointer = p; 00129 s->mThisPointer = p; 00130 Object::InsertInObjectList(p); 00131 if (lock) s->LockThis(); 00132 return p; 00133 }
static boost::shared_ptr<U> bbtk::Object::MakePointer | ( | U * | s, | |
bool | lock = false | |||
) | [inline, static, protected, inherited] |
Definition at line 97 of file bbtkObject.h.
References bbtk::Object::InsertInObjectList().
Referenced by bbtk::ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(), bbtk::Executer::Executer(), bbtk::Interpreter::Init(), bbtk::Transcriptor::New(), bbtk::Package::New(), New(), bbtk::Interpreter::New(), bbtk::Factory::New(), bbtk::Executer::New(), and bbtk::ComplexBlackBoxDescriptor::New().
00098 { 00099 if (s->mThisPointer.lock()) 00100 { 00101 boost::shared_ptr<U> p = s->GetThisPointer<U>(); 00102 if (!lock) s->mThisPointerLocked.reset(); 00103 return p; 00104 } 00105 boost::shared_ptr<U> p = boost::shared_ptr<U>(s,Object::Deleter()); 00106 static_cast<Object::Deleter*> 00107 (p._internal_get_deleter(typeid(Object::Deleter))) 00108 ->mPointer = p; 00109 s->mThisPointer = p; 00110 Object::InsertInObjectList(p); 00111 if (lock) s->LockThis(); 00112 return p; 00113 }
InterpreterVirtual::Pointer bbtk::InterpreterVirtual::New | ( | ) | [static] |
Definition at line 55 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, InterpreterVirtual(), and bbtk::Object::MakePointer().
Referenced by bbtk::WxGUIPackageBrowser2::IncludeAll(), bbtk::Interpreter::Init(), main(), bbtk::WxGUIConsole::OnButtonRun(), bbtk::WxGUIConsole::OnMenuCreateBlackBox(), bbtk::WxGUIConsole::OnMenuCreatePackage(), bbtk::WxGUIConsole::WxGUIConsole(), and bbtk::WxGUIScriptingInterface::WxGUIScriptingInterface().
00056 { 00057 bbtkDebugMessage("kernel",9,"InterpreterVirtual::New()"<<std::endl); 00058 return MakePointer( new InterpreterVirtual() ); 00059 }
void bbtk::Object::PrintObjectInfo | ( | const Pointer & | o | ) | [static, inherited] |
Definition at line 180 of file bbtkObject.cxx.
Referenced by bbtk::Object::PrintObjectListInfo().
00181 { 00182 std::cout << "* [" << p << "] \t" 00183 << p.use_count()-1 << " r \t" 00184 << p->GetObjectRecursiveSize() << " (" 00185 << p->GetObjectSize() << ") b \t" 00186 << p->GetObjectName() 00187 << std::endl; 00188 std::cout << p->GetObjectInfo(); 00189 }
void bbtk::Object::PrintObjectListInfo | ( | const std::string & | name | ) | [static, inherited] |
Definition at line 105 of file bbtkObject.cxx.
References bbtk::i, bbtk::Object::mgObjectList, and bbtk::Object::PrintObjectInfo().
Referenced by bbtk::Interpreter::commandDebug().
00106 { 00107 00108 std::cout 00109 << "=============== Living bbtk::Object pointers ========="<<std::endl; 00110 00111 long n = 0; 00112 long u = 0; 00113 size_t m = 0; 00114 ObjectListType::iterator i; 00115 for (i = mgObjectList.begin(); 00116 i!=mgObjectList.end(); 00117 ++i) 00118 { 00119 if (i->use_count() == 0) 00120 { 00121 u++; 00122 } 00123 else 00124 { 00125 Object::Pointer p(i->lock()); 00126 if (p->GetObjectName().find(name) != std::string::npos ) 00127 { 00128 std::cout << n << "/" << mgObjectList.size() << " "; 00129 PrintObjectInfo(p); 00130 m += p->GetObjectSize(); 00131 n++; 00132 } 00133 } 00134 } 00135 std::cout 00136 << "------------------------------------------------------"<<std::endl; 00137 00138 std::cout << " Total : "<<n<<" objects - "<<m<<" b"<<std::endl; 00139 if (u==1) 00140 { 00141 std::cout<<"* Note : "<<u 00142 <<" object in list has 0 ref count, " 00143 <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl; 00144 } 00145 else if (u>1) 00146 { 00147 std::cout<<"* Note : "<<u 00148 <<" objects in list have 0 ref count, " 00149 <<"i.e. are no more accessible by bbtk but did not properly destroyed because another ref counting system is holding them !"<<std::endl; 00150 } 00151 std::cout 00152 << "============ EO Living bbtk::Object pointers ========="<<std::endl; 00153 00154 }
void bbtk::Object::ReleasePackages | ( | ) | [static, inherited] |
Definition at line 222 of file bbtkObject.cxx.
References bbtkDebugMessage, bbtk::i, bbtk::Object::mgPackageList, and bbtk::Package::Release().
Referenced by bbtk::StaticInitTime::~StaticInitTime().
00223 { 00224 bbtkDebugMessage("object",1,"##> Object::ReleasePackages()"<<std::endl); 00225 // Release package pointers 00226 ObjectListType::iterator i; 00227 for (i = mgPackageList.begin(); 00228 i!= mgPackageList.end(); 00229 ++i) 00230 { 00231 if (i->use_count() != 0) 00232 { 00233 bbtkDebugMessage("object",1,"##> Releasing package '"<< 00234 i->lock()->GetThisPointer<Package>()->GetName() 00235 <<"'"<<std::endl); 00236 // Object::Pointer p(i->lock()); 00237 Package::WeakPointer w(i->lock()->GetThisPointer<Package>()); 00238 Package::Release(w); 00239 /* 00240 if (p->GetObjectName().find(name) != std::string::npos ) 00241 { 00242 std::cout << n << "/" << mgObjectList.size() << " "; 00243 PrintObjectInfo(p); 00244 m += p->GetObjectSize(); 00245 n++; 00246 } 00247 */ 00248 } 00249 } 00250 00251 }
void bbtk::Object::RemoveFromObjectList | ( | WeakPointer | p | ) | [static, inherited] |
Definition at line 80 of file bbtkObject.cxx.
References bbtkDebugMessage, and bbtk::Object::mgObjectList.
Referenced by bbtk::Object::Deleter::operator()().
00081 { 00082 bbtkDebugMessage("object",9,"##> Object::RemoveFromObjectList()" 00083 <<std::endl); 00084 mgObjectList.erase(p); 00085 00086 }
void bbtk::InterpreterVirtual::SetCommandLine | ( | bool | v = true |
) | [inline] |
Sets the bool that indicates wether we are in command line context.
Definition at line 170 of file bbtkInterpreterVirtual.h.
00170 { mCommandLine = v; }
void bbtk::InterpreterVirtual::SetCurrentFileName | ( | const std::string & | fullPathScriptName | ) | [protected, virtual] |
Reimplemented in bbtk::Interpreter.
Definition at line 1548 of file bbtkInterpreterVirtual.cxx.
Referenced by SwitchToFile().
void bbtk::InterpreterVirtual::SetThrow | ( | bool | b | ) | [inline] |
void bbtk::InterpreterVirtual::SetUser | ( | InterpreterUser * | c | ) | [inline] |
Sets the user of the interpreter (if any).
Definition at line 176 of file bbtkInterpreterVirtual.h.
00176 { mUser = c; }
void bbtk::InterpreterVirtual::SplitLine | ( | const std::string & | line, | |
std::vector< std::string > & | words | |||
) | [protected] |
Splits a line into words.
Definition at line 1135 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, bbtk::i, and bbtk::Utilities::SplitString().
Referenced by DoInterpretLine().
01136 { 01137 bbtkDebugMessage("interpreter",9,"==> InterpreterVirtual::SplitLine(\""<<str<<"\")"<<std::endl); 01138 01139 std::string delimiters = "\""; 01140 std::vector<std::string> quote; 01141 Utilities::SplitString(str,delimiters,quote); 01142 01143 delimiters = " \t"; 01144 std::vector<std::string>::iterator i; 01145 for (i=quote.begin(); i!=quote.end(); ) 01146 { 01147 Utilities::SplitString(*i,delimiters,tokens); 01148 ++i; 01149 if (i!=quote.end()) 01150 { 01151 // bbtkDebugMessage("interpreter",0,"\""<<*i<<"\""<<std::endl); 01152 tokens.push_back(*i); 01153 ++i; 01154 } 01155 } 01156 01157 for (i=tokens.begin(); i!=tokens.end(); ++i) 01158 { 01159 bbtkDebugMessage("interpreter",9,"--["<<*i<<"]"<<std::endl); 01160 } 01161 bbtkDebugMessage("interpreter",9,"<== InterpreterVirtual::SplitLine(\""<<str<<"\")"<<std::endl); 01162 01163 }
void bbtk::InterpreterVirtual::SwitchToFile | ( | const std::string & | filename, | |
bool | source = false | |||
) | [protected] |
Switch to the interpretation of a file.
Definition at line 1254 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, bbtkError, bbtkMessage, bbtk::Utilities::ExpandLibName(), bbtk::Utilities::Explore(), bbtk::Utilities::ExtractScriptName(), bbtk::Utilities::FileExists(), bbtk::ConfigurationFile::Get_bbs_paths(), bbtk::ConfigurationFile::Get_file_separator(), bbtk::ConfigurationFile::GetInstance(), bbtk::i, bbtk::Utilities::IsDirectory(), LoadScript(), bbtk::Utilities::MakePkgnameFromPath(), SetCurrentFileName(), and SwitchToStream().
Referenced by bbtk::Interpreter::commandInclude(), and InterpretFile().
01255 { 01256 // Note : in the following : 01257 // name : the user supplied name 01258 // - abreviated name e.g. scr scr.bbs 01259 // - relative full name e.g. ./scr.bbs ../../scr.bbs 01260 // - absolute full name e.g. /home/usrname/proj/dir/scr.bbs 01261 // same for Windows, with c:, d: ... 01262 // 01263 // use ./directory/subdir/scrname.bbs 01264 // 01265 01266 bbtkDebugMessage("interpreter",4,"==> InterpreterVirtual::SwitchToFile( \"" 01267 <<name<<"\")"<<std::endl); 01268 01269 std::vector<std::string> script_paths; 01270 std::string fullPathScriptName; // full path script name 01271 std::string pkgname; // e.g. <scriptname>.bbs 01272 std::vector<std::string> Filenames; 01273 01274 // The following is *NOT* a debug time message : 01275 // It's a user intended message. 01276 // Please don't remove it. 01277 bbtkMessage("interpreter",1, 01278 "look for : [" << name 01279 << "]" << std::endl); 01280 01281 01282 std::string upath; 01283 pkgname = Utilities::ExtractScriptName(name,upath); 01284 01285 bbtkMessage("interpreter",3, 01286 "package name:[" << pkgname 01287 << "] path:[" << upath << "]" << std::endl); 01288 bool fullnameGiven = false; 01289 bool foundFile = false; 01290 01291 // ==== "*" provided : load all scripts in given path 01292 // relative (e.g. std/boxes/*) or absolute 01293 if (pkgname == "*") 01294 { 01295 01296 std::stringstream* stream = new std::stringstream; 01297 //if (upath.size()!=0) // avoid troubles for "*" 01298 01299 // ==== no path provided : look in root bbs path 01300 if (upath.size()==0) 01301 { 01302 // bbtkMessage("interpreter",1, 01303 // LG : add all bbs path 01304 // script_paths.push_back( ConfigurationFile::GetInstance().Get_root_bbs_path() ); 01305 std::vector<std::string>::const_iterator i; 01306 for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin(); 01307 i!=ConfigurationFile::GetInstance().Get_bbs_paths().end(); 01308 i++) 01309 { 01310 script_paths.push_back(*i); 01311 } 01312 } 01313 // ==== absolute path provided 01314 else if (upath[0]=='/' || upath[1] == ':' ) 01315 { 01316 if ( Utilities::IsDirectory( upath ) ) 01317 { 01318 script_paths.push_back(upath); 01319 } 01320 else 01321 { 01322 bbtkError("'"<<upath<<"' : directory does not exist"); 01323 } 01324 } 01325 // ==== relative path provided : search all bbs path appended with 01326 // the relative path provided 01327 else 01328 { 01329 std::vector<std::string>::const_iterator i; 01330 for (i=ConfigurationFile::GetInstance().Get_bbs_paths().begin(); 01331 i!=ConfigurationFile::GetInstance().Get_bbs_paths().end(); 01332 i++) 01333 { 01334 std::string full_path(*i); 01335 printf("EED InterpreterVirtual::SwitchToFile 1. >>%s\n", full_path.c_str() ); 01336 // we *really* want '.' to be the current working directory 01337 if (full_path == ".") 01338 { 01339 char buf[2048]; // for getcwd 01340 char * currentDir = getcwd(buf, 2048); 01341 std::string cwd(currentDir); 01342 full_path = currentDir; 01343 } // if full_path 01344 01345 full_path += ConfigurationFile::GetInstance().Get_file_separator(); 01346 full_path += upath; 01347 01348 if ( Utilities::IsDirectory( full_path ) ) 01349 { 01350 script_paths.push_back(full_path); 01351 } 01352 } 01353 if (script_paths.empty()) 01354 { 01355 bbtkError("no '"<<upath<<"' subdir found in search paths" 01356 << std::endl); 01357 } 01358 } 01359 01360 // === search paths list complete : now explore it 01361 int nbBssFiles = 0; 01362 // ==== relative name, iterate + load all .bbs/.bbp files 01363 std::vector<std::string>::iterator i; 01364 for (i=script_paths.begin();i!=script_paths.end();i++) 01365 { 01366 01367 printf("EED InterpreterVirtual::SwitchToFile jaja >> %s\n", (*i).c_str() ); 01368 01369 bbtkMessage("interpreter",1, 01370 "--> Looking in '" << *i << "'" << std::endl); 01371 01372 Filenames.clear(); 01373 //int nbFiles = 01374 Utilities::Explore(*i, false, Filenames); 01375 01376 for (std::vector<std::string>::iterator j = Filenames.begin(); 01377 j!= Filenames.end(); ++j) 01378 { 01379 01380 printf("EED InterpreterVirtual::SwitchToFile kkkkk >> %s\n", (*j).c_str() ); 01381 01382 int lgr = (*j).size(); 01383 if (lgr < 5) continue; 01384 // ignore non .bbp file 01385 if ( (*j).substr(lgr-4, 4) != ".bbp") continue; 01386 01387 (*stream) << "include \"" << *j << "\"\n"; 01388 bbtkMessage("interpreter",2," --> Found '" << *j << "'" << std::endl); 01389 01390 nbBssFiles++; 01391 } // for (std::vector... 01392 } // for (i=script_... 01393 01394 // === Result ... 01395 if (nbBssFiles==0) 01396 { 01397 bbtkMessage("interpreter",1, 01398 " --> No .bbp found"<< std::endl); 01399 } 01400 else 01401 { 01402 bbtkMessage("interpreter",1, 01403 " --> "<<nbBssFiles<<" .bbp found"<< std::endl); 01404 SwitchToStream(stream); 01405 } 01406 return; 01407 } 01408 //=============== end pkgname=="*" =========== 01409 01410 01411 // if name starts with a / or a . or contains : user is assumed to have passed a relative/absolute name 01412 // (not only a plain script name) 01413 // we trust him, and try to expland the directory name 01414 // WARNING : starting from current local directory : ./whatYouWant (./ mandatory!) 01415 01416 if (name[0]=='/' || name[1] == ':' || name[0]=='.') // absolute path (linux/windows) or relative path 01417 { 01418 01419 // ===========================================================check user supplied location 01420 fullnameGiven = true; 01421 01422 fullPathScriptName = Utilities::ExpandLibName(name, false); 01423 01424 // allow user to always forget ".bbs" 01425 int l = fullPathScriptName.size(); 01426 01427 if (l!=0) 01428 { 01429 if ((fullPathScriptName.substr(l-4, 4) != ".bbs")&& 01430 (fullPathScriptName.substr(l-4, 4) != ".bbp")) 01431 { 01432 std::string tfullPathScriptName = fullPathScriptName + ".bbs"; 01433 if ( Utilities::FileExists(tfullPathScriptName) ) 01434 { 01435 fullPathScriptName = tfullPathScriptName; 01436 foundFile = true; 01437 } 01438 else 01439 { 01440 tfullPathScriptName = fullPathScriptName + ".bbp"; 01441 if ( Utilities::FileExists(tfullPathScriptName) ) 01442 { 01443 fullPathScriptName = tfullPathScriptName; 01444 foundFile = true; 01445 } 01446 } 01447 } 01448 else 01449 { 01450 if ( Utilities::FileExists(fullPathScriptName) ) 01451 { 01452 foundFile = true; 01453 } 01454 } 01455 } // endif l != 0 01456 } 01457 else 01458 // =============================== iterate on the paths 01459 { 01460 script_paths = ConfigurationFile::GetInstance().Get_bbs_paths(); 01461 std::string path; 01462 std::vector<std::string>::iterator i; 01463 for (i=script_paths.begin();i!=script_paths.end();++i) 01464 { 01465 path = *i; 01466 // we *really* want '.' to be the current working directory 01467 if (path == ".") 01468 { 01469 char buf[2048]; // for getcwd 01470 char * currentDir = getcwd(buf, 2048); 01471 std::string cwd(currentDir); 01472 path = currentDir; 01473 } 01474 01475 std::string tfullPathScriptName = Utilities::MakePkgnameFromPath(path, name, false); 01476 01477 //Addition JCP tfullPathScriptName.size()>=4 01478 if(tfullPathScriptName.size()>=4){ 01479 if (tfullPathScriptName.substr(tfullPathScriptName.size()-4, 3)==".bb") 01480 { 01481 fullPathScriptName = tfullPathScriptName; 01482 if ( ! Utilities::FileExists(fullPathScriptName) ) 01483 { 01484 // The following is *NOT* a debug time message : 01485 // It's a user intended message. 01486 // Please don't remove it. 01487 bbtkMessage("interpreter",2, 01488 " [" <<fullPathScriptName <<"] : does not exist" 01489 <<std::endl); 01490 continue; // try next path 01491 } 01492 bbtkMessage("interpreter",2, 01493 " [" <<fullPathScriptName 01494 <<"] : found" <<std::endl); 01495 foundFile = true; 01496 break; // a script was found; we stop iterating 01497 } 01498 else 01499 { 01500 fullPathScriptName = tfullPathScriptName + ".bbs"; 01501 // Check if library exists 01502 if ( ! Utilities::FileExists(fullPathScriptName) ) 01503 { 01504 fullPathScriptName = tfullPathScriptName + ".bbp"; 01505 if ( ! Utilities::FileExists(fullPathScriptName) ) 01506 { 01507 // The following is *NOT* a debug time message : 01508 // It's a user intended message. 01509 // Please don't remove it. 01510 bbtkMessage("interpreter",2, 01511 " [" <<tfullPathScriptName <<".bbs/.bbp] : do not exist" 01512 <<std::endl); 01513 continue; // try next path 01514 } 01515 } 01516 bbtkMessage("interpreter",2, 01517 " [" <<fullPathScriptName 01518 <<"] : found" <<std::endl); 01519 foundFile = true; 01520 break; // a script was found; we stop iterating 01521 } 01522 } 01523 } //------------------ // end for ( package_paths.begin();i!=package_paths.end() ) 01524 } 01525 01526 if (!foundFile) 01527 { 01528 if (fullnameGiven) 01529 if(fullPathScriptName == "") 01530 bbtkError("Path ["<<upath<<"] doesn't exist"); 01531 else 01532 bbtkError("Script ["<<fullPathScriptName<<"] not found"); 01533 else 01534 bbtkError("No ["<<pkgname<<".bbs/.bbp] script found"); 01535 return; 01536 } else { 01537 //EED printf("EED D. SwitchToFile %s\n", fullPathScriptName.c_str() ); 01538 LoadScript(fullPathScriptName,name); 01539 //EED Borrame if (source) GetExecuter()->SetCurrentFileName(fullPathScriptName); 01540 if (source) SetCurrentFileName(fullPathScriptName); 01541 } 01542 01543 return; 01544 }
void bbtk::InterpreterVirtual::SwitchToStream | ( | std::stringstream * | stream | ) | [protected] |
Switch to the interpretation of a stringstream.
Definition at line 1554 of file bbtkInterpreterVirtual.cxx.
References bbtkDebugMessage, bufferNb, mFile, mFileName, mIncludeFileName, and mLine.
Referenced by bbtk::Interpreter::commandNewGUI(), InterpretBuffer(), and SwitchToFile().
01555 { 01556 bbtkDebugMessage("interpreter",4,"==> InterpreterVirtual::SwitchToStream()" 01557 <<std::endl); 01558 mFile.push_back(stream); 01559 std::ostringstream buffer_name; 01560 bufferNb++; 01561 buffer_name << "buffer_" ; 01562 01563 if (mFileName.size()>0 ) 01564 { 01565 buffer_name << mFileName.back() << "_" << mLine.back(); 01566 } 01567 mFileName.push_back(buffer_name.str()); 01568 mIncludeFileName.push_back(buffer_name.str()); 01569 mLine.push_back(0); 01570 }
void bbtk::Object::UnLockThis | ( | ) | [inline, protected, inherited] |
friend struct Object::Deleter [friend] |
int bbtk::InterpreterVirtual::bufferNb [private] |
Definition at line 390 of file bbtkInterpreterVirtual.h.
Referenced by Init(), and SwitchToStream().
The dictionnary of commands.
Definition at line 356 of file bbtkInterpreterVirtual.h.
Referenced by bbtk::Interpreter::commandHelp(), FindCommandsWithPrefix(), bbtk::Interpreter::HelpCommands(), Init(), and InterpretCommand().
bool bbtk::InterpreterVirtual::mCommandLine [protected] |
Are we in a command line context ?
Definition at line 344 of file bbtkInterpreterVirtual.h.
Referenced by bbtk::Interpreter::commandInclude(), CommandLineInterpreter(), Init(), InterpretBuffer(), and InterpretFile().
std::vector<std::istream*> bbtk::InterpreterVirtual::mFile [private] |
Vector of open files / buffers (can be stringstream).
Definition at line 374 of file bbtkInterpreterVirtual.h.
Referenced by CatchBbtkException(), CatchStdException(), CatchUnknownException(), CloseAllFiles(), CloseCurrentFile(), DoInterpretLine(), InterpretCurrentStreams(), LoadScript(), and SwitchToStream().
std::vector<std::string> bbtk::InterpreterVirtual::mFileName [protected] |
Vector of names of open files with full path (as open).
Definition at line 335 of file bbtkInterpreterVirtual.h.
Referenced by CatchBbtkException(), bbtk::Interpreter::CatchBbtkException(), CatchStdException(), bbtk::Interpreter::CatchStdException(), CatchUnknownException(), bbtk::Interpreter::CatchUnknownException(), CloseCurrentFile(), DoInterpretLine(), LoadScript(), and SwitchToStream().
std::vector<std::string> bbtk::InterpreterVirtual::mFileNameHistory [protected] |
Vector of names of files which have been open before (and may closed then which are no more in mFileName) with full path (as open)
Definition at line 350 of file bbtkInterpreterVirtual.h.
Referenced by bbtk::Interpreter::commandReset(), and LoadScript().
std::deque< char* > bbtk::InterpreterVirtual::mHistory [private] |
std::vector<std::string> bbtk::InterpreterVirtual::mIncludeFileName [private] |
Vector of names of open files as given to the include command.
Definition at line 378 of file bbtkInterpreterVirtual.h.
Referenced by CloseCurrentFile(), LoadScript(), and SwitchToStream().
bool bbtk::InterpreterVirtual::mInsideComment [private] |
Are we inside a commented-out zone ?
Definition at line 382 of file bbtkInterpreterVirtual.h.
Referenced by CommandLineInterpreter(), DoInterpretLine(), InterpretBuffer(), InterpretFile(), and InterpretLine().
std::vector<int> bbtk::InterpreterVirtual::mLine [protected] |
Stores the current line number in each open file.
Definition at line 339 of file bbtkInterpreterVirtual.h.
Referenced by CatchBbtkException(), bbtk::Interpreter::CatchBbtkException(), CatchStdException(), bbtk::Interpreter::CatchStdException(), CatchUnknownException(), bbtk::Interpreter::CatchUnknownException(), CloseCurrentFile(), DoInterpretLine(), InterpretCurrentStreams(), LoadScript(), and SwitchToStream().
ExitStatus bbtk::InterpreterVirtual::mStatus [private] |
The current interpreter status.
Definition at line 385 of file bbtkInterpreterVirtual.h.
Referenced by CatchBbtkException(), CatchInterpreterException(), CatchStdException(), CatchUnknownException(), InterpretBuffer(), InterpretCurrentStreams(), InterpretFile(), and InterpretLine().
bool bbtk::InterpreterVirtual::mThrow [protected] |
Definition at line 341 of file bbtkInterpreterVirtual.h.
Referenced by CatchBbtkException(), CatchInterpreterException(), CatchStdException(), CatchUnknownException(), bbtk::Interpreter::commandExec(), and Init().
bbtk::InterpreterUser* bbtk::InterpreterVirtual::mUser [protected] |
The user of the interpreter (0 if none).
Definition at line 353 of file bbtkInterpreterVirtual.h.
Referenced by bbtk::Interpreter::commandGraph(), bbtk::Interpreter::commandHelp(), and Init().