bbtk::Interpreter Class Reference

The bbtk language interpreter. More...

#include <bbtkInterpreter.h>

Inheritance diagram for bbtk::Interpreter:

Inheritance graph
[legend]
Collaboration diagram for bbtk::Interpreter:

Collaboration graph
[legend]

List of all members.

Public Types

typedef Interpreter Self
typedef boost::shared_ptr< SelfPointer
typedef boost::weak_ptr< SelfWeakPointer
typedef Object InterpreterVirtual
typedef VirtualExec::DialogModeType DialogModeType
enum  ExitStatus { Interpreter_OK, Interpreter_ERROR, Interpreter_QUIT, Interpreter_BREAK }
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
void SetInputs (const std::map< std::string, std::string > &m)
void SetNoExecMode (bool m)
void SetNoErrorMode (bool m)
void SetDialogMode (DialogModeType t)
VirtualExec::Pointer GetExecuter () const
 Gets the Executer.
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).
InterpreterUserGetUser ()
 Gets the InterpreterUser of this.
const InterpreterUserGetUser () const
 Gets the InterpreterUser of this (const).
long GetUseCount ()

Static Public Member Functions

static Pointer New (const std::string &cpp_file="")
static Pointer New (VirtualExec::Pointer)
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

virtual void commandReset ()
 Resets all.
virtual void commandHelp (const std::vector< std::string > &words)
 Displays help (entry point of any help).
void HelpCommands ()
 Displays help on all the commands.
virtual void commandHelp (const std::string &command)
 Displays help on a particular command.
virtual void commandGraph (const std::vector< std::string > &words)
virtual void commandConfig () const
 Displays the Configuration.
virtual void commandIndex (const std::string &filename, const std::string &type="Initials")
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)
 Interpreter (const std::string &cpp_file="")
 Constructor.
 Interpreter (VirtualExec::Pointer)
 ~Interpreter ()
virtual void CatchInterpreterException (const InterpreterException &e)
virtual void CatchBbtkException (const bbtk::Exception &e)
virtual void CatchStdException (const std::exception &e)
virtual void CatchUnknownException ()
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.
void FindCommandsWithPrefix (char *buf, int n, std::vector< std::string > &commands)
void Init ()
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::InterpreterUsermUser
 The user of the interpreter (0 if none).
CommandDictType mCommandDict
 The dictionnary of commands.

Private Member Functions

void Init (VirtualExec::Pointer, const std::string &cpp_file)

Private Attributes

bbtk::VirtualExec::Pointer mVirtualExecuter
 The command executer used.
bbtk::Executer::WeakPointer mRealExecuter

Friends

struct Object::Deleter


Detailed Description

The bbtk language interpreter.

Definition at line 139 of file bbtkInterpreter.h.


Member Typedef Documentation

typedef std::map<std::string,CommandInfoType> bbtk::InterpreterVirtual::CommandDictType [protected, inherited]

The type of dictionnary of commands.

Definition at line 244 of file bbtkInterpreterVirtual.h.

Definition at line 188 of file bbtkInterpreter.h.

Definition at line 141 of file bbtkInterpreter.h.

typedef boost::shared_ptr<Self> bbtk::Interpreter::Pointer

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 141 of file bbtkInterpreter.h.

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 141 of file bbtkInterpreter.h.

Definition at line 138 of file bbtkInterpreterVirtual.h.

typedef boost::weak_ptr<Self> bbtk::Interpreter::WeakPointer

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 141 of file bbtkInterpreter.h.


Member Enumeration Documentation

enum bbtk::InterpreterVirtual::CommandCodeType [protected, inherited]

The enumeration of command codes == Command name.

Enumerator:
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 

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;

Enumerator:
Interpreter_OK 
Interpreter_ERROR 
Interpreter_QUIT 
Interpreter_BREAK 

Definition at line 143 of file bbtkInterpreterVirtual.h.

00144       {
00145         Interpreter_OK,
00146         Interpreter_ERROR,
00147         Interpreter_QUIT,
00148         Interpreter_BREAK,
00149       }


Constructor & Destructor Documentation

bbtk::Interpreter::Interpreter ( const std::string &  cpp_file = ""  )  [protected]

Constructor.

Definition at line 73 of file bbtkInterpreter.cxx.

References bbtkDebugMessage, and bbtk::InterpreterVirtual::Init().

Referenced by New().

00074   {
00075     bbtkDebugMessage("object",2,"==> Interpreter("<<cpp_file<<")"<<std::endl);
00076     Init(VirtualExec::Pointer(), cpp_file);
00077     bbtkDebugMessage("object",2,"<== Interpreter("<<cpp_file<<")"<<std::endl);
00078   }

Here is the call graph for this function:

Here is the caller graph for this function:

bbtk::Interpreter::Interpreter ( VirtualExec::Pointer  e  )  [protected]

Definition at line 82 of file bbtkInterpreter.cxx.

References bbtkDebugMessage, and bbtk::InterpreterVirtual::Init().

00083   {
00084     bbtkDebugMessage("object",2,"==> Interpreter(VirtualExec)"<<std::endl);
00085     Init(e,"");
00086     bbtkDebugMessage("object",2,"<== Interpreter(VirtualExec)"<<std::endl);
00087   }

Here is the call graph for this function:

bbtk::Interpreter::~Interpreter (  )  [protected]

Definition at line 124 of file bbtkInterpreter.cxx.

References bbtkDebugMessage, and mVirtualExecuter.

00125   {
00126     bbtkDebugMessage("object",2,"==> ~Interpreter()" <<std::endl);
00127     mVirtualExecuter = VirtualExec::Pointer();
00128     bbtkDebugMessage("object",2,"<== ~Interpreter()" <<std::endl);
00129   }


Member Function Documentation

