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
bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbNew(\""<<name<<"\")"<<std::endl); \
bbCreateDescriptorIfNeeded(); \
CLASS* c = new CLASS(name); \
- bbtkDebugDecTab("Kernel",9); \
+ c->bbGetDescriptor()->Reference(); \
+ bbtkDebugDecTab("Kernel",9); \
return c; \
} \
inline bbtk::BlackBox* bbClone(const std::string& name) \
bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbClone(\""<<name<<"\")"<<std::endl); \
bbCreateDescriptorIfNeeded(); \
CLASS* c = new CLASS(*this,name); \
- bbtkDebugDecTab("Kernel",9); \
+ bbGetDescriptor()->Reference(); \
+ bbtkDebugDecTab("Kernel",9); \
return c; \
} \
bbtk::BlackBoxDescriptor* bbGetDescriptor() const \
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
/// Destruction method of a black box
void BlackBox::bbDelete()
{
- bbtkDebugMessage("Kernel",5,"BlackBox::bbDelete() ["
+ bbtkDebugMessage("Kernel",1,"BlackBox::bbDelete() ["
<<bbGetFullName()<<"]"<<std::endl);
+ bbGetDescriptor()->UnReference();
this->bbUserDelete();
}
//=========================================================================
*/
//=========================================================================
+ //=========================================================================
+ void BlackBox::Check(bool recursive)
+ {
+ bbtkMessage("Debug",1,"*** Checking Black Box "<<(void*)this<<" ["<<bbGetFullName()
+ <<"] ... OK"<<std::endl);
+ }
+ //=========================================================================
} // EO namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkBlackBox.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:29 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
std::string bbGetInputAsString( const std::string &input); //,Factory *factory);
virtual BlackBox *bbFindBlackBox(const std::string &blackboxname) { return NULL;}
+ virtual void Check(bool recursive = true);
+
protected:
//==================================================================
// PROTECTED PART : ACCESSIBLE TO THE BlackBox DEVELOPER
// PRIVATE PART
/// Default constructor is private : derived classes must use the constructor with the BlackBox's name
BlackBox() {}
+ BlackBox(const BlackBox&) {}
/// The status of the box
IOStatus bbmStatus;
/// The name of the black-box
Program: bbtk
Module: $RCSfile: bbtkBlackBoxDescriptor.cxx,v $
Language: C++
- Date: $Date: 2008/02/19 18:40:09 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.15 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
mAuthor(""),
mCategory(""),
mKind(STANDARD),
- mPackage(NULL)
+ mPackage(NULL),
+ mRefCount(0)
{
bbtkDebugMessage("Kernel",9,
"BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
}
//=========================================================================
+ //=========================================================================
+ /// Dtor
+ void BlackBoxDescriptor::UnReference()
+ {
+ bbtkDebugMessageInc("Kernel",1,
+ "BlackBoxDescriptor::UnReference() ["
+ <<mTypeName<<"] #"<<mRefCount-1<<std::endl);
+ mRefCount--;
+ if (mRefCount<=0)
+ {
+ bbtkDebugMessage("Kernel",1,"--> Destructing BlackBoxDescriptor ["<<mTypeName<<"]"<<std::endl);
+ delete this;
+ }
+ }
+ //=========================================================================
+
+ //=========================================================================
+ /// Check
+ void BlackBoxDescriptor::Check(bool) const
+ {
+
+ }
+ //=========================================================================
+
//=========================================================================
/// Adds the string to the BlackBox description
void BlackBoxDescriptor::AddToDescription( const std::string& s, bool clear)
{
bbtkDebugMessage("Kernel",9,"BlackBoxDescriptor::AddToDescription(\""<<s<<
- "\") ["<<GetTypeName()<<"]"<<std::endl);
+ "\") ["<<GetFullTypeName()<<"]"<<std::endl);
if (clear) mDescription = s;
else mDescription += s;
}
void BlackBoxDescriptor::AddToAuthor( const std::string& s, bool clear)
{
bbtkDebugMessage("Kernel",9,"BlackBoxDescriptor::AddToAuthor(\""<<s<<"\") ["
- <<GetTypeName()<<"]"<<std::endl);
+ <<GetFullTypeName()<<"]"<<std::endl);
if (clear) mAuthor = s;
else mAuthor += s;
}
void BlackBoxDescriptor::AddToCategory( const std::string& s, bool clear)
{
bbtkDebugMessage("Kernel",9,"BlackBoxDescriptor::AddToCategory(\""<<s<<"\") ["
- <<GetTypeName()<<"]"<<std::endl);
+ <<GetFullTypeName()<<"]"<<std::endl);
if (clear) mCategory = s;
else mCategory += s;
mCategory += ";";
BlackBoxDescriptor::GetInputDescriptor(const std::string & name) const
{
bbtkDebugMessageInc("Kernel",9,"BlackBoxDescriptor::GetInputDescriptor('"
- <<name<<"') ["<<GetTypeName()<<"]"<<std::endl);
+ <<name<<"') ["<<GetFullTypeName()<<"]"<<std::endl);
InputDescriptorMapType::const_iterator i;
i = mInput.find(name);
BlackBoxDescriptor::GetOutputDescriptor(const std::string & name) const
{
bbtkDebugMessageInc("Kernel",9,"BlackBoxDescriptor::GetOutputDescriptor('"
- <<name<<"') ["<<GetTypeName()<<"]"<<std::endl);
+ <<name<<"') ["<<GetFullTypeName()<<"]"<<std::endl);
OutputDescriptorMapType::const_iterator i;
i = mOutput.find(name);
//=========================================================================
void BlackBoxDescriptor::GetHelp(bool full) const
{
- bbtkDebugMessageInc("Kernel",9,"BlackBoxDescriptor::GetHelp() ["<<GetTypeName()<<"]"<<std::endl);
- if (GetPackage())
- {
- bbtkMessage("Help",1,"Black Box <"<<
- GetPackage()->GetName()<<"::"<<GetTypeName()<<">"<<std::endl);
- }
- else
- {
- bbtkMessage("Help",1,"Black Box <::"<<GetTypeName()<<">"<<std::endl);
- }
+ bbtkDebugMessageInc("Kernel",9,"BlackBoxDescriptor::GetHelp() ["<<GetFullTypeName()<<"]"<<std::endl);
+
+ bbtkMessage("Help",1,"Black Box <"<<GetFullTypeName()<<">"<<std::endl);
bbtkMessage("Help",1," " <<GetDescription()<<std::endl);
bbtkMessage("Help",1," By : " <<GetAuthor() <<std::endl);
bbtkMessage("Help",1," Categories : " <<GetCategory() <<std::endl);
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->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 )
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 )
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,
- " '"<<name
- <<" <"<<type
- <<" : "<<i->second->GetDescription()<<std::endl);
+ " '"<<name
+ <<" <"<<type
+ <<" ["<<nature
+ <<" : "<<i->second->GetDescription()<<std::endl);
}
if (mOutput.size())
bbtkMessage("Help",1," * Outputs : "<<std::endl);
std::string type(o->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,
" '"<<name
- <<" <"<<type
- <<" : "<<o->second->GetDescription()<<std::endl);
+ <<" <"<<type
+ <<" ["<<nature
+ <<" : "<<o->second->GetDescription()<<std::endl);
}
bbtkDebugDecTab("Kernel",9);
}
//=========================================================================
-
+
+ //=========================================================================
+ /// Returns the full name of the **TYPE** of the black box (+package name)
+ std::string BlackBoxDescriptor::GetFullTypeName() const
+ {
+ if (mPackage!=0) return mPackage->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() ["<<GetTypeName()<<"]"<<std::endl);
+ bbtkDebugMessageInc("Kernel",9,"BlackBoxDescriptor::InsertHtmlHelp() ["<<GetFullTypeName()<<"]"<<std::endl);
//-------------
// General info
Program: bbtk
Module: $RCSfile: bbtkBlackBoxDescriptor.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:29 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.8 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// Default ctor
BlackBoxDescriptor();
- /// Default dtor
- virtual ~BlackBoxDescriptor();
/// Creates an instance with name boxname of the BlackBox
/// of which this is the descriptor
virtual BlackBox* CreateInstance(const std::string& boxname) = 0;
/// Returns the name of the **TYPE** of the black box
const std::string& GetTypeName() const { return mTypeName; }
+ /// Returns the full name of the **TYPE** of the black box (+package name)
+ std::string GetFullTypeName() const;
+
/// Returns the description of the BlackBox
const std::string& GetDescription() const { return mDescription; }
const std::string& output_dir = "",
bool relative_link = false );
+ /// Increase ref count
+ void Reference() { mRefCount++; }
+ /// Decrease ref count and delete if no more used
+ void UnReference();
+
+ ///
+ virtual void Check(bool recursive=true) const;
+
protected:
+ /// Default dtor is protected : use UnRegister to destroy (ref counting)
+ virtual ~BlackBoxDescriptor();
+
/// Adds an input descriptor
void AddInputDescriptor( BlackBoxInputDescriptor *d )
{ mInput[d->GetName()] = d; }
InputDescriptorMapType mInput;
/// The outputs
OutputDescriptorMapType mOutput;
+
+ /// Reference counting
+ int mRefCount;
+ private:
+ BlackBoxDescriptor(const BlackBoxDescriptor&) {}
};
// class BlackBoxDescriptor
//==========================================================================
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
bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection("
<<c<<")"<<std::endl);
- std::vector<Connection*>::iterator i;
- for (i=mConnection.begin();i!=mConnection.end();++i)
- {
- if ( *i == c) break;
- }
- //= std::find(mConnection,c);
+ c->Check();
+ std::vector<Connection*>::iterator i
+ = find(mConnection.begin(),mConnection.end(),c);
if (i==mConnection.end())
{
- bbtkError("no connexion "<<c);
+ bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : connection is absent from connections list");
}
mConnection.erase(i);
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.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
bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<
(*j)->GetFullName()<<"\""<<std::endl);
- BlackBox* bbfrom = bbGetBlackBox( (*j)->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);
/// Destructor
ComplexBlackBox::~ComplexBlackBox()
{
- bbtkDebugMessageInc("Kernel",9,
+ bbtkDebugMessageInc("Kernel",1,
"ComplexBlackBox::~ComplexBlackBox() ["
<<bbGetFullName()<<"]"<<std::endl);
- bbtkDebugMessageInc("Kernel",9,"* Delete Connections"<<std::endl);
+ bbtkDebugMessageInc("Kernel",1,"* Delete Connections"<<std::endl);
ConnectionListType::iterator j;
for ( j = mConnectionList.begin(); j != mConnectionList.end(); ++j )
{
- bbtkDebugMessageInc("Kernel",9,"* Delete \""<<
+ bbtkDebugMessageInc("Kernel",1,"* Delete \""<<
(*j)->GetFullName()<<"\""<<std::endl);
delete *j;
bbtkDebugDecTab("Kernel",9);
bbtkDebugDecTab("Kernel",9);
- bbtkDebugMessageInc("Kernel",9,"* Delete Black Boxes"<<std::endl);
+ bbtkDebugMessageInc("Kernel",1,"* Delete Black Boxes"<<std::endl);
BlackBoxMapType::iterator i;
for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i )
{
- bbtkDebugMessageInc("Kernel",9,"* Delete \""<<i->first<<"\""<<std::endl);
+ bbtkDebugMessageInc("Kernel",1,"* Delete \""<<i->first<<"\""<<std::endl);
i->second->bbDelete();
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugDecTab("Kernel",1);
}
- bbtkDebugDecTab("Kernel",9);
- // bbtkDebugMessage("Kernel",9,"EO ComplexBlackBox::~ComplexBlackBox ["
- // <<bbGetFullName()<<"]"<<std::endl);
-
+ bbtkDebugDecTab("Kernel",1);
+
+ bbtkDebugMessage("Kernel",1,"EO ComplexBlackBox::~ComplexBlackBox ["
+ <<bbGetFullName()<<"]"<<std::endl);
this->bbDesallocateConnectors();
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugDecTab("Kernel",1);
}
//=======================================================================
<<bbGetFullName()<<"]"<<std::endl);
ComplexBlackBox* CBB = new ComplexBlackBox(*this,name);
-
+ bbGetDescriptor()->Reference();
+
bbtkDebugDecTab("Kernel",9);
return CBB;
"ComplexBlackBox::bbBackwardUpdate("
<<(caller?caller->GetFullName():"0")<<") ["
<<bbGetFullName()<<"]"<<std::endl);
-
+ bbtkInternalError("ComplexBlackBox::bbBackwardUpdate should never be called !");
+ /*
if (caller==0)
{
bbtkInternalError("ComplexBlackBox::bbBackwardUpdate called with caller=0");
// std::cout << "tmpout = "<<d->GetOutput()<<std::endl;
// caller->SetBlackBoxFromOutput(d->GetOutput());
//
- Connection newcaller(*caller);
- newcaller.SetBlackBoxFromOutput(d->GetOutput());
- IOStatus s1 = b->bbBackwardUpdate(&newcaller);
- newcaller.Clear();
+ //Connection newcaller(*caller);
+ //newcaller.SetBlackBoxFromOutput(d->GetOutput());
+ //IOStatus s1 = b->bbBackwardUpdate(&newcaller);
+ IOStatus s1 = b->bbBackwardUpdate(caller);
+ //newcaller.Clear();
// restore old output
// caller->SetBlackBoxFromOutput(oldout);
bbSetExecuting(false);
return s;
+ */
+ return UPTODATE;
}
//==================================================================
}
//==================================================================
+ //=========================================================================
+ /// Connects the input <name> to the connection c
+ void ComplexBlackBox::bbConnectInput( const std::string& name, Connection* c)
+ {
+ bbtkDebugMessageInc("Kernel",7,
+ "ComplexBlackBox::bbConnectInput(\""
+ <<name<<"\","<<c<<") ["
+ <<bbGetFullName()<<"]"
+ <<std::endl);
+
+ ComplexBlackBoxInputDescriptor* d = (ComplexBlackBoxInputDescriptor*)
+ bbGetDescriptor()->GetInputDescriptor(name);
+
+ BlackBox* t = bbGetBlackBox(d->GetTarget());
+ c->SetBlackBoxTo(t);
+ c->SetBlackBoxToInput(d->GetInput());
+ t->bbConnectInput(d->GetInput(),c);
+
+ bbtkMessage("Debug",1,"ComplexBlackBox["<<bbGetFullName()<<"]::bbConnectInput : "
+ <<c->GetFullName()<<std::endl);
+
+ bbtkDebugDecTab("Kernel",7);
+ }
+ //=========================================================================
+
+
+ //=========================================================================
+ /// Connects the output <name> to the connection c
+ void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection* c)
+ {
+ bbtkDebugMessageInc("Kernel",7,
+ "ComplexBlackBox::bbConnectOutput(\""
+ <<name<<"\","<<c<<") ["
+ <<bbGetFullName()<<"]"<<std::endl);
+
+ ComplexBlackBoxOutputDescriptor* d = (ComplexBlackBoxOutputDescriptor*)
+ bbGetDescriptor()->GetOutputDescriptor(name);
+
+ BlackBox* t = bbGetBlackBox(d->GetTarget());
+ c->SetBlackBoxFrom(t);
+ c->SetBlackBoxFromOutput(d->GetOutput());
+ t->bbConnectOutput(d->GetOutput(),c);
+
+ bbtkMessage("Debug",1,"ComplexBlackBox["<<bbGetFullName()<<"]::bbConnectOutput : "
+ <<c->GetFullName()<<std::endl);
+
+ bbtkDebugDecTab("Kernel",7);
+ }
+ //=========================================================================
+
+
//==================================================================
/// Adds the black box to the complex box
void ComplexBlackBox::bbAddBlackBox( BlackBox* b)
}
//=======================================================================
*/
+
+ //=======================================================================
+ void ComplexBlackBox::Check(bool recursive)
+ {
+ bbtkMessage("Debug",1,"**** Checking Complex Black Box "<<(void*)this
+ <<" ["<<bbGetFullName()<<"]"<<std::endl);
+
+ BlackBoxMapType::const_iterator i;
+ for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i )
+ {
+ i->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
+ <<" ["<<bbGetFullName()<<"] ... OK"<<std::endl);
+
+ }
+ //=======================================================================
+
}
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.h,v $
Language: C++
- Date: $Date: 2008/01/22 15:02:00 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.2 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
// PUBLIC PART : ACCESSIBLE TO THE END-USER
/// Returns the pointer on the box' descriptor
BlackBoxDescriptor* bbGetDescriptor() const { return mDescriptor; }
+ /// Returns a pointer on a new instance with name <name>
+ //BlackBox* bbNew(const std::string& name);
/// Returns a pointer on a clone of the box with name <name>
BlackBox* bbClone(const std::string& name);
void* data,
bool setModified = true);
- ~ComplexBlackBox();
+ /// Connects the input <name> to the connection c
+ virtual void bbConnectInput( const std::string& name, Connection* c);
+ /// Connects the output <name> to the connection c
+ virtual void bbConnectOutput( const std::string& name, Connection* c);
BlackBox* bbGetBlackBox( const std::string& name );
virtual BlackBox *bbFindBlackBox(const std::string &blackboxname);
+ void Check(bool recursive=true);
protected:
//==================================================================
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:
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
SetTypeName(name);
AddToCategory("complex box");
mPrototype = new ComplexBlackBox(name+std::string("Prototype"),this);
+ // this->Reference();
bbtkDebugDecTab("Kernel",9);
}
//=======================================================================
/// Default dtor
ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor()
{
- bbtkDebugMessageInc("Kernel",9,"ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
+ bbtkDebugMessageInc("Kernel",1,"ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
delete mPrototype;
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugMessage("Kernel",1,"EO ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
+ bbtkDebugDecTab("Kernel",1);
}
//=======================================================================
+ //=========================================================================
+ /// Check
+ void ComplexBlackBoxDescriptor::Check(bool recursive) const
+ {
+ mPrototype->Check(recursive);
+ }
+ //=========================================================================
//=======================================================================
/// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
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)
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();
}
}
//
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,
- " '"<<name
- <<" <"<<type
- <<" : "<<i->second->GetDescription()<<std::endl);
+ " '"<<name
+ <<" <"<<type
+ <<" ["<<nature
+ <<" : "<<i->second->GetDescription()<<std::endl);
}
if (full)
{
std::string type(o->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,
- " '"<<name
+ " '"<<name
<<" <"<<type
+ <<" ["<<nature
<<" : "<<o->second->GetDescription()<<std::endl);
}
}
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBoxDescriptor.h,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
friend class ComplexBlackBox;
/// Default ctor with name
ComplexBlackBoxDescriptor(const std::string& name);
- /// Default dtor
+ protected:
+ /// Default dtor
~ComplexBlackBoxDescriptor();
-
+ public:
/// Sets the factory used
void SetFactory(Factory* f) { mFactory = f; }
/// Gets the factory used
bool relative_link = false );
+ ///
+ virtual void Check(bool recursive=true) const;
private:
/// Default ctor is private (must have name and factory)
Program: bbtk
Module: $RCSfile: bbtkConnection.cxx,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.6 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
<<to->bbGetName()<<"\",\""<<input<<"\")"
<<std::endl);
- mFrom = from;
- mTo = to;
- mInput = input;
- mOutput = output;
+ mFrom = mOriginalFrom = from;
+ mTo = mOriginalTo = to;
+ mInput = mOriginalInput = input;
+ mOutput = mOriginalOutput = output;
if (! from->bbHasOutput(output) )
void Connection::Clear()
{
- mFrom = 0;
- mTo = 0;
+ mFrom = mOriginalFrom = 0;
+ mTo = mOriginalTo = 0;
mAdaptor = 0;
}
bbtkDebugMessageInc("Kernel",7,
"Connection::~Connection() ["
<<GetFullName()<<"]"<<std::endl);
+ std::cout << "~Connection() " << GetFullName() << std::endl;
- if (mFrom) mFrom->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);
}
//==================================================================
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<<" ["<<GetFullName()<<"]"
+ <<std::endl);
+ if (mFrom==0)
+ {
+ bbtkMessage("Debug",2," - From = 0"<<std::endl);
+ }
+ else
+ {
+ bbtkMessage("Debug",2," - From : "<<mFrom->bbGetFullName()<<std::endl);
+ if (!mFrom->bbHasOutput(mOutput))
+ {
+ bbtkError(mFrom->bbGetFullName()<<" does not have output '"
+ <<mOutput<<"'");
+ }
+ bbtkMessage("Debug",2," - From : Output '"<<mOutput<<"' exists"<<std::endl);
+ BlackBox::OutputConnectorMapType::const_iterator i
+ = mFrom->bbGetOutputConnectorMap().find(mOutput);
+ if (i== mFrom->bbGetOutputConnectorMap().end())
+ {
+ bbtkError(mFrom->bbGetFullName()<<" output '"
+ <<mOutput<<"' is not in OutputConnectorMap");
+ }
+ bbtkMessage("Debug",2," - From : Output '"<<mOutput
+ <<"' is in OutputConnectorMap"<<std::endl);
+
+ std::vector< Connection * >::const_iterator j;
+ j = find(i->second->GetConnectionVector().begin(),
+ i->second->GetConnectionVector().end(),
+ this);
+ if (j==i->second->GetConnectionVector().end())
+ {
+ bbtkError("Connection ["<<GetFullName()<<"] : "
+ <<" OutputConnector '"
+ <<mOutput<<"' of "<<mFrom->bbGetFullName()
+ <<" does not point to this connection");
+
+ }
+ bbtkMessage("Debug",2," - From : This connection is in OutputConnector connection vector"<<std::endl);
+ bbtkMessage("Debug",1," * Box from : Check successfull"<<std::endl);
+ }
+
+ if (mTo==0)
+ {
+ bbtkMessage("Debug",2," - To = 0"<<std::endl);
+ }
+ else
+ {
+ bbtkMessage("Debug",2," - To : "<<mTo->bbGetName()<<std::endl);
+ std::cout << mTo << std::endl;
+ std::cout << mTo->bbGetDescriptor() << std::endl;
+ std::cout << mTo->bbGetDescriptor()->GetTypeName() << std::endl;
+ mTo->bbGetFullName();
+ bbtkMessage("Debug",2," - To : "<<mTo->bbGetFullName()<<std::endl);
+ if (!mTo->bbHasInput(mInput))
+ {
+ bbtkError(mTo->bbGetFullName()<<" does not have input '"
+ <<mInput<<"'");
+ }
+ bbtkMessage("Debug",2," - To : Input '"<<mInput<<"' exists"<<std::endl);
+ BlackBox::InputConnectorMapType::const_iterator i
+ = mTo->bbGetInputConnectorMap().find(mInput);
+ if (i== mTo->bbGetInputConnectorMap().end())
+ {
+ bbtkError(mTo->bbGetFullName()<<" input '"
+ <<mInput<<"' is not in InputConnectorMap");
+ }
+ bbtkMessage("Debug",2," - To : Input '"<<mInput
+ <<"' is in InputConnectorMap"<<std::endl);
+
+ if (i->second->GetConnection()==0)
+ {
+ bbtkError("Connection "<<GetFullName()<<" : "
+ <<" InputConnector '"
+ <<mInput<<"' of "<<mTo->bbGetFullName()
+ <<" does not point to this connection");
+
+ }
+ bbtkMessage("Debug",2," - To : This connection is in InputConnector connection vector"<<std::endl);
+ bbtkMessage("Debug",1," * Box to : Check successfull"<<std::endl);
+
+ }
+ }
+ //==================================================================
}// namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkConnection.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.5 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
virtual void SetModifiedStatus();
std::string GetFullName() const;
+ /// Returns the original initial black box of the connection
+ BlackBox* GetOriginalBlackBoxFrom() const { return mOriginalFrom; }
+ /// Returns the origianl final black box of the connection
+ BlackBox* GetOriginalBlackBoxTo() const { return mOriginalTo; }
+ /// Returns the original output of the initial black box of the connection
+ const std::string& GetOriginalBlackBoxFromOutput() const { return mOriginalOutput; }
+ /// Returns the original input of the final black box of the connection
+ const std::string& GetOriginalBlackBoxToInput() const { return mOriginalInput; }
+
/// Returns the initial black box of the connection
BlackBox* GetBlackBoxFrom() const { return mFrom; }
/// Returns the final black box of the connection
/// Returns the input of the final black box of the connection
const std::string& GetBlackBoxToInput() const { return mInput; }
+ /// Sets the initial black box of the connection
+ void SetBlackBoxFrom(BlackBox* b) { mFrom = b; }
+ /// Sets the final black box of the connection
+ void SetBlackBoxTo(BlackBox* b) { mTo = b; }
/// Sets the output of the initial black box of the connection
void SetBlackBoxFromOutput(const std::string& o) { mOutput = o; }
+ /// Sets the input of the final black box of the connection
+ void SetBlackBoxToInput(const std::string& o) { mInput = o; }
+
+ /// Checks that the connection is ok (throws error if not)
+ void Check() const;
+
protected:
/// Black box origin of the connection
BlackBox* mFrom;
+ BlackBox* mOriginalFrom;
/// Output of mFrom which is connected
std::string mOutput;
+ std::string mOriginalOutput;
/// Output connector of mFrom which is connected
// BlackBoxOutputConnector* mOutputConnector;
/// Black box destination of the connection
BlackBox* mTo;
+ BlackBox* mOriginalTo;
/// Input of mTo which is connected
std::string mInput;
+ std::string mOriginalInput;
/// Input connector of mTo which is connected
// BlackBoxInputConnector* mInputConnector;
/// Adaptor black box if needed
Program: bbtk
Module: $RCSfile: bbtkExecuter.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.16 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.17 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
if (mRootCBB)
{
mRootPackage->UnRegisterBlackBox("workspace");
- delete mRootCBB;
+ mRootCBB->UnReference();
}
if (mRootPackage)
{
{
bbtkDebugMessageInc("Kernel",9,"Executer::Reset()" <<std::endl);
+ GetFactory()->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
// 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)
{
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");
// And in the list of open packages
mOpenPackage.push_back(mRootPackage);
+
+ GetFactory()->CheckPackages();
+
bbtkDebugDecTab("Kernel",9);
}
//=======================================================================
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
const DataInfo& typeout,
std::string& adaptor) const
{
- bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
+ bbtkDebugMessageInc("Kernel",8,"Factory::FindAdaptor(<"
<<typein<<">,<"
<<typeout<<">)"<<bbtkendl);
adaptor);
if (b) break;
}
- /*
+ bbtkDebugDecTab("Kernel",7);
+ return b;
+ }
+ //===================================================================
+
+ //===================================================================
+ /// Creates an instance of a black box of type <type> with name <name>
+ bool Factory::FindWidgetAdaptor2(const DataInfo& typein,
+ const DataInfo& typeout,
+ std::string& widget,
+ std::string& adaptor) const
+ {
+ bbtkDebugMessageInc("Kernel",8,"Factory::FindWidgetAdaptor(<"
+ <<typein<<">,<"
+ <<typeout<<">)"<<bbtkendl);
+
+ bool b = false;
+ adaptor = widget = "";
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ b = i->second.mPackage->FindWidgetAdaptor(typein,
+ typeout,
+ widget);
+ if (b) break;
+ }
if (!b)
{
- bbtkError("no "<<typein<<" to "<<typeout
- <<"> widget adaptor available");
- }
- */
-
+ // Look for a widget adaptor with good nature out
+ bbtkMessage("Kernel",5,
+ "*** Looking for a two pieces widget adaptor for : "
+ << typein << "->"<<typeout<<std::endl);
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ Package::AdaptorMapType::const_iterator j;
+ for (j=i->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 : "<<widget
+ << " "<<j->first.mTypeIn<<"->"
+ <<j->first.mTypeOut<<std::endl);
+ DataInfo ti( j->first.mTypeOut.GetType(), "");
+ DataInfo to( typeout.GetType(), "");
+ b = FindAdaptor( ti, to, adaptor );
+ if (b)
+ {
+ bbtkMessage("Kernel",5,
+ "===> Found second part : "<<adaptor
+ <<std::endl);
+ break;
+ }
+ else
+ {
+ bbtkMessage("Kernel",5,
+ "===> No second part found"<<std::endl);
+ }
+ }
+ }
+ if (b) break;
+ }
+ }
bbtkDebugDecTab("Kernel",7);
return b;
}
}
//===================================================================
+ //===================================================================
+ void Factory::CheckPackages() const
+ {
+ bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
+ <<std::endl);
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ i->second.mPackage->CheckBoxes();
+ }
+ bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
+ <<" ... OK"<<std::endl);
+ }
+ //===================================================================
+
//===================================================================
void Factory::WriteDotFilePackagesList(FILE *ff)
{
Program: bbtk
Module: $RCSfile: bbtkFactory.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.13 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
const DataInfo& typeout,
std::string& adaptor) const;
+ bool FindWidgetAdaptor2(const DataInfo& typein,
+ const DataInfo& typeout,
+ std::string& widget,
+ std::string& adaptor) const;
+
Connection* NewConnection(BlackBox* from,
const std::string& output,
BlackBox* to,
void Reset();
+ void CheckPackages() const;
+
typedef enum
{
Packages,
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/09 11:16:57 $
+ Version: $Revision: 1.59 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
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);
case cReset :
this->mExecuter->Reset();
+ mFileNameHistory.clear();
break;
case cInclude :
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;iStrScript<sizeVecStricpt;iStrScript++)
- {
- if (mFileName[iStrScript] == fullPathScriptName )
- {
- okScriptExist=true;
- } // if
- } // for
-
- if (find(mFileName.begin(),mFileName.end(),fullPathScriptName)!=mFileName.end())
-// if (okScriptExist==true)
+ Utilities::replace( fullPathScriptName ,
+ INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);
+
+ if (find(mFileNameHistory.begin(),
+ mFileNameHistory.end(),
+ fullPathScriptName)!=mFileNameHistory.end())
{
- bbtkMessage("Interpreter",1,"file '"<<fullPathScriptName
- <<"' already open : I do not open it once more to prevent recursive inclusion"<<std::endl);
return;
}
mFile.push_back(s);
mFileName.push_back(fullPathScriptName);
+ mFileNameHistory.push_back(fullPathScriptName);
mIncludeFileName.push_back(includeScriptName);
mLine.push_back(0);
while (mFile.size() != 0)
{
CloseCurrentFile();
- /*
- mFile.back()->close();
- delete mFile.back();
- mFile.pop_back();
- bbtkDebugMessage("Interpreter",9,
- " Closing file '"<<mFileName.back()<<"'"<<std::endl);
- mFileName.pop_back();
- mIncludeFileName.pop_back();
- mLine.pop_back();
-*/
}
bbtkDebugMessage("Interpreter",9,"EO Interpreter::CloseAllFiles()"
<<std::endl);
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 "<<adaptor<<" "<<i->first<<std::endl;
- // command to create the output
- (*s) << " output "<<i->first<<" "
- <<i->first<<".Out "<<i->first<<std::endl;
- // <<" Output of the widget which allows to set "
- //<i->first<<"'"<<std::endl;
// 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 \""
+ <<box->bbGetInputAsString(i->first)<<"\""
+ << std::endl;
+ // store the input name
+ in.push_back(i->first);
(*s) << " connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
+ //<i->first<<"'"<<std::endl;
(*s) << " connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
}
+ // try to find a two pieces adaptor
+ else if (F->FindWidgetAdaptor2(DataInfo(d->GetTypeInfo(),""),
+ d->GetDataInfo(),
+ widget,adaptor) )
+ {
+ // command to create the widget
+ (*s) << " new "<<widget<<" "<<i->first<<"Widget"<<std::endl;
+ // command to create the adaptor
+ (*s) << " new "<<adaptor<<" "<<i->first<<std::endl;
+ // connect the two
+ (*s) << " connect "<<i->first<<"Widget.Out "
+ <<i->first<<".In"<<std::endl;
+ // 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 \""
+ <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
+ // store the input name
+ in.push_back(i->first);
+ (*s) << " connect "<<i->first<<"Widget.Widget layout.Widget"<<in.size()<<std::endl;
+ //<i->first<<"'"<<std::endl;
+ (*s) << " connect "<<i->first<<"Widget.BoxChange change.In"<<in.size()<<std::endl;
+
+ }
// try to find an adaptor from string
// If found then can create a text input which
// will be automatically adapted
d->GetDataInfo(),
adaptor))
{
- // store the input name
- in.push_back(i->first);
// command to create the adaptor
(*s) << " new InputText "<<i->first<<std::endl;
- // command to create the output
- (*s) << " output "<<i->first<<" "
- <<i->first<<".Out "<<i->first<<std::endl;
- // <<" Output of the widget which allows to set "
- //<i->first<<"'"<<std::endl;
// 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 \""
+ <<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
+ // store the input name
+ in.push_back(i->first);
(*s) << " connect "<<i->first<<".Widget layout.Widget"<<in.size()<<std::endl;
+ //<i->first<<"'"<<std::endl;
(*s) << " connect "<<i->first<<".BoxChange change.In"<<in.size()<<std::endl;
- }
+ }
+ else
+ {
+ widok = false;
+ }
+ if (widok)
+ {
+ // command to create the output
+ (*s) << " output "<<i->first<<" "
+ <<i->first<<".Out "<<i->first<<std::endl;
+ // <<" Output of the widget which allows to set "
+
+ }
}
// Inputs for window properties
(*s) << " input WinTitle layout.WinTitle Title"<<std::endl;
Program: bbtk
Module: $RCSfile: bbtkInterpreter.h,v $ $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.24 $
+ Date: $Date: 2008/04/09 11:16:57 $
+ Version: $Revision: 1.25 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
/// Vector of names of open files with full path (as open)
std::vector<std::string> 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<std::string> mFileNameHistory;
+
/// Vector of names of open files as given to the include command
std::vector<std::string> mIncludeFileName;
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
i!=mBlackBoxMap.end();
++i)
{
- delete i->second;
+ i->second->UnReference();
}
// Adaptors are also stored in the black box map : hence already deleted
/*
}
//==========================================================================
+
+
//==========================================================================
/// Returns true is the package contains
/// an adaptor of input type <typein> and
">::FindWidgetAdaptor("
<<typein<<","
<<typeout<<")"<<bbtkendl);
-
+
AdaptorKey key(typein,typeout,
BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR);
+ // First try to find a single widget adaptor
AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
if (i == mAdaptorMap.end())
{
{
bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
+ BlackBoxMapType::iterator i = mBlackBoxMap.find(d->GetTypeName());
+ if (i!=mBlackBoxMap.end())
+ {
+ bbtkWarning("Package<"<<GetName()<<"> : Trying to register box type <"
+ <<d->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
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 "<<infoin<<" to "<<infoout
+ bbtkDebugMessage("Kernel",9,"Adaptor "<<infoin<<" to "<<infoout
<<" - kind="<<d->GetKind()<<std::endl);
AdaptorKey key(infoin,infoout,d->GetKind());
// If already an adaptor registered : error
else
{
- bbtkError("Package <"<<GetName()<<
- "> : trying to register black box <"
- <<d->GetTypeName()
- <<"> as default adaptor but there is already a default adaptor registered (<"
- <<i->second->GetTypeName()<<">)");
+ if (i->second->GetTypeName() != d->GetTypeName())
+ {
+ bbtkError("Package <"<<GetName()<<
+ "> : trying to register black box <"
+ <<d->GetTypeName()
+ <<"> as default adaptor but there is already a default adaptor registered (<"
+ <<i->second->GetTypeName()<<">)");
+ }
}
}
}
//==========================================================================
+ //===================================================================
+ void Package::CheckBoxes() const
+ {
+ bbtkMessage("Debug",1,"****** Checking Package "<<(void*)this
+ <<" ["<<GetName()<<"]"<<std::endl);
+ BlackBoxMapType::const_iterator i;
+ for (i=mBlackBoxMap.begin();
+ i!=mBlackBoxMap.end();
+ ++i)
+ {
+ i->second->Check(true);
+ }
+ bbtkMessage("Debug",1,"****** Checking Package "<<(void*)this
+ <<" ["<<GetName()<<"] ... OK"<<std::endl);
+ }
+ //===================================================================
//==========================================================================
/// UnRegisters a black box descriptor from the package
bbtkError("UnRegister : The package <"<<GetName()<<"> does not contains the black box <"<<name<<">");
}
mBlackBoxMap.erase(i);
+
// Is it also in the adaptors map ?
/*
AdaptorMapType::iterator j = mAdaptorMap.find(name);
mAdaptorMap.erase(j);
}
*/
+
+ i->second->UnReference();
+
bbtkDebugDecTab("Kernel",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
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); }
/// Gets the set of factories which use the package (const)
const std::set<Factory*>& GetFactorySet() const { return mFactorySet; }
+ void CheckBoxes() const;
+
private:
/// The name of the package
/// (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;
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
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);
.MinimizeButton(true)
.MaximizeButton(true)
.Bottom()
- .MinSize(wxSize(100,100))
+ .MinSize(wxSize(100,300))
);