From c2a4b1893412e50a3d9abff221938a2d16c4a7cb Mon Sep 17 00:00:00 2001 From: guigues Date: Wed, 9 Apr 2008 11:16:56 +0000 Subject: [PATCH] *** empty log message *** --- kernel/src/bbtkAtomicBlackBoxMacros.h | 10 +- kernel/src/bbtkBlackBox.cxx | 14 +- kernel/src/bbtkBlackBox.h | 7 +- kernel/src/bbtkBlackBoxDescriptor.cxx | 90 +++++++++---- kernel/src/bbtkBlackBoxDescriptor.h | 25 +++- kernel/src/bbtkBlackBoxOutputConnector.cxx | 15 +-- kernel/src/bbtkComplexBlackBox.cxx | 127 +++++++++++++++---- kernel/src/bbtkComplexBlackBox.h | 14 +- kernel/src/bbtkComplexBlackBoxDescriptor.cxx | 38 ++++-- kernel/src/bbtkComplexBlackBoxDescriptor.h | 11 +- kernel/src/bbtkConnection.cxx | 123 ++++++++++++++++-- kernel/src/bbtkConnection.h | 27 +++- kernel/src/bbtkExecuter.cxx | 16 ++- kernel/src/bbtkFactory.cxx | 95 ++++++++++++-- kernel/src/bbtkFactory.h | 11 +- kernel/src/bbtkInterpreter.cxx | 110 +++++++++------- kernel/src/bbtkInterpreter.h | 9 +- kernel/src/bbtkPackage.cxx | 55 ++++++-- kernel/src/bbtkPackage.h | 71 +++++++---- kernel/src/bbtkWxGUIPackageBrowser2.cxx | 8 +- 20 files changed, 669 insertions(+), 207 deletions(-) diff --git a/kernel/src/bbtkAtomicBlackBoxMacros.h b/kernel/src/bbtkAtomicBlackBoxMacros.h index 605c10d..ed05e79 100644 --- a/kernel/src/bbtkAtomicBlackBoxMacros.h +++ b/kernel/src/bbtkAtomicBlackBoxMacros.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $ Language: C++ - Date: $Date: 2008/04/08 06:59:29 $ - Version: $Revision: 1.3 $ + Date: $Date: 2008/04/09 11:16:56 $ + Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -41,7 +41,8 @@ bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbNew(\""<bbGetDescriptor()->Reference(); \ + bbtkDebugDecTab("Kernel",9); \ return c; \ } \ inline bbtk::BlackBox* bbClone(const std::string& name) \ @@ -49,7 +50,8 @@ bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbClone(\""<Reference(); \ + bbtkDebugDecTab("Kernel",9); \ return c; \ } \ bbtk::BlackBoxDescriptor* bbGetDescriptor() const \ diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index cd26c11..9a62efb 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBox.cxx,v $ Language: C++ -Date: $Date: 2008/04/08 06:59:29 $ -Version: $Revision: 1.8 $ +Date: $Date: 2008/04/09 11:16:57 $ +Version: $Revision: 1.9 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -86,8 +86,9 @@ namespace bbtk /// Destruction method of a black box void BlackBox::bbDelete() { - bbtkDebugMessage("Kernel",5,"BlackBox::bbDelete() [" + bbtkDebugMessage("Kernel",1,"BlackBox::bbDelete() [" <UnReference(); this->bbUserDelete(); } //========================================================================= @@ -1085,6 +1086,13 @@ namespace bbtk */ //========================================================================= + //========================================================================= + void BlackBox::Check(bool recursive) + { + bbtkMessage("Debug",1,"*** Checking Black Box "<<(void*)this<<" ["< Destructing BlackBoxDescriptor ["<GetName()<<"::"<"<"<"<second->GetName().size()>namelmax) namelmax = i->second->GetName().size(); if (i->second->GetHumanTypeName().size()>typelmax) typelmax = i->second->GetHumanTypeName().size(); + if (i->second->GetNature().size()>natlmax) + natlmax = i->second->GetNature().size(); } OutputDescriptorMapType::const_iterator o; for ( o = mOutput.begin(); o != mOutput.end(); ++o ) @@ -170,6 +191,8 @@ namespace bbtk namelmax = o->second->GetName().size(); if (o->second->GetHumanTypeName().size()>typelmax) typelmax = o->second->GetHumanTypeName().size(); + if (o->second->GetNature().size()>natlmax) + natlmax = o->second->GetNature().size(); } // for ( i = mInput.begin(); i != mInput.end(); ++i ) @@ -180,10 +203,14 @@ namespace bbtk std::string type(i->second->GetHumanTypeName()); type += ">"; type.append(1+typelmax-type.size(),' '); + std::string nature(i->second->GetNature()); + nature += "]"; + nature.append(1+natlmax-nature.size(),' '); bbtkMessage("Help",1, - " '"<second->GetDescription()<second->GetDescription()<second->GetHumanTypeName()); type += ">"; type.append(1+typelmax-type.size(),' '); + std::string nature(o->second->GetNature()); + nature += "]"; + nature.append(1+natlmax-nature.size(),' '); bbtkMessage("Help",1, " '"<second->GetDescription()<second->GetDescription()<GetName() + "::" + mTypeName; + return "::" + mTypeName; + } + //========================================================================= + //========================================================================= void BlackBoxDescriptor::InsertHtmlHelp ( std::ofstream& s, int detail, int level, const std::string& output_dir, bool relative_link ) { - bbtkDebugMessageInc("Kernel",9,"BlackBoxDescriptor::InsertHtmlHelp() ["<GetName()] = d; } @@ -165,7 +177,12 @@ namespace bbtk InputDescriptorMapType mInput; /// The outputs OutputDescriptorMapType mOutput; + + /// Reference counting + int mRefCount; + private: + BlackBoxDescriptor(const BlackBoxDescriptor&) {} }; // class BlackBoxDescriptor //========================================================================== diff --git a/kernel/src/bbtkBlackBoxOutputConnector.cxx b/kernel/src/bbtkBlackBoxOutputConnector.cxx index 7535b35..d2ee80e 100644 --- a/kernel/src/bbtkBlackBoxOutputConnector.cxx +++ b/kernel/src/bbtkBlackBoxOutputConnector.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $ Language: C++ - Date: $Date: 2008/02/05 13:23:46 $ - Version: $Revision: 1.2 $ + Date: $Date: 2008/04/09 11:16:57 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -64,15 +64,12 @@ namespace bbtk bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection(" <::iterator i; - for (i=mConnection.begin();i!=mConnection.end();++i) - { - if ( *i == c) break; - } - //= std::find(mConnection,c); + c->Check(); + std::vector::iterator i + = find(mConnection.begin(),mConnection.end(),c); if (i==mConnection.end()) { - bbtkError("no connexion "<GetFullName()<<"\""<GetBlackBoxFrom()->bbGetName() ); - BlackBox* bbto = bbGetBlackBox( (*j)->GetBlackBoxTo()->bbGetName() ); + BlackBox* bbfrom = bbGetBlackBox( (*j)->GetOriginalBlackBoxFrom()->bbGetName() ); + BlackBox* bbto = bbGetBlackBox( (*j)->GetOriginalBlackBoxTo()->bbGetName() ); Connection* c = mDescriptor->GetFactory()-> NewConnection( bbfrom, - (*j)->GetBlackBoxFromOutput(), + (*j)->GetOriginalBlackBoxFromOutput(), bbto, - (*j)->GetBlackBoxToInput() ); + (*j)->GetOriginalBlackBoxToInput() ); + bbAddConnection(c); bbtkDebugDecTab("Kernel",9); @@ -100,15 +101,15 @@ namespace bbtk /// Destructor ComplexBlackBox::~ComplexBlackBox() { - bbtkDebugMessageInc("Kernel",9, + bbtkDebugMessageInc("Kernel",1, "ComplexBlackBox::~ComplexBlackBox() [" <GetFullName()<<"\""<first<<"\""<first<<"\""<second->bbDelete(); - bbtkDebugDecTab("Kernel",9); + bbtkDebugDecTab("Kernel",1); } - bbtkDebugDecTab("Kernel",9); - // bbtkDebugMessage("Kernel",9,"EO ComplexBlackBox::~ComplexBlackBox [" - // <bbDesallocateConnectors(); - bbtkDebugDecTab("Kernel",9); + bbtkDebugDecTab("Kernel",1); } //======================================================================= @@ -215,7 +216,8 @@ namespace bbtk <Reference(); + bbtkDebugDecTab("Kernel",9); return CBB; @@ -300,7 +302,8 @@ namespace bbtk "ComplexBlackBox::bbBackwardUpdate(" <<(caller?caller->GetFullName():"0")<<") [" <GetInputDescriptor(name); + + BlackBox* t = bbGetBlackBox(d->GetTarget()); + c->SetBlackBoxTo(t); + c->SetBlackBoxToInput(d->GetInput()); + t->bbConnectInput(d->GetInput(),c); + + bbtkMessage("Debug",1,"ComplexBlackBox["<GetFullName()< to the connection c + void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection* c) + { + bbtkDebugMessageInc("Kernel",7, + "ComplexBlackBox::bbConnectOutput(\"" + <GetOutputDescriptor(name); + + BlackBox* t = bbGetBlackBox(d->GetTarget()); + c->SetBlackBoxFrom(t); + c->SetBlackBoxFromOutput(d->GetOutput()); + t->bbConnectOutput(d->GetOutput(),c); + + bbtkMessage("Debug",1,"ComplexBlackBox["<GetFullName()<second->Check(recursive); + } + ConnectionListType::const_iterator j; + for ( j = mConnectionList.begin(); + j != mConnectionList.end(); ++j ) + { + (*j)->Check(); + } + bbtkMessage("Debug",1,"**** Checking Complex Black Box "<<(void*)this + <<" ["< + //BlackBox* bbNew(const std::string& name); /// Returns a pointer on a clone of the box with name BlackBox* bbClone(const std::string& name); @@ -64,7 +66,10 @@ namespace bbtk void* data, bool setModified = true); - ~ComplexBlackBox(); + /// Connects the input to the connection c + virtual void bbConnectInput( const std::string& name, Connection* c); + /// Connects the output to the connection c + virtual void bbConnectOutput( const std::string& name, Connection* c); BlackBox* bbGetBlackBox( const std::string& name ); @@ -105,6 +110,7 @@ namespace bbtk virtual BlackBox *bbFindBlackBox(const std::string &blackboxname); + void Check(bool recursive=true); protected: //================================================================== @@ -113,6 +119,8 @@ namespace bbtk ComplexBlackBox(const std::string &name, ComplexBlackBoxDescriptor* desc); /// Constructor from an existing box (copy) with a new name ComplexBlackBox(ComplexBlackBox& from, const std::string &name); + // + ~ComplexBlackBox(); public: diff --git a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx index e421055..6795575 100644 --- a/kernel/src/bbtkComplexBlackBoxDescriptor.cxx +++ b/kernel/src/bbtkComplexBlackBoxDescriptor.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkComplexBlackBoxDescriptor.cxx,v $ Language: C++ - Date: $Date: 2008/04/08 06:59:30 $ - Version: $Revision: 1.13 $ + Date: $Date: 2008/04/09 11:16:57 $ + Version: $Revision: 1.14 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -40,6 +40,7 @@ namespace bbtk SetTypeName(name); AddToCategory("complex box"); mPrototype = new ComplexBlackBox(name+std::string("Prototype"),this); + // this->Reference(); bbtkDebugDecTab("Kernel",9); } //======================================================================= @@ -50,14 +51,22 @@ namespace bbtk /// Default dtor ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor() { - bbtkDebugMessageInc("Kernel",9,"ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<Check(recursive); + } + //========================================================================= //======================================================================= /// Creates an instance of name of the ComplexBlackBox of which this is the descriptor @@ -466,12 +475,15 @@ namespace bbtk InputDescriptorMapType::const_iterator i; unsigned int namelmax = 0; unsigned int typelmax = 0; + unsigned int natlmax = 0; for ( i = mInput.begin(); i != mInput.end(); ++i ) { if (i->second->GetName().size()>namelmax) namelmax = i->second->GetName().size(); if (i->second->GetTypeName().size()>typelmax) typelmax = i->second->GetTypeName().size(); + if (i->second->GetNature().size()>natlmax) + natlmax = i->second->GetNature().size(); } OutputDescriptorMapType::const_iterator o; if (full) @@ -482,6 +494,8 @@ namespace bbtk namelmax = o->second->GetName().size(); if (o->second->GetTypeName().size()>typelmax) typelmax = o->second->GetTypeName().size(); + if (o->second->GetNature().size()>natlmax) + natlmax = o->second->GetNature().size(); } } // @@ -494,10 +508,14 @@ namespace bbtk std::string type(i->second->GetTypeName()); type += ">"; type.append(1+typelmax-type.size(),' '); + std::string nature(i->second->GetNature()); + nature += "]"; + nature.append(1+natlmax-nature.size(),' '); bbtkMessage("Help",1, - " '"<second->GetDescription()<second->GetDescription()<second->GetTypeName()); type += ">"; type.append(1+typelmax-type.size(),' '); + std::string nature(o->second->GetNature()); + nature += "]"; + nature.append(1+natlmax-nature.size(),' '); bbtkMessage("Help",1, - " '"<second->GetDescription()<bbGetName()<<"\",\""<bbHasOutput(output) ) @@ -124,8 +124,8 @@ namespace bbtk void Connection::Clear() { - mFrom = 0; - mTo = 0; + mFrom = mOriginalFrom = 0; + mTo = mOriginalTo = 0; mAdaptor = 0; } @@ -136,10 +136,11 @@ namespace bbtk bbtkDebugMessageInc("Kernel",7, "Connection::~Connection() [" <bbDisconnectOutput(mOutput,this); - if (mTo) mTo->bbDisconnectInput(mInput,this); - if (mAdaptor) mAdaptor->bbDelete(); + if (mFrom!=0) mFrom->bbDisconnectOutput(mOutput,this); + if (mTo!=0) mTo->bbDisconnectInput(mInput,this); + if (mAdaptor!=0) mAdaptor->bbDelete(); bbtkDebugDecTab("Kernel",7); } @@ -320,14 +321,108 @@ namespace bbtk //================================================================== std::string Connection::GetFullName() const { - if (mFrom && mTo) - return mFrom->bbGetName()+"."+mOutput+"--" - +mTo->bbGetName()+"."+mInput; + if (mFrom && mTo) + { + std::string res = mFrom->bbGetName()+"."+mOutput+"--" + +mTo->bbGetName()+"."+mInput; + if ((mFrom!=mOriginalFrom)||(mTo!=mOriginalTo)) + { + res += "("+mOriginalFrom->bbGetName()+"."+mOriginalOutput+"--" + + mOriginalTo->bbGetName()+"."+mOriginalInput+")"; + } + return res; + } return "***Invalid Connection***"; } //================================================================== + //================================================================== + void Connection::Check() const + { + bbtkMessage("Debug",1,"** Checking Connection "<<(void*)this<<" ["<bbGetFullName()<bbHasOutput(mOutput)) + { + bbtkError(mFrom->bbGetFullName()<<" does not have output '" + <bbGetOutputConnectorMap().find(mOutput); + if (i== mFrom->bbGetOutputConnectorMap().end()) + { + bbtkError(mFrom->bbGetFullName()<<" output '" + <::const_iterator j; + j = find(i->second->GetConnectionVector().begin(), + i->second->GetConnectionVector().end(), + this); + if (j==i->second->GetConnectionVector().end()) + { + bbtkError("Connection ["<bbGetFullName() + <<" does not point to this connection"); + + } + bbtkMessage("Debug",2," - From : This connection is in OutputConnector connection vector"<bbGetName()<bbGetDescriptor() << std::endl; + std::cout << mTo->bbGetDescriptor()->GetTypeName() << std::endl; + mTo->bbGetFullName(); + bbtkMessage("Debug",2," - To : "<bbGetFullName()<bbHasInput(mInput)) + { + bbtkError(mTo->bbGetFullName()<<" does not have input '" + <bbGetInputConnectorMap().find(mInput); + if (i== mTo->bbGetInputConnectorMap().end()) + { + bbtkError(mTo->bbGetFullName()<<" input '" + <second->GetConnection()==0) + { + bbtkError("Connection "<bbGetFullName() + <<" does not point to this connection"); + + } + bbtkMessage("Debug",2," - To : This connection is in InputConnector connection vector"<UnRegisterBlackBox("workspace"); - delete mRootCBB; + mRootCBB->UnReference(); } if (mRootPackage) { @@ -93,6 +93,8 @@ namespace bbtk { bbtkDebugMessageInc("Kernel",9,"Executer::Reset()" <CheckPackages(); + // The 'user' package must be closed before all other // because box destructors must not be unloaded when bb are deleted! // Similarly, the 'workspace' CBB must be destroyed before @@ -101,8 +103,8 @@ namespace bbtk // access a user CBB descriptor which has been previously freed if (mRootCBB) { - mRootPackage->UnRegisterBlackBox(mRootCBB->GetTypeName()); - delete mRootCBB; + mRootPackage->UnRegisterBlackBox(mRootCBB->GetTypeName()); + mRootCBB->UnReference(); } if (mRootPackage) { @@ -117,6 +119,7 @@ namespace bbtk BBTK_STRINGIFY_SYMBOL(BBTK_VERSION)); // Create user workspace mRootCBB = new ComplexBlackBoxDescriptor("workspace"); //,f); + mRootCBB->Reference(); mRootCBB->SetFactory(GetFactory()); mRootCBB->AddToAuthor("bbi (internal)"); mRootCBB->AddToDescription("User's workspace"); @@ -128,6 +131,9 @@ namespace bbtk // And in the list of open packages mOpenPackage.push_back(mRootPackage); + + GetFactory()->CheckPackages(); + bbtkDebugDecTab("Kernel",9); } //======================================================================= diff --git a/kernel/src/bbtkFactory.cxx b/kernel/src/bbtkFactory.cxx index 036231f..82bf038 100644 --- a/kernel/src/bbtkFactory.cxx +++ b/kernel/src/bbtkFactory.cxx @@ -4,8 +4,8 @@ Program: bbtk Module: $RCSfile: bbtkFactory.cxx,v $ Language: C++ -Date: $Date: 2008/04/08 06:59:30 $ -Version: $Revision: 1.31 $ +Date: $Date: 2008/04/09 11:16:57 $ +Version: $Revision: 1.32 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de @@ -748,7 +748,7 @@ namespace bbtk const DataInfo& typeout, std::string& adaptor) const { - bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<" + bbtkDebugMessageInc("Kernel",8,"Factory::FindAdaptor(<" <,<" <)"< with name + bool Factory::FindWidgetAdaptor2(const DataInfo& typein, + const DataInfo& typeout, + std::string& widget, + std::string& adaptor) const + { + bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<" + <,<" + <)"<second.mPackage->FindWidgetAdaptor(typein, + typeout, + widget); + if (b) break; + } if (!b) { - bbtkError("no "< widget adaptor available"); - } - */ - + // Look for a widget adaptor with good nature out + bbtkMessage("Kernel",5, + "*** Looking for a two pieces widget adaptor for : " + << typein << "->"<second.mPackage->GetAdaptorMap().begin(); + j!=i->second.mPackage->GetAdaptorMap().end(); + ++j) + { + if ( ( j->first.mKind == + BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR) && + //(j->first.mTypeIn == typein) && + (j->first.mTypeOut.GetNature() == typeout.GetNature() ) + ) + { + widget = j->second->GetTypeName(); + bbtkMessage("Kernel",5, + "===> Found first part : "<first.mTypeIn<<"->" + <first.mTypeOut<first.mTypeOut.GetType(), ""); + DataInfo to( typeout.GetType(), ""); + b = FindAdaptor( ti, to, adaptor ); + if (b) + { + bbtkMessage("Kernel",5, + "===> Found second part : "< No second part found"<second.mPackage->CheckBoxes(); + } + bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this + <<" ... OK"< words; SplitLine(line,words); @@ -800,6 +800,7 @@ void Interpreter::InterpretLine( const std::string& line, bool &insideComment ) case cReset : this->mExecuter->Reset(); + mFileNameHistory.clear(); break; case cInclude : @@ -1240,23 +1241,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 '"<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< mFileName; + /// 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) + std::vector mFileNameHistory; + /// Vector of names of open files as given to the include command std::vector mIncludeFileName; diff --git a/kernel/src/bbtkPackage.cxx b/kernel/src/bbtkPackage.cxx index c50abbd..b242721 100644 --- a/kernel/src/bbtkPackage.cxx +++ b/kernel/src/bbtkPackage.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkPackage.cxx,v $ Language: C++ - Date: $Date: 2008/04/08 06:59:30 $ - Version: $Revision: 1.11 $ + Date: $Date: 2008/04/09 11:16:57 $ + Version: $Revision: 1.12 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -78,7 +78,7 @@ namespace bbtk i!=mBlackBoxMap.end(); ++i) { - delete i->second; + i->second->UnReference(); } // Adaptors are also stored in the black box map : hence already deleted /* @@ -174,6 +174,8 @@ namespace bbtk } //========================================================================== + + //========================================================================== /// Returns true is the package contains /// an adaptor of input type and @@ -187,9 +189,10 @@ namespace bbtk ">::FindWidgetAdaptor(" <::RegisterBlackBox(\""<GetTypeName()<<"\")"<GetTypeName()); + if (i!=mBlackBoxMap.end()) + { + bbtkWarning("Package<"< : Trying to register box type <" + <GetTypeName()<<"> which is already in the package"); + return false; + } + mBlackBoxMap[d->GetTypeName()] = d; + d->Reference(); d->SetPackage(this); // If it is a default adaptor, also register it in the adaptors map @@ -253,7 +265,7 @@ namespace bbtk TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo(); DataInfo infoin(typein,d->GetInputDescriptor("In")->GetNature()); DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature()); - bbtkDebugMessage("Kernel",8,"LG Adaptor "< : trying to register black box <" - <GetTypeName() - <<"> as default adaptor but there is already a default adaptor registered (<" - <second->GetTypeName()<<">)"); + if (i->second->GetTypeName() != d->GetTypeName()) + { + bbtkError("Package <"< : trying to register black box <" + <GetTypeName() + <<"> as default adaptor but there is already a default adaptor registered (<" + <second->GetTypeName()<<">)"); + } } } @@ -280,6 +295,22 @@ namespace bbtk } //========================================================================== + //=================================================================== + void Package::CheckBoxes() const + { + bbtkMessage("Debug",1,"****** Checking Package "<<(void*)this + <<" ["<second->Check(true); + } + bbtkMessage("Debug",1,"****** Checking Package "<<(void*)this + <<" ["< does not contains the black box <"<"); } mBlackBoxMap.erase(i); + // Is it also in the adaptors map ? /* AdaptorMapType::iterator j = mAdaptorMap.find(name); @@ -302,6 +334,9 @@ namespace bbtk mAdaptorMap.erase(j); } */ + + i->second->UnReference(); + bbtkDebugDecTab("Kernel",8); } //========================================================================== diff --git a/kernel/src/bbtkPackage.h b/kernel/src/bbtkPackage.h index f869bcc..4c0b705 100644 --- a/kernel/src/bbtkPackage.h +++ b/kernel/src/bbtkPackage.h @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkPackage.h,v $ Language: C++ - Date: $Date: 2008/04/08 06:59:30 $ - Version: $Revision: 1.6 $ + Date: $Date: 2008/04/09 11:16:57 $ + Version: $Revision: 1.7 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See doc/license.txt or @@ -115,6 +115,41 @@ namespace bbtk const BlackBoxMapType& GetBlackBoxMap() const { return mBlackBoxMap; } BlackBoxMapType& GetBlackBoxMap() { return mBlackBoxMap; } + /// The type of key in the map of adaptor descriptors + class AdaptorKey + { + public: + AdaptorKey( const DataInfo& typein, const DataInfo& typeout, + BlackBoxDescriptor::Kind kind ) + : mTypeIn(typein), mTypeOut(typeout), mKind(kind) {} + + bool operator< ( const AdaptorKey& k ) const + { + return ( ( mKind < k.mKind ) || + ( ( mKind == k.mKind ) && + ( ( mTypeIn < k.mTypeIn ) || + ( ( mTypeIn == k.mTypeIn ) && + ( mTypeOut < k.mTypeOut ) ) ) ) ); + } + + bool operator== ( const AdaptorKey& k ) const + { + return ( ( mKind == k.mKind ) && + ( mTypeIn == k.mTypeIn ) && + ( mTypeOut == k.mTypeOut ) ); + } + DataInfo mTypeIn; + DataInfo mTypeOut; + BlackBoxDescriptor::Kind mKind; + }; + + /// The type of map of adaptor descriptors + typedef std::map< AdaptorKey, BlackBoxDescriptor*> AdaptorMapType; + + + const AdaptorMapType& GetAdaptorMap() const { return mAdaptorMap; } + + // Factories management /// Adds the factory to the set of factories which use the package void AddFactory(Factory* f) { mFactorySet.insert(f); } @@ -126,6 +161,8 @@ namespace bbtk /// Gets the set of factories which use the package (const) const std::set& GetFactorySet() const { return mFactorySet; } + void CheckBoxes() const; + private: /// The name of the package @@ -146,36 +183,14 @@ namespace bbtk /// (path relative to bbtk doc root) std::string mDocRelativeURL; - /// The map of black boxes descriptors BlackBoxMapType mBlackBoxMap; - /// The type of key in the map of adaptor descriptors - class AdaptorKey - { - public: - AdaptorKey( const DataInfo& typein, const DataInfo& typeout, - BlackBoxDescriptor::Kind kind ) - : mTypeIn(typein), mTypeOut(typeout), mKind(kind) {} - - bool operator< ( const AdaptorKey& k ) const - { - return ( ( mKind < k.mKind ) || - ( ( mKind == k.mKind ) && - ( ( mTypeIn < k.mTypeIn ) || - ( ( mTypeIn == k.mTypeIn ) && - ( mTypeOut < k.mTypeOut ) ) ) ) ); - } - - private: - DataInfo mTypeIn; - DataInfo mTypeOut; - BlackBoxDescriptor::Kind mKind; - }; - - /// The type of map of adaptor descriptors - typedef std::map< AdaptorKey, BlackBoxDescriptor*> AdaptorMapType; + public: + + + private: /// The map of adaptors descriptors AdaptorMapType mAdaptorMap; diff --git a/kernel/src/bbtkWxGUIPackageBrowser2.cxx b/kernel/src/bbtkWxGUIPackageBrowser2.cxx index d00e4de..d7349e8 100644 --- a/kernel/src/bbtkWxGUIPackageBrowser2.cxx +++ b/kernel/src/bbtkWxGUIPackageBrowser2.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $ Language: C++ -Date: $Date: 2008/04/08 06:59:30 $ -Version: $Revision: 1.3 $ +Date: $Date: 2008/04/09 11:16:57 $ +Version: $Revision: 1.4 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -722,7 +722,7 @@ namespace bbtk wxListItem kNewItem; kNewItem.SetAlign(wxLIST_FORMAT_LEFT); int nID = l->GetItemCount(); - std::cout << nID << std::endl; + // std::cout << nID << std::endl; kNewItem.SetId(nID); // kNewItem.SetMask(wxLIST_MASK_DATA); // kNewItem.SetData(d); @@ -790,7 +790,7 @@ namespace bbtk .MinimizeButton(true) .MaximizeButton(true) .Bottom() - .MinSize(wxSize(100,100)) + .MinSize(wxSize(100,300)) ); -- 2.45.1