void bbtk::Interpreter::CatchBbtkException ( const bbtk::Exception e  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 178 of file bbtkInterpreter.cxx.

References bbtkWarning, bbtk::Exception::GetErrorMessage(), GetExecuter(), bbtk::InterpreterVirtual::mFileName, and bbtk::InterpreterVirtual::mLine.

00179   {
00180     if (GetExecuter()->GetNoErrorMode()) 
00181       {
00182         std::string file("?");
00183         int line = 0;
00184         if (mFileName.size()) {
00185           file = mFileName.back();
00186           line = mLine.back();
00187         }    
00188         bbtkWarning("ERROR '"<<e.GetErrorMessage()
00189                     <<"' ("<<file<<":"<<line<<") skipped");
00190         
00191         return;
00192       }
00193           
00194           bbtk::InterpreterVirtual::CatchBbtkException(  e );     
00195   }

Here is the call graph for this function:

void bbtk::Interpreter::CatchInterpreterException ( const InterpreterException e  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 162 of file bbtkInterpreter.cxx.

References bbtkWarning, bbtk::Exception::GetErrorMessage(), GetExecuter(), bbtk::InterpreterException::GetScriptFile(), and bbtk::InterpreterException::GetScriptLine().

00163   {
00164     if (GetExecuter()->GetNoErrorMode()) 
00165       {
00166         bbtkWarning("ERROR :"<<e.GetErrorMessage()
00167                     <<" ("<<e.GetScriptFile()<<":"<<e.GetScriptLine()
00168                     <<" skipped");
00169 
00170         return;
00171       }
00172           
00173           bbtk::InterpreterVirtual::CatchInterpreterException(  e );      
00174   }

Here is the call graph for this function:

void bbtk::Interpreter::CatchStdException ( const std::exception &  e  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 199 of file bbtkInterpreter.cxx.

References bbtkWarning, GetExecuter(), bbtk::InterpreterVirtual::mFileName, and bbtk::InterpreterVirtual::mLine.

00200   {  
00201         if (GetExecuter()->GetNoErrorMode()) 
00202         {
00203                 std::string file("?");
00204                 int line = 0;
00205                 if (mFileName.size()) 
00206                 {
00207                         file = mFileName.back();
00208                         line = mLine.back();
00209                 }    
00210                 bbtkWarning("ERROR '"<<e.what() <<"' ("<<file<<":"<<line<<") skipped");
00211                 return;
00212       }
00213           bbtk::InterpreterVirtual::CatchStdException(  e );      
00214   }

Here is the call graph for this function:

void bbtk::Interpreter::CatchUnknownException (  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 218 of file bbtkInterpreter.cxx.

References bbtkWarning, GetExecuter(), bbtk::InterpreterVirtual::mFileName, and bbtk::InterpreterVirtual::mLine.

00219   {
00220         if (GetExecuter()->GetNoErrorMode()) 
00221         {
00222                 std::string file("?");
00223                 int line = 0;
00224                 if (mFileName.size()) 
00225                 {
00226                         file = mFileName.back();
00227                         line = mLine.back();
00228                 }  
00229                 bbtkWarning("UNDEFINED ERROR " <<"("<<file<<":"<<line<<") skipped");
00230                 return;
00231         }
00232 
00233           bbtk::InterpreterVirtual::CatchUnknownException( );     
00234   }

Here is the call graph for this function:

void bbtk::InterpreterVirtual::CloseAllFiles (  )  [protected, inherited]

Closes all open files.

Definition at line 1646 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, bbtk::InterpreterVirtual::CloseCurrentFile(), and bbtk::InterpreterVirtual::mFile.

Referenced by bbtk::InterpreterVirtual::CatchBbtkException(), bbtk::InterpreterVirtual::CatchInterpreterException(), bbtk::InterpreterVirtual::CatchStdException(), bbtk::InterpreterVirtual::CatchUnknownException(), and 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   }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::InterpreterVirtual::CloseCurrentFile (  )  [protected, inherited]

Closes the currently open file.

Definition at line 1615 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, bbtk::InterpreterVirtual::mFile, bbtk::InterpreterVirtual::mFileName, bbtk::InterpreterVirtual::mIncludeFileName, and bbtk::InterpreterVirtual::mLine.

Referenced by bbtk::InterpreterVirtual::CloseAllFiles(), and bbtk::InterpreterVirtual::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   }

Here is the caller graph for this function:

void bbtk::Interpreter::commandAuthor ( const std::string &  author  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 463 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00464     {
00465                 mVirtualExecuter->Author(author);
00466     }

void bbtk::Interpreter::commandBreak (  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 510 of file bbtkInterpreter.cxx.

References bbtkError.

00511     {
00512             /*
00513                  std::cout << "BreakException(" 
00514                  <<in_script<<","
00515                  <<file<<","
00516                  <<line<<")"<<std::endl;
00517                  */
00518                 bbtkError("break");//,in_script,file,line);
00519             //      throw BreakException(in_script,file,line);
00520     }

void bbtk::Interpreter::commandCategory ( const std::string &  categorytype  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 468 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00469     {
00470                 mVirtualExecuter->Category(categorytype);
00471     }

void bbtk::Interpreter::commandClear (  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 479 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00480     {
00481                 mVirtualExecuter->Clear();
00482     }

void bbtk::Interpreter::commandConfig (  )  const [protected, virtual]

Displays the Configuration.

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 1534 of file bbtkInterpreter.cxx.

References bbtk::ConfigurationFile::GetHelp(), and bbtk::ConfigurationFile::GetInstance().

01535   {
01536     ConfigurationFile::GetInstance().GetHelp(1);
01537   }  

Here is the call graph for this function:

void bbtk::Interpreter::commandConnection ( const std::string &  nodeFrom,
const std::string &  outputLabel,
const std::string &  nodeTo,
const std::string &  inputLabel 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 387 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00388     {
00389                 mVirtualExecuter->Connect(nodeFrom,outputLabel,nodeTo,inputLabel);
00390     }

void bbtk::Interpreter::commandDebug ( const std::string &  arg  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 2122 of file bbtkInterpreter.cxx.

References mVirtualExecuter, bbtk::Object::PrintObjectListInfo(), and bbtk::StaticInitTime::PrintObjectListInfo.

02123   {
02124     if ((name.length()==2)&&(name[0]=='-'))
02125       {
02126         if (name[1]=='D')
02127           {
02128             bbtk::StaticInitTime::PrintObjectListInfo = true;
02129           }
02130         if (name[1]=='C')
02131           {
02132             //      int o = MessageManager::GetMessageLevel("debug");
02133             //      if (o<2) MessageManager::SetMessageLevel("debug",2);
02134             mVirtualExecuter->GetFactory()->Check();
02135             //      MessageManager::SetMessageLevel("debug",o);
02136           }
02137       }
02138     else 
02139       {
02140         Object:: PrintObjectListInfo(name);
02141       }
02142   }

Here is the call graph for this function:

void bbtk::Interpreter::commandDefine ( const std::string &  name,
const std::string &  pack,
const std::string &  scriptfilename 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 402 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00403     {
00404                 mVirtualExecuter->Define(name,pack,scriptfilename);
00405     }

void bbtk::Interpreter::commandDelete ( const std::string &  boxName  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 382 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00383     {
00384                 mVirtualExecuter->Destroy(boxName);
00385     }

void bbtk::Interpreter::commandDescription ( const std::string &  description  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 473 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00474     {
00475                 mVirtualExecuter->Description(description);
00476     }

void bbtk::Interpreter::commandEndDefine (  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 407 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00408     {
00409                 mVirtualExecuter->EndDefine();
00410     }

void bbtk::Interpreter::commandEndPackage (  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 397 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00398     {
00399                 mVirtualExecuter->EndPackage();
00400     }

void bbtk::Interpreter::commandExec ( const std::string &  word  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 423 of file bbtkInterpreter.cxx.

References bbtk::InterpreterVirtual::mThrow, and mVirtualExecuter.

00424     {
00425                 if (word=="freeze") 
00426                 {
00427                         mVirtualExecuter->SetNoExecMode(true);
00428                         mThrow = false;
00429                 }
00430                 else if (word=="freeze_no_error") 
00431                 {
00432                         mVirtualExecuter->SetNoExecMode(true);
00433                         mVirtualExecuter->SetNoErrorMode(true);
00434                         mThrow = false;
00435                 }
00436                 else if (word=="unfreeze") 
00437                 {
00438                         mVirtualExecuter->SetNoExecMode(false);
00439                         mVirtualExecuter->SetNoErrorMode(false);
00440                 }
00441                 else
00442                 {
00443                         mVirtualExecuter->Execute(word);
00444                 } // if
00445     }

void bbtk::Interpreter::commandGraph ( const std::vector< std::string > &  words  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 1885 of file bbtkInterpreter.cxx.

References bbtk::InterpreterUser::InterpreterUserHasOwnHtmlPageViewer(), bbtk::InterpreterUser::InterpreterUserViewHtmlPage(), bbtk::InterpreterVirtual::mUser, and mVirtualExecuter.

01886 {
01887   std::string page;
01888     bool system_display = true;
01889 
01890     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
01891       system_display = false; 
01892  
01893     if (words.size()==1) 
01894     {
01895       page = mVirtualExecuter->ShowGraph(".","0","0","","","",system_display);
01896     }
01897     else if (words.size()==2) 
01898     {
01899       page = mVirtualExecuter->ShowGraph(words[1],"0","0","","","",system_display);
01900     }
01901     else if (words.size()==3) 
01902     {
01903       page = mVirtualExecuter->ShowGraph(words[1],words[2],"0","","","",system_display);
01904     }
01905     else if (words.size()==4) 
01906     {
01907       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],"","","",system_display);
01908     } 
01909     else if (words.size()==5) 
01910     {
01911       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],"","",system_display);
01912     } 
01913     else if (words.size()==6) 
01914     {
01915       page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display);
01916     } 
01917     else if (words.size()==7) 
01918       {
01919         page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display);
01920       } 
01921     
01922     if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
01923       mUser->InterpreterUserViewHtmlPage(page);
01924 
01925   }

Here is the call graph for this function:

void bbtk::Interpreter::commandHelp ( const std::string &  command  )  [protected, virtual]

Displays help on a particular command.

Displays help on a particular commands.

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 1561 of file bbtkInterpreter.cxx.

References bbtkError, and bbtk::InterpreterVirtual::mCommandDict.

01562   {
01563     CommandDictType::iterator c;
01564     c = mCommandDict.find(s);
01565     if ( c == mCommandDict.end() ) {
01566       bbtkError(s<<" : Unknown command");
01567     }   
01568     //    std::cout << " " << s << " : "<<  std::endl;
01569     //    CommandParamDictType::iterator i;
01570     //    for ( i =  c->second.begin();
01571     //      i != c->second.end();
01572     //      ++i) {
01573     std::cout << " usage : " << c->second.syntax << std::endl;
01574     std::cout << "  " << c->second.help << std::endl;
01575 
01576   }

void bbtk::Interpreter::commandHelp ( const std::vector< std::string > &  words  )  [protected, virtual]

Displays help (entry point of any help).

Displays help on all the commands.

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 1434 of file bbtkInterpreter.cxx.

References bbtkError, bbtk::Utilities::FileExists(), bbtk::ConfigurationFile::Get_doc_path(), GetExecuter(), bbtk::ConfigurationFile::GetInstance(), HelpCommands(), bbtk::InterpreterUser::InterpreterUserViewHtmlPage(), and bbtk::InterpreterVirtual::mUser.

01435 {
01436     unsigned int nbarg = words.size()-1;
01437 
01438     if (nbarg==0) 
01439     {
01440        HelpCommands();
01441     }
01442     else if (nbarg==1) 
01443     {
01444       if (words[1]=="packages") 
01445       {
01446          GetExecuter()->GetFactory()->PrintHelpListPackages(true);
01447          return;
01448       }
01449       try 
01450       {
01451           commandHelp(words[1]);
01452       }
01453       catch (bbtk::Exception e) 
01454       {
01455          try 
01456          {
01457             GetExecuter()->GetFactory()->PrintHelpPackage(words[1]);
01458             if ( mUser != 0 )
01459               {
01460                 std::string url = 
01461                   ConfigurationFile::GetInstance().Get_doc_path();
01462                 url += "/bbdoc/" + words[1] + "/index.html";
01463                 if (Utilities::FileExists(url)) 
01464                   {
01465                     mUser->InterpreterUserViewHtmlPage(url);
01466                   }
01467               }
01468          }
01469          catch (bbtk::Exception f) 
01470          {
01471            try 
01472              {
01473                std::string package;
01474                GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1],
01475                                                                 package);
01476                if ( mUser != 0 )
01477                  {
01478                    std::string url = 
01479                      ConfigurationFile::GetInstance().Get_doc_path();
01480                    url += "/bbdoc/" + package + "/index.html";
01481                    if (Utilities::FileExists(url)) 
01482                      {
01483                        url += "#" + words[1];
01484                        mUser->InterpreterUserViewHtmlPage(url);
01485                      }
01486                  }
01487              }
01488            catch (bbtk::Exception g) 
01489              {
01490                try
01491                  {
01492                    GetExecuter()->PrintHelpBlackBox(words[1],"0","9999");
01493                  }
01494                catch (bbtk::Exception h){
01495                  bbtkError("\""<<words[1].c_str()
01496                            <<"\" is not a known command, package, black box type or black box name");
01497                }
01498              }
01499          }
01500       }
01501     }
01502     else if (nbarg==2) 
01503     {
01504       if (words[2]=="all")
01505       {
01506          if ( words[1]=="packages" )
01507          {
01508             GetExecuter()->GetFactory()->PrintHelpListPackages(true,true);
01509             return;
01510           }
01511          try 
01512          {
01513             GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true);
01514          }
01515          catch (bbtk::Exception f) 
01516          {
01517          }
01518      }
01519      else 
01520      {
01521         commandHelp(words[0]);
01522         bbtkError(words[0]<<" : syntax error");
01523      }
01524   }
01525   else 
01526   {
01527      bbtkError("Should not reach here !!!");
01528   }
01529 }

Here is the call graph for this function:

void bbtk::Interpreter::commandInclude ( const std::string &  word,
bool  ok 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 484 of file bbtkInterpreter.cxx.

References bbtk::InterpreterVirtual::InterpretFile(), bbtk::InterpreterVirtual::mCommandLine, and bbtk::InterpreterVirtual::SwitchToFile().

00485     {
00486                 // if 'source' was given (words.size()==3) then tell to set the 
00487                 // source file name of the current complex box with the full file name included
00488                 if (mCommandLine)
00489                 {
00490                         InterpretFile(word, ok ); 
00491                 }
00492                 else
00493                 {
00494                         SwitchToFile(word , ok );
00495                 }
00496     }

Here is the call graph for this function:

void bbtk::Interpreter::commandIndex ( const std::string &  filename,
const std::string &  type = "Initials" 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 1930 of file bbtkInterpreter.cxx.

References bbtk::Factory::Adaptors, bbtk::Factory::Categories, GetExecuter(), bbtk::Factory::Initials, and bbtk::Factory::Packages.

01932 {
01933   Factory::IndexEntryType t;
01934   if (type=="Initials") t = Factory::Initials;
01935   else if (type=="Categories") t = Factory::Categories;
01936   else if (type=="Packages") t = Factory::Packages;
01937   else if (type=="Adaptors") t = Factory::Adaptors;
01938   
01939   GetExecuter()->GetFactory()->CreateHtmlIndex(t,filename);
01940 }

Here is the call graph for this function:

void bbtk::Interpreter::commandInput ( const std::string &  name,
const std::string &  box,
const std::string &  input,
const std::string &  help 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 448 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00449     {
00450                 mVirtualExecuter->DefineInput(name,box,input,help);
00451     }

void bbtk::Interpreter::commandKind ( const std::string &  kind  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 412 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00413     {
00414                 mVirtualExecuter->Kind(kind);
00415     }

void bbtk::InterpreterVirtual::CommandLineInterpreter (  )  [inherited]

Launches a command line interpreter (with a prompt).

Definition at line 1951 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugDecTab, bbtkDebugMessageInc, bbtk::InterpreterVirtual::DoInterpretLine(), bbtk::InterpreterVirtual::GetLineFromPrompt(), bbtk::InterpreterVirtual::mCommandLine, bbtk::InterpreterVirtual::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   }

Here is the call graph for this function:

void bbtk::Interpreter::commandLoad ( const std::string &  packageName  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 499 of file bbtkInterpreter.cxx.

References GetExecuter().

00500     {
00501                 printf("EED Interpreter::commandLoad %s\n", packageName.c_str());
00502                 GetExecuter()->LoadPackage(packageName);
00503     }

Here is the call graph for this function:

void bbtk::Interpreter::commandMessage ( const std::string &  kind,
const std::string &  levelstr 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 533 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00534     {
00535                 int level=0;
00536                 sscanf(levelstr.c_str(),"%d",&level);
00537                 mVirtualExecuter->SetMessageLevel(kind,level);
00538 
00539     }

void bbtk::Interpreter::commandMessage (  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 528 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00529     {
00530                 mVirtualExecuter->HelpMessages();
00531     }

void bbtk::Interpreter::commandNew ( const std::string &  boxType,
const std::string &  boxName 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 377 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00378     {
00379                 mVirtualExecuter->Create(boxType,boxName);
00380     }

void bbtk::Interpreter::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 from bbtk::InterpreterVirtual.

Definition at line 1945 of file bbtkInterpreter.cxx.

References bbtkError, bbtk::BlackBoxInputOutputDescriptor::GetCreatorTypeInfo(), bbtk::BlackBoxInputOutputDescriptor::GetDataInfo(), bbtk::BlackBoxInputOutputDescriptor::GetTypeInfo(), bbtk::i, mRealExecuter, mVirtualExecuter, and bbtk::InterpreterVirtual::SwitchToStream().

01947 {
01948   if (mRealExecuter.expired())
01949     {
01950       bbtkError("command 'newgui' cannot be compiled yet");
01951     }
01952 
01953   std::string typeName = instanceName+"Type";
01954   std::stringstream* s = new std::stringstream;
01955   // create the complex box
01956   (*s) << "define "<<typeName<<std::endl;
01957   //  (*s) << "  description 'Automatically generated user interface for the box "
01958   //       << boxname << "'" <<std::endl;
01959   // create the Layout box
01960   (*s) << "  load wx"<<std::endl;
01961   (*s) << "  new LayoutLine layout"<<std::endl;
01962   // create the output 'Widget'
01963   (*s) << "  output Widget layout.Widget Widget"<<std::endl;
01964   // the box change output 
01965   (*s) << "  new MultipleInputs change"<<std::endl;
01966   (*s) << "  output BoxChange change.Out BoxChange"<<std::endl;
01967 
01968   // Browse the inputs of the box in order to find which ones are not 
01969   // connected and can be adapted from a widget adaptor
01970   // vector which stores the list of inputs of the box which must be connected
01971   std::vector<std::string> in;
01972  
01973   Factory::Pointer F = mVirtualExecuter->GetFactory();
01974   /*
01975   Package::Pointer user = F->GetPackage("user");
01976   */
01977   ComplexBlackBoxDescriptor::Pointer workspace = 
01978     mRealExecuter.lock()->GetCurrentDescriptor();
01979 
01980   if (workspace==0)
01981     {
01982       delete s;
01983       bbtkError("interpreter::CreateGUI : could not access the executer currently defined complex box");
01984     }
01985  
01986 
01987   /*
01988     (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
01989   */
01990 
01991   BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
01992   //  BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
01993   // int nb = 0;
01994   BlackBox::InputConnectorMapType::iterator i;
01995   for (i=box->bbGetInputConnectorMap().begin();
01996        i!=box->bbGetInputConnectorMap().end();
01997        ++i)
01998     {
01999       // If the input is connected : continue
02000       if (i->second->IsConnected()) continue;
02001       // Get the input descriptor 
02002       const BlackBoxInputDescriptor* d = box->bbGetDescriptor()->GetInputDescriptor(i->first);
02003       // If it is a "system" input : skip it
02004 #ifdef USE_WXWIDGETS
02005       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) ||
02006            ( d->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) )
02007         continue;
02008 #else
02009       if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) )
02010         continue;
02011 #endif
02012       bool widok = true;
02013       std::string widget,adaptor;
02014       // try to find a widget adaptor
02015       if (F->FindWidgetAdaptor(DataInfo(d->GetTypeInfo(),""),
02016                                d->GetDataInfo(),
02017                                adaptor))
02018         {
02019           // command to create the adaptor
02020           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
02021           // Sets the label of the widget adaptor to the name of the input
02022           (*s) << "  set "<<i->first<<".Label "<<i->first<<std::endl;
02023           // Sets the initial value of the widget to the value of the input
02024           (*s) << "  set "<<i->first<<".In \" "
02025                <<box->bbGetInputAsString(i->first)<<"\""
02026                << std::endl;
02027           // store the input name
02028           in.push_back(i->first);
02029           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
02030             //<i->first<<"'"<<std::endl;
02031           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
02032         }
02033       // try to find a two pieces adaptor
02034       else if (F->FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""),
02035                                      d->GetDataInfo(),
02036                                      widget,adaptor) )
02037         {
02038           // command to create the widget
02039           (*s) << "  new "<<widget<<" "<<i->first<<"Widget"<<std::endl;
02040           // command to create the adaptor
02041           (*s) << "  new "<<adaptor<<" "<<i->first<<std::endl;
02042           // connect the two
02043           (*s) << "  connect "<<i->first<<"Widget.Out "
02044                <<i->first<<".In"<<std::endl;
02045           // Sets the label of the widget adaptor to the name of the input
02046           (*s) << "  set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
02047           // Sets the initial value of the widget to the value of the input
02048           (*s) << "  set "<<i->first<<"Widget.In \" "
02049                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
02050           // store the input name
02051           in.push_back(i->first);
02052           (*s) << "  connect "<<i->first<<"Widget.Widget layout.Widget"<<in.size()<<std::endl;
02053             //<i->first<<"'"<<std::endl;
02054           (*s) << "  connect "<<i->first<<"Widget.BoxChange change.In"<<in.size()<<std::endl;
02055 
02056         }
02057       // try to find an adaptor from string 
02058       // If found then can create a text input which 
02059       // will be automatically adapted 
02060       else if (F->FindAdaptor(DataInfo(typeid(std::string),""),
02061                                d->GetDataInfo(),
02062                                adaptor))
02063         {
02064           // command to create the adaptor
02065           (*s) << "  new InputText "<<i->first<<std::endl;
02066           // Sets the label of the widget adaptor to the name of the input
02067           (*s) << "  set "<<i->first<<".Title "<<i->first<<std::endl;
02068           // Sets the initial value of the widget to the value of the input
02069           (*s) << "  set "<<i->first<<".In \" "
02070                <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
02071           // store the input name
02072           in.push_back(i->first);
02073           (*s) << "  connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
02074             //<i->first<<"'"<<std::endl;
02075           (*s) << "  connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
02076 
02077         }
02078       else 
02079         {
02080           widok = false;
02081         }
02082       if (widok)
02083         {
02084           // command to create the output
02085           (*s) << "  output "<<i->first<<" "
02086                <<i->first<<".Out "<<i->first<<std::endl;
02087             //         <<" Output of the widget which allows to set "
02088           
02089         }
02090     }   
02091   // Inputs for window properties
02092   (*s) << "  input WinTitle layout.WinTitle Title"<<std::endl;
02093   (*s) << "  input WinWidth layout.WinWidth Width"<<std::endl;
02094   (*s) << "  input WinHeight layout.WinHeight Height"<<std::endl;
02095   (*s) << "  input WinDialog layout.WinDialog Dialog"<<std::endl;
02096   (*s) << "  input WinHide layout.WinHide Hide"<<std::endl;
02097 
02098   
02099   
02100   // Execute the box executes the layout
02101   (*s) << "  exec layout" << std::endl;
02102   (*s) << "endefine" << std::endl;
02103   // (*s) << "help "<< typeName<< std::endl;
02104   // instanciate the box and connect it
02105   (*s) << "new "<<typeName<<" "<<instanceName<<std::endl;
02106   // connections
02107   std::vector<std::string>::iterator j;
02108   for (j=in.begin();j!=in.end();++j)
02109     {
02110       // connect
02111       (*s) << "connect "<<instanceName<<"."<<*j<<" "
02112            << boxname<<"."<<*j<<std::endl;
02113     }
02114   // That's all folks ! now execute the commands :
02115   SwitchToStream(s);
02116 }

Here is the call graph for this function:

void bbtk::Interpreter::commandOutput ( const std::string &  name,
const std::string &  box,
const std::string &  output,
const std::string &  help 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 453 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00454     {
00455                 mVirtualExecuter->DefineOutput(name,box,output,help);
00456     }

void bbtk::Interpreter::commandPackage ( const std::string &  packageName  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 392 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00393     {
00394                 mVirtualExecuter->BeginPackage(packageName);
00395     }

void bbtk::Interpreter::commandPrint ( const std::string &  value  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 417 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00418     {
00419                 mVirtualExecuter->Print(value);
00420     }

void bbtk::Interpreter::commandQuit (  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 522 of file bbtkInterpreter.cxx.

References bbtkError.

00523     {
00524                 bbtkError("quit");//,in_script,file,line);
00525                 //throw QuitException(in_script,file,line);
00526     }

void bbtk::Interpreter::commandReset (  )  [protected, virtual]

Resets all.

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 906 of file bbtkInterpreter.cxx.

References bbtk::InterpreterVirtual::CloseAllFiles(), bbtk::InterpreterVirtual::mFileNameHistory, and mVirtualExecuter.

00907   {
00908     // Cannot close all files if the reset command is read from a file !
00909     CloseAllFiles();
00910     mFileNameHistory.clear();
00911     this->mVirtualExecuter->Reset();
00912   }

Here is the call graph for this function:

void bbtk::Interpreter::commandSet ( const std::string &  box,
const std::string &  input,
const std::string &  value 
) [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 458 of file bbtkInterpreter.cxx.

References mVirtualExecuter.

00459     {
00460                 mVirtualExecuter->Set(box,input,value);
00461     }

void bbtk::Interpreter::commandUnload ( const std::string &  packageName  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 505 of file bbtkInterpreter.cxx.

References GetExecuter().

00506     {
00507                 GetExecuter()->UnLoadPackage(packageName);
00508     }

Here is the call graph for this function:

void bbtk::InterpreterVirtual::DoInterpretLine ( const std::string &  line  )  [protected, inherited]

Interprets a line.

Definition at line 799 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugDecTab, bbtkDebugMessage, bbtkInternalError, bbtkMessage, bbtk::InterpreterVirtual::cAuthor, bbtk::InterpreterVirtual::cBreak, bbtk::InterpreterVirtual::cCategory, bbtk::InterpreterVirtual::cClear, bbtk::InterpreterVirtual::cConfig, bbtk::InterpreterVirtual::cConnect, bbtk::InterpreterVirtual::cDebug, bbtk::InterpreterVirtual::cDefine, bbtk::InterpreterVirtual::cDelete, bbtk::InterpreterVirtual::cDescription, bbtk::InterpreterVirtual::cEndDefine, bbtk::InterpreterVirtual::cEndPackage, bbtk::InterpreterVirtual::cExec, bbtk::InterpreterVirtual::cGraph, bbtk::InterpreterVirtual::cHelp, bbtk::InterpreterVirtual::cInclude, bbtk::InterpreterVirtual::cIndex, bbtk::InterpreterVirtual::cInput, bbtk::InterpreterVirtual::cKind, bbtk::InterpreterVirtual::cLoad, bbtk::InterpreterVirtual::cMessage, bbtk::InterpreterVirtual::cNew, bbtk::InterpreterVirtual::cNewGUI, bbtk::InterpreterVirtual::CommandInfoType::code, bbtk::InterpreterVirtual::commandAuthor(), bbtk::InterpreterVirtual::commandBreak(), bbtk::InterpreterVirtual::commandCategory(), bbtk::InterpreterVirtual::commandClear(), bbtk::InterpreterVirtual::commandConfig(), bbtk::InterpreterVirtual::commandConnection(), bbtk::InterpreterVirtual::commandDebug(), bbtk::InterpreterVirtual::commandDefine(), bbtk::InterpreterVirtual::commandDelete(), bbtk::InterpreterVirtual::commandDescription(), bbtk::InterpreterVirtual::commandEndDefine(), bbtk::InterpreterVirtual::commandEndPackage(), bbtk::InterpreterVirtual::commandExec(), bbtk::InterpreterVirtual::commandGraph(), bbtk::InterpreterVirtual::commandHelp(), bbtk::InterpreterVirtual::commandInclude(), bbtk::InterpreterVirtual::commandIndex(), bbtk::InterpreterVirtual::commandInput(), bbtk::InterpreterVirtual::commandKind(), bbtk::InterpreterVirtual::commandLoad(), bbtk::InterpreterVirtual::commandMessage(), bbtk::InterpreterVirtual::commandNew(), bbtk::InterpreterVirtual::commandNewGUI(), bbtk::InterpreterVirtual::commandOutput(), bbtk::InterpreterVirtual::commandPackage(), bbtk::InterpreterVirtual::commandPrint(), bbtk::InterpreterVirtual::commandQuit(), bbtk::InterpreterVirtual::commandReset(), bbtk::InterpreterVirtual::commandSet(), bbtk::InterpreterVirtual::commandUnload(), bbtk::InterpreterVirtual::cOutput, bbtk::InterpreterVirtual::cPackage, bbtk::InterpreterVirtual::cPrint, bbtk::InterpreterVirtual::cQuit, bbtk::InterpreterVirtual::cReset, bbtk::InterpreterVirtual::cSet, bbtk::InterpreterVirtual::cUnload, bbtk::InterpreterVirtual::InterpretCommand(), bbtk::InterpreterVirtual::CommandInfoType::keyword, bbtk::InterpreterVirtual::mFile, bbtk::InterpreterVirtual::mFileName, bbtk::InterpreterVirtual::mInsideComment, bbtk::InterpreterVirtual::mLine, bbtk::Utilities::SplitAroundFirstDot(), and bbtk::InterpreterVirtual::SplitLine().

Referenced by bbtk::InterpreterVirtual::CommandLineInterpreter(), bbtk::InterpreterVirtual::InterpretCurrentStreams(), and bbtk::InterpreterVirtual::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   }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::InterpreterVirtual::FindCommandsWithPrefix ( char *  buf,
int  n,
std::vector< std::string > &  commands 
) [protected, inherited]

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 bbtk::InterpreterVirtual::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   }

VirtualExec::Pointer bbtk::Interpreter::GetExecuter (  )  const [inline]

Gets the Executer.

Definition at line 210 of file bbtkInterpreter.h.

Referenced by CatchBbtkException(), CatchInterpreterException(), CatchStdException(), CatchUnknownException(), commandHelp(), commandIndex(), commandLoad(), commandUnload(), and SetCurrentFileName().

00210 { return mVirtualExecuter; }

Here is the caller graph for this function:

void bbtk::InterpreterVirtual::GetLineFromPrompt ( std::string &  line  )  [protected, inherited]

Reads a line from prompt.

Definition at line 1918 of file bbtkInterpreterVirtual.cxx.

Referenced by bbtk::InterpreterVirtual::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   }

Here is the caller graph for this function:

std::string bbtk::Interpreter::GetObjectInfo (  )  const [virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 2163 of file bbtkInterpreter.cxx.

References bbtk::i.

02164   {
02165     std::stringstream i;
02166     return i.str();
02167   }

size_t bbtk::Interpreter::GetObjectInternalSize (  )  const [virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 2179 of file bbtkInterpreter.cxx.

Referenced by GetObjectRecursiveSize(), and GetObjectSize().

02180 {
02181   size_t s = sizeof(Interpreter);
02182   return s;
02183   }

Here is the caller graph for this function:

std::string bbtk::Interpreter::GetObjectName (  )  const [virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 2156 of file bbtkInterpreter.cxx.

02157   {
02158     return std::string("Interpreter");
02159   }

size_t bbtk::Interpreter::GetObjectRecursiveSize (  )  const [virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 2186 of file bbtkInterpreter.cxx.

References GetObjectInternalSize(), bbtk::Object::GetObjectRecursiveSize(), and mVirtualExecuter.

02187   {
02188     size_t s = Superclass::GetObjectRecursiveSize();
02189     s += Interpreter::GetObjectInternalSize();
02190     s += mVirtualExecuter->GetObjectRecursiveSize();
02191     return s;
02192   }

Here is the call graph for this function:

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(); }

Here is the caller graph for this function:

size_t bbtk::Interpreter::GetObjectSize (  )  const [virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 2171 of file bbtkInterpreter.cxx.

References GetObjectInternalSize(), and bbtk::Object::GetObjectSize().

02172 {
02173   size_t s = Superclass::GetObjectSize();
02174   s += Interpreter::GetObjectInternalSize();
02175   return s;
02176   }

Here is the call graph for this function:

template<class U >
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]

Definition at line 63 of file bbtkObject.h.

00063 { return mThisPointer.use_count(); }

const InterpreterUser* bbtk::InterpreterVirtual::GetUser (  )  const [inline, inherited]

Gets the InterpreterUser of this (const).

Definition at line 180 of file bbtkInterpreterVirtual.h.

00180 { return mUser; }

InterpreterUser* bbtk::InterpreterVirtual::GetUser (  )  [inline, inherited]

Gets the InterpreterUser of this.

Definition at line 178 of file bbtkInterpreterVirtual.h.

00178 { return mUser; }

void bbtk::Interpreter::HelpCommands (  )  [protected]

Displays help on all the commands.

Definition at line 1542 of file bbtkInterpreter.cxx.

References bbtk::i, and bbtk::InterpreterVirtual::mCommandDict.

Referenced by commandHelp().

01543   {
01544     std::cout << "Available commands :" << std::endl;
01545     CommandDictType::iterator i;
01546     for ( i =  mCommandDict.begin();
01547           i != mCommandDict.end();
01548         ++i) {
01549               std::cout << " " << i->first << std::endl;
01550       //      std::cout << "   usage : " << i->second.syntax << std::endl;
01551       //     std::cout << "    " << i->second.help << std::endl;
01552 
01553     }
01554   }

Here is the caller graph for this function:

void bbtk::InterpreterVirtual::Init (  )  [protected, inherited]

Definition at line 71 of file bbtkInterpreterVirtual.cxx.

References bbtk::InterpreterVirtual::CommandInfoType::argmax, bbtk::InterpreterVirtual::CommandInfoType::argmin, bbtkDebugMessageInc, bbtk::InterpreterVirtual::bufferNb, bbtk::InterpreterVirtual::cAuthor, bbtk::InterpreterVirtual::cBreak, bbtk::InterpreterVirtual::cCategory, bbtk::InterpreterVirtual::cClear, bbtk::InterpreterVirtual::cConfig, bbtk::InterpreterVirtual::cConnect, bbtk::InterpreterVirtual::cDebug, bbtk::InterpreterVirtual::cDefine, bbtk::InterpreterVirtual::cDelete, bbtk::InterpreterVirtual::cDescription, bbtk::InterpreterVirtual::cEndDefine, bbtk::InterpreterVirtual::cEndPackage, bbtk::InterpreterVirtual::cExec, bbtk::InterpreterVirtual::cGraph, bbtk::InterpreterVirtual::cHelp, bbtk::InterpreterVirtual::cInclude, bbtk::InterpreterVirtual::cIndex, bbtk::InterpreterVirtual::cInput, bbtk::InterpreterVirtual::cKind, bbtk::InterpreterVirtual::cLoad, bbtk::InterpreterVirtual::cMessage, bbtk::InterpreterVirtual::cNew, bbtk::InterpreterVirtual::cNewGUI, bbtk::InterpreterVirtual::CommandInfoType::code, bbtk::InterpreterVirtual::cOutput, bbtk::InterpreterVirtual::cPackage, bbtk::InterpreterVirtual::cPrint, bbtk::InterpreterVirtual::cQuit, bbtk::InterpreterVirtual::cReset, bbtk::InterpreterVirtual::cSet, bbtk::InterpreterVirtual::cUnload, bbtk::InterpreterVirtual::CommandInfoType::help, bbtk::InterpreterVirtual::CommandInfoType::keyword, bbtk::InterpreterVirtual::mCommandDict, bbtk::InterpreterVirtual::mCommandLine, bbtk::InterpreterVirtual::mThrow, bbtk::InterpreterVirtual::mUser, bbtk::MessageManager::RegisterMessageType(), and bbtk::InterpreterVirtual::CommandInfoType::syntax.

Referenced by Init(), Interpreter(), and bbtk::InterpreterVirtual::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   } 

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::Interpreter::Init ( VirtualExec::Pointer  e,
const std::string &  cpp_file 
) [private]

Definition at line 91 of file bbtkInterpreter.cxx.

References bbtk::InterpreterVirtual::Init(), bbtk::Object::MakePointer(), mRealExecuter, mVirtualExecuter, and bbtk::InterpreterVirtual::New().

00092   {
00093     if (e)
00094       {
00095         mVirtualExecuter = e;
00096       }
00097     else if (cpp_file.size()!=0)
00098       {
00099         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
00100       }
00101     else 
00102       {
00103         bbtk::Executer::Pointer exe = bbtk::Executer::New();
00104         mRealExecuter = exe;
00105         mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(exe);
00106       }
00107 
00108           
00109           
00110     // Lock this pointer or will auto-destruct !!
00111     if (!e) mVirtualExecuter->SetInterpreter(MakePointer(this,true));
00112 
00113           
00114           bbtk::InterpreterVirtual::Init();
00115   } 

Here is the call graph for this function:

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   }

Here is the caller graph for this function:

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  )  [inherited]

Runs the interpretation of a buffer and deletes it !

Definition at line 609 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, CATCH_MACRO, bbtk::InterpreterVirtual::InterpretCurrentStreams(), bbtk::InterpreterVirtual::Interpreter_OK, bbtk::InterpreterVirtual::mCommandLine, bbtk::InterpreterVirtual::mInsideComment, bbtk::InterpreterVirtual::mStatus, and bbtk::InterpreterVirtual::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   }

Here is the call graph for this function:

void bbtk::InterpreterVirtual::InterpretCommand ( const std::vector< std::string > &  words,
CommandInfoType info 
) [protected, inherited]

Executes the right action depending on the command name.

Definition at line 1663 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, bbtkError, bbtk::InterpreterVirtual::commandHelp(), and bbtk::InterpreterVirtual::mCommandDict.

Referenced by bbtk::InterpreterVirtual::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   }

Here is the call graph for this function:

Here is the caller graph for this function:

InterpreterVirtual::ExitStatus bbtk::InterpreterVirtual::InterpretCurrentStreams (  )  [inherited]

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, bbtk::InterpreterVirtual::CloseCurrentFile(), bbtk::InterpreterVirtual::DoInterpretLine(), bbtk::InterpreterVirtual::mFile, bbtk::InterpreterVirtual::mLine, and bbtk::InterpreterVirtual::mStatus.

Referenced by bbtk::InterpreterVirtual::InterpretBuffer(), and bbtk::InterpreterVirtual::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   }

Here is the call graph for this function:

Here is the caller graph for this function:

InterpreterVirtual::ExitStatus bbtk::InterpreterVirtual::InterpretFile ( const std::string &  filename,
bool  source = false 
) [inherited]

Runs the interpretation of a file.

Definition at line 579 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, CATCH_MACRO, bbtk::InterpreterVirtual::InterpretCurrentStreams(), bbtk::InterpreterVirtual::Interpreter_OK, bbtk::InterpreterVirtual::mCommandLine, bbtk::InterpreterVirtual::mInsideComment, bbtk::InterpreterVirtual::mStatus, and bbtk::InterpreterVirtual::SwitchToFile().

Referenced by 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   }

Here is the call graph for this function:

Here is the caller graph for this function:

InterpreterVirtual::ExitStatus bbtk::InterpreterVirtual::InterpretLine ( const std::string &  line  )  [inherited]

Runs the interpretation of a command.

Definition at line 674 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, CATCH_MACRO, bbtk::InterpreterVirtual::DoInterpretLine(), bbtk::InterpreterVirtual::Interpreter_OK, bbtk::InterpreterVirtual::mInsideComment, and bbtk::InterpreterVirtual::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   }

Here is the call graph for this function:

void bbtk::Object::LockThis (  )  [inline, protected, inherited]

Definition at line 88 of file bbtkObject.h.

00088 { mThisPointerLocked = mThisPointer.lock(); }   

template<class U , class D >
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     }                                                                   

Here is the call graph for this function:

template<class U >
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(), Init(), bbtk::Transcriptor::New(), bbtk::Package::New(), bbtk::InterpreterVirtual::New(), 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     }                                                                   

Here is the call graph for this function:

Here is the caller graph for this function:

InterpreterVirtual::Pointer bbtk::InterpreterVirtual::New (  )  [static, inherited]

Interpreter::Pointer bbtk::Interpreter::New ( VirtualExec::Pointer  e  )  [static]

Definition at line 65 of file bbtkInterpreter.cxx.

References bbtkDebugMessage, Interpreter(), and bbtk::Object::MakePointer().

00066   {
00067     bbtkDebugMessage("kernel",9,"Interpreter::New(VirtualExec)"<<std::endl);
00068     return MakePointer(new Interpreter(e));
00069   }

Here is the call graph for this function:

Interpreter::Pointer bbtk::Interpreter::New ( const std::string &  cpp_file = ""  )  [static]

Definition at line 57 of file bbtkInterpreter.cxx.

References bbtkDebugMessage, Interpreter(), and bbtk::Object::MakePointer().

00058   {
00059     bbtkDebugMessage("kernel",9,"Interpreter::New('"<<cpp_file<<"')"<<std::endl);
00060     return MakePointer(new Interpreter(cpp_file));
00061   }

Here is the call graph for this function:

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   }

Here is the caller graph for this function:

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 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   }

Here is the call graph for this function:

Here is the caller graph for this function:

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   }

