X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=sidebyside;f=kernel%2Fsrc%2FbbtkInterpreter.cxx;h=ede613aae17a55c7142de17f212c98ed20d9a02e;hb=4ad5b5ee44357ad873bc8c43230defb6d0a79879;hp=c925050a17fd99e20bf257351e8fcd94a2d11f9f;hpb=6c5d7746e8e4cb0b5d6e164b917008a7137910fb;p=bbtk.git diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index c925050..ede613a 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ $ Language: C++ - Date: $Date: 2008/04/08 06:59:30 $ - Version: $Revision: 1.58 $ + Date: $Date: 2008/04/18 12:59:15 $ + Version: $Revision: 1.60 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -39,32 +39,38 @@ namespace bbtk { - //Interpreter* Interpreter::mGlobalInterpreter = NULL; + //======================================================================= + Interpreter::Pointer Interpreter::New(const std::string& cpp_file) + { + bbtkDebugMessage("Kernel",9,"Interpreter::New()"<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()" <(bbtk::Transcriptor::New(cpp_file)); } else { - mExecuter = new bbtk::Executer(); + mExecuter = boost::static_pointer_cast(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 @@ -291,6 +297,14 @@ bufferNb =0; 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 "; + info.help = "Provides debug info on object "; + mCommandDict[info.keyword] = info; + /* info.keyword = "workspace"; info.argmin = 1; @@ -314,10 +328,9 @@ bufferNb =0; */ Interpreter::~Interpreter() { - bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" < Interpreter::~Interpreter()" < words; SplitLine(line,words); @@ -800,6 +813,7 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment ) case cReset : this->mExecuter->Reset(); + mFileNameHistory.clear(); break; case cInclude : @@ -827,9 +841,13 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment ) 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) @@ -1240,23 +1258,13 @@ void Interpreter::SwitchToStream( std::stringstream* stream ) void Interpreter::LoadScript( std::string fullPathScriptName, std::string includeScriptName) { - Utilities::replace( fullPathScriptName , INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - - bool okScriptExist=false; - int iStrScript,sizeVecStricpt=mFileName.size(); - for ( iStrScript=0;iStrScriptclose(); - delete mFile.back(); - mFile.pop_back(); - bbtkDebugMessage("Interpreter",9, - " Closing file '"< 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; @@ -1925,26 +1932,51 @@ void Interpreter::NewGUI(const std::string& boxname, if ( ( d->GetCreatorTypeInfo() == typeid(AtomicBlackBoxDescriptor)) || ( d->GetCreatorTypeInfo() == typeid(WxBlackBoxDescriptor)) ) continue; + bool widok = true; + std::string widget,adaptor; // try to find a widget adaptor - std::string adaptor; - if (F->FindWidgetAdaptor(DataInfo(typeid(Void),""), + if (F->FindWidgetAdaptor(DataInfo(d->GetTypeInfo(),""), d->GetDataInfo(), adaptor)) { - // store the input name - in.push_back(i->first); // command to create the adaptor (*s) << " new "<first<first<<" " - <first<<".Out "<first<first<<"'"<first<<".Label "<first<first<<".In \" " + <bbGetInputAsString(i->first)<<"\"" + << std::endl; + // store the input name + in.push_back(i->first); (*s) << " connect "<first<<".Widget layout.Widget"<first<<"'"<first<<".BoxChange change.In"<FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""), + d->GetDataInfo(), + widget,adaptor) ) + { + // command to create the widget + (*s) << " new "<first<<"Widget"<first<first<<"Widget.Out " + <first<<".In"<first<<"Widget.Label "<first<first<<"Widget.In \" " + <bbGetInputAsString(i->first)<<"\""<< std::endl; + // store the input name + in.push_back(i->first); + (*s) << " connect "<first<<"Widget.Widget layout.Widget"<first<<"'"<first<<"Widget.BoxChange change.In"<GetDataInfo(), adaptor)) { - // store the input name - in.push_back(i->first); // command to create the adaptor (*s) << " new InputText "<first<first<<" " - <first<<".Out "<first<first<<"'"<first<<".Title "<first<first<<".In \" " + <bbGetInputAsString(i->first)<<"\""<< std::endl; + // store the input name + in.push_back(i->first); (*s) << " connect "<first<<".Widget layout.Widget"<first<<"'"<first<<".BoxChange change.In"<first<<" " + <first<<".Out "<first<GetObjectRecursiveSize(); + return s; + } + //========================================================================== }//namespace