Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/25 07:33:17 $
- Version: $Revision: 1.64 $
+ Date: $Date: 2008/07/23 11:46:11 $
+ Version: $Revision: 1.69 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//=======================================================================
Interpreter::Pointer Interpreter::New(const std::string& cpp_file)
{
- bbtkDebugMessage("Kernel",9,"Interpreter::New()"<<std::endl);
+ bbtkDebugMessage("Kernel",9,"Interpreter::New('"<<cpp_file<<"')"<<std::endl);
return MakePointer(new Interpreter(cpp_file));
}
//=======================================================================
+ //=======================================================================
+ Interpreter::Pointer Interpreter::New(VirtualExec::Pointer e)
+ {
+ bbtkDebugMessage("Kernel",9,"Interpreter::New(VirtualExec)"<<std::endl);
+ return MakePointer(new Interpreter(e));
+ }
+ //=======================================================================
+
//=======================================================================
Interpreter::Interpreter(const std::string& cpp_file)
- :
- mUser(0),
- mCommandLine(false),
- mThrow(false)
{
+ Init(VirtualExec::Pointer(), cpp_file);
+ }
+ //=======================================================================
+ //=======================================================================
+ Interpreter::Interpreter(VirtualExec::Pointer e)
+ {
+ Init(e,"");
+ }
+ //=======================================================================
+
+ //=======================================================================
+ void Interpreter::Init(VirtualExec::Pointer e, const std::string& cpp_file)
+ {
+ mUser = 0;
+ mCommandLine = false;
+ mThrow = false;
bufferNb =0;
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);
bbtk::MessageManager::RegisterMessageType("Interpreter","Messages of the interpreter",0);
bbtkDebugMessageInc("Interpreter",9,"Interpreter::Interpreter()" <<std::endl);
-
- if (cpp_file.size()!=0)
+ if (e)
+ {
+ mVirtualExecuter = e;
+ }
+ else if (cpp_file.size()!=0)
{
mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
}
}
// Lock this pointer or will auto-destruct !!
- mVirtualExecuter->SetInterpreter(MakePointer(this,true));
+ if (!e) mVirtualExecuter->SetInterpreter(MakePointer(this,true));
// For the time being, comment out previous line, and
// uncomment next line to check Transcriptor
info.argmax = 0;
info.code = cReset;
info.syntax = "reset";
- info.help = "Deletes all boxes and unloads all packages (bbi is reset to its start state)";
+ info.help = "Deletes all boxes and unloads all packages (reset to start state)";
mCommandDict[info.keyword] = info;
info.keyword = "author";
info.argmax = 2;
info.code = cMessage;
info.syntax = "message <kind> <level>";
- 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."; mCommandDict[info.keyword] = info;
+ 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.";
+ mCommandDict[info.keyword] = info;
info.keyword = "include";
info.argmin = 1;
info.argmax = 2;
info.code = cInclude;
info.syntax = "include <filename> [source]";
- info.help = "Includes the file <filename>.\n 'source' : If the keyword 'source' is provided then informs bbi 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).";
+ 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).";
mCommandDict[info.keyword] = info;
info.keyword = "quit";
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')";
mCommandDict[info.keyword] = info;
- info.keyword = "object";
+ info.keyword = "debug";
info.argmin = 0;
info.argmax = 1;
- info.code = cObject;
- info.syntax = "object <object name>";
- info.help = "Provides debug info on object <object name>";
+ info.code = cDebug;
+ info.syntax = "debug [expr|-C|-D]";
+ 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";
mCommandDict[info.keyword] = info;
/*
throw QuitException();
break;
- case cObject :
- if (words.size()==2) ObjectInfo(words[1]);
- else ObjectInfo("");
+ case cDebug :
+ if (words.size()==2) Debug(words[1]);
+ else Debug("");
break;
/* obsolete
case cWorkspace :
Filenames.clear();
- int nbFiles = Utilities::Explore(*i, false, Filenames);
+ //int nbFiles =
+ Utilities::Explore(*i, false, Filenames);
nbBssFiles = 0;
for (std::vector<std::string>::iterator j = Filenames.begin();
}
// tests the number of args
- if ( ( words.size()-1 < c->second.argmin ) ||
- ( words.size()-1 > c->second.argmax ) )
+ if ( ( ((int)words.size())-1 < c->second.argmin ) ||
+ ( ((int)words.size())-1 > c->second.argmax ) )
{
HelpCommand(words[0]);
bbtkError(words[0]<<" : wrong number of arguments");
void Interpreter::GetLineFromPrompt(std::string& s)
{
int c;
- int ind=0;
+ unsigned int ind=0;
- int MAX_LINE_SIZE = 160;
- int MAX_HISTORY_SIZE = 100;
+ unsigned int MAX_LINE_SIZE = 160;
+ unsigned int MAX_HISTORY_SIZE = 100;
char* newline = new char[MAX_LINE_SIZE];
memset(newline,0,MAX_LINE_SIZE);
memset(histline,0,MAX_LINE_SIZE);
char* line = newline;
- int hist = mHistory.size();
+ unsigned int hist = mHistory.size();
write(1,"> ",2);
while(1)
BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
// BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
- int nb = 0;
+ // int nb = 0;
BlackBox::InputConnectorMapType::iterator i;
for (i=box->bbGetInputConnectorMap().begin();
i!=box->bbGetInputConnectorMap().end();
//==========================================================================
- void Interpreter::ObjectInfo(const std::string& name)
+ void Interpreter::Debug(const std::string& name)
{
if ((name.length()==2)&&(name[0]=='-'))
{
- if (name[1]=='S')
+ if (name[1]=='D')
{
bbtk::StaticInitTime::PrintObjectListInfo = true;
}