Here is the call graph for this function:

Here is the caller graph for this function:

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   }

Here is the caller graph for this function:

void bbtk::InterpreterVirtual::SetCommandLine ( bool  v = true  )  [inline, inherited]

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::Interpreter::SetCurrentFileName ( const std::string &  fullPathScriptName  )  [protected, virtual]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 1284 of file bbtkInterpreter.cxx.

References GetExecuter().

01285         {
01286                 GetExecuter()->SetCurrentFileName(fullPathScriptName);
01287         }       

Here is the call graph for this function:

void bbtk::Interpreter::SetDialogMode ( DialogModeType  t  )  [inline]

Definition at line 190 of file bbtkInterpreter.h.

00190 { mVirtualExecuter->SetDialogMode(t);}

void bbtk::Interpreter::SetInputs ( const std::map< std::string, std::string > &  m  )  [inline]

Sets the inputs of the workspace : the map is passed as is to the Executer

Definition at line 176 of file bbtkInterpreter.h.

00177     { mVirtualExecuter->SetInputs(m); }

void bbtk::Interpreter::SetNoErrorMode ( bool  m  )  [inline]

Puts the executer in "no error" mode, Errors do not stop execution (but warnings are produced)

Definition at line 185 of file bbtkInterpreter.h.

00185 { mVirtualExecuter->SetNoErrorMode(m);}

