Program: bbtk
Module: $RCSfile: bbtkExecuter.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/22 06:59:31 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2008/04/22 09:40:10 $
+ Version: $Revision: 1.20 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
void Executer::EndDefine ()
{
bbtkDebugMessageInc("Kernel",9,"Executer::EndDefine(\""
- <<Current()->GetTypeName()<<"\")"
+ <<GetCurrentDescriptor()->GetTypeName()<<"\")"
<<std::endl);
// Does current package exist ?
Package::Pointer p;
{
p = mOpenPackage.back().lock();
}
- p->RegisterBlackBox(Current());
+ p->RegisterBlackBox(GetCurrentDescriptor());
mOpenDefinition.pop_back();
}
{
if (kind=="ADAPTOR")
{
- Current()->AddToCategory("adaptor");
- Current()->SetKind(bbtk::BlackBoxDescriptor::ADAPTOR);
+ GetCurrentDescriptor()->AddToCategory("adaptor");
+ GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::ADAPTOR);
}
else if (kind=="DEFAULT_ADAPTOR")
{
- Current()->AddToCategory("adaptor");
- Current()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);
+ GetCurrentDescriptor()->AddToCategory("adaptor");
+ GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_ADAPTOR);
}
if (kind=="GUI")
{
- Current()->AddToCategory("gui");
- Current()->SetKind(bbtk::BlackBoxDescriptor::GUI);
+ GetCurrentDescriptor()->AddToCategory("gui");
+ GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::GUI);
}
else if (kind=="DEFAULT_GUI")
{
- Current()->AddToCategory("gui");
- Current()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_GUI);
+ GetCurrentDescriptor()->AddToCategory("gui");
+ GetCurrentDescriptor()->SetKind(bbtk::BlackBoxDescriptor::DEFAULT_GUI);
}
else
{
void Executer::Create ( const std::string& nodeType,
const std::string& nodeName)
{
- Current()->Add(nodeType,nodeName);
+ GetCurrentDescriptor()->Add(nodeType,nodeName);
}
//=======================================================================
//=======================================================================
void Executer::Destroy(const std::string &boxName)
{
- Current()->Remove(boxName,true);
+ GetCurrentDescriptor()->Remove(boxName,true);
}
//=======================================================================
const std::string &nodeTo,
const std::string &inputLabel)
{
- Current()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel);
+ GetCurrentDescriptor()->Connect(nodeFrom, outputLabel, nodeTo, inputLabel);
}
//=======================================================================
void Executer::Execute (const std::string &nodeName)
{
// if in root
- if (Current()==GetWorkspace())
+ if (GetCurrentDescriptor()==GetWorkspace())
{
if (!mNoExecMode)
{
- Current()->GetPrototype()->bbGetBlackBox(nodeName)->bbExecute(true);
+ GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(nodeName)->bbExecute(true);
}
}
else
{
- Current()->AddToExecutionList(nodeName) ;
+ GetCurrentDescriptor()->AddToExecutionList(nodeName) ;
}
}
//=======================================================================
const std::string& help)
{
// If the input is defined in the Root box
- if (Current()==GetWorkspace())
+ if (GetCurrentDescriptor()==GetWorkspace())
{
// If the dialog mode is set to NoDialog
// and the user passed the name in the Inputs map
#endif
}
- Current()->DefineInput(name,box,input,help);
+ GetCurrentDescriptor()->DefineInput(name,box,input,help);
}
//=======================================================================
const std::string &output,
const std::string& help)
{
- Current()->DefineOutput(name,box,output,help);
+ GetCurrentDescriptor()->DefineOutput(name,box,output,help);
}
//=======================================================================
const std::string &input,
const std::string &value)
{
- BlackBox::Pointer b = Current()->GetPrototype()->bbGetBlackBox(box);
+ BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
// Looks for the adaptor
if ( b->bbGetInputType(input) != typeid(std::string) )
std::string Executer::Get(const std::string &box,
const std::string &output)
{
- BlackBox::Pointer b = Current()->GetPrototype()->bbGetBlackBox(box);
+ BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
// Looks for the adaptor
if (b->bbGetOutputType(output) != typeid(std::string))
{
//=======================================================================
void Executer::Author(const std::string &authorName)
{
- Current()->AddToAuthor(authorName,Current()==GetWorkspace());
+ GetCurrentDescriptor()->AddToAuthor(authorName,GetCurrentDescriptor()==GetWorkspace());
}
//=======================================================================
//=======================================================================
void Executer::Category(const std::string &category)
{
- Current()->AddToCategory(category,Current()==GetWorkspace());
+ GetCurrentDescriptor()->AddToCategory(category,GetCurrentDescriptor()==GetWorkspace());
}
//=======================================================================
//=======================================================================
void Executer::Description(const std::string &d)
{
- Current()->AddToDescription(d,Current()==GetWorkspace());
+ GetCurrentDescriptor()->AddToDescription(d,GetCurrentDescriptor()==GetWorkspace());
}
//=======================================================================
void Executer::PrintBoxes()
{
bbtkMessageInc("Help",1,"The black box descriptor \""
- <<Current()->GetTypeName()<<"\" contains : "<<std::endl);
- Current()->PrintBlackBoxes();
+ <<GetCurrentDescriptor()->GetTypeName()<<"\" contains : "<<std::endl);
+ GetCurrentDescriptor()->PrintBlackBoxes();
bbtkDecTab("Help",1);
}
//=======================================================================
BlackBox::Pointer blackbox;
if (nameblackbox==".")
{
- blackbox = Current()->GetPrototype();
+ blackbox = GetCurrentDescriptor()->GetPrototype();
}
else
{
- blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox);
+ blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
}
std::string page;
BlackBox::Pointer blackbox;
if (nameblackbox.compare(".")==0)
{
- blackbox=Current()->GetPrototype();
+ blackbox=GetCurrentDescriptor()->GetPrototype();
}
else
{
- blackbox = Current()->GetPrototype()->bbFindBlackBox(nameblackbox);
+ blackbox = GetCurrentDescriptor()->GetPrototype()->bbFindBlackBox(nameblackbox);
}
if (blackbox)
///
void Executer::Print(const std::string &str)
{
- if (GetNoExecMode() && (Current()==GetWorkspace()) ) return;
- if (Current()!=GetWorkspace()) return;
+ if (GetNoExecMode() && (GetCurrentDescriptor()==GetWorkspace()) ) return;
+ if (GetCurrentDescriptor()!=GetWorkspace()) return;
bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
std::vector<std::string>::iterator i;
for (i= chains.begin(); i!=chains.end(); ++i)
{
- // bbtkMessage("Echo",1,*i);
Utilities::SubsBackslashN(*i);
bbtkMessage("Output",1,*i);
}
Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/22 08:29:09 $
- Version: $Revision: 1.62 $
+ Date: $Date: 2008/04/22 09:40:10 $
+ Version: $Revision: 1.63 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
{
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("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)
{
- mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
+ mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
}
else
{
- mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Executer::New());
+ bbtk::Executer::Pointer exe = bbtk::Executer::New();
+ mRealExecuter = exe;
+ mVirtualExecuter = boost::static_pointer_cast<VirtualExec>(exe);
}
// Lock this pointer or will auto-destruct !!
- mExecuter->SetInterpreter(MakePointer(this,true));
+ mVirtualExecuter->SetInterpreter(MakePointer(this,true));
// For the time being, comment out previous line, and
// uncomment next line to check Transcriptor
- //mExecuter = new bbtk::Transcriptor("GeneratedProgram.txt");
+ //mVirtualExecuter = new bbtk::Transcriptor("GeneratedProgram.txt");
// Builds the commands dict
CommandInfoType info;
info.argmax = 1;
info.code = cPrint;
info.syntax = "print <string>";
- 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').";
+ 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').";
mCommandDict[info.keyword] = info;
info.keyword = "exec";
Interpreter::~Interpreter()
{
bbtkDebugMessageInc("Interpreter",9,"==> Interpreter::~Interpreter()" <<std::endl);
- mExecuter = VirtualExec::Pointer();
+ mVirtualExecuter = VirtualExec::Pointer();
bbtkDebugMessageInc("Interpreter",9,"<== Interpreter::~Interpreter()" <<std::endl);
}
//=======================================================================
void Interpreter::InterpretLine( const std::string& line, bool &insideComment )
{
bbtkDebugMessageInc("Interpreter",9,"Interpreter::InterpretLine(\""<<line<<"\")"<<std::endl);
- bbtkMessage("Echo",2,line<<std::endl);
+ bbtkMessage("echo",2,line<<std::endl);
std::vector<std::string> words;
SplitLine(line,words);
switch (command.code)
{
case cNew :
- mExecuter->Create(words[1],words[2]);
+ mVirtualExecuter->Create(words[1],words[2]);
break;
case cDelete :
- mExecuter->Destroy(words[1]);
+ mVirtualExecuter->Destroy(words[1]);
break;
case cConnect :
Utilities::SplitAroundFirstDot(words[1],left,right);
Utilities::SplitAroundFirstDot(words[2],left2,right2);
- mExecuter->Connect(left,right,left2,right2);
+ mVirtualExecuter->Connect(left,right,left2,right2);
break;
case cPackage :
- mExecuter->BeginPackage(words[1]);
+ mVirtualExecuter->BeginPackage(words[1]);
break;
case cEndPackage :
- mExecuter->EndPackage();
+ mVirtualExecuter->EndPackage();
break;
case cDefine :
}
if (words.size()==2)
{
- mExecuter->Define(words[1],"",filename);
+ mVirtualExecuter->Define(words[1],"",filename);
}
else
{
- mExecuter->Define(words[1],words[2],filename);
+ mVirtualExecuter->Define(words[1],words[2],filename);
}
break;
case cEndDefine :
- mExecuter->EndDefine();
+ mVirtualExecuter->EndDefine();
break;
case cKind :
- mExecuter->Kind(words[1]);
+ mVirtualExecuter->Kind(words[1]);
break;
case cPrint :
- mExecuter->Print(words[1]);
+ mVirtualExecuter->Print(words[1]);
break;
case cExec :
if (words[1]=="freeze")
- mExecuter->SetNoExecMode(true);
+ mVirtualExecuter->SetNoExecMode(true);
else if (words[1]=="unfreeze")
- mExecuter->SetNoExecMode(false);
+ mVirtualExecuter->SetNoExecMode(false);
else
- mExecuter->Execute(words[1]);
+ mVirtualExecuter->Execute(words[1]);
break;
case cInput :
Utilities::SplitAroundFirstDot(words[2],left,right);
- mExecuter->DefineInput(words[1],left,right,words[3]);
+ mVirtualExecuter->DefineInput(words[1],left,right,words[3]);
break;
case cOutput :
Utilities::SplitAroundFirstDot(words[2],left,right);
- mExecuter->DefineOutput(words[1],left,right,words[3]);
+ mVirtualExecuter->DefineOutput(words[1],left,right,words[3]);
break;
case cSet :
Utilities::SplitAroundFirstDot(words[1],left,right);
- mExecuter->Set(left,right,words[2]);
+ mVirtualExecuter->Set(left,right,words[2]);
break;
case cAuthor :
- mExecuter->Author(words[1]);
+ mVirtualExecuter->Author(words[1]);
break;
case cNewGUI :
break;
case cCategory :
- mExecuter->Category(words[1]);
+ mVirtualExecuter->Category(words[1]);
break;
case cIndex :
break;
case cDescription :
- mExecuter->Description(words[1]);
+ mVirtualExecuter->Description(words[1]);
break;
case cHelp :
case cMessage :
if (words.size()<3)
{
- mExecuter->HelpMessages();
+ mVirtualExecuter->HelpMessages();
}
else
{
sscanf(words[2].c_str(),"%d",&level);
- mExecuter->SetMessageLevel(words[1],level);
+ mVirtualExecuter->SetMessageLevel(words[1],level);
}
break;
case cWorkspace :
if (words.size() == 2)
{
- if (words[1]=="freeze") mExecuter->SetNoExecMode(true);
- else if (words[1]=="unfreeze") mExecuter->SetNoExecMode(false);
+ if (words[1]=="freeze") mVirtualExecuter->SetNoExecMode(true);
+ else if (words[1]=="unfreeze") mVirtualExecuter->SetNoExecMode(false);
}
else
{
- mExecuter->SetWorkspaceName(words[2]);
+ mVirtualExecuter->SetWorkspaceName(words[2]);
}
break;
*/
// Cannot close all files if the reset command is read from a file !
// CloseAllFiles();
mFileNameHistory.clear();
- this->mExecuter->Reset();
+ this->mVirtualExecuter->Reset();
}
//=======================================================================
/*
void Interpreter::Print( const std::string& str)
{
- if (mExecuter->GetNoExecMode()) return;
+ if (mVirtualExecuter->GetNoExecMode()) return;
bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
std::string tok,box,output;
tok = str.substr(lastPos, pos - lastPos);
Utilities::SplitAroundFirstDot(tok,box,output);
- chains.push_back( mExecuter->Get(box,output) );
+ chains.push_back( mVirtualExecuter->Get(box,output) );
// InterpretLine("connect %tok% _C_.In%num%")
std::vector<std::string>::iterator i;
for (i= chains.begin(); i!=chains.end(); ++i)
{
- // bbtkMessage("Echo",1,*i);
+
Utilities::SubsBackslashN(*i);
std::cout << *i;
}
if (words.size()==1)
{
- page = mExecuter->ShowGraph(".","0","0","","","",system_display);
+ page = mVirtualExecuter->ShowGraph(".","0","0","","","",system_display);
}
else if (words.size()==2)
{
- page = mExecuter->ShowGraph(words[1],"0","0","","","",system_display);
+ page = mVirtualExecuter->ShowGraph(words[1],"0","0","","","",system_display);
}
else if (words.size()==3)
{
- page = mExecuter->ShowGraph(words[1],words[2],"0","","","",system_display);
+ page = mVirtualExecuter->ShowGraph(words[1],words[2],"0","","","",system_display);
}
else if (words.size()==4)
{
- page = mExecuter->ShowGraph(words[1],words[2],words[3],"","","",system_display);
+ page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],"","","",system_display);
}
else if (words.size()==5)
{
- page = mExecuter->ShowGraph(words[1],words[2],words[3],words[4],"","",system_display);
+ page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],"","",system_display);
}
else if (words.size()==6)
{
- page = mExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display);
+ page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],"",system_display);
}
else if (words.size()==7)
{
- page = mExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display);
+ page = mVirtualExecuter->ShowGraph(words[1],words[2],words[3],words[4],words[5],words[6],system_display);
}
if ( ( mUser != 0 ) && ( mUser->InterpreterUserHasOwnHtmlPageViewer() ) )
void Interpreter::NewGUI(const std::string& boxname,
const std::string& instanceName)
{
+ if (mRealExecuter.expired())
+ {
+ bbtkError("command 'newgui' cannot be compiled yet");
+ }
+
std::string typeName = instanceName+"Type";
std::stringstream* s = new std::stringstream;
// create the complex box
// vector which stores the list of inputs of the box which must be connected
std::vector<std::string> in;
- Factory::Pointer F = mExecuter->GetFactory();
+ Factory::Pointer F = mVirtualExecuter->GetFactory();
/*
Package::Pointer user = F->GetPackage("user");
*/
- ComplexBlackBoxDescriptor::Pointer workspace = mExecuter->GetWorkspace();
+ ComplexBlackBoxDescriptor::Pointer workspace =
+ mRealExecuter.lock()->GetCurrentDescriptor();
if (workspace==0)
{
delete s;
- bbtkError("Interpreter::CreateGUI : could not access the executer workspace");
+ bbtkError("Interpreter::CreateGUI : could not access the executer currently defined complex box");
}
{
// int o = MessageManager::GetMessageLevel("debug");
// if (o<2) MessageManager::SetMessageLevel("debug",2);
- mExecuter->GetFactory()->CheckPackages();
+ mVirtualExecuter->GetFactory()->CheckPackages();
// MessageManager::SetMessageLevel("debug",o);
}
}
{
size_t s = Superclass::GetObjectRecursiveSize();
s += Interpreter::GetObjectInternalSize();
- s += mExecuter->GetObjectRecursiveSize();
+ s += mVirtualExecuter->GetObjectRecursiveSize();
return s;
}
//==========================================================================