Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.59 $
+ Date: $Date: 2008/04/22 06:59:31 $
+ Version: $Revision: 1.61 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace bbtk
{
- //Interpreter* Interpreter::mGlobalInterpreter = NULL;
+ //=======================================================================
+ Interpreter::Pointer Interpreter::New(const std::string& cpp_file)
+ {
+ bbtkDebugMessage("Kernel",9,"Interpreter::New()"<<std::endl);
+ return MakePointer(new Interpreter(cpp_file));
+ }
+ //=======================================================================
//=======================================================================
- /**
- *
- */
Interpreter::Interpreter(const std::string& cpp_file)
:
mUser(0),
mCommandLine(false),
mThrow(false)
{
-bufferNb =0;
+
+ bufferNb =0;
bbtk::MessageManager::RegisterMessageType("Echo","Level>0 : Prints the 'echo' 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)
{
- mExecuter = new bbtk::Transcriptor(cpp_file);
+ mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
}
else
{
- mExecuter = new bbtk::Executer();
+ mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Executer::New());
}
- mExecuter->SetInterpreter(this);
+
+ // Lock this pointer or will auto-destruct !!
+ mExecuter->SetInterpreter(MakePointer(this,true));
// For the time being, comment out previous line, and
// uncomment next line to check Transcriptor
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.argmin = 0;
+ info.argmax = 1;
+ info.code = cObject;
+ info.syntax = "object <object name>";
+ info.help = "Provides debug info on object <object name>";
+ mCommandDict[info.keyword] = info;
+
/*
info.keyword = "workspace";
info.argmin = 1;
*/
Interpreter::~Interpreter()
{
- bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
- delete mExecuter;
-
- bbtkDebugDecTab("Interpreter",9);
+ bbtkDebugMessageInc("Interpreter",9,"==> Interpreter::~Interpreter()" <<std::endl);
+ mExecuter = VirtualExec::Pointer();
+ bbtkDebugMessageInc("Interpreter",9,"<== Interpreter::~Interpreter()" <<std::endl);
}
//=======================================================================
/// Runs the interpretation of a command
Interpreter::ExitStatus Interpreter::InterpretLine( const std::string& line )
{
-printf("EED Interpreter::InterpretLine %s \n", line.c_str() );
bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretLine('"<<line<<"')"<<std::endl);
ExitStatus status = Interpreter_OK;
break;
case cQuit :
- delete mExecuter;
throw QuitException();
break;
+
+ case cObject :
+ if (words.size()==2) ObjectInfo(words[1]);
+ else ObjectInfo("");
+ break;
/* obsolete
case cWorkspace :
if (words.size() == 2)
// connected and can be adapted from a widget adaptor
// vector which stores the list of inputs of the box which must be connected
std::vector<std::string> in;
- Factory* F = mExecuter->GetFactory();
- if (F==0)
+
+ Factory::Pointer F = mExecuter->GetFactory();
+ /*
+ Package::Pointer user = F->GetPackage("user");
+ */
+ ComplexBlackBoxDescriptor::Pointer workspace = mExecuter->GetWorkspace();
+
+ if (workspace==0)
{
delete s;
- bbtkError("Interpreter::CreateGUI : could not access the executer factory");
+ bbtkError("Interpreter::CreateGUI : could not access the executer workspace");
}
- Package* user = F->GetPackage("user");
- ComplexBlackBoxDescriptor* workspace
- = (ComplexBlackBoxDescriptor*)user->GetBlackBoxMap().find("workspace")->second;
-
- BlackBox* box = workspace->GetPrototype()->bbGetBlackBox(boxname);
+
+
+ /*
+ (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
+ */
+
+ BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
// BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
int nb = 0;
BlackBox::InputConnectorMapType::iterator i;
// Sets the label of the widget adaptor to the name of the input
(*s) << " set "<<i->first<<".Label "<<i->first<<std::endl;
// Sets the initial value of the widget to the value of the input
- (*s) << " set "<<i->first<<".In \""
+ (*s) << " set "<<i->first<<".In \" "
<<box->bbGetInputAsString(i->first)<<"\""
<< std::endl;
// store the input name
// Sets the label of the widget adaptor to the name of the input
(*s) << " set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
// Sets the initial value of the widget to the value of the input
- (*s) << " set "<<i->first<<"Widget.In \""
+ (*s) << " set "<<i->first<<"Widget.In \" "
<<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
// store the input name
in.push_back(i->first);
// Sets the label of the widget adaptor to the name of the input
(*s) << " set "<<i->first<<".Title "<<i->first<<std::endl;
// Sets the initial value of the widget to the value of the input
- (*s) << " set "<<i->first<<".In \""
+ (*s) << " set "<<i->first<<".In \" "
<<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
// store the input name
in.push_back(i->first);
}
//=======================================================================
+
+
+ //==========================================================================
+ void Interpreter::ObjectInfo(const std::string& name)
+ {
+ Object:: PrintObjectInfo(name);
+ }
+ //==========================================================================
+ //==========================================================================
+ std::string Interpreter::GetObjectName() const
+ {
+ return std::string("Interpreter");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Interpreter::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+size_t Interpreter::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += Interpreter::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Interpreter::GetObjectInternalSize() const
+{
+ size_t s = sizeof(Interpreter);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Interpreter::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Interpreter::GetObjectInternalSize();
+ s += mExecuter->GetObjectRecursiveSize();
+ return s;
+ }
+ //==========================================================================
}//namespace