void bbtk::Interpreter::SetNoExecMode ( bool  m  )  [inline]

Puts the executer in "no exec" mode, which creates but does not execute pipelines.

Definition at line 181 of file bbtkInterpreter.h.

00181 { mVirtualExecuter->SetNoExecMode(m); }

void bbtk::InterpreterVirtual::SetThrow ( bool  b  )  [inline, inherited]

Definition at line 172 of file bbtkInterpreterVirtual.h.

00172 { mThrow = b; }

void bbtk::InterpreterVirtual::SetUser ( InterpreterUser c  )  [inline, inherited]

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, inherited]

Splits a line into words.

Definition at line 1135 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, bbtk::i, and bbtk::Utilities::SplitString().

Referenced by bbtk::InterpreterVirtual::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  }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::InterpreterVirtual::SwitchToFile ( const std::string &  filename,
bool  source = false 
) [protected, inherited]

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(), bbtk::InterpreterVirtual::LoadScript(), bbtk::Utilities::MakePkgnameFromPath(), bbtk::InterpreterVirtual::SetCurrentFileName(), and bbtk::InterpreterVirtual::SwitchToStream().

Referenced by commandInclude(), and bbtk::InterpreterVirtual::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   }

Here is the call graph for this function:

Here is the caller graph for this function:

void bbtk::InterpreterVirtual::SwitchToStream ( std::stringstream *  stream  )  [protected, inherited]

Switch to the interpretation of a stringstream.

Definition at line 1554 of file bbtkInterpreterVirtual.cxx.

References bbtkDebugMessage, bbtk::InterpreterVirtual::bufferNb, bbtk::InterpreterVirtual::mFile, bbtk::InterpreterVirtual::mFileName, bbtk::InterpreterVirtual::mIncludeFileName, and bbtk::InterpreterVirtual::mLine.

Referenced by commandNewGUI(), bbtk::InterpreterVirtual::InterpretBuffer(), and bbtk::InterpreterVirtual::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 }

Here is the caller graph for this function:

void bbtk::Object::UnLockThis (  )  [inline, protected, inherited]

Definition at line 89 of file bbtkObject.h.

00089 { mThisPointerLocked = Pointer(); }


Friends And Related Function Documentation

friend struct Object::Deleter [friend]

Reimplemented from bbtk::InterpreterVirtual.

Definition at line 141 of file bbtkInterpreter.h.


Member Data Documentation

bool bbtk::InterpreterVirtual::mCommandLine [protected, inherited]

std::vector<std::string> bbtk::InterpreterVirtual::mFileName [protected, inherited]

std::vector<std::string> bbtk::InterpreterVirtual::mFileNameHistory [protected, inherited]

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 commandReset(), and bbtk::InterpreterVirtual::LoadScript().

std::vector<int> bbtk::InterpreterVirtual::mLine [protected, inherited]

Definition at line 388 of file bbtkInterpreter.h.

Referenced by commandNewGUI(), and Init().

bool bbtk::InterpreterVirtual::mThrow [protected, inherited]

The user of the interpreter (0 if none).

Definition at line 353 of file bbtkInterpreterVirtual.h.

Referenced by commandGraph(), commandHelp(), and bbtk::InterpreterVirtual::Init().


The documentation for this class was generated from the following files:

Generated on Thu May 31 14:14:44 2012 for BBTK by  doxygen 1.5.7.1