* All bbtk major objects are now smart pointed (using boost::shared_ptr) and auto-destruct when no more used. They inherit from bbtk::Object with pose the basis for the mechanism...
bool OnCmdLineParsed(wxCmdLineParser& parser);
void Run(bbtk::Interpreter*);
- bbtk::Executer* mExecuter;
+ bbtk::Executer::Pointer mExecuter;
// int argc;
// std::vector<std::string> argv;
bool command;
bbtk::Wx::CreateInvisibleTopWindow();
try {
- mExecuter = new bbtk::Executer();
+ mExecuter = bbtk::Executer::New();
mExecuter->SetInputs(param_map);
if (help) mExecuter->SetNoExecMode(true);
mess += bbtk::std2wx ( e.GetMessage() );
wxMessageBox(mess,_T("Error"),wxOK | wxICON_ERROR);
bbtk::Wx::GetTopWindow()->Close();
- delete mExecuter;
return false;
}
if (help || !bbtk::Wx::IsSomeWindowAlive())
mFile << "{\n";
// Interface
- mFile << " BBTK_USER_BLACK_BOX_INTERFACE("
+ mFile << " BBTK_BLACK_BOX_INTERFACE("
<< mName << ","
<< mParentBlackBox << ");\n";
mFile << "{\n";
// Interface
- mFile << " BBTK_USER_BLACK_BOX_INTERFACE("
+ mFile << " BBTK_BLACK_BOX_INTERFACE("
<< mName << "Generic,bbtk::AtomicBlackBox);\n";
// Inputs
if (mTemplateParam.size()>0)
{
// Implementation
- mFile << "BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION("
+ mFile << "BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION("
<< mName << ","
<< mParentBlackBox << ");\n";
if (mGeneric)
{
// Implementation
- mFile << "BBTK_USER_BLACK_BOX_IMPLEMENTATION("
+ mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
<< mName << "Generic,bbtk::AtomicBlackBox);\n";
// Package
mFile << "BBTK_ADD_BLACK_BOX_TO_PACKAGE("
<< mName << ")\n";
// Implementation
- mFile << "BBTK_USER_BLACK_BOX_IMPLEMENTATION("
+ mFile << "BBTK_BLACK_BOX_IMPLEMENTATION("
<< mName << ","
<< mParentBlackBox << ");\n";
}
//==========================================================================
// WITH WX
//==========================================================================
+#include "bbtkObject.h"
#include "bbtkInterpreter.h"
#include "bbtkWxBlackBox.h"
#include "bbtkWxGUIConsole.h"
static const wxCmdLineEntryDesc cmdLineDesc[] =
{
+ { wxCMD_LINE_SWITCH, _T("M"), _T("Memory debug"), _T("Display memory debug message on exit") },
{ wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Debug messages on (message All 9)") },
{ wxCMD_LINE_SWITCH, _T("c"), _T("command"), _T("turn to command line mode after file(s) processing") },
{ wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet") },
bool OnInit( );
int OnExit() {
// std::cout << "wxBBIApp::OnExit()"<<std::endl;
+ // bbtk::Object::PrintObjectListInfo();
return true; }
void OnInitCmdLine(wxCmdLineParser& parser);
bool OnCmdLineParsed(wxCmdLineParser& parser);
bool wxBBIApp::OnCmdLineParsed(wxCmdLineParser& parser)
{
+ if (parser.Found(_T("M")))
+ {
+ bbtk::StaticInitTime::PrintObjectListInfo = true;
+ }
+
debug = ( parser.Found(_T("d")) );
quiet = ( parser.Found(_T("q")) );
help = ( parser.Found(_T("h")) );
std::string file,path;
file = bbtk::Utilities::ExtractScriptName(argv[1],path);
file += ".h";
- bbtk::Interpreter* I = new bbtk::Interpreter(file);
+ bbtk::Interpreter::Pointer I = bbtk::Interpreter::New(file);
I->SetThrow(true);
e.Print();
}
- delete I;
-
return 0;
}
ENDIF(BUILD_BBTK_DOC)
#-----------------------------------------------------------------------------
+
+#-----------------------------------------------------------------------------
+# BOOST C++
+OPTION(BBTK_USE_BOOST "Use the boost C++ library" ON)
+IF(BBTK_USE_BOOST)
+ADD_DEF( _USE_BOOST_ )
+ENDIF(BBTK_USE_BOOST)
+#-----------------------------------------------------------------------------
+
# SOURCES DIR MUST ALSO BE IN INCLUDE DIRS FOR FILES COMPILED IN BINARY DIR
# WHICH NEED TO INCLUDE OTHER FILES OF THE PACKAGE
INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/kernel/src )
+INCLUDE_DIRECTORIES( ${PROJECT_SOURCE_DIR}/kernel/src/ThirdParty )
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# collaboration diagrams in a style similar to the OMG's Unified Modeling
# Language.
-UML_LOOK = YES
+UML_LOOK = NO
# If set to YES, the inheritance and collaboration graphs will show the
# relations between templates and their instances.
# Symbols must be exported (Windows)
ADD_DEF(BBTK_EXPORT_SYMBOLS)
-INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty)
ADD_DEFINITIONS(-DCHECKBOXVIEW=1)
#-----------------------------------------------------------------------------
# Sources files
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:29 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:14 $
+ 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
AtomicBlackBox::AtomicBlackBox(const std::string &name, bool alloc)
: BlackBox(name)
{
- bbtkDebugMessageInc("Kernel",7,
- "AtomicBlackBox::AtomicBlackBox(\""
- <<name<<"\")"<<std::endl);
- bbtkDebugDecTab("Kernel",7);
+ bbtkDebugMessage("object",3,
+ "==> AtomicBlackBox::AtomicBlackBox(\""
+ <<name<<"\")"<<std::endl);
+ bbtkDebugMessage("object",3,
+ "<== AtomicBlackBox::AtomicBlackBox(\""
+ <<name<<"\")"<<std::endl);
}
//=========================================================================
bool alloc)
: BlackBox(from,name)
{
- bbtkDebugMessageInc("Kernel",7,
- "AtomicBlackBox::AtomicBlackBox("
- <<from.bbGetFullName()<<",\""
- <<name<<"\")"<<std::endl);
- bbtkDebugDecTab("Kernel",7);
+ bbtkDebugMessage("object",3,
+ "==>AtomicBlackBox::AtomicBlackBox("
+ <<from.bbGetFullName()<<",\""
+ <<name<<"\")"<<std::endl);
+ bbtkDebugMessage("object",3,
+ "<==AtomicBlackBox::AtomicBlackBox("
+ <<from.bbGetFullName()<<",\""
+ <<name<<"\")"<<std::endl);
}
//=========================================================================
/// Destructor
AtomicBlackBox::~AtomicBlackBox()
{
- bbtkDebugMessage("Kernel",7,"AtomicBlackBox::~AtomicBlackBox()"
- <<std::endl);
+ bbtkDebugMessage("object",3,"==> AtomicBlackBox::~AtomicBlackBox()"
+ <<std::endl);
+ bbtkDebugMessage("object",3,"<== AtomicBlackBox::~AtomicBlackBox()"
+ <<std::endl);
}
//=========================================================================
-
+
//=========================================================================
/// Main processing method of the box.
- IOStatus AtomicBlackBox::bbBackwardUpdate( Connection* caller )
+ IOStatus AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
{
bbtkDebugMessageInc("Process",1,
"=> AtomicBlackBox::bbBackwardUpdate("
bbtkDebugDecTab("Data",7);
}
//=========================================================================
+
+
+
+ //==========================================================================
+ std::string AtomicBlackBox::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+ size_t AtomicBlackBox::GetObjectSize() const
+ {
+ return sizeof(*this);
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t AtomicBlackBox::GetObjectRecursiveSize() const
+ {
+ size_t s = GetObjectSize();
+ return s;
+ }
+ //==========================================================================
+
+
}
// EO namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBox.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:29 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:14 $
+ 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
{
//==================================================================
public:
+ //==================================================================
+ bbtk::BlackBoxDescriptor::Pointer bbGetDescriptor() const
+ {
+ return bbmDescriptorPointer;
+ }
//==================================================================
/// Gets the output Data of a given label
Data bbGetOutput( const std::string &label );
//==================================================================
//==================================================================
- /// Destructor
- virtual ~AtomicBlackBox();
+ std::string GetObjectInfo() const;
+ size_t GetObjectSize() const;
+ size_t GetObjectRecursiveSize() const;
//==================================================================
//==================================================================
AtomicBlackBox(AtomicBlackBox& from, const std::string &name,
bool alloc = true);
//==================================================================
+ //==================================================================
+ /// Destructor
+ virtual ~AtomicBlackBox();
+ //==================================================================
+
+ //==================================================================
+ protected:
+ virtual void bbLockDescriptor() = 0;
+ // private:
+ // virtual void bbReleaseDescriptor();
+ //==================================================================
public:
//==================================================================
/// - updates its inputs by calling bbUpdateInputs (which recursively calls bbBackwardUpdate on upstream boxes)
/// - calls bbProcess which here simply calls the user callback bbUserProcess which does the actual processing.
/// bbProcess is overloaded in WxBlackBox to handle widget creation and show
- virtual IOStatus bbBackwardUpdate(Connection* caller);
+ virtual IOStatus bbBackwardUpdate(Connection::Pointer caller);
//==================================================================
//==================================================================
AtomicBlackBox() : BlackBox("") {}
//==================================================================
+ protected:
+ //==================================================================
+ // The pointer on the descriptor
+ bbtk::BlackBoxDescriptor::Pointer bbmDescriptorPointer;
+ //==================================================================
};
// Class AtomicBlackBox
--- /dev/null
+#include "bbtkAtomicBlackBoxDescriptor.h"
+#include "bbtkBlackBox.h"
+#include "bbtkPackage.h"
+
+namespace bbtk
+{
+ AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()
+ {
+ bbtkDebugMessage("object",3,"==> AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+ // Creates the input 'BoxProcessMode'
+ AddInputDescriptor
+ (new
+ bbtk::AtomicBlackBoxInputDescriptor
+ (typeid(AtomicBlackBoxDescriptor),
+ "BoxProcessMode",
+ "Sets the processing mode of the box (Pipeline | Always | Reactive)",
+ "",
+ new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbGetInputBoxProcessMode),
+ new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbSetInputBoxProcessMode) ) );
+ // Creates the input 'BoxExecute'
+ AddInputDescriptor
+ (new
+ bbtk::AtomicBlackBoxInputDescriptor
+ (typeid(AtomicBlackBoxDescriptor),
+ "BoxExecute",
+ "Any signal received by this input executes the box",
+ "",
+ new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetInputBoxExecute),
+ new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetInputBoxExecute) ) );
+ // Creates the output 'BoxChange'
+ AddOutputDescriptor
+ (new
+ bbtk::AtomicBlackBoxOutputDescriptor
+ (typeid(AtomicBlackBoxDescriptor),
+ "BoxChange",
+ "Signal modifications of the box",
+ "",
+ new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetOutputBoxChange),
+ new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetOutputBoxChange) ) );
+ //
+ AddToCategory("atomic box");
+ bbtkDebugMessage("object",3,"<== AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+ }
+ //===================================================================
+
+ AtomicBlackBoxDescriptor::~AtomicBlackBoxDescriptor()
+ {
+ bbtkDebugMessage("object",3,"==> AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+ bbtkDebugMessage("object",3,"<== AtomicBlackBoxDescriptor::AtomicBlackBoxDescriptor()"<<std::endl);
+ }
+}// namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBoxDescriptor.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:29 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:14 $
+ 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
class BBTK_EXPORT AtomicBlackBoxDescriptor : public bbtk::BlackBoxDescriptor
{
public:
- AtomicBlackBoxDescriptor()
- {
- // Creates the input 'BoxProcessMode'
- AddInputDescriptor
- (new
- bbtk::AtomicBlackBoxInputDescriptor
- (typeid(AtomicBlackBoxDescriptor),
- "BoxProcessMode",
- "Sets the processing mode of the box (Pipeline | Always | Reactive)",
- "",
- new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbGetInputBoxProcessMode),
- new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,std::string,std::string>(&BlackBox::bbSetInputBoxProcessMode) ) );
- // Creates the input 'BoxExecute'
- AddInputDescriptor
- (new
- bbtk::AtomicBlackBoxInputDescriptor
- (typeid(AtomicBlackBoxDescriptor),
- "BoxExecute",
- "Any signal received by this input executes the box",
- "",
- new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetInputBoxExecute),
- new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetInputBoxExecute) ) );
- // Creates the output 'BoxChange'
- AddOutputDescriptor
- (new
- bbtk::AtomicBlackBoxOutputDescriptor
- (typeid(AtomicBlackBoxDescriptor),
- "BoxChange",
- "Signal modifications of the box",
- "",
- new bbtk::AtomicBlackBoxTGetFunctor<BlackBox,Void,Void>(&BlackBox::bbGetOutputBoxChange),
- new bbtk::AtomicBlackBoxTSetFunctor<BlackBox,Void,Void>(&BlackBox::bbSetOutputBoxChange) ) );
- //
- AddToCategory("atomic box");
- }
+ /// Releases the descriptor
+ // virtual void Release(bool release_package = true);
+
+ protected:
+ AtomicBlackBoxDescriptor();
+ virtual ~AtomicBlackBoxDescriptor();
+ virtual AtomicBlackBoxDescriptor::Pointer GetInstance() const = 0;
+
};
-
}
// namespace bbtk
#endif
Program: bbtk
Module: $RCSfile: bbtkAtomicBlackBoxMacros.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:56 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
//============================================================================
/// Declares the standard interface of a AtomicBlackBox
/// (ctor, New, descriptor related methods)
-#define BBTK_USER_BLACK_BOX_INTERFACE(CLASS,PARENT) \
+#define BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT) \
+ BBTK_OBJECT_MINIMAL_INTERFACE; \
private: \
- inline static void bbCreateDescriptorIfNeeded(); \
protected: \
CLASS(const std::string& name, bool allocate_connectors = true); \
- CLASS(CLASS& from, const std::string& name, \
+ CLASS(Self& from, const std::string& name, \
bool allocate_connectors = true); \
~CLASS(); \
- public: \
- inline static CLASS* bbNew(const std::string& name) \
- { \
- bbtkDebugMessageInc("Kernel",9,#CLASS<<"::bbNew(\""<<name<<"\")"<<std::endl); \
- bbCreateDescriptorIfNeeded(); \
- CLASS* c = new CLASS(name); \
- 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); \
- bbGetDescriptor()->Reference(); \
- bbtkDebugDecTab("Kernel",9); \
- return c; \
- } \
- bbtk::BlackBoxDescriptor* bbGetDescriptor() const \
+ public: \
+ std::string GetObjectName() const \
+ { return std::string(#CLASS)+std::string(" '") \
+ +bbGetNameWithParent()+std::string("'"); } \
+ inline static Pointer New(const std::string& name) \
{ \
- return (bbtk::BlackBoxDescriptor*)bbDescriptor(); \
+ bbtkDebugMessage("object",1,"##> "<<#CLASS \
+ <<"::New(\""<<name<<"\")"<<std::endl); \
+ Pointer p = MakeBlackBoxPointer(new Self(name)); \
+ bbtkDebugMessage("object",1,"<## "<<#CLASS \
+ <<"::New(\""<<name<<"\")"<<std::endl); \
+ return p; \
} \
- static bbtk::BlackBoxDescriptor* bbDescriptor() \
+ inline bbtk::BlackBox::Pointer bbClone(const std::string& name) \
{ \
- bbCreateDescriptorIfNeeded(); \
- return bbDescriptorPointer(); \
+ bbtkDebugMessage("object",1,"##> "<<#CLASS \
+ <<"::bbClone(\""<<name<<"\")"<<std::endl); \
+ Pointer p = MakeBlackBoxPointer(new Self(*this,name)); \
+ bbtkDebugMessage("object",1,"<## "<<#CLASS \
+ <<"::bbClone(\""<<name<<"\")"<<std::endl); \
+ return p; \
} \
+ virtual void bbLockDescriptor(); \
private: \
CLASS() : PARENT("") {} \
- static bbtk::BlackBoxDescriptor*& bbDescriptorPointer() \
- { \
- static bbtk::BlackBoxDescriptor* d = 0; \
- return d; \
- }
+ CLASS(const CLASS&) : PARENT("") {}
+
//============================================================================
+//============================================================================
+#define BBTK_BLACK_BOX_INTERFACE(CLASS,PARENT) \
+ public : typedef CLASS Self; \
+ BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
+//============================================================================
//============================================================================
/// Defines the bbUserProcess method
//============================================================================
#define BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,ALLOC) \
- bbtkDebugMessageInc("Kernel",7,#CLASS<<"::"<<#CLASS \
- <<"(\""<<bbGetName()<<"\")"<<std::endl); \
- if (ALLOC) bbAllocateConnectors();
+ bbtkDebugMessage("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
+ <<"(\""<<bbGetName()<<"\")"<<std::endl); \
+ if (ALLOC) \
+ { \
+ bbLockDescriptor(); \
+ bbAllocateConnectors(); \
+ }
+//============================================================================
+
+//============================================================================
+#define BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS) \
+ bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
+ <<"(\""<<bbGetName()<<"\")"<<std::endl);
//============================================================================
//============================================================================
#define BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM,ALLOC) \
- bbtkDebugMessageInc("Kernel",7,#CLASS<<"::"<<#CLASS \
+ bbtkDebugMessageInc("object",2,"==> "<<#CLASS<<"::"<<#CLASS \
<<"("<<FROM.bbGetFullName()<<",\"" \
<<bbGetName()<<"\")"<<std::endl); \
if (ALLOC) \
{ \
+ bbLockDescriptor(); \
bbAllocateConnectors(); \
bbCopyIOValues(FROM); \
}
//============================================================================
-
//============================================================================
-#define BBTK_END_BLACK_BOX_CONSTRUCTOR \
- bbtkDebugDecTab("Kernel",7)
+#define BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,FROM) \
+ bbtkDebugMessage("object",2,"<== "<<#CLASS<<"::"<<#CLASS \
+ <<"("<<FROM.bbGetFullName()<<",\"" \
+ <<bbGetName()<<"\")"<<std::endl);
//============================================================================
//============================================================================
#define BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS) \
- bbtkDebugMessageInc("Kernel",7,#CLASS <<"::~"<< #CLASS \
- <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
+ bbtkDebugMessage("object",2,"==> "<<#CLASS <<"::~"<< #CLASS \
+ <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
//============================================================================
-
-
-
//============================================================================
-#define BBTK_END_BLACK_BOX_DESTRUCTOR \
- bbtkDebugDecTab("Kernel",7)
+#define BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS) \
+ bbtkDebugMessage("object",2,"<== "<<#CLASS <<"::~"<< #CLASS \
+ <<"() ["<<this->bbGetFullName()<<"]"<<std::endl);
+
//============================================================================
//============================================================================
/// AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
+#define BBTK_BLACK_BOX_IMPLEMENTATION(CLASS,PARENT) \
CLASS::CLASS(const std::string& name, bool allocate_connectors) \
: PARENT(name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,allocate_connectors); \
CLASS::bbUserConstructor(); \
- BBTK_END_BLACK_BOX_CONSTRUCTOR; \
+ BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
} \
CLASS::CLASS(CLASS& from, \
const std::string& name, bool allocate_connectors) \
{ \
BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
CLASS::bbUserCopyConstructor(); \
- BBTK_END_BLACK_BOX_CONSTRUCTOR; \
+ BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
} \
CLASS::~CLASS() \
{ \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
CLASS::bbUserDestructor(); \
- BBTK_END_BLACK_BOX_DESTRUCTOR; \
- }
+ BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
+ } \
+ void CLASS::bbLockDescriptor() \
+ { \
+ bbmDescriptorPointer = CLASS ## Descriptor::Instance(); \
+ }
//============================================================================
#define BBTK_BEGIN_DESCRIBE_BLACK_BOX(CLASS,PARENT) \
class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
{ \
+ public: typedef CLASS ## Descriptor Self; \
+ BBTK_OBJECT_MINIMAL_INTERFACE; \
public: \
- bbtk::BlackBox::Pointer CreateInstance(const std::string& name) \
+ std::string GetObjectName() const \
+ { \
+ return std::string(BBTK_STRINGIFY(CLASS)) \
+ +std::string("Descriptor '")+GetFullTypeName() \
+ +std::string("'"); \
+ } \
+ size_t GetObjectSize() const { return sizeof(*this); } \
+ bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
{ \
- return CLASS::bbNew(name); \
+ return CLASS::New(name); \
} \
+ virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
+ { \
+ return Instance(); \
+ } \
+ static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
+ { \
+ static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
+ bbtk::AtomicBlackBoxDescriptor::Pointer j; \
+ if (!i.lock()) { j = Self::New(); i = j; } \
+ return i.lock(); \
+ } \
+ static CLASS ## Descriptor::Pointer New() \
+ { \
+ bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
+ <<"Descriptor::New" <<std::endl); \
+ CLASS ## Descriptor::Pointer p = \
+ MakePointer(new CLASS ## Descriptor()); \
+ bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
+ <<"Descriptor::New" <<std::endl); \
+ return p; \
+ } \
+ protected: \
CLASS ## Descriptor() \
{ \
- bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
- <<"Descriptor()"<<std::endl)
+ bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor::" \
+ <<#CLASS<<"Descriptor()"<<std::endl);
//============================================================================
//============================================================================
/// Ends the AtomicBlackBox description block
#define BBTK_END_DESCRIBE_BLACK_BOX(CLASS) \
- bbtkDecTab("Kernel",9); \
+ bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor::" \
+ <<#CLASS<<"Descriptor()"<<std::endl); \
} \
}; \
- void CLASS::bbCreateDescriptorIfNeeded() \
- { \
- if ( !bbDescriptorPointer() ) \
- bbDescriptorPointer() = new CLASS ## Descriptor; \
- }
+
//============================================================================
//============================================================================
/// Describes a AtomicBlackBox input (to be put inside the UBB description block)
-#define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
+#define BBTK_INPUT(CLASS,NAME,DESCR,TYPE,NATURE) \
AddInputDescriptor(new bbtk::AtomicBlackBoxInputDescriptor \
(typeid(CLASS ## Descriptor), \
#NAME,DESCR,NATURE, \
//============================================================================
//============================================================================
+//============================================================================
+#define BBTK_TEMPLATE_BLACK_BOX_INTERFACE(CLASS,PARENT,T) \
+ public : typedef CLASS<T> Self; \
+ BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
+//============================================================================
+
//============================================================================
/// Begins a template AtomicBlackBox of template param T description block
-#define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
- template <class T> \
- class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
+#define BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS,PARENT) \
+ template <class T> \
+ class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
{ \
+ public: typedef CLASS ## Descriptor<T> Self; \
+ BBTK_OBJECT_MINIMAL_INTERFACE; \
public: \
- bbtk::BlackBox::Pointer CreateInstance(const std::string& name) \
+ std::string GetObjectName() const \
+ { \
+ return std::string(BBTK_STRINGIFY(CLASS)) \
+ +std::string("Descriptor<")+bbtk::TypeName<T>() \
+ +std::string("> '")+GetFullTypeName() \
+ +std::string("'"); \
+ } \
+ static Pointer New() \
+ { \
+ bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
+ <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
+ <<std::endl); \
+ Pointer p = MakePointer(new Self()); \
+ bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
+ <<"Descriptor<"<<bbtk::TypeName<T>()<<">::New" \
+ <<std::endl); \
+ return p; \
+ } \
+ virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
+ { \
+ return Instance(); \
+ } \
+ static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
+ { \
+ static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
+ bbtk::AtomicBlackBoxDescriptor::Pointer j; \
+ if (!i.lock()) { j = Self::New(); i = j; } \
+ return i.lock(); \
+ } \
+ bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
{ \
- return CLASS<T>::bbNew(name); \
+ return CLASS<T>::New(name); \
} \
CLASS ## Descriptor() \
{ \
- bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
- <<"Descriptor()"<<std::endl)
+ bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
+ <<bbtk::TypeName<T>()<<">::" \
+ <<#CLASS<<"Descriptor()"<<std::endl);
+
//============================================================================
//============================================================================
/// Ends a template AtomicBlackBox of template param T description block
-#define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
- bbtkDecTab("Kernel",9); \
+#define BBTK_END_DESCRIBE_TEMPLATE_BLACK_BOX(CLASS) \
+ bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
+ <<bbtk::TypeName<T>()<<">::" \
+ <<#CLASS<<"Descriptor()"<<std::endl); \
} \
- }; \
- template <class T> \
- void CLASS<T>::bbCreateDescriptorIfNeeded() \
- { \
- if ( !bbDescriptorPointer() ) \
- bbDescriptorPointer() = new CLASS ## Descriptor<T>; \
- }
+ };
+
//============================================================================
//============================================================================
//============================================================================
/// Template AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
+#define BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(CLASS,PARENT) \
template <class T> \
CLASS<T>::CLASS(const std::string& name, bool alloc) \
: PARENT(name,false) \
{ \
- BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS<T>,alloc); \
- CLASS<T>::bbUserConstructor(); \
- BBTK_END_BLACK_BOX_CONSTRUCTOR; \
- } \
+ BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
+ CLASS<T>::bbUserConstructor(); \
+ BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
+ } \
template <class T> \
- CLASS<T>::CLASS(CLASS<T>& from, \
- const std::string& name, bool allocate_connectors) \
+ CLASS<T>::CLASS(CLASS<T>& from, \
+ const std::string& name, bool allocate_connectors) \
: PARENT(from,name,false) \
{ \
- BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS<T>,from,allocate_connectors); \
+ BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
CLASS<T>::bbUserCopyConstructor(); \
- BBTK_END_BLACK_BOX_CONSTRUCTOR; \
- } \
+ BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
+ } \
template <class T> \
CLASS<T>::~CLASS() \
{ \
- BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS<T>); \
+ BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
CLASS<T>::bbUserDestructor(); \
- BBTK_END_BLACK_BOX_DESTRUCTOR; \
- }
+ BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
+ } \
+ template <class T> \
+ void CLASS<T>::bbLockDescriptor() \
+ { \
+ bbmDescriptorPointer = CLASS ## Descriptor<T>::Instance(); \
+ }
//============================================================================
+
+
//============================================================================
// Two template params user black boxes macros
+//============================================================================
+
+//============================================================================
+#define BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(CLASS,PARENT,T1,T2) \
+ public : typedef CLASS<T1,T2> Self; \
+ BBTK_BLACK_BOX_INTERFACE_INTERNAL(CLASS,PARENT);
+//===========================================================================
+//============================================================================
/// Begins a template AtomicBlackBox description block of template param T1 and T2
-#define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
+#define BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS,PARENT) \
template <class T1, class T2> \
- class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
+ class /*BBTK_EXPORT*/ CLASS ## Descriptor : public PARENT ## Descriptor \
{ \
+ public: typedef CLASS ## Descriptor<T1,T2> Self; \
+ BBTK_OBJECT_MINIMAL_INTERFACE; \
public: \
- bbtk::BlackBox::Pointer CreateInstance(const std::string& name) \
+ std::string GetObjectName() const \
+ { \
+ return std::string(BBTK_STRINGIFY(CLASS)) \
+ +std::string("Descriptor<")+bbtk::TypeName<T1>() \
+ +std::string(",")+bbtk::TypeName<T2>() \
+ +std::string("> '")+GetFullTypeName() \
+ +std::string("'"); \
+ } \
+ static Pointer New() \
+ { \
+ bbtkDebugMessage("object",1,"##> "<<BBTK_STRINGIFY(CLASS) \
+ <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
+ <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
+ Pointer p = MakePointer(new Self()); \
+ bbtkDebugMessage("object",1,"<## "<<BBTK_STRINGIFY(CLASS) \
+ <<"Descriptor<"<<bbtk::TypeName<T1>()<<"," \
+ <<bbtk::TypeName<T2>()<<">::New"<<std::endl); \
+ return p; \
+ } \
+ virtual bbtk::AtomicBlackBoxDescriptor::Pointer GetInstance() const \
+ { \
+ return Instance(); \
+ } \
+ static bbtk::AtomicBlackBoxDescriptor::Pointer Instance() \
+ { \
+ static bbtk::AtomicBlackBoxDescriptor::WeakPointer i; \
+ bbtk::AtomicBlackBoxDescriptor::Pointer j; \
+ if (!i.lock()) { j = Self::New(); i = j; } \
+ return i.lock(); \
+ } \
+ bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
{ \
- return CLASS<T1,T2>::bbNew(name); \
+ return CLASS<T1,T2>::New(name); \
} \
CLASS ## Descriptor() \
{ \
- bbtkDebugMessageInc("Kernel",9,#CLASS<<"Descriptor::"<<#CLASS \
- <<"Descriptor()"<<std::endl)
+ bbtkDebugMessage("object",2,"==> "<<#CLASS<<"Descriptor<" \
+ <<bbtk::TypeName<T1>()<<"," \
+ <<bbtk::TypeName<T2>()<<">::" \
+ <<#CLASS<<"Descriptor()"<<std::endl);
//============================================================================
//============================================================================
/// Ends a template AtomicBlackBox description block of template param T1 and T2
-#define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
- bbtkDecTab("Kernel",9); \
+#define BBTK_END_DESCRIBE_TEMPLATE2_BLACK_BOX(CLASS) \
+ bbtkDebugMessage("object",2,"<== "<<#CLASS<<"Descriptor<" \
+ <<bbtk::TypeName<T1>()<<"," \
+ <<bbtk::TypeName<T2>()<<">::" \
+ <<#CLASS<<"Descriptor()"<<std::endl); \
} \
- }; \
- template <class T1, class T2> \
- void CLASS<T1,T2>::bbCreateDescriptorIfNeeded() \
- { \
- if ( !bbDescriptorPointer() ) \
- bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>; \
- }
+ };
+
//============================================================================
+
+
+/*
//============================================================================
// Two template params user black boxes macros
/// Begins a template AtomicBlackBox description block of template param T1 and T2
#define BBTK_BEGIN_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
template <TYPE1 T1, TYPE2 T2> \
- class /*BBTK_EXPORT*/ CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
+ class CLASS ## Descriptor : public bbtk::BlackBoxDescriptor \
{ \
public: \
- bbtk::BlackBox::Pointer CreateInstance(const std::string& name) \
+ virtual bbtk:AtomicBlackBoxDescriptor::Pointer GetInstance() const \
+ { \
+ return Instance(); \
+ } \
+ static bbtk:AtomicBlackBoxDescriptor::Pointer Instance() \
+ { \
+ static bbtk:AtomicBlackBoxDescriptor::WeakPointer i; \
+ bbtk:AtomicBlackBoxDescriptor::Pointer j; \
+ if (!i.lock()) { j = Self::New(); i = j; } \
+ return i.lock(); \
+ } \
+ bbtk::BlackBox::Pointer NewBlackBox(const std::string& name) \
{ \
return new CLASS<T1,T2>(name); \
} \
#define BBTK_END_DESCRIBE_TEMPLATE2_WITH_TYPES_BLACK_BOX(CLASS,TYPE1,TYPE2) \
bbtkDecTab("Kernel",9); \
} \
- }; \
- template <TYPE1 T1, TYPE2 T2> \
- void CLASS<T1,T2>::bbCreateDescriptorIfNeeded() \
- { \
- if ( !bbDescriptorPointer() ) \
- bbDescriptorPointer() = new CLASS ## Descriptor<T1,T2>; \
- }
-//============================================================================
+ };
+//============================================================================
+*/
//============================================================================
/// Describes a 2 template params AtomicBlackBox input (to be put inside the UBB description block)
//============================================================================
/// Template AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
+#define BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(CLASS,PARENT) \
template <class T1, class T2> \
CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
: PARENT(name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_CONSTRUCTOR(CLASS,alloc); \
CLASS<T1,T2>::bbUserConstructor(); \
- BBTK_END_BLACK_BOX_CONSTRUCTOR; \
+ BBTK_END_BLACK_BOX_CONSTRUCTOR(CLASS); \
} \
- template <class T1, class T2> \
- CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
- const std::string& name, bool allocate_connectors) \
+ template <class T1, class T2> \
+ CLASS<T1,T2>::CLASS(CLASS<T1,T2>& from, \
+ const std::string& name, bool allocate_connectors) \
: PARENT(from,name,false) \
{ \
BBTK_BEGIN_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from,allocate_connectors); \
CLASS<T1,T2>::bbUserCopyConstructor(); \
- BBTK_END_BLACK_BOX_CONSTRUCTOR; \
+ BBTK_END_BLACK_BOX_COPY_CONSTRUCTOR(CLASS,from); \
} \
template <class T1, class T2> \
CLASS<T1,T2>::~CLASS() \
{ \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
CLASS<T1,T2>::bbUserDestructor(); \
- BBTK_END_BLACK_BOX_DESTRUCTOR; \
- }
+ BBTK_END_BLACK_BOX_DESTRUCTOR(CLASS); \
+ } \
+ template <class T1, class T2> \
+ void CLASS<T1,T2>::bbLockDescriptor() \
+ { \
+ bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
+ }
//============================================================================
+/*
//============================================================================
/// Template AtomicBlackBox std implementation of ctor and dtor
-#define BBTK_USER_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
+#define BBTK_BLACK_BOX_TEMPLATE2_WITH_TYPES_IMPLEMENTATION(CLASS,PARENT,TYPE1,TYPE2) \
template <TYPE1 T1, TYPE2 T2> \
CLASS<T1,T2>::CLASS(const std::string& name, bool alloc) \
: PARENT(name,false) \
BBTK_BEGIN_BLACK_BOX_DESTRUCTOR(CLASS); \
this->bbUserDestructor(); \
BBTK_END_BLACK_BOX_DESTRUCTOR; \
- }
+ } \
+ template <class T1, class T2> \
+ void CLASS<T1,T2>::bbLockDescriptor() \
+ { \
+ bbmDescriptorPointer = CLASS ## Descriptor<T1,T2>::Instance(); \
+ }
//============================================================================
-
+*/
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
-Date: $Date: 2008/04/09 11:16:57 $
-Version: $Revision: 1.9 $
+Date: $Date: 2008/04/18 12:59:15 $
+Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See doc/license.txt or
namespace bbtk
{
-//EED
+
static bool bbmgSomeBoxExecuting = false;
static bool bbmgFreezeExecution = false;
- static std::set<BlackBox*> bbmgExecutionList;
+ static std::set<BlackBox::Pointer> bbmgExecutionList;
+ //=========================================================================
+ BlackBox::Deleter::Deleter()
+ {
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void BlackBox::Deleter::Delete(Object* p)
+ {
+ BlackBox* b = dynamic_cast<BlackBox*>(p);
+ if (!b)
+ {
+ bbtkInternalError("BlackBox::Deleter::Delete("<<p->GetObjectName()
+ <<"["<<p<<"]) : "
+ <<"dynamic cast to BlackBox* failed !");
+ }
+ std::string name = p->GetObjectName();//b->bbGetNameWithParent();
+ bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\")"<<std::endl);
+
+
+ BlackBoxDescriptor::WeakPointer desc = b->bbGetDescriptor();
+ bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : deleting black box"<<std::endl);
+
+ b->bbDelete();
+
+ bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor ["<<desc.lock()<<"]"<<std::endl);
+
+ if (!desc.expired())
+ {
+ Package::WeakPointer pack = desc.lock()->GetPackage();
+ if (!pack.expired())
+ {
+ Package::ReleaseBlackBoxDescriptor(pack,desc);
+ }
+ else
+ {
+ bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : descriptor package expired (was not held by a package and the box was the last instance)"<<std::endl);
+ }
+ }
+ else
+ {
+ bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : descriptor expired : nothing to do (was not held by a package or the box is a complex black box prototype)"<<std::endl);
+ }
+ bbtkDebugMessage("object",2,"<## BlackBox::Deleter(\""<<name<<"\")"<<std::endl);
+ }
+ //=========================================================================
//=========================================================================
BlackBox::BlackBox(const std::string &name)
: bbmName(name),
bbmStatus(MODIFIED),
bbmBoxProcessMode("Pipeline"),
- bbmParent(NULL),
+ bbmParent(),
bbmExecuting(false)
{
- bbtkDebugMessage("Kernel",7,"BlackBox::BlackBox(\""
+ bbtkDebugMessage("object",4,"==> BlackBox::BlackBox(\""
+ <<name<<"\")"<<std::endl);
+ bbtkDebugMessage("object",4,"<== BlackBox::BlackBox(\""
<<name<<"\")"<<std::endl);
}
//=========================================================================
: bbmName(name),
bbmStatus(from.bbmStatus),
bbmBoxProcessMode(from.bbmBoxProcessMode),
- bbmParent(NULL),
+ bbmParent(),
bbmExecuting(false)
{
- bbtkDebugMessage("Kernel",7,"BlackBox::BlackBox("
+ bbtkDebugMessage("object",4,"==> BlackBox::BlackBox("
+ <<from.bbGetFullName()<<",\""
+ <<name<<"\")"<<std::endl);
+ bbtkDebugMessage("object",4,"<== BlackBox::BlackBox("
<<from.bbGetFullName()<<",\""
<<name<<"\")"<<std::endl);
}
//=========================================================================
BlackBox::~BlackBox()
{
- // std::cout << "EED BlackBox::~BlackBox 01 [" << bbGetName()<<"]\n";
- bbtkDebugMessageInc("Kernel",7,"BlackBox::~BlackBox()"<<std::endl);
+ bbtkDebugMessage("object",4,"==> BlackBox::~BlackBox() ["<<bbmName
+ <<"]"<<std::endl);
this->bbDesallocateConnectors();
- //printf("EED BlackBox::~BlackBox 02 \n");
- bbtkDebugDecTab("Kernel",7);
- }
- //=========================================================================
-
- //=========================================================================
- /// Destruction method of a black box
- void BlackBox::bbDelete()
- {
- bbtkDebugMessage("Kernel",1,"BlackBox::bbDelete() ["
- <<bbGetFullName()<<"]"<<std::endl);
- bbGetDescriptor()->UnReference();
- this->bbUserDelete();
+ bbtkDebugMessage("object",4,"<== BlackBox::~BlackBox() ["<<bbmName
+ <<"]"<<std::endl);
}
//=========================================================================
if (force) bbSetModifiedStatus();
// Calls the main recursive update method
- bbBackwardUpdate(0);
+ bbBackwardUpdate(Connection::Pointer());
Wx::EndBusyCursor();
//=========================================================================
std::string BlackBox::bbGetFullName() const
{
- return bbGetNameWithParent()+"<"+this->bbGetDescriptor()->GetTypeName()+">";
+ return this->bbGetNameWithParent()+"<"+this->bbGetDescriptor()->GetTypeName()+">";
}
//=========================================================================
/// Returns the name with the name of the parent prepended if any
std::string BlackBox::bbGetNameWithParent() const
{
- if (bbmParent)
+ if (bbmParent.lock())
{
- return bbmParent->bbGetNameWithParent() + ":" + bbmName;
+ return bbmParent.lock()->bbGetNameWithParent() + ":" + bbmName;
}
else
{
{
bbtkDebugMessage("Kernel",8,"* Allocate \""<<i->first<<"\""<<std::endl);
bbGetInputConnectorMap()[i->second->GetName()]
- = new BlackBoxInputConnector(this);
+ = new BlackBoxInputConnector(GetThisPointer<BlackBox>());
}
const BlackBoxDescriptor::OutputDescriptorMapType& omap
= bbGetDescriptor()->GetOutputDescriptorMap();
bbtkDebugMessage("Process",9,
"-> Execution triggered by Reactive mode or BoxExecute input change"<<std::endl);
this->bbSetStatus(MODIFIED);
- bbGlobalAddToExecutionList( this );
+ bbGlobalAddToExecutionList( GetThisPointer<BlackBox>() );
}
else if ( bbGetStatus() == MODIFIED ) //! this->bbIsUptodate())
{
//=========================================================================
/// Connects the input <name> to the connection c
- void BlackBox::bbConnectInput( const std::string& name, Connection* c)
+ void BlackBox::bbConnectInput( const std::string& name, Connection::Pointer c)
{
bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbConnectInput(\""<<name<<"\","<<c<<") ["
//=========================================================================
/// Connects the output <name> to the connection c
- void BlackBox::bbConnectOutput( const std::string& name, Connection* c)
+ void BlackBox::bbConnectOutput( const std::string& name, Connection::Pointer c)
{
bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbConnectOutput(\""<<name<<"\","<<c<<") ["
//=========================================================================
/// Disconnects the input <name> from the connection c
- void BlackBox::bbDisconnectInput( const std::string& name, Connection* c)
+ void BlackBox::bbDisconnectInput( const std::string& name, Connection::Pointer c)
{
+ if (!c) return;
bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbDisconnectInput(\""<<name
<<"\","<<c<<") ["
//=========================================================================
/// Disconnects the output <name> from the connection c
- void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c)
+ void BlackBox::bbDisconnectOutput( const std::string& name, Connection::Pointer c)
{
+ if (!c) return;
bbtkDebugMessageInc("Kernel",7,
"BlackBox::bbDisconnectOutput(\""<<name
<<"\","<<c<<") ["
if (bbGetOutputType(output).name() != typeid(std::string).name() )
{
// Look for factory
- Package* p = bbGetDescriptor()->GetPackage();
+ Package::Pointer p = bbGetDescriptor()->GetPackage();
if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
{
- Factory* f = *p->GetFactorySet().begin();
- BlackBox* a = 0;
+ Factory::Pointer f = p->GetFactorySet().begin()->lock();
+ BlackBox::Pointer a;
try
{
a = f->NewAdaptor(
} catch (bbtk::Exception e)
{
}
- if (a!=NULL){
+ if (a){
// bbUpdate();
a->bbSetInput("In",bbGetOutput(output));
a->bbExecute();
if (bbGetInputType(input) != typeid(std::string))
{
// Look for factory
- Package* p = bbGetDescriptor()->GetPackage();
+ Package::Pointer p = bbGetDescriptor()->GetPackage();
if ((p != 0) && ( ! p->GetFactorySet().empty() ) )
{
- Factory* f = *p->GetFactorySet().begin();
- BlackBox* a = 0;
+ Factory::Pointer f = p->GetFactorySet().begin()->lock();
+ BlackBox::Pointer a;
try
{
a = f->NewAdaptor(
}catch (bbtk::Exception e)
{
}
- if (a!=NULL)
+ if (a)
{
// bbUpdate();
a->bbSetInput("In",bbGetInput(input));
//=========================================================================
/// Write Graphviz-dot description in file
void BlackBox::bbWriteDotFileBlackBox(FILE *ff,
- BlackBox *parentblackbox,
+ BlackBox::Pointer parentblackbox,
int detail, int level,
bool instanceOrtype,
bool relative_link )
// std::cout << labelStr << std::endl;
// Relation Input
- if (this!=parentblackbox){
+ if (GetThisPointer<BlackBox>()!=parentblackbox){
for ( i = mInputConnectorMap.begin(); i != mInputConnectorMap.end(); ++i )
{
if (i->second)
{
- Connection* con = i->second->GetConnection();
+ Connection::Pointer con = i->second->GetConnection();
if (con!=NULL){
- BlackBox *a=con->GetBlackBoxFrom();
- BlackBox *b=con->GetBlackBoxTo();
+ BlackBox::Pointer a=con->GetBlackBoxFrom();
+ BlackBox::Pointer b=con->GetBlackBoxTo();
fprintf(ff," ");
a->bbWriteDotInputOutputName(ff,false,detail,level);
if (detail==1)
//=========================================================================
- void BlackBox::bbShowRelations(BlackBox *parentblackbox,
+ void BlackBox::bbShowRelations(BlackBox::Pointer parentblackbox,
int detail, int level
/*,Factory *factory*/ )
{
ivalue.push_back(bbGetInputAsString(i->first));
if (ivalue.back().size()>valuelmax) valuelmax = ivalue.back().size();
std::string s("");
- Connection* con = i->second->GetConnection();
+ Connection::Pointer con = i->second->GetConnection();
if (con!=0){
s = con->GetBlackBoxFrom()->bbGetName();
s += ".";
ovalue.push_back(bbGetOutputAsString(o->first));
if (ovalue.back().size()>valuelmax) valuelmax = ovalue.back().size();
std::vector<std::string> ss;
- const std::vector<Connection*>& con = o->second->GetConnectionVector();
- std::vector<Connection*>::const_iterator c;
+ const std::vector<Connection::WeakPointer>& con
+ = o->second->GetConnectionVector();
+ std::vector<Connection::WeakPointer>::const_iterator c;
for (c=con.begin();c!=con.end();++c)
{
std::string s;
- s = (*c)->GetBlackBoxTo()->bbGetName();
+ s = (*c).lock()->GetBlackBoxTo()->bbGetName();
s += ".";
- s += (*c)->GetBlackBoxToInput();
+ s += (*c).lock()->GetBlackBoxToInput();
ss.push_back(s);
} // if con
oconn.push_back(ss);
"=> BlackBox::bbGlobalProcessExecutionList()"
<<std::endl);
- std::set<BlackBox*>::iterator i;
+ std::set<BlackBox::Pointer>::iterator i;
for (i=bbmgExecutionList.begin();
i!=bbmgExecutionList.end();
++i)
return bbmgFreezeExecution;
}
- void BlackBox::bbGlobalAddToExecutionList( BlackBox* b )
+ void BlackBox::bbGlobalAddToExecutionList( BlackBox::Pointer b )
{
bbmgExecutionList.insert(b);
}
}
//=========================================================================
+
+
} // EO namespace bbtk
// EOF
Program: bbtk
Module: $RCSfile: bbtkBlackBox.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
#include "bbtkSystem.h"
#include "bbtkBlackBoxDescriptor.h"
-//#include "bbtkConnection.h"
#include "bbtkBlackBoxInputConnector.h"
#include "bbtkBlackBoxOutputConnector.h"
#include <set>
class Factory;
- class BBTK_EXPORT BlackBox
+ class BBTK_EXPORT BlackBox : public Object
{
-
-
+ BBTK_ABSTRACT_OBJECT_INTERFACE(BlackBox);
public:
//==================================================================
// INTERFACE
//==================================================================
- /// The type of pointer on a BlackBox
- typedef BlackBox* Pointer;
-
+
/// The type of map of output connector pointers
typedef std::map<std::string, BlackBoxOutputConnector*>
OutputConnectorMapType;
InputConnectorMapType;
/// Returns the pointer on the descriptor of the box
- virtual BlackBoxDescriptor* bbGetDescriptor() const = 0;
+ virtual BlackBoxDescriptor::Pointer bbGetDescriptor() const = 0;
/// Returns a pointer on a clone of the box with name <name>
- virtual BlackBox* bbClone(const std::string& name) = 0;
+ virtual BlackBox::Pointer bbClone(const std::string& name) = 0;
- /// Destruction method of a black box
- virtual void bbDelete();
/// User overloadable destruction method of a black box
+ /// UNUSED FOR THE MOMENT
virtual void bbUserDelete();
/// Returns the Name of the Type of the BlackBox
virtual std::string bbGetFullName() const;
/// Returns the name with the name of the parent prepended if any
- std::string bbGetNameWithParent() const;
+ virtual std::string bbGetNameWithParent() const;
/// Sets the parent of the BlackBox
void bbSetParent(BlackBox::Pointer p) { bbmParent = p; }
/// Returns the parent of the BlackBox, i.e the BlackBox that contains it (0 if none)
- BlackBox::Pointer bbGetParent() const { return bbmParent; }
+ BlackBox::Pointer bbGetParent() const { return bbmParent.lock(); }
/// Main processing method of the box.
virtual void bbSetOutput( const std::string &name, Data data) = 0;
/// Connects the input <name> to the connection c
- virtual void bbConnectInput( const std::string& name, Connection* c);
+ virtual void bbConnectInput( const std::string& name,
+ Connection::Pointer c);
/// Connects the output <name> to the connection c
- virtual void bbConnectOutput( const std::string& name, Connection* c);
-
+ virtual void bbConnectOutput( const std::string& name,
+ Connection::Pointer c);
/// Disconnects the input <name> from the connection c
- virtual void bbDisconnectInput( const std::string& name, Connection* c);
+ virtual void bbDisconnectInput( const std::string& name,
+ Connection::Pointer c);
/// Disconnects the output <name> from the connection c
- virtual void bbDisconnectOutput( const std::string& name, Connection* c);
+ virtual void bbDisconnectOutput( const std::string& name,
+ Connection::Pointer c);
/// Returns the input connectors map
InputConnectorMapType& bbGetInputConnectorMap()
/// (uses bbGetInputAsString / bbGetOutputAsString which use adaptors)
/// If relative_link is true then creates relative hrefs
virtual void bbWriteDotFileBlackBox(FILE *ff,
- BlackBox *parentblackbox,
+ BlackBox::Pointer parentblackbox,
int detail, int level,
bool instanceOrtype,
bool relative_link );
int detail, int level);
- virtual void bbShowRelations(BlackBox *parentblackbox,
+ virtual void bbShowRelations(BlackBox::Pointer parentblackbox,
int detail, int level
);
std::string bbGetOutputAsString( const std::string &output ); //,Factory *factory);
std::string bbGetInputAsString( const std::string &input); //,Factory *factory);
- virtual BlackBox *bbFindBlackBox(const std::string &blackboxname) { return NULL;}
+ virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname)
+ { return BlackBox::Pointer();}
virtual void Check(bool recursive = true);
BlackBox(const std::string &name);
/// Constructor from an existing box (copy) with a new name
BlackBox(BlackBox& from, const std::string &name);
- /// Destructor
- virtual ~BlackBox();
//==================================================================
/// - calls bbUpdateChildren
/// - calls bbShowWidget which shows the widget associated to the box (if any)
public:
- virtual IOStatus bbBackwardUpdate(Connection* caller) = 0;
+ virtual IOStatus bbBackwardUpdate(Connection::Pointer caller) = 0;
//==================================================================
//==================================================================
/// - calls bbCreateWidget
/// - calls bbProcess which is the user callback which does the actual processing
/// - calls bbUpdateChildren which recursively calls bbForwardUpdate on connections attached the "Child" output
- // virtual void bbForwardUpdate(Connection* caller) = 0;
+ // virtual void bbForwardUpdate(Connection::Pointer caller) = 0;
//==================================================================
protected:
//==================================================================
//==================================================================
/// Updates the pipeline in upstream-downstream direction along the "Child"-"Parent" connections only.
/// Does nothing here. Overloaded in WxContainerBlackbox
- //virtual void bbUpdateChildren( Connection* caller ) { }
+ //virtual void bbUpdateChildren( Connection::Pointer caller ) { }
//==================================================================
//==================================================================
/// Shows the window associated to the box
/// (called after bbProcess during bbExecute)
/// Does nothing here but overloaded in WxBlackBox and WxContainerBlackBox
- virtual void bbShowWindow(Connection* caller) { }
+ virtual void bbShowWindow(Connection::Pointer caller) { }
virtual void bbHideWindow() {}
//==================================================================
virtual bool bbCanReact() const;
- static void bbGlobalAddToExecutionList( BlackBox* b );
+ static void bbGlobalAddToExecutionList( BlackBox::Pointer b );
static void bbGlobalProcessExecutionList();
//==================================================================
bool bbGetExecuting() const { return bbmExecuting; }
void bbSetExecuting(bool b) { bbmExecuting = b; }
+ // Black box objects have a special deleter
+ // which must take care of releasing the descriptor
+ // **AFTER** the box is deleted
+ // (Releasing it in the destructor may cause dl close and crash)
+ /// Black box deleter
+ /// 1) Calls the user overloadable bbDelete method
+ /// 2) Releases the box descriptor
+ struct Deleter : public Object::Deleter
+ {
+ Deleter();
+ void Delete(Object* p);
+ };
+
+ template <class U>
+ static boost::shared_ptr<U> MakeBlackBoxPointer(U* s, bool lock = false)
+ {
+ return MakePointer(s,BlackBox::Deleter(),lock);
+ }
+
+ virtual void bbDelete() { delete this; }
private:
//==================================================================
// 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
std::string bbmBoxProcessMode;
/// The parent of the black box in the ComplexBlackBox hierarchy
- BlackBox::Pointer bbmParent;
+ BlackBox::WeakPointer bbmParent;
//==================================================================
//==================================================================
Program: bbtk
Module: $RCSfile: bbtkBlackBoxDescriptor.cxx,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.15 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ Version: $Revision: 1.16 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace bbtk
{
-
+
+ typedef Package::Pointer PackagePointer;
+
+
+
//=========================================================================
/// Default ctor
BlackBoxDescriptor::BlackBoxDescriptor()
mAuthor(""),
mCategory(""),
mKind(STANDARD),
- mPackage(NULL),
- mRefCount(0)
+ mPackage()
{
- bbtkDebugMessage("Kernel",9,
- "BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
+ bbtkDebugMessage("object",4,
+ "==> BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
+ bbtkDebugMessage("object",4,
+ "<== BlackBoxDescriptor::BlackBoxDescriptor()"<<std::endl);
}
//=========================================================================
/// Dtor
BlackBoxDescriptor::~BlackBoxDescriptor()
{
- bbtkDebugMessageInc("Kernel",9,
- "BlackBoxDescriptor::~BlackBoxDescriptor() ["
- <<mTypeName<<"]"<<std::endl);
+ bbtkDebugMessage("object",4,
+ "==> BlackBoxDescriptor::~BlackBoxDescriptor() ["
+ <<mTypeName<<"]"<<std::endl);
// deletes all I/O descriptors
InputDescriptorMapType::iterator i;
OutputDescriptorMapType::iterator o;
for (o=mOutput.begin(); o!=mOutput.end(); ++o) delete o->second;
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugMessage("object",4,
+ "<== BlackBoxDescriptor::~BlackBoxDescriptor() ["
+ <<mTypeName<<"]"<<std::endl);
}
//=========================================================================
+ /*
+ //=======================================================================
+ /// Release
+ void BlackBoxDescriptor::Release(BlackBoxDescriptor::WeakPointer desc)
+ {
+ bbtkMessage("object",2,"==> BlackBoxDescriptor::Release('"
+ <<desc.lock()->GetTypeName()<<"')"<<std::endl);
+ long c = desc.use_count();
+ bbtkMessage("object",3," - ref count = "<<c<<std::endl);
+ // If only one ref
+ if ((c == 1) && (desc.lock()->mPackage))
+ {
+ bbtkMessage("object",2," --> No more instance alive = releasing from package"<<std::endl);
+
+ Package::WeakPointer pack = desc.lock()->mPackage;
+ Package::ReleaseBlackBoxDescriptor(pack,desc);
+ }
+ else
+ {
+ bbtkMessage("object",2," --> Still some instances alive = Keeping it alive"<<std::endl);
+ }
+ bbtkMessage("object",2,"<== BlackBoxDescriptor::Release('"
+ <<desc.lock()->GetTypeName()<<"')"<<std::endl);
+
+ }
+ //=========================================================================
+ */
+
+ /*
//=========================================================================
/// Dtor
void BlackBoxDescriptor::UnReference()
}
}
//=========================================================================
-
+ */
//=========================================================================
/// Check
void BlackBoxDescriptor::Check(bool) const
/// 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;
+ if (GetPackage()!=0) return GetPackage()->GetName() + "::" + mTypeName;
return "::" + mTypeName;
}
//=========================================================================
Program: bbtk
Module: $RCSfile: bbtkBlackBoxDescriptor.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.8 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
#ifndef __bbtkBlackBoxDescriptor_h__
#define __bbtkBlackBoxDescriptor_h__
+#include "bbtkObject.h"
#include "bbtkBlackBoxInputDescriptor.h"
#include "bbtkBlackBoxOutputDescriptor.h"
#include <map>
class BlackBox;
class Package;
+ BBTK_FORWARD_DECLARE_POINTER(BlackBox);
+ BBTK_FORWARD_DECLARE_POINTER(Package);
//==========================================================================
- class BBTK_EXPORT BlackBoxDescriptor
+ class BBTK_EXPORT BlackBoxDescriptor : public Object
{
+ BBTK_ABSTRACT_OBJECT_INTERFACE(BlackBoxDescriptor);
public:
/// The type of descriptor of inputs
typedef BlackBoxInputDescriptor InputDescriptor;
}
Kind;
- /// Default ctor
- BlackBoxDescriptor();
- /// Creates an instance with name boxname of the BlackBox
+ /// Releases a descriptor
+ // static void Release(BlackBoxDescriptor::WeakPointer);
+
+ /// Creates an instance with name boxname of the BlackBox
/// of which this is the descriptor
- virtual BlackBox* CreateInstance(const std::string& boxname) = 0;
+ virtual BlackBoxPointer NewBlackBox(const std::string& boxname) = 0;
/// Returns the name of the **TYPE** of the black box
const std::string& GetTypeName() const { return mTypeName; }
/// Returns the category(s) of the BlackBox
const std::string& GetCategory() const { return mCategory; }
- /// Returns the Package to which the box belongs
- Package* GetPackage() { return mPackage; }
-
/// Returns the Package to which the box belongs (const pointer)
- const Package* GetPackage() const { return mPackage; }
+ PackagePointer GetPackage() const { return mPackage; }
/// Returns the kind of box
Kind GetKind() const { return mKind; }
void AddToCategory( const std::string&, bool clear = false );
/// Sets the Package to which the box belongs
- void SetPackage(Package *package) { mPackage = package; }
+ void SetPackage(PackagePointer package) { mPackage = package; }
/// Sets the kind of box
void SetKind(Kind kind) { mKind = kind; }
int detail, int level,
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; }
/// The kind of box (standard / adaptor)
Kind mKind;
/// The Package to which the box belongs
- Package *mPackage;
+ PackagePointer mPackage;
/// The inputs
InputDescriptorMapType mInput;
/// The outputs
OutputDescriptorMapType mOutput;
- /// Reference counting
- int mRefCount;
-
- private:
- BlackBoxDescriptor(const BlackBoxDescriptor&) {}
};
// class BlackBoxDescriptor
//==========================================================================
Program: bbtk
Module: $RCSfile: bbtkBlackBoxInputConnector.cxx,v $
Language: C++
- Date: $Date: 2008/02/05 13:23:46 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
*/
#include "bbtkBlackBoxInputConnector.h"
#include "bbtkMessageManager.h"
+#include "bbtkBlackBox.h"
namespace bbtk
{
- BlackBoxInputConnector::BlackBoxInputConnector(BlackBox* b)
- : mBox(b), mConnection(0), mStatus(MODIFIED)
+ BlackBoxInputConnector::BlackBoxInputConnector(BlackBox::Pointer b)
+ : mBox(b), mConnection(), mStatus(MODIFIED)
{
bbtkDebugMessage("Kernel",9,"BlackBoxInputConnector::BlackBoxInputConnector()"<<std::endl);
}
BlackBoxInputConnector::~BlackBoxInputConnector()
{
bbtkDebugMessageInc("Kernel",9,"BlackBoxInputConnector::~BlackBoxInputConnector()"<<std::endl);
- if (mConnection) delete mConnection;
bbtkDebugDecTab("Kernel",9);
}
- void BlackBoxInputConnector::SetConnection(Connection* c)
+ void BlackBoxInputConnector::SetConnection(Connection::Pointer c)
{
bbtkDebugMessage("Kernel",9,"BlackBoxInputConnector::SetConnection("<<c<<")"<<std::endl);
mConnection = c;
}
- void BlackBoxInputConnector::UnsetConnection(Connection* c)
+ void BlackBoxInputConnector::UnsetConnection(Connection::Pointer c)
{
bbtkDebugMessage("Kernel",9,"BlackBoxInputConnector::UnsetConnection("
<<c<<")"<<std::endl);
- mConnection = 0;
+ mConnection.reset();
}
IOStatus BlackBoxInputConnector::BackwardUpdate()
bbtkDebugMessageInc("Process",4,"BlackBoxInputConnector::BackwardUpdate()"
<<std::endl);
- if (mConnection)
+ if (mConnection.lock())
{
- IOStatus s = mConnection->BackwardUpdate();
+ IOStatus s = mConnection.lock()->BackwardUpdate();
mStatus = s;
}
else
Program: bbtk
Module: $RCSfile: bbtkBlackBoxInputConnector.h,v $
Language: C++
- Date: $Date: 2008/01/22 15:02:00 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
namespace bbtk
{
+ class BlackBox;
+ BBTK_FORWARD_DECLARE_POINTER(BlackBox);
class BBTK_EXPORT BlackBoxInputConnector
{
public:
/// Ctor
- BlackBoxInputConnector(BlackBox* b);
+ BlackBoxInputConnector(BlackBoxPointer b);
/// Dtor
~BlackBoxInputConnector();
/// Sets a connection
- void SetConnection(Connection* c);
+ void SetConnection(Connection::Pointer c);
/// Unsets the connection
/// The parameter is USELESS today but would be useful if we allow multiple connections on inputs
- void UnsetConnection(Connection* c);
+ void UnsetConnection(Connection::Pointer c);
IOStatus BackwardUpdate();
/// Returns the connection plugged into this input (const)
- const Connection* GetConnection() const { return mConnection; }
- /// Returns the connection plugged into this input
- Connection* GetConnection() { return mConnection; }
+ Connection::Pointer GetConnection() const { return mConnection.lock(); }
/// Returns true iff a connection is connected to it
- bool IsConnected() const { return (mConnection != 0); }
+ bool IsConnected() const { return (mConnection.lock() != 0); }
/// Returns the status of the input (UPTODATE | MODIFIED)
const IOStatus& GetStatus() const { return mStatus; }
///
- BlackBox* GetBlackBox() const { return mBox; }
+ BlackBoxPointer GetBlackBox() const { return mBox.lock(); }
private:
///
- BlackBox* mBox;
+ BlackBoxWeakPointer mBox;
/// The connection plugged into the input
- Connection* mConnection;
+ Connection::WeakPointer mConnection;
/// The status of the input (UPTODATE | MODIFIED)
IOStatus mStatus;
};
Program: bbtk
Module: $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
BlackBoxOutputConnector::~BlackBoxOutputConnector()
{
- bbtkDebugMessageInc("Kernel",9,
- "BlackBoxOutputConnector::~BlackBoxOutputConnector()"
- <<std::endl);
- std::vector<Connection*>::iterator i;
- for (i=mConnection.begin();i!=mConnection.end();++i)
- {
- delete *i;
- }
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugMessage("Kernel",9,
+ "==> BlackBoxOutputConnector::~BlackBoxOutputConnector()"
+ <<std::endl);
+ ConnectionVector::iterator i;
+ for (i=mConnection.begin();
+ i!=mConnection.end();
+ ++i)
+ (*i) = Connection::WeakPointer();
+ bbtkDebugMessage("Kernel",9,
+ "<== BlackBoxOutputConnector::~BlackBoxOutputConnector()"
+ <<std::endl);
}
///
- void BlackBoxOutputConnector::SetConnection(Connection* c)
+ void BlackBoxOutputConnector::SetConnection(Connection::Pointer c)
{
bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::SetConnection("
<<c<<")"<<std::endl);
///
- void BlackBoxOutputConnector::UnsetConnection(Connection* c)
+ void BlackBoxOutputConnector::UnsetConnection(Connection::Pointer c)
{
bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection("
<<c<<")"<<std::endl);
- c->Check();
- std::vector<Connection*>::iterator i
- = find(mConnection.begin(),mConnection.end(),c);
+ if (!c)
+ {
+ bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : invalid connection");
+
+ }
+ // c->Check();
+ //Connection::WeakPointer w(c);
+ ConnectionVector::iterator i;
+ // = find(mConnection.begin(),mConnection.end(),c);
+ for (i=mConnection.begin();
+ i!=mConnection.end();
+ ++i)
+ {
+ if (i->lock()==c) break;
+ }
if (i==mConnection.end())
{
bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : connection is absent from connections list");
bbtkDebugMessageInc("Process",5,
"BlackBoxOutputConnector::SetModifiedStatus()"
<<std::endl);
- std::vector<Connection*>::iterator i;
+ ConnectionVector::iterator i;
for (i=mConnection.begin();i!=mConnection.end();++i)
{
- (*i)->SetModifiedStatus();
+ (*i).lock()->SetModifiedStatus();
}
bbtkDebugDecTab("Process",5);
Program: bbtk
Module: $RCSfile: bbtkBlackBoxOutputConnector.h,v $
Language: C++
- Date: $Date: 2008/01/22 15:02:00 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
BlackBoxOutputConnector();
~BlackBoxOutputConnector();
- void SetConnection(Connection* c);
- void UnsetConnection(Connection* c);
+ void SetConnection(Connection::Pointer c);
+ void UnsetConnection(Connection::Pointer c);
//IOStatus Update();
void SetModifiedStatus();
- const std::vector<Connection*>& GetConnectionVector() const { return mConnection; }
+ typedef std::vector<Connection::WeakPointer> ConnectionVector;
+ const ConnectionVector& GetConnectionVector() const { return mConnection; }
private:
/// The vector of output connections
- std::vector<Connection*> mConnection;
+ ConnectionVector mConnection;
/// The status of the output
//IOStatus mStatus;
};
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.cxx,v $
Language: C++
-Date: $Date: 2008/04/09 11:16:57 $
-Version: $Revision: 1.9 $
+Date: $Date: 2008/04/18 12:59:15 $
+Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace bbtk
{
+ //==========================================================================
+ /// Creates a new complex black box
+ ComplexBlackBox::Pointer ComplexBlackBox::New(const std::string& name,
+ ComplexBlackBoxDescriptor::Pointer desc)
+ {
+ bbtkDebugMessage("object",1,"##> ComplexBlackBox::New('"<<name<<"','"<<
+ desc->GetTypeName()<<"')" <<bbtkendl);
+ ComplexBlackBox::Pointer p =
+ MakeBlackBoxPointer(new ComplexBlackBox(name,desc));
+ bbtkDebugMessage("object",2,"<## ComplexBlackBox::New('"<<name<<"','"<<
+ desc->GetTypeName()<<"')" <<bbtkendl);
+ return p;
+ }
+ //==========================================================================
//=======================================================================
/// Usefull constructor
ComplexBlackBox::ComplexBlackBox(const std::string &name,
- ComplexBlackBoxDescriptor* desc)
- : BlackBox(name),
- mDescriptor(desc)
+ ComplexBlackBoxDescriptor::Pointer desc)
+ :
+ BlackBox(name),
+ mLockedDescriptor(desc),
+ mDescriptor(desc)
{
- bbtkDebugMessageInc("Kernel",9,
- "ComplexBlackBox::ComplexBlackBox(\""
- <<name<<"\")"<<std::endl);
+ bbtkDebugMessage("object",3,
+ "##> ComplexBlackBox::ComplexBlackBox(\""
+ <<name<<"\")"<<std::endl);
bbAllocateConnectors();
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugMessage("object",3,
+ "<## ComplexBlackBox::ComplexBlackBox(\""
+ <<name<<"\")"<<std::endl);
}
//=======================================================================
ComplexBlackBox::ComplexBlackBox(ComplexBlackBox& from,
const std::string &name)
: BlackBox(from,name),
+ // The locked descriptor is copied from the unlocked one
+ // to make the box a non-prototype !!
+ mLockedDescriptor(from.mDescriptor),
mDescriptor(from.mDescriptor),
mExecutionList(from.mExecutionList)
{
- bbtkDebugMessageInc("Kernel",9,
- "ComplexBlackBox::ComplexBlackBox(\""
+ bbtkDebugMessage("object",3,
+ "##> ComplexBlackBox::ComplexBlackBox(\""
<<from.bbGetName()<<"\",\""
<<name<<"\")"<<std::endl);
-
- bbtkDebugMessageInc("Kernel",9,"* Cloning Black Boxes"<<std::endl);
+ bbtkDebugMessage("object",4," * Cloning Black Boxes"<<std::endl);
BlackBoxMapType::const_iterator i;
for ( i = from.mBlackBoxMap.begin(); i != from.mBlackBoxMap.end(); ++i )
{
- bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<i->first<<"\""<<std::endl);
- BlackBox* B = i->second->bbClone(i->second->bbGetName());
+ bbtkDebugMessageInc("object",5," * Cloning \""<<i->first<<"\""<<std::endl);
+ BlackBox::Pointer B = i->second->bbClone(i->second->bbGetName());
bbUnsafeAddBlackBox(B);
- bbtkDebugDecTab("Kernel",9);
}
- bbtkDebugDecTab("Kernel",9);
- bbtkDebugMessageInc("Kernel",9,"* Cloning Connections"<<std::endl);
+ bbtkDebugMessage("object",4," * Cloning Connections"<<std::endl);
ConnectionListType::const_iterator j;
for ( j = from.mConnectionList.begin(); j != from.mConnectionList.end(); ++j )
{
- bbtkDebugMessageInc("Kernel",9,"* Cloning \""<<
- (*j)->GetFullName()<<"\""<<std::endl);
+ bbtkDebugMessage("object",5," * Cloning \""<<
+ (*j)->GetFullName()<<"\""<<std::endl);
+
+ BlackBox::Pointer bbfrom = bbGetBlackBox( (*j)->GetOriginalBlackBoxFrom()->bbGetName() );
+ BlackBox::Pointer bbto = bbGetBlackBox( (*j)->GetOriginalBlackBoxTo()->bbGetName() );
- BlackBox* bbfrom = bbGetBlackBox( (*j)->GetOriginalBlackBoxFrom()->bbGetName() );
- BlackBox* bbto = bbGetBlackBox( (*j)->GetOriginalBlackBoxTo()->bbGetName() );
- Connection* c = mDescriptor->GetFactory()->
+ Connection::Pointer c = mDescriptor.lock()->GetFactory()->
NewConnection( bbfrom,
(*j)->GetOriginalBlackBoxFromOutput(),
bbto,
(*j)->GetOriginalBlackBoxToInput() );
-
+ //c->Check();
bbAddConnection(c);
- bbtkDebugDecTab("Kernel",9);
}
- bbtkDebugDecTab("Kernel",9);
bbAllocateConnectors();
- bbtkDebugDecTab("Kernel",9);
+ bbtkDebugMessage("object",3,
+ "<## ComplexBlackBox::ComplexBlackBox(\""
+ <<from.bbGetName()<<"\",\""
+ <<name<<"\")"<<std::endl);
}
//=======================================================================
/// Destructor
ComplexBlackBox::~ComplexBlackBox()
{
- bbtkDebugMessageInc("Kernel",1,
- "ComplexBlackBox::~ComplexBlackBox() ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- bbtkDebugMessageInc("Kernel",1,"* Delete Connections"<<std::endl);
- ConnectionListType::iterator j;
- for ( j = mConnectionList.begin(); j != mConnectionList.end(); ++j )
- {
- bbtkDebugMessageInc("Kernel",1,"* Delete \""<<
- (*j)->GetFullName()<<"\""<<std::endl);
- delete *j;
- bbtkDebugDecTab("Kernel",9);
- }
- bbtkDebugDecTab("Kernel",9);
-
-
- bbtkDebugMessageInc("Kernel",1,"* Delete Black Boxes"<<std::endl);
- BlackBoxMapType::iterator i;
- for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i )
+ bbtkDebugMessage("object",3,
+ "==> ComplexBlackBox::~ComplexBlackBox() ["
+ <<bbGetName()<<"]"<<std::endl);
+
+ bbtkDebugMessage("object",4,
+ " -> Releasing connections"<<std::endl);
+ mConnectionList.clear();
+ bbtkDebugMessage("object",4,
+ " -> Releasing boxes"<<std::endl);
+ mBlackBoxMap.clear();
+
+ /*
+ // Clear();
+ this->bbDesallocateConnectors();
+ if (mLockedDescriptor)
{
- bbtkDebugMessageInc("Kernel",1,"* Delete \""<<i->first<<"\""<<std::endl);
- i->second->bbDelete();
- bbtkDebugDecTab("Kernel",1);
+ bbtkMessage("object",3," --> Releasing descriptor"<<std::endl);
+ mLockedDescriptor.reset();
+ if (!mDescriptor.expired()) BlackBoxDescriptor::Release(mDescriptor);
}
- bbtkDebugDecTab("Kernel",1);
-
- bbtkDebugMessage("Kernel",1,"EO ComplexBlackBox::~ComplexBlackBox ["
- <<bbGetFullName()<<"]"<<std::endl);
-
- this->bbDesallocateConnectors();
- bbtkDebugDecTab("Kernel",1);
+ */
+ bbtkDebugMessage("object",3,
+ "<== ComplexBlackBox::~ComplexBlackBox() ["
+ <<bbGetName()<<"]"<<std::endl);
}
//=======================================================================
+
//=========================================================================
/// Allocates the i/o connectors of the black box
"ComplexBlackBox::bbAllocateConnectors() ["
<<bbGetFullName()<<"]"
<<std::endl);
-
+ /*
// Input connectors
const BlackBoxDescriptor::InputDescriptorMapType& imap
= bbGetDescriptor()->GetInputDescriptorMap();
bbGetOutputConnectorMap()[o->second->GetName()] = c;
//new BlackBoxOutputConnector();
}
+
+*/
+
bbtkDebugDecTab("Kernel",8);
}
//=========================================================================
// but by the internal boxes. Hence **DO NOT** desallocate !
// just clear the maps to avoid that
// BlackBox::bbDesallocateConnectors delete the connectors
- bbGetInputConnectorMap().clear();
+
+ /*
+ bbGetInputConnectorMap().clear();
bbGetOutputConnectorMap().clear();
-
+ */
bbtkDebugDecTab("Kernel",8);
}
//=========================================================================
//=======================================================================
- BlackBox* ComplexBlackBox::bbClone(const std::string& name)
+ BlackBox::Pointer ComplexBlackBox::bbClone(const std::string& name)
{
bbtkDebugMessageInc("Kernel",9,
"ComplexBlackBox::bbClone(\""<<name<<"\") ["
<<bbGetFullName()<<"]"<<std::endl);
ComplexBlackBox* CBB = new ComplexBlackBox(*this,name);
- bbGetDescriptor()->Reference();
-
- bbtkDebugDecTab("Kernel",9);
-
- return CBB;
+ return MakeBlackBoxPointer(CBB);
}
//=======================================================================
}
else
{
- std::map<std::string, BlackBox*>::iterator i;
+ std::map<std::string, BlackBox::Pointer>::iterator i;
for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i)
{
i->second->bbExecute(force);
//==================================================================
//==================================================================
- IOStatus ComplexBlackBox::bbBackwardUpdate(Connection* caller)
+ IOStatus ComplexBlackBox::bbBackwardUpdate(Connection::Pointer caller)
{
bbtkDebugMessageInc("Process",1,
"ComplexBlackBox::bbBackwardUpdate("
//=========================================================================
/// Connects the input <name> to the connection c
- void ComplexBlackBox::bbConnectInput( const std::string& name, Connection* c)
+ void ComplexBlackBox::bbConnectInput( const std::string& name, Connection::Pointer c)
{
bbtkDebugMessageInc("Kernel",7,
"ComplexBlackBox::bbConnectInput(\""
ComplexBlackBoxInputDescriptor* d = (ComplexBlackBoxInputDescriptor*)
bbGetDescriptor()->GetInputDescriptor(name);
- BlackBox* t = bbGetBlackBox(d->GetTarget());
+ BlackBox::Pointer t = bbGetBlackBox(d->GetTarget());
c->SetBlackBoxTo(t);
c->SetBlackBoxToInput(d->GetInput());
t->bbConnectInput(d->GetInput(),c);
//=========================================================================
/// Connects the output <name> to the connection c
- void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection* c)
+ void ComplexBlackBox::bbConnectOutput( const std::string& name, Connection::Pointer c)
{
bbtkDebugMessageInc("Kernel",7,
"ComplexBlackBox::bbConnectOutput(\""
ComplexBlackBoxOutputDescriptor* d = (ComplexBlackBoxOutputDescriptor*)
bbGetDescriptor()->GetOutputDescriptor(name);
- BlackBox* t = bbGetBlackBox(d->GetTarget());
+ BlackBox::Pointer t = bbGetBlackBox(d->GetTarget());
+
c->SetBlackBoxFrom(t);
c->SetBlackBoxFromOutput(d->GetOutput());
t->bbConnectOutput(d->GetOutput(),c);
- bbtkMessage("Debug",1,"ComplexBlackBox["<<bbGetFullName()<<"]::bbConnectOutput : "
+ bbtkMessage("Debug",5,"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::bbAddBlackBox( BlackBox::Pointer b)
{
bbtkDebugMessageInc("Kernel",7,
"ComplexBlackBox::AddBlackBox(\""<<b->bbGetName()
bbtkError("a black box called \""<<b->bbGetName()
<<"\" already exists");
}
- b->bbSetParent(this);
+ b->bbSetParent(GetThisPointer<ComplexBlackBox>());
mBlackBoxMap[b->bbGetName()] = b;
bbtkDebugDecTab("Kernel",7);
//==================================================================
/// Adds the black box to the complex box (unsafe)
- void ComplexBlackBox::bbUnsafeAddBlackBox( BlackBox* b)
+ void ComplexBlackBox::bbUnsafeAddBlackBox( BlackBox::Pointer b)
{
bbtkDebugMessageInc("Kernel",7,
"ComplexBlackBox::UnsafeAddBlackBox(\""<<b->bbGetName()
<<"\") ["
<<bbGetFullName()<<"]"<<std::endl);
- b->bbSetParent(this);
+ b->bbSetParent(GetThisPointer<ComplexBlackBox>());
mBlackBoxMap[b->bbGetName()] = b;
bbtkDebugDecTab("Kernel",7);
//==================================================================
/// Removes the black box from the complex box
- void ComplexBlackBox::bbRemoveBlackBox( const std::string& name )
+ void ComplexBlackBox::bbRemoveBlackBox( const std::string& name,
+ bool remove_connections )
{
bbtkDebugMessageInc("Kernel",7,
"ComplexBlackBox::RemoveBlackBox(\""<<name<<"\") ["
<<bbGetFullName()<<"]"<<std::endl);
- bbtkError("ComplexBlackBox::RemoveBlackBox not implemented");
+ BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
+ if ( i == mBlackBoxMap.end() )
+ {
+ bbtkError("the black box \""<<name<<"\" does not exist");
+ }
+ BlackBox::WeakPointer p = i->second;
+
+ if (remove_connections)
+ {
+ ConnectionListType::const_iterator j;
+ for ( j = mConnectionList.begin();
+ j != mConnectionList.end(); ++j )
+ {
+ //(*j)->Check();
+ }
+ }
+ if (p.use_count()!=1)
+ {
+ bbtkError("the black box \""<<name<<"\" is still connected");
+ }
+
+ mBlackBoxMap.erase(i);
+
+
+ // Unload orphan dl packages
+ Package::UnLoadReleasedDynamicallyLoadedPackages();
bbtkDebugDecTab("Kernel",7);
}
//==================================================================
/// Adds the connection to the complex box
- void ComplexBlackBox::bbAddConnection( Connection* c)
+ void ComplexBlackBox::bbAddConnection( Connection::Pointer c)
{
bbtkDebugMessageInc("Kernel",7,
"ComplexBlackBox::AddConnection(\""<<"..."<<"\") ["
//==================================================================
/// Returns the black box with name <name>
- BlackBox* ComplexBlackBox::bbGetBlackBox( const std::string& name )
+ BlackBox::Pointer ComplexBlackBox::bbGetBlackBox( const std::string& name )
{
bbtkDebugMessageInc("Kernel",9,
"ComplexBlackBox::GetBlackBox(\""<<name<<"\") ["
//==================================================================
/// Returns the black box with name <name> : does not throw an exception
/// if it does not exist but return a null pointer
- BlackBox* ComplexBlackBox::bbUnsafeGetBlackBox( const std::string& name )
+ BlackBox::Pointer ComplexBlackBox::bbUnsafeGetBlackBox( const std::string& name )
{
bbtkDebugMessageInc("Kernel",9,
"ComplexBlackBox::UnsafeGetBlackBox(\""<<name<<"\") ["
if ( i == mBlackBoxMap.end() )
{
bbtkDebugDecTab("Kernel",9);
- return 0;
+ return BlackBox::Pointer();
}
bbtkDebugDecTab("Kernel",9);
//=========================================================================
- BlackBox *ComplexBlackBox::bbFindBlackBox(const std::string &blackboxname)
+ BlackBox::Pointer ComplexBlackBox::bbFindBlackBox(const std::string &blackboxname)
{
- BlackBox *blackbox=NULL;
+ BlackBox::Pointer blackbox;
std::string subname="";
std::string restname="";
std::string delimiters(">");
}
BlackBoxMapType::iterator i = mBlackBoxMap.find(subname);
- if ( i == mBlackBoxMap.end() )
- {
- blackbox = NULL;
- }
- else
+ if ( i != mBlackBoxMap.end() )
{
blackbox = i->second;
if (restname!="")
fprintf(ff,"rankdir=LR%s\n",";");
fprintf(ff,"node [shape=record]%s\n",";");
- this->bbWriteDotFileBlackBox(ff,this,detail,level,
+ this->bbWriteDotFileBlackBox(ff,
+ GetThisPointer<ComplexBlackBox>(),
+ detail,level,
instanceOrtype,
relative_link );
//=========================================================================
/// Write Graphviz-dot description in file
void ComplexBlackBox::bbWriteDotFileBlackBox(FILE *ff,
- BlackBox *parentblackbox,
+ BlackBox::Pointer parentblackbox,
int detail, int level,
bool instanceOrtype,
bool relative_link )
{
std::string tmp1;
std::string valueStr("");
- Package *package = this->bbGetDescriptor()->GetPackage();
+ Package::Pointer package = this->bbGetDescriptor()->GetPackage();
if (package!=NULL)
{
}
std::string boxname="["+bbGetTypeName()+"]";
- if (this!=parentblackbox)
+ if (GetThisPointer<ComplexBlackBox>()!=parentblackbox)
{
if (detail==0)
{
{
if (level>-1)
{
- j->second->bbWriteDotFileBlackBox(ff,parentblackbox,detail,
+ j->second->bbWriteDotFileBlackBox(ff,
+ parentblackbox,
+ detail,
level-1,
instanceOrtype,
relative_link);
fprintf(ff,":%s",cbbid->GetName().c_str() );
}
fprintf(ff,"->" );
- BlackBox *bb = bbGetBlackBox( cbbid->GetTarget() );
+ BlackBox::Pointer bb = bbGetBlackBox( cbbid->GetTarget() );
bb->bbWriteDotInputOutputName(ff,true,detail,level);
if (detail==1)
{
{
ComplexBlackBoxOutputDescriptor *cbbod = (ComplexBlackBoxOutputDescriptor*)yy->second;
fprintf(ff," ");
- BlackBox *bb = bbGetBlackBox( cbbod->GetTarget() );
+ BlackBox::Pointer bb = bbGetBlackBox( cbbod->GetTarget() );
bb->bbWriteDotInputOutputName(ff,false,detail,level);
if (detail==1)
{
// Relation from the out side of this ComplexBlackBox with its Inputs
- if (this!=parentblackbox) {
+ if (GetThisPointer<ComplexBlackBox>()!=parentblackbox) {
for ( ii = bbGetInputConnectorMap().begin();
ii != bbGetInputConnectorMap().end(); ++ii )
{
if (ii->second)
{
- Connection* con = ii->second->GetConnection();
+ Connection::Pointer con = ii->second->GetConnection();
if (con!=NULL){
- BlackBox *a=con->GetBlackBoxFrom();
- BlackBox *b=con->GetBlackBoxTo();
+ BlackBox::Pointer a=con->GetBlackBoxFrom();
+ BlackBox::Pointer b=con->GetBlackBoxTo();
fprintf(ff," ");
a->bbWriteDotInputOutputName(ff,false,detail,level);
if (detail==1)
for ( j = mConnectionList.begin();
j != mConnectionList.end(); ++j )
{
- (*j)->Check();
+ //(*j)->Check();
}
bbtkMessage("Debug",1,"**** Checking Complex Black Box "<<(void*)this
<<" ["<<bbGetFullName()<<"] ... OK"<<std::endl);
}
//=======================================================================
+ //=========================================================================
+ /// Returns the name with the name of the parent prepended if any
+ std::string ComplexBlackBox::bbGetNameWithParent() const
+ {
+ if (!IsAPrototype()) return BlackBox::bbGetNameWithParent();
+ if (bbGetDescriptor())
+ {
+ return bbGetDescriptor()->GetFullTypeName() + ":" + bbGetName();
+ }
+ else
+ {
+ return std::string(":") + bbGetName();
+ }
+ }
+ //=========================================================================
+
+ //==========================================================================
+ std::string ComplexBlackBox::GetObjectName() const
+ {
+ return std::string("ComplexBlackBox '")+bbGetNameWithParent()
+ +std::string("'");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string ComplexBlackBox::GetObjectInfo() const
+ {
+ std::stringstream i;
+ i << " - "<<mBlackBoxMap.size() << " boxes / "
+ <<mConnectionList.size() << " connections" << std::endl;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+ size_t ComplexBlackBox::GetObjectSize() const
+ {
+ size_t s = Superclass::GetObjectSize();
+ s += ComplexBlackBox::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t ComplexBlackBox::GetObjectInternalSize() const
+ {
+ size_t s = sizeof(ComplexBlackBox);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t ComplexBlackBox::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += ComplexBlackBox::GetObjectInternalSize();
+ BlackBoxMapType::const_iterator i;
+ for ( i = mBlackBoxMap.begin(); i != mBlackBoxMap.end(); ++i )
+ {
+ s += i->second->GetObjectRecursiveSize();
+ }
+ ConnectionListType::const_iterator j;
+ for ( j = mConnectionList.begin();
+ j != mConnectionList.end(); ++j )
+ {
+ s += (*j)->GetObjectRecursiveSize();
+ }
+ return s;
+ }
+ //==========================================================================
+
}
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBox.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
//==================================================================
class BBTK_EXPORT ComplexBlackBox : public bbtk::BlackBox
{
+ BBTK_OBJECT_INTERFACE(ComplexBlackBox);
friend class ComplexBlackBoxDescriptor;
+ typedef BlackBox Superclass;
public:
//==================================================================
// PUBLIC PART : ACCESSIBLE TO THE END-USER
/// Returns the pointer on the box' descriptor
- BlackBoxDescriptor* bbGetDescriptor() const { return mDescriptor; }
+ BlackBoxDescriptor::Pointer bbGetDescriptor() const { return mDescriptor.lock(); }
/// 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);
+ BlackBox::Pointer bbClone(const std::string& name);
+
+ /// Clear
+ void Clear();
+ /// Set as prototype
+ void SetAsPrototype() { mLockedDescriptor.reset(); }
+ /// Returns true if it is a prototype
+ bool IsAPrototype() const { return (!mLockedDescriptor); }
+
+ std::string bbGetNameWithParent() const;
void bbExecute(bool force = false);
bool setModified = true);
/// Connects the input <name> to the connection c
- virtual void bbConnectInput( const std::string& name, Connection* c);
+ virtual void bbConnectInput( const std::string& name,
+ Connection::Pointer c);
/// Connects the output <name> to the connection c
- virtual void bbConnectOutput( const std::string& name, Connection* c);
+ virtual void bbConnectOutput( const std::string& name,
+ Connection::Pointer c);
- BlackBox* bbGetBlackBox( const std::string& name );
+ BlackBox::Pointer bbGetBlackBox( const std::string& name );
+
+ /// The type of map of black boxes
+ typedef std::map<std::string, BlackBox::Pointer> BlackBoxMapType;
- const std::map<std::string, BlackBox*>& bbGetBlackBoxMap()
- {
- return mBlackBoxMap;
- }
+ const BlackBoxMapType& bbGetBlackBoxMap() { return mBlackBoxMap; }
void bbPrintBlackBoxes();
/// Generates own description and recursively calls itself
/// on internal boxes with level-1
virtual void bbWriteDotFileBlackBox(FILE *ff,
- BlackBox *parentblackbox,
+ BlackBox::Pointer parentblackbox,
int detail, int level,
bool instanceOrtype,
bool relative_link );
bool inputoutput,
int detail, int level);
- virtual BlackBox *bbFindBlackBox(const std::string &blackboxname);
+ virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname);
void Check(bool recursive=true);
+
+
protected:
//==================================================================
// PROTECTED PART : ACCESSIBLE TO ComplexBlackBoxDescriptor
+ static ComplexBlackBox::Pointer
+ New(const std::string &name,
+ ComplexBlackBoxDescriptor::Pointer desc);
+
+ private:
/// Constructor that takes the ComplexBlackBox name
- ComplexBlackBox(const std::string &name, ComplexBlackBoxDescriptor* desc);
+ ComplexBlackBox(const std::string &name,
+ ComplexBlackBoxDescriptor::Pointer desc);
/// Constructor from an existing box (copy) with a new name
ComplexBlackBox(ComplexBlackBox& from, const std::string &name);
- //
- ~ComplexBlackBox();
-
public:
- IOStatus bbBackwardUpdate(Connection* caller);
+ IOStatus bbBackwardUpdate(Connection::Pointer caller);
// void bbForwardUpdate(Connection* caller);
void bbSetModifiedStatus(BlackBoxInputConnector* c);
- void bbAddBlackBox( BlackBox* );
+ void bbAddBlackBox( BlackBox::Pointer );
void bbAddToExecutionList( const std::string& name );
- void bbUnsafeAddBlackBox( BlackBox* );
- void bbRemoveBlackBox( const std::string& name );
- void bbAddConnection( Connection* );
+ void bbUnsafeAddBlackBox( BlackBox::Pointer );
+ void bbRemoveBlackBox( const std::string& name,
+ bool remove_connections = true);
+ void bbAddConnection( Connection::Pointer );
// void RemoveConnection( );
- BlackBox* bbUnsafeGetBlackBox( const std::string& name );
+ BlackBox::Pointer bbUnsafeGetBlackBox( const std::string& name );
///
void bbAllocateConnectors();
// PRIVATE PART : MEMBERS AND USEFULL INTERNAL METHODS
/// Default constructor : derived classes must use the constructor with the ComplexBlackBox's name
- ComplexBlackBox() : BlackBox("") {}
+ //ComplexBlackBox() : BlackBox("") {}
+ // true if the box is a prototype of a ComplexBlackBoxDescriptor
+ // bool mIsAPrototype;
+
+ /// The descriptor pointer : is 0 if the box is a prototype
+ ComplexBlackBoxDescriptor::Pointer mLockedDescriptor;
/// The descriptor pointer
- ComplexBlackBoxDescriptor* mDescriptor;
+ ComplexBlackBoxDescriptor::WeakPointer mDescriptor;
- /// The type of map of black boxes
- typedef std::map<std::string, BlackBox*> BlackBoxMapType;
/// The map of black boxes
BlackBoxMapType mBlackBoxMap;
/// The type of list of connections
- typedef std::list<Connection*> ConnectionListType;
+ typedef std::list<Connection::Pointer> ConnectionListType;
/// The list of connections
ConnectionListType mConnectionList;
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBoxDescriptor.cxx,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.14 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
namespace bbtk
{
-
+ //=======================================================================
+ ///
+ ComplexBlackBoxDescriptor::Pointer
+ ComplexBlackBoxDescriptor::New(const std::string& name)
+ {
+ bbtkDebugMessage("object",1,"##> ComplexBlackBoxDescriptor::New(\""<<name<<"\")"<<std::endl);
+ ComplexBlackBoxDescriptor::Pointer p =
+ MakePointer(new ComplexBlackBoxDescriptor(name));
+ bbtkDebugMessage("object",1,"<## ComplexBlackBoxDescriptor::New(\""<<name<<"\")"<<std::endl);
+ return p;
+ }
+ //=======================================================================
//=======================================================================
/// Default ctor
ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(const std::string& name)
- : BlackBoxDescriptor(),
- mFactory(0)
{
- bbtkDebugMessageInc("Kernel",9,"ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
+ bbtkDebugMessage("object",2,"==> ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
SetTypeName(name);
AddToCategory("complex box");
- mPrototype = new ComplexBlackBox(name+std::string("Prototype"),this);
- // this->Reference();
- bbtkDebugDecTab("Kernel",9);
+ mPrototype = ComplexBlackBox::New(name+std::string("Prototype"),
+ MakePointer(this,true));
+ mPrototype->SetAsPrototype();
+ bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::ComplexBlackBoxDescriptor(\""<<name<<"\")"<<std::endl);
}
//=======================================================================
/// Default dtor
ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor()
{
- bbtkDebugMessageInc("Kernel",1,"ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
-
- delete mPrototype;
-
- bbtkDebugMessage("Kernel",1,"EO ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
- bbtkDebugDecTab("Kernel",1);
+ bbtkDebugMessage("object",2,"==> ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
+ // mPrototype->Delete();
+ mPrototype.reset();
+ bbtkDebugMessage("object",2,"<== ComplexBlackBoxDescriptor::~ComplexBlackBoxDescriptor(\""<<GetTypeName()<<"\")"<<std::endl);
}
//=======================================================================
//=======================================================================
/// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
- BlackBox* ComplexBlackBoxDescriptor::CreateInstance(const std::string& name)
+ BlackBox::Pointer
+ ComplexBlackBoxDescriptor::NewBlackBox(const std::string& name)
{
- //bbtkError("ComplexBlackBoxDescriptor::CreateInstance not implemented");
bbtkDebugMessageInc("Kernel",5,
- "ComplexBlackBoxDescriptor::CreateInstance(\""
+ "ComplexBlackBoxDescriptor::NewBlackBox(\""
<<name<<"\") ["
<<GetTypeName()<<"]"<<std::endl);
}
//=======================================================================
-
+ /*
+ //=======================================================================
+ /// Release
+ void ComplexBlackBoxDescriptor::Release(bool release_package)
+ {
+ }
+ //=======================================================================
+ */
//=======================================================================
/// Adds a black box to the complex box
<<GetTypeName()<<"]"<<std::endl);
//
- if (mFactory == 0)
+ if (!GetFactory())
{
bbtkError("ComplexBlackBoxDescriptor::Add : no factory set");
}
bbtkError("a black box \""<<name<<"\" already exists");
}
// ok : create new one
- mPrototype->bbAddBlackBox ( mFactory->NewBlackBox(type,name) );
+ mPrototype->bbAddBlackBox ( GetFactory()->NewBlackBox(type,name) );
bbtkDebugDecTab("Kernel",5);
}
//=======================================================================
+
+ //=======================================================================
+ /// Removes a black box from the complex box
+ void ComplexBlackBoxDescriptor::Remove( const std::string& name,
+ bool remove_connections)
+ {
+ mPrototype->bbRemoveBlackBox(name,remove_connections);
+ }
+ //=======================================================================
- //=======================================================================
+
+ //=======================================================================
/// Adds a black box to the execution list
void ComplexBlackBoxDescriptor::AddToExecutionList ( const std::string& box)
{
<<box<<"\" ["
<<GetTypeName()<<"]"<<std::endl);
// Verify that the box exists
- BlackBox* b = mPrototype->bbUnsafeGetBlackBox( box );
+ BlackBox::Pointer b = mPrototype->bbUnsafeGetBlackBox( box );
if ( !b )
{
bbtkError("the black box \""<<box<<"\" does not exist");
<<"\") ["
<<GetTypeName()<<"]"<<std::endl);
//
- if (mFactory == 0)
+ if (!GetFactory())
{
bbtkError("ComplexBlackBoxDescriptor::Connect : no factory set");
}
// Verify that a box with the same name does not exist already
- BlackBox* bbfrom = mPrototype->bbGetBlackBox( from );
+ BlackBox::Pointer bbfrom = mPrototype->bbGetBlackBox( from );
if ( !bbfrom )
{
bbtkError("the black box \""<<from<<"\" does not exist");
}
- BlackBox* bbto = mPrototype->bbGetBlackBox( to );
+ BlackBox::Pointer bbto = mPrototype->bbGetBlackBox( to );
if ( !bbto )
{
bbtkError("the black box \""<<to<<"\" does not exist");
}
- Connection* c = mFactory->NewConnection( bbfrom, output, bbto, input );
+ Connection::Pointer c
+ = GetFactory()->NewConnection( bbfrom, output, bbto, input );
mPrototype->bbAddConnection(c);
<<"\") ["
<<GetTypeName()<<"]"<<std::endl);
- BlackBox* bb = mPrototype->bbGetBlackBox( box );
+ BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box );
if ( !bb )
{
bbtkError("the black box \""<<box<<"\" does not exist");
<<"\") ["
<<GetTypeName()<<"]"<<std::endl);
- BlackBox* bb = mPrototype->bbGetBlackBox( box );
+ BlackBox::Pointer bb = mPrototype->bbGetBlackBox( box );
if ( !bb )
{
bbtkError("the black box \""<<box<<"\" does not exist");
{
(s) << "<TR><TD style='vertical-align: top;'><b> Uses </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> ";
- std::set<BlackBoxDescriptor*> pdeps;
+ std::set<BlackBoxDescriptor::Pointer> pdeps;
ComplexBlackBox::BlackBoxMapType::const_iterator b;
for ( b = B.begin(); b != B.end(); ++b )
{
- BlackBoxDescriptor* d = b->second->bbGetDescriptor();
+ BlackBoxDescriptor::Pointer d = b->second->bbGetDescriptor();
if (pdeps.find(d) != pdeps.end())
continue;
pdeps.insert(d);
- Package* p = d->GetPackage();
+ Package::Pointer p = d->GetPackage();
std::string name = b->second->bbGetTypeName();
}
//=======================================================================
-
-
+ //==========================================================================
+ std::string ComplexBlackBoxDescriptor::GetObjectName() const
+ {
+ return std::string("ComplexBlackBoxDescriptor '")+GetFullTypeName()
+ +std::string("'");
+ }
+ //==========================================================================
+ //=======================================================================
+ std::string ComplexBlackBoxDescriptor::GetObjectInfo() const
+ {
+ std::string i;
+ return i;
+ }
+ //=======================================================================
+ //==========================================================================
+size_t ComplexBlackBoxDescriptor::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += ComplexBlackBoxDescriptor::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t ComplexBlackBoxDescriptor::GetObjectInternalSize() const
+{
+ size_t s = sizeof(ComplexBlackBoxDescriptor);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t ComplexBlackBoxDescriptor::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += ComplexBlackBoxDescriptor::GetObjectInternalSize();
+ s += mPrototype->GetObjectRecursiveSize();
+ return s;
+ }
+ //==========================================================================
}
Program: bbtk
Module: $RCSfile: bbtkComplexBlackBoxDescriptor.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
{
class ComplexBlackBox;
-
+ typedef boost::shared_ptr<ComplexBlackBox> ComplexBlackBoxPointer;
+
//==========================================================================
- class BBTK_EXPORT ComplexBlackBoxDescriptor : public bbtk::BlackBoxDescriptor
+ class BBTK_EXPORT ComplexBlackBoxDescriptor :
+ public bbtk::BlackBoxDescriptor
{
+ BBTK_OBJECT_INTERFACE(ComplexBlackBoxDescriptor);
+ typedef BlackBoxDescriptor Superclass;
public:
friend class ComplexBlackBox;
- /// Default ctor with name
- ComplexBlackBoxDescriptor(const std::string& name);
- protected:
- /// Default dtor
- ~ComplexBlackBoxDescriptor();
- public:
+
+ static Pointer New(const std::string& name);
/// Sets the factory used
- void SetFactory(Factory* f) { mFactory = f; }
+ void SetFactory(Factory::Pointer f) { mFactory = f; }
/// Gets the factory used
- Factory* GetFactory() { return mFactory; }
+ Factory::Pointer GetFactory() const { return mFactory.lock(); }
+
+ /// Releases the descriptor
+ // void Release(bool release_package = true);
+
/// Gets the factory used (const)
- const Factory* GetFactory() const { return mFactory; }
+ // const Factory* GetFactory() const { return mFactory; }
/// Creates an instance of name <name> of the ComplexBlackBox of which this is the descriptor
- virtual BlackBox* CreateInstance(const std::string& name);
+ virtual BlackBoxPointer NewBlackBox(const std::string& name);
/// Adds a black box to the complex box
/// Needs a factory set !
void Add ( const std::string& type,
const std::string& name
);
+
+ /// Removes a black box from the complex box
+ void Remove( const std::string& name, bool remove_connections = true);
+
/// Connects two black boxes of the complex box
/// Needs a factory set !
void Connect ( const std::string& from,
///
void AddToExecutionList( const std::string& box );
- ComplexBlackBox* GetPrototype() { return mPrototype; }
+ ComplexBlackBoxPointer GetPrototype() { return mPrototype; }
void PrintBlackBoxes();
/// Prints help on the black box
///
virtual void Check(bool recursive=true) const;
+
+
+
+ protected:
+ /// Default ctor with name is protected
+ ComplexBlackBoxDescriptor(const std::string& name);
private:
- /// Default ctor is private (must have name and factory)
- ComplexBlackBoxDescriptor() {}
/// The factory used
- Factory* mFactory;
+ Factory::WeakPointer mFactory;
/// The complex box in which boxes and connections are stored
- ComplexBlackBox* mPrototype;
+ ComplexBlackBoxPointer mPrototype;
/// The name of the script file from which it was created
std::string mScriptFileName;
Program: bbtk
Module: $RCSfile: bbtkConnection.cxx,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
namespace bbtk
{
-
+ Connection::Pointer Connection::New(BlackBox::Pointer from,
+ const std::string& output,
+ BlackBox::Pointer to,
+ const std::string& input ,
+ const Factory::Pointer f )
+ {
+ bbtkDebugMessage("object",1,"##> Connection::Connection(\""
+ <<from->bbGetName()<<"\",\""<<output<<"\",\""
+ <<to->bbGetName()<<"\",\""<<input<<"\")"
+ <<std::endl);
+ Connection::Pointer p =
+ MakePointer(new Connection(from,output,to,input,f));
+ bbtkDebugMessage("object",1,"<## Connection::Connection(\""
+ <<from->bbGetName()<<"\",\""<<output<<"\",\""
+ <<to->bbGetName()<<"\",\""<<input<<"\")"
+ <<std::endl);
+ return p;
+ }
+
//==================================================================
/// Ctor with the black box from and to and their input and output.
/// Check the input and output compatibility
- Connection::Connection(BlackBox* from, const std::string& output,
- BlackBox* to, const std::string& input ,
- const Factory* f )
- : mAdaptor(0),
+Connection::Connection(BlackBox::Pointer from, const std::string& output,
+ BlackBox::Pointer to, const std::string& input ,
+ const Factory::Pointer f )
+ : mAdaptor(),
mFactory(f),
mFromAny(false),
mToAny(false)
{
- bbtkDebugMessageInc("Kernel",7,"Connection::Connection(\""
- <<from->bbGetName()<<"\",\""<<output<<"\",\""
- <<to->bbGetName()<<"\",\""<<input<<"\")"
- <<std::endl);
+ bbtkDebugMessage("object",2,"==> Connection::Connection(\""
+ <<from->bbGetName()<<"\",\""<<output<<"\",\""
+ <<to->bbGetName()<<"\",\""<<input<<"\")"
+ <<std::endl);
- mFrom = mOriginalFrom = from;
- mTo = mOriginalTo = to;
- mInput = mOriginalInput = input;
- mOutput = mOriginalOutput = output;
if (! from->bbHasOutput(output) )
std::string name;
name = from->bbGetName() + "." + output + "-"
+ to->bbGetName() + "." + input;
- mAdaptor = mFactory->NewAdaptor(from->bbGetOutputType(output),
- to->bbGetInputType(input),
- name);
+ mAdaptor = mFactory.lock()
+ ->NewAdaptor(from->bbGetOutputType(output),
+ to->bbGetInputType(input),
+ name);
if (!mAdaptor)
{
bbtkError("did not find any <"
}
}
- //
- from->bbConnectOutput(output,this);
- to->bbConnectInput(input,this);
-
- bbtkDebugDecTab("Kernel",7);
- }
+ // Lock this pointer !!!
+ Pointer p = MakePointer(this,true);
+ from->bbConnectOutput(output,p);
+ to->bbConnectInput(input,p);
+ mFrom = from;
+ mOriginalFrom = from;
+ mTo = to;
+ mOriginalTo = to;
+ mInput = mOriginalInput = input;
+ mOutput = mOriginalOutput = output;
- //==================================================================
-
- void Connection::Clear()
- {
- mFrom = mOriginalFrom = 0;
- mTo = mOriginalTo = 0;
- mAdaptor = 0;
+
+ bbtkDebugMessage("object",2,"==> Connection::Connection(\""
+ <<from->bbGetName()<<"\",\""<<output<<"\",\""
+ <<to->bbGetName()<<"\",\""<<input<<"\")"
+ <<std::endl);
}
-
+ //==================================================================
+
//==================================================================
/// Dtor
Connection::~Connection()
{
- bbtkDebugMessageInc("Kernel",7,
- "Connection::~Connection() ["
- <<GetFullName()<<"]"<<std::endl);
- std::cout << "~Connection() " << GetFullName() << std::endl;
-
- if (mFrom!=0) mFrom->bbDisconnectOutput(mOutput,this);
- if (mTo!=0) mTo->bbDisconnectInput(mInput,this);
- if (mAdaptor!=0) mAdaptor->bbDelete();
+ bbtkDebugMessage("object",2,
+ "==> Connection::~Connection() ["
+ <<GetFullName()<<"]"<<std::endl);
+
+ if (mAdaptor) mAdaptor.reset();
+ mOriginalFrom.reset();
+ mOriginalTo.reset();
+ if (mFrom!=0)
+ {
+ mFrom->bbDisconnectOutput(mOutput,
+ GetThisPointer<Connection>());
+ }
+ else
+ {
+ bbtkInternalError("Connection::~Connection() : invalid initial box pointer");
+ }
+ if (mTo!=0)
+ {
+ mTo->bbDisconnectInput(mInput,
+ GetThisPointer<Connection>());
+ }
+ else
+ {
+ bbtkInternalError("Connection::~Connection() : invalid final box pointer");
+ }
+ mFrom.reset();
+ mTo.reset();
- bbtkDebugDecTab("Kernel",7);
+ bbtkDebugMessage("object",2,
+ "<== Connection::~Connection() ["
+ <<GetFullName()<<"]"<<std::endl);
}
//==================================================================
<<GetFullName()<<"]"<<std::endl);
IOStatus s = UPTODATE;
- s = mFrom->bbBackwardUpdate(this);
+ s = mFrom->bbBackwardUpdate(GetThisPointer<Connection>());
TransferData();
else
{
// 2) Look for an adaptor
- bbtk::BlackBox* adaptor = 0;
+ bbtk::BlackBox::Pointer adaptor;
try
{
- adaptor = mFactory->NewAdaptor(mFrom->bbGetOutput(mOutput).type(),
- mTo->bbGetInputType(mInput),
- "");
+ adaptor = mFactory.lock()
+ ->NewAdaptor(mFrom->bbGetOutput(mOutput).type(),
+ mTo->bbGetInputType(mInput),
+ "");
}
catch (...)
{
adaptor->bbExecute();
// LG : Connection Update does not set mTo as modified
mTo->bbSetInput(mInput, adaptor->bbGetOutput("Out"),false);
- adaptor->bbDelete();
+ // adaptor->bbDelete();
}
// 3) If no adaptor found but the any content is a pointer
// and target type is also a pointer : we try run-time cast
{
std::string res = mFrom->bbGetName()+"."+mOutput+"--"
+mTo->bbGetName()+"."+mInput;
- if ((mFrom!=mOriginalFrom)||(mTo!=mOriginalTo))
+ if ((!mOriginalFrom.expired()) && (!mOriginalTo.expired()) &&
+ ((mFrom!=mOriginalFrom.lock())||(mTo!=mOriginalTo.lock())))
{
- res += "("+mOriginalFrom->bbGetName()+"."+mOriginalOutput+"--"
- + mOriginalTo->bbGetName()+"."+mOriginalInput+")";
+ res += "("+mOriginalFrom.lock()->bbGetName()
+ +"."+mOriginalOutput+"--"
+ + mOriginalTo.lock()->bbGetName()+"."+mOriginalInput+")";
}
return res;
}
bbtkMessage("Debug",2," - From : "<<mFrom->bbGetFullName()<<std::endl);
if (!mFrom->bbHasOutput(mOutput))
{
- bbtkError(mFrom->bbGetFullName()<<" does not have output '"
+ bbtkError("** Checking Connection "<<(void*)this
+ <<" ["<<GetFullName()<<"] : "
+ << mFrom->bbGetFullName()<<" does not have output '"
<<mOutput<<"'");
}
bbtkMessage("Debug",2," - From : Output '"<<mOutput<<"' exists"<<std::endl);
= mFrom->bbGetOutputConnectorMap().find(mOutput);
if (i== mFrom->bbGetOutputConnectorMap().end())
{
- bbtkError(mFrom->bbGetFullName()<<" output '"
+ bbtkError("** Checking Connection "<<(void*)this
+ <<" ["<<GetFullName()<<"] : "
+ <<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;
+ std::vector< Connection::WeakPointer >::const_iterator j;
+ for (j = i->second->GetConnectionVector().begin();
+ j != i->second->GetConnectionVector().end();
+ ++j)
+ {
+ if ((*j).lock()==GetThisPointer<Connection>()) break;
+ }
+ /*
j = find(i->second->GetConnectionVector().begin(),
i->second->GetConnectionVector().end(),
- this);
+ GetThisPointer<Connection>());
+ */
if (j==i->second->GetConnectionVector().end())
{
- bbtkError("Connection ["<<GetFullName()<<"] : "
+ bbtkError("** Checking Connection "<<(void*)this
+ <<" ["<<GetFullName()<<"] : "
+ << "Connection ["<<GetFullName()<<"] : "
<<" OutputConnector '"
<<mOutput<<"' of "<<mFrom->bbGetFullName()
<<" does not point to this connection");
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();
+ // 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 '"
+ bbtkError("** Checking Connection "<<(void*)this
+ <<" ["<<GetFullName()<<"] : "
+ <<mTo->bbGetFullName()<<" does not have input '"
<<mInput<<"'");
}
bbtkMessage("Debug",2," - To : Input '"<<mInput<<"' exists"<<std::endl);
= mTo->bbGetInputConnectorMap().find(mInput);
if (i== mTo->bbGetInputConnectorMap().end())
{
- bbtkError(mTo->bbGetFullName()<<" input '"
+ bbtkError("** Checking Connection "<<(void*)this
+ <<" ["<<GetFullName()<<"] : "
+ <<mTo->bbGetFullName()<<" input '"
<<mInput<<"' is not in InputConnectorMap");
}
bbtkMessage("Debug",2," - To : Input '"<<mInput
if (i->second->GetConnection()==0)
{
- bbtkError("Connection "<<GetFullName()<<" : "
+ bbtkError("** Checking Connection "<<(void*)this
+ <<" ["<<GetFullName()<<"] : "
+ <<"Connection "<<GetFullName()<<" : "
<<" InputConnector '"
<<mInput<<"' of "<<mTo->bbGetFullName()
<<" does not point to this connection");
}
}
//==================================================================
+ //==========================================================================
+ std::string Connection::GetObjectName() const
+ {
+ std::string s("Connection '");
+ s += GetFullName();
+ s += "'";
+ return s;
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Connection::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+size_t Connection::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += Connection::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Connection::GetObjectInternalSize() const
+{
+ size_t s = sizeof(Connection);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Connection::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Connection::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
}// namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkConnection.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
#define __bbtkConnection_h__
#include "bbtkSystem.h"
+#include "bbtkObject.h"
#include <string>
{
class Factory;
+ BBTK_FORWARD_DECLARE_POINTER(Factory);
+ class BlackBox;
+ BBTK_FORWARD_DECLARE_POINTER(BlackBox);
+ class BlackBoxInputConnector;
+ class BlackBoxOutputConnector;
///
typedef int IOStatus;
///
const int UPDATING = 2;
- class BlackBox;
- class BlackBoxInputConnector;
- class BlackBoxOutputConnector;
- class BBTK_EXPORT Connection
+ class BBTK_EXPORT Connection : public Object
{
+ BBTK_OBJECT_INTERFACE(Connection);
+ typedef Object Superclass;
public:
- /// Ctor
- Connection(BlackBox* from, const std::string& output,
- BlackBox* to, const std::string& input,
- const Factory* f);
+
+ static Pointer New(BlackBoxPointer from, const std::string& output,
+ BlackBoxPointer to, const std::string& input,
+ const FactoryPointer f);
/// Dtor
- ~Connection();
+ // ~Connection();
- void Clear();
+ // void Delete();
/// Amont direction pipeline processing
/// 1) call bbBackwardUpdate(this) on the upstream box
std::string GetFullName() const;
/// Returns the original initial black box of the connection
- BlackBox* GetOriginalBlackBoxFrom() const { return mOriginalFrom; }
+ BlackBoxPointer GetOriginalBlackBoxFrom() const { return mOriginalFrom.lock(); }
/// Returns the origianl final black box of the connection
- BlackBox* GetOriginalBlackBoxTo() const { return mOriginalTo; }
+ BlackBoxPointer GetOriginalBlackBoxTo() const { return mOriginalTo.lock(); }
/// 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; }
+ BlackBoxPointer GetBlackBoxFrom() const { return mFrom; }
/// Returns the final black box of the connection
- BlackBox* GetBlackBoxTo() const { return mTo; }
+ BlackBoxPointer GetBlackBoxTo() const { return mTo; }
/// Returns the output of the initial black box of the connection
const std::string& GetBlackBoxFromOutput() const { return mOutput; }
/// 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; }
+ void SetBlackBoxFrom(BlackBoxPointer b) { mFrom = b; }
/// Sets the final black box of the connection
- void SetBlackBoxTo(BlackBox* b) { mTo = b; }
+ void SetBlackBoxTo(BlackBoxPointer 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
protected:
/// Black box origin of the connection
- BlackBox* mFrom;
- BlackBox* mOriginalFrom;
+ BlackBoxPointer mFrom;
+ BlackBoxWeakPointer 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;
+ BlackBoxPointer mTo;
+ BlackBoxWeakPointer 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
- BlackBox* mAdaptor;
+ BlackBoxPointer mAdaptor;
/// The factory used to create adaptors
- const Factory* mFactory;
+ const FactoryWeakPointer mFactory;
/// Is the connection input type is any<thing> ?
bool mFromAny;
// BlackBox* to, const std::string& input, int );
void TransferData();
+
+ private:
+ /// Ctor
+ Connection(BlackBoxPointer from, const std::string& output,
+ BlackBoxPointer to, const std::string& input,
+ const FactoryPointer f);
+
};
}// namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkData.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
TypeInfo GetType() const { return mType; }
const std::string& GetNature() const { return mNature; }
-
/// Equality
bool operator== ( const DataInfo& k ) const
{
Program: bbtk
Module: $RCSfile: bbtkExecuter.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.17 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ Version: $Revision: 1.18 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace bbtk
{
+ //=======================================================================
+ Executer::Pointer Executer::New()
+ {
+ bbtkDebugMessage("Kernel",9,"Executer::New()"<<std::endl);
+ return MakePointer(new Executer());
+ }
+ //=======================================================================
+
//=======================================================================
Executer::Executer()
:
- mFactory(0),
- mRootPackage(0),
- mRootCBB(0),
+ mFactory(),
+ mRootPackage(),
+ mRootCBB(),
mNoExecMode(false),
mDialogMode(NoDialog)
{
bbtkDebugMessageInc("Kernel",9,"Executer::Executer()" <<std::endl);
- mFactory = new Factory;
- mFactory->SetExecuter(this);
+ mFactory = Factory::New();
+ // The smart pointer on this is not made yet (is made by New)
+ // -> create it to pass it to the factory
+ // We have to "lock" the smart pointer because the factory
+ // only keeps a weak pointer on the executer
+ // -> this would auto-destroy !!
+ mFactory->SetExecuter(MakePointer(this,true));
Reset();
bbtkDebugDecTab("Kernel",9);
}
//=======================================================================
Executer::~Executer()
{
- bbtkDebugMessageInc("Kernel",9,"Executer::~Executer()" <<std::endl);
- if (mRootCBB)
- {
- mRootPackage->UnRegisterBlackBox("workspace");
- mRootCBB->UnReference();
- }
- if (mRootPackage)
- {
- GetFactory()->UnLoadPackage("user");
- }
- delete mFactory;
-
+ bbtkDebugMessageInc("Kernel",9,"==> Executer::~Executer()" <<std::endl);
+ mOpenDefinition.clear();
+ mOpenPackage.clear();
+ mFactory->Reset();
+ mFactory.reset();
bbtkDebugDecTab("Kernel",9);
}
//=======================================================================
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
- // all user defined CBB otherwise any instance
- // of a user CBB that is in the 'workspace' would try to
- // access a user CBB descriptor which has been previously freed
- if (mRootCBB)
- {
- mRootPackage->UnRegisterBlackBox(mRootCBB->GetTypeName());
- mRootCBB->UnReference();
- }
- if (mRootPackage)
- {
- GetFactory()->UnLoadPackage("user");
- }
+
+ mOpenDefinition.clear();
+ mOpenPackage.clear();
GetFactory()->Reset();
// Create user package
- mRootPackage = new Package("user","internal to bbi",
- "User defined black boxes",
- "",
- 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");
- mOpenDefinition.push_back(CBBDefinition(mRootCBB,"user"));
- // Register it into the user package
- mRootPackage->RegisterBlackBox(mRootCBB);
+ Package::Pointer p =
+ Package::New("user","internal to bbi",
+ "User defined black boxes",
+ "",
+ BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
// Insert the user package in the factory
- GetFactory()->InsertPackage(mRootPackage);
+ GetFactory()->InsertPackage(p);
// And in the list of open packages
- mOpenPackage.push_back(mRootPackage);
+ mOpenPackage.push_back(p);
+ mRootPackage = p;
+ // Create user workspace
+ ComplexBlackBoxDescriptor::Pointer r =
+ ComplexBlackBoxDescriptor::New("workspace");
+ // mRootCBB->Reference();
+ r->SetFactory(GetFactory());
+ r->AddToAuthor("bbi (internal)");
+ r->AddToDescription("User's workspace");
+ mOpenDefinition.push_back(CBBDefinition(r,"user"));
+ // Register it into the user package
+ p->RegisterBlackBox(r);
+ mRootCBB = r;
- GetFactory()->CheckPackages();
+ // Object::PrintObjectListInfo();
+ // GetFactory()->CheckPackages();
bbtkDebugDecTab("Kernel",9);
}
/// changes the workspace name
void Executer::SetWorkspaceName( const std::string& n )
{
- mRootPackage->ChangeBlackBoxName( mRootCBB->GetTypeName(), n );
+ GetUserPackage()->ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n );
}
//=======================================================================
{
bbtkDebugMessageInc("Kernel",9,"Executer::BeginPackage(\""<<name<<"\")"
<<std::endl);
- Package* p;
+ Package::Pointer p;
try
{
p = GetFactory()->GetPackage(name);
}
catch (Exception e)
{
- p = new Package(name,
+ p = Package::New(name,
"",
"",
"",
BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
- GetFactory()->InsertPackage(p);
+ GetFactory()->InsertPackage(p);
}
mOpenPackage.push_back(p);
}
","<<pack<<"\")"
<<std::endl);
- ComplexBlackBoxDescriptor* b = new ComplexBlackBoxDescriptor(name);
+ ComplexBlackBoxDescriptor::Pointer b
+ = ComplexBlackBoxDescriptor::New(name);
b->SetFactory(GetFactory());
b->SetScriptFileName(scriptfilename);
mOpenDefinition.push_back( CBBDefinition( b, pack ) );
<<Current()->GetTypeName()<<"\")"
<<std::endl);
// Does current package exist ?
- Package* p;
+ Package::Pointer p;
std::string pname(mOpenDefinition.back().package);
if (pname.size()>0)
{
}
catch (Exception e)
{
- p = new Package(pname,
- "",
- "",
- "",
- BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
+ p = Package::New(pname,
+ "",
+ "",
+ "",
+ BBTK_STRINGIFY_SYMBOL(BBTK_VERSION));
GetFactory()->InsertPackage(p);
}
}
else
{
- p = mOpenPackage.back();
+ p = mOpenPackage.back().lock();
}
p->RegisterBlackBox(Current());
//=======================================================================
void Executer::Destroy(const std::string &boxName)
{
- bbtkError("Executer::Destroy : NOT IMPLEMENTED !");
+ Current()->Remove(boxName,true);
}
//=======================================================================
void Executer::Execute (const std::string &nodeName)
{
// if in root
- if (Current()==mRootCBB)
+ if (Current()==GetWorkspace())
{
if (!mNoExecMode)
{
const std::string& help)
{
// If the input is defined in the Root box
- if (Current()==mRootCBB)
+ if (Current()==GetWorkspace())
{
// If the dialog mode is set to NoDialog
// and the user passed the name in the Inputs map
const std::string &input,
const std::string &value)
{
- BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
+ BlackBox::Pointer b = Current()->GetPrototype()->bbGetBlackBox(box);
// Looks for the adaptor
if ( b->bbGetInputType(input) != typeid(std::string) )
{
- BlackBox* a =
+ BlackBox::Pointer a =
GetFactory()->NewAdaptor(typeid(std::string),
b->bbGetInputType(input),
"tmp");
a->bbSetInput("In",v);
a->bbExecute();
b->bbSetInput(input,a->bbGetOutput("Out"));
- a->bbDelete();
+ // a->Delete();
}
else
{
std::string Executer::Get(const std::string &box,
const std::string &output)
{
- BlackBox* b = Current()->GetPrototype()->bbGetBlackBox(box);
+ BlackBox::Pointer b = Current()->GetPrototype()->bbGetBlackBox(box);
// Looks for the adaptor
if (b->bbGetOutputType(output) != typeid(std::string))
{
- BlackBox* a =
+ BlackBox::Pointer a =
GetFactory()->NewAdaptor(
b->bbGetOutputType(output),
typeid(std::string),
// << std::endl;
//std::string v(value);
//b->bbSetInput(input,a->bbGetOutput("Out"));
- a->bbDelete();
+ // a->bbDelete();
return r;
}
else
//=======================================================================
void Executer::Author(const std::string &authorName)
{
- Current()->AddToAuthor(authorName,Current()==mRootCBB);
+ Current()->AddToAuthor(authorName,Current()==GetWorkspace());
}
//=======================================================================
//=======================================================================
void Executer::Category(const std::string &category)
{
- Current()->AddToCategory(category,Current()==mRootCBB);
+ Current()->AddToCategory(category,Current()==GetWorkspace());
}
//=======================================================================
//=======================================================================
void Executer::Description(const std::string &d)
{
- Current()->AddToDescription(d,Current()==mRootCBB);
+ Current()->AddToDescription(d,Current()==GetWorkspace());
}
//=======================================================================
relative_link = false;
}
- Package* p;
+ Package::Pointer p;
try
{
p = GetFactory()->GetPackage(nameblackbox);
}
catch (Exception e)
{
- p = mRootPackage;
+ p = GetUserPackage();
}
// Generating documentation-help of workspace
p->SetDocURL(filename_rootHtml);
bool system_display)
{
- BlackBox* blackbox=NULL;
+ BlackBox::Pointer blackbox;
if (nameblackbox==".")
{
- blackbox=Current()->GetPrototype();
+ blackbox = Current()->GetPrototype();
}
else
{
int detail = atoi(detailStr.c_str());
int level = atoi(levelStr.c_str());
- BlackBox* blackbox=NULL;
+ BlackBox::Pointer blackbox;
if (nameblackbox.compare(".")==0)
{
blackbox=Current()->GetPrototype();
///
void Executer::Print(const std::string &str)
{
- if (GetNoExecMode() && (Current()==mRootCBB) ) return;
- if (Current()!=mRootCBB) return;
+ if (GetNoExecMode() && (Current()==GetWorkspace()) ) return;
+ if (Current()!=GetWorkspace()) return;
bbtkDebugMessageInc("Interpreter",9,"Interpreter::Print(\""<<str<<"\")"<<std::endl);
}
bbtkMessage("Output",1,std::endl);
}
+ //==========================================================================
+ //==========================================================================
+ std::string Executer::GetObjectName() const
+ {
+ return std::string("Executer");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Executer::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Executer::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += Executer::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Executer::GetObjectInternalSize() const
+{
+ size_t s = sizeof(Executer);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Executer::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Executer::GetObjectInternalSize();
+ s += mFactory->GetObjectRecursiveSize();
+ return s;
+ }
+ //==========================================================================
}//namespace
Program: bbtk
Module: $RCSfile: bbtkExecuter.h,v $ $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
class /*BBTK_EXPORT*/ Executer : public VirtualExec
{
-
+ BBTK_OBJECT_INTERFACE(Executer);
+ typedef VirtualExec Superclass;
public:
-
- /// Constructor
- Executer();
- /// Destructor
- ~Executer();
+ static Pointer New();
/// Gets the factory used by the executer
- Factory* GetFactory() { return mFactory; }
+ Factory::Pointer GetFactory() { return mFactory; }
/// Gets the factory used by the executer (const)
- const Factory* GetFactory() const { return mFactory; }
+ // const Factory::Pointer GetFactory() const { return mFactory; }
/// Sets the inputs of the workspace :
// static const std::string& GetObjectDescription();
// { static std::string s("Executer"); return s; }
+
+ ComplexBlackBoxDescriptor::Pointer GetWorkspace()
+ { return mRootCBB.lock(); }
+ Package::Pointer GetUserPackage()
+ { return mRootPackage.lock(); }
+
protected:
private:
/// Gets the current working black box
- ComplexBlackBoxDescriptor* Current()
- { return mOpenDefinition.back().box; }
+ ComplexBlackBoxDescriptor::Pointer Current()
+ { return mOpenDefinition.back().box; }
/// Returns true when we are inside a define/endefine block
// bool InDefinitionBlock() { return (mOpenDefinition.size()>1); }
// ATTRIBUTES
/// The factory used
- Factory* mFactory;
+ Factory::Pointer mFactory;
/// The Root Package
/// Contains the root ComplexBlabkBox
/// In which ComplexBlackBoxes are put by default
/// Its name in bbi is 'user'
- Package* mRootPackage;
+ Package::WeakPointer mRootPackage;
/// The root ComplexBlackBox
/// in which operations are done when outside a define/endefine block
/// Its name in bbi is 'workspace'
- ComplexBlackBoxDescriptor* mRootCBB;
+ ComplexBlackBoxDescriptor::WeakPointer mRootCBB;
/// Struct that stores info on user defined complex black boxes
struct CBBDefinition
{
- ComplexBlackBoxDescriptor* box;
+ ComplexBlackBoxDescriptor::Pointer box;
std::string package;
- CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
+ CBBDefinition(ComplexBlackBoxDescriptor::Pointer d,
+ const std::string& p )
: box(d), package(p) {}
};
/// The stack of current working package
/// (is a stack for nested definitions)
- std::deque<Package*> mOpenPackage;
+ std::deque<Package::WeakPointer> mOpenPackage;
/// The input values of the Root ComplexBlackBox
std::map<std::string,std::string> mInputs;
Module: $RCSfile: bbtkFactory.cxx,v $
Language: C++
-Date: $Date: 2008/04/09 11:16:57 $
-Version: $Revision: 1.32 $
+Date: $Date: 2008/04/18 12:59:15 $
+Version: $Revision: 1.33 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
namespace bbtk
{
- typedef Package* (*PackageAccessor)();
- typedef void (*PackageDeleteFunction)();
+ //===================================================================
+ /// Default ctor
+ Factory::Pointer Factory::New()
+ {
+ bbtkDebugMessage("Kernel",9,"Factory::New()"<<std::endl);
+ return MakePointer(new Factory());
+ }
+ //===================================================================
//===================================================================
/// Default ctor
Factory::Factory()
- : mExecuter(0)
+ : mExecuter()
{
bbtkDebugMessage("Kernel",7,"Factory::Factory()"<<std::endl);
}
//===================================================================
- //===================================================================
- void Factory::CloseAllPackages()
- {
- bbtkDebugMessageInc("Kernel",7,"Factory::CloseAllPackages()"<<std::endl);
- while (mPackageMap.begin() != mPackageMap.end())
- {
- PackageMapType::iterator i = mPackageMap.begin();
- ClosePackage(i);
- }
- bbtkDebugDecTab("Kernel",7);
- }
- //===================================================================
//===================================================================
void Factory::Reset()
std::string path)
{
-#if defined(__GNUC__)
-
- void *handler;
- handler = dlopen(libname.c_str(),
- BBTK_RTLD_TIME | BBTK_RTLD_SCOPE );
- if (!handler)
- {
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkError("Could not open shared library [" <<libname<<"] : "
- <<dlerror() << std::endl);
-
- return false; // try next path
- }
-
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkMessage("Output",2," -->[" <<libname<<"] found" << std::endl);
-
- // Loads the Package accessor
-
- std::string getpackname(pkgname);
- getpackname += "GetPackage";
- void *getpack = dlsym(handler, getpackname.c_str());
- if (!getpack)
+ Package::Pointer p = Package::CreateFromDynamicLibrary(libname,
+ pkgname,
+ path);
+ if (p!=0)
{
- dlclose(handler);
- bbtkError("Shared library ["<<libname<<"] is not a valid bbtk package."
- <<" Symbol ["<<getpackname<<"] :"<<dlerror());
+ //===================================================================
+ bbtkMessage("Output",2,p->GetName()<<" "
+ <<p->GetVersion()
+ <<" "
+ <<p->GetAuthor() << " Category(s) :"
+ <<p->GetCategory()
+ <<std::endl);
+ bbtkMessage("Output",2,p->GetDescription()<<std::endl);
+ //===================================================================
+ p->AddFactory(GetThisPointer<Factory>());
+ mPackageMap[pkgname] = p;
+ return true;
}
+ return false;
- // Verifies that the Package delete function is present
- std::string delfname(pkgname);
- delfname += "DeletePackage";
- void *delf = dlsym(handler, delfname.c_str());
- if (!delf)
- {
- dlclose(handler);
- bbtkError("Shared library ["<<libname<<"] is not a valid bbtk package."
- <<" Symbol ["<<delfname<<"] :"<<dlerror());
- }
-
-#elif defined(_WIN32)
-
- HINSTANCE handler;
-
- SetErrorMode(0);
- handler = LoadLibrary(libname.c_str());
- if (!handler)
- {
- // The following is *NOT* a debug time message :
- // It's a user intended message.
- // Please don't remove it.
- bbtkError("Error loading library [" <<libname<<"]" << std::endl);
- return false;// Problem with the found library
- }
-
- bbtkMessage("Output",2," --->[" <<libname<<"] found" << std::endl);
-
- // Loads the Package accessor
-
- std::string getpackname(pkgname);
- getpackname += "GetPackage";
- void *getpack = GetProcAddress(handler, getpackname.c_str());
- if (!getpack)
- {
- FreeLibrary(handler);
- bbtkError("[1] Could not load package \""<<pkgname
- <<"\" : "<<getpackname<<" symbol not found (is it a bbtk package lib ?)");
- // look how to get the error message on win
- //<<dlerror());
- }
- // Verifies that the Package delete function is present
- std::string delfname(pkgname);
- delfname += "DeletePackage";
- void *delf = GetProcAddress(handler, delfname.c_str());
- if (!delf)
- {
- FreeLibrary(handler);
- bbtkError("[2] Could not load package \""<<pkgname
- <<"\" : "<<delfname<<" symbol not found (is it a bbtk package lib ?)");
- // look how to get the error message on win
- //<<dlerror());
- }
-#else
- bbtkError("neither __GNUC__ nor _WIN32 ?!? How did you compile ?");
-#endif
-
- // Stores the package
- PackageInfoType pack;
- pack.mDynamicLibraryHandler = handler;
- // Invokes the accessor to the PackageUnit pointer
- pack.mPackage = ((PackageAccessor)getpack)();
-
- // Test bbtk build version ok
- if ( pack.mPackage->GetBBTKVersion() != bbtk::GetVersion() )
- {
- std::string v(pack.mPackage->GetBBTKVersion());
- UnLoadPackage(pkgname);
- bbtkError("Cannot load package ["<<libname<<"]. "
- <<"Package build with bbtk version "
- << v
- << " whereas application build with version "
- << bbtk::GetVersion());
- }
-
- pack.mPackage->AddFactory(this);
- mPackageMap[pkgname] = pack;
-
- std::string separator =
- ConfigurationFile::GetInstance().Get_file_separator ();
- //BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
- std::string docreldoc =
- separator + "bbdoc" + separator + pkgname + separator + "index.html";
- std::string reldoc =
- ".." + separator + ".." + docreldoc;
- std::string doc = path + separator + ".." + separator
- + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
- + docreldoc;
-
- pack.mPackage->SetDocURL(doc);
- pack.mPackage->SetDocRelativeURL(reldoc);
-
- //===================================================================
- bbtkMessage("Output",2,pack.mPackage->GetName()<<" "
- <<pack.mPackage->GetVersion()
- <<" (bbtk "
- <<pack.mPackage->GetBBTKVersion()<<") "
- <<pack.mPackage->GetAuthor() << " Category(s) :"
- <<pack.mPackage->GetCategory()
- <<std::endl);
- bbtkMessage("Output",2,pack.mPackage->GetDescription()<<std::endl);
- //===================================================================
-
- bbtkDebugDecTab("Kernel",7);
- return true;
}
//===================================================================
//===================================================================
+ //===================================================================
+ void Factory::CloseAllPackages()
+ {
+ bbtkDebugMessageInc("Kernel",7,"Factory::CloseAllPackages()"<<std::endl);
+ while (mPackageMap.begin() != mPackageMap.end())
+ {
+ PackageMapType::iterator i = mPackageMap.begin();
+ ClosePackage(i);
+ }
+ bbtkDebugDecTab("Kernel",7);
+ }
+ //===================================================================
+
//===================================================================
/// \brief Close the package referenced by the iterator
///
void Factory::ClosePackage(PackageMapType::iterator& i)
{
bbtkDebugMessageInc("Kernel",7,"Factory::ClosePackage(\""
- <<i->second.mPackage->GetName()
+ <<i->second->GetName()
<<"\")"<<std::endl);
// Removes this from the set of factories which use the package
- i->second.mPackage->RemoveFactory(this);
-
- // If no more factory which use it
- if (i->second.mPackage->GetFactorySet().empty())
- {
- // If it is a dynamically loaded package
- if (i->second.mDynamicLibraryHandler)
- {
-
-
- // Loads the Package delete function
-
- std::string delfname(i->second.mPackage->GetName());
- delfname += "DeletePackage";
-#if defined(__GNUC__)
- void *delf = dlsym(i->second.mDynamicLibraryHandler, delfname.c_str());
- if (!delf)
- {
- bbtkError("could not close package \""
- <<i->second.mPackage->GetName()
- <<"\" :"<<dlerror());
- }
-#elif defined(_WIN32)
- void *delf = GetProcAddress(i->second.mDynamicLibraryHandler,
- delfname.c_str());
- if (!delf)
- {
- bbtkError("could not close package \""
- <<i->second.mPackage->GetName()
- <<"\" : "<<delfname
- <<" symbol not found (how did you open it ???");
- //<<"\" :"<<dlerror());
- }
-#endif
-
- // deletes the package
- ((PackageDeleteFunction)delf)();
-
- // closes the dl handler
-#if defined(__GNUC__)
- dlclose(i->second.mDynamicLibraryHandler);
-#elif defined(_WIN32)
-
- FreeLibrary(i->second.mDynamicLibraryHandler);
-#endif
- }
-
- else
- {
- // If it is a manually inserted package : delete it normally
- delete i->second.mPackage;
- }
- }
-
- // in any cases remove the entry in the map
+ i->second->RemoveFactory(GetThisPointer<Factory>());
+ Package::WeakPointer p = i->second;
+ // remove the entry in the map
mPackageMap.erase(i);
+ // Release the package if not already destroyed
+ if (p.lock()) Package::Release(p);
+
bbtkDebugDecTab("Kernel",7);
}
{
bbtkMessage("Help",1, i->first << std::endl);
if (details) {
- i->second.mPackage->PrintBlackBoxes(false,adaptors);
+ i->second->PrintBlackBoxes(false,adaptors);
}
}
{
bbtkMessage("Help",1, "Package "<<i->first<<" ");
- if (i->second.mPackage->GetVersion().length()>0)
- bbtkMessageCont("Help",1,"v" <<i->second.mPackage->GetVersion());
+ if (i->second->GetVersion().length()>0)
+ bbtkMessageCont("Help",1,"v" <<i->second->GetVersion());
- if (i->second.mPackage->GetAuthor().length()>0)
- bbtkMessageCont("Help",1,"- "<<i->second.mPackage->GetAuthor());
+ if (i->second->GetAuthor().length()>0)
+ bbtkMessageCont("Help",1,"- "<<i->second->GetAuthor());
- if (i->second.mPackage->GetCategory().length()>0)
- bbtkMessageCont("Help",1,"- "<<i->second.mPackage->GetCategory());
+ if (i->second->GetCategory().length()>0)
+ bbtkMessageCont("Help",1,"- "<<i->second->GetCategory());
bbtkMessageCont("Help",1,std::endl);
bbtkIncTab("Help",1);
- bbtkMessage("Help",1,i->second.mPackage->GetDescription()<<std::endl);
- if (i->second.mPackage->GetNumberOfBlackBoxes()>0)
+ bbtkMessage("Help",1,i->second->GetDescription()<<std::endl);
+ if (i->second->GetNumberOfBlackBoxes()>0)
{
bbtkMessage("Help",1, "Black boxes : "<<std::endl);
- i->second.mPackage->PrintBlackBoxes(true,adaptors);
+ i->second->PrintBlackBoxes(true,adaptors);
}
else
{
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- if (i->second.mPackage->ContainsBlackBox(name))
+ if (i->second->ContainsBlackBox(name))
{
- i->second.mPackage->HelpBlackBox(name,full);
- package = i->second.mPackage->GetName();
+ i->second->HelpBlackBox(name,full);
+ package = i->second->GetName();
found = true;
}
}
//===================================================================
/// Inserts a package in the factory
- void Factory::InsertPackage( Package* p )
+ void Factory::InsertPackage( Package::Pointer p )
{
bbtkDebugMessageInc("Kernel",9,"Factory::InsertPackage(\""<<
p->GetName()<<"\")"<<std::endl);
- p->AddFactory(this);
- PackageInfoType pack;
- pack.mDynamicLibraryHandler = 0;
- pack.mPackage = p;
- mPackageMap[p->GetName()] = pack;
+ std::cout << p.use_count() <<std::endl;
+
+ p->AddFactory(GetThisPointer<Factory>());
+ mPackageMap[p->GetName()] = p;
+
+ std::cout << p.use_count() <<std::endl;
bbtkDebugDecTab("Kernel",9);
}
//===================================================================
/// Removes a package from the factory (and deletes it)
- void Factory::RemovePackage( Package* p )
+ void Factory::RemovePackage( Package::Pointer p )
{
bbtkDebugMessageInc("Kernel",9,"Factory::RemovePackage(\""<<
p->GetName()<<"\")"<<std::endl);
PackageMapType::iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- if (i->second.mPackage == p) break;
+ if (i->second == p) break;
};
if (i!=mPackageMap.end())
//===================================================================
/// Creates an instance of a black box of type <type> with name <name>
- BlackBox* Factory::NewBlackBox(const std::string& type,
+ BlackBox::Pointer Factory::NewBlackBox(const std::string& type,
const std::string& name) const
{
bbtkDebugMessageInc("Kernel",7,"Factory::NewBlackBox(\""
<<type<<"\",\""<<name<<"\")"<<std::endl);
- BlackBox* b = 0;
+ BlackBox::Pointer b;
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- b = i->second.mPackage->NewBlackBox(type,name);
+ b = i->second->NewBlackBox(type,name);
if (b) break;
}
if (!b)
//===================================================================
/// Creates an instance of a black box of type <type> with name <name>
- BlackBox* Factory::NewAdaptor(const DataInfo& typein,
+ BlackBox::Pointer Factory::NewAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const
{
<<name<<"\")"<<bbtkendl);
- BlackBox* b = 0;
+ BlackBox::Pointer b;
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- b = i->second.mPackage->NewAdaptor(typein,typeout,name);
+ b = i->second->NewAdaptor(typein,typeout,name);
if (b) break;
}
if (!b)
//===================================================================
/// Creates an instance of a black box of type <type> with name <name>
- BlackBox* Factory::NewWidgetAdaptor(const DataInfo& typein,
+ BlackBox::Pointer Factory::NewWidgetAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const
{
<<name<<"\")"<<bbtkendl);
- BlackBox* b = 0;
+ BlackBox::Pointer b;
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- b = i->second.mPackage->NewWidgetAdaptor(typein,
+ b = i->second->NewWidgetAdaptor(typein,
typeout,
name);
if (b) break;
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- b = i->second.mPackage->FindAdaptor(typein,
+ b = i->second->FindAdaptor(typein,
typeout,
adaptor);
if (b) break;
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- b = i->second.mPackage->FindWidgetAdaptor(typein,
+ b = i->second->FindWidgetAdaptor(typein,
typeout,
adaptor);
if (b) break;
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- b = i->second.mPackage->FindWidgetAdaptor(typein,
+ b = i->second->FindWidgetAdaptor(typein,
typeout,
widget);
if (b) break;
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();
+ for (j=i->second->GetAdaptorMap().begin();
+ j!=i->second->GetAdaptorMap().end();
++j)
{
if ( ( j->first.mKind ==
(j->first.mTypeOut.GetNature() == typeout.GetNature() )
)
{
- widget = j->second->GetTypeName();
+ widget = j->second.lock()->GetTypeName();
bbtkMessage("Kernel",5,
"===> Found first part : "<<widget
<< " "<<j->first.mTypeIn<<"->"
//===================================================================
/// Creates an instance of a connection
- Connection* Factory::NewConnection(BlackBox* from,
- const std::string& output,
- BlackBox* to,
- const std::string& input) const
+ Connection::Pointer Factory::NewConnection(BlackBox::Pointer from,
+ const std::string& output,
+ BlackBox::Pointer to,
+ const std::string& input) const
{
bbtkDebugMessage("Kernel",7,"Factory::NewConnection(\""
<<from->bbGetName()<<"\",\""<<output<<"\",\""
<<to->bbGetName()<<"\",\""<<input
<<"\")"<<std::endl);
- return new Connection(from,output,to,input,this);
+ return Connection::New(from,output,to,input,
+ GetThisPointer<Factory>());
}
//===================================================================
//===================================================================
- const Package* Factory::GetPackage(const std::string& name) const
+ Package::Pointer Factory::GetPackage(const std::string& name) const
{
bbtkDebugMessageInc("Kernel",9,"Factory::GetPackage(\""<<name<<"\")"
<<std::endl);
if ( i != mPackageMap.end() )
{
bbtkDebugDecTab("Kernel",9);
- return i->second.mPackage;
+ return i->second;
}
else
{
}
//===================================================================
- //===================================================================
- Package* Factory::GetPackage(const std::string& name)
- {
- bbtkDebugMessageInc("Kernel",9,"Factory::GetPackage(\""<<name<<"\")"
- <<std::endl);
-
- PackageMapType::const_iterator i = mPackageMap.find(name);
- if ( i != mPackageMap.end() )
- {
- bbtkDebugDecTab("Kernel",9);
- return i->second.mPackage;
- }
- else
- {
- bbtkDebugDecTab("Kernel",9);
- bbtkError("package \""<<name<<"\" unknown");
- }
-
- bbtkDebugDecTab("Kernel",9);
- }
- //===================================================================
//===================================================================
void Factory::CheckPackages() const
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- i->second.mPackage->CheckBoxes();
+ i->second->CheckBoxes();
}
bbtkMessage("Debug",1,"****** Checking Factory "<<(void*)this
<<" ... OK"<<std::endl);
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- if (i->second.mPackage->ContainsBlackBox(name))
+ if (i->second->ContainsBlackBox(name))
{
std::string separator = ConfigurationFile::GetInstance().Get_file_separator ();
ff=fopen(filename2.c_str(),"w");
fprintf(ff,"<html><head><title>TMP</title> <script type=\"text/javascript\"> <!--\n");
- fprintf(ff," window.location=\"%s#%s\";\n" , i->second.mPackage->GetDocURL().c_str(),name.c_str() );
+ fprintf(ff," window.location=\"%s#%s\";\n" , i->second->GetDocURL().c_str(),name.c_str() );
fprintf(ff,"//--></script></head><body></body></html>\n");
- //fprintf(ff, "<a href=\"%s#%s\">Link</a>\n", i->second.mPackage->GetDocURL().c_str(),name.c_str() );
+ //fprintf(ff, "<a href=\"%s#%s\">Link</a>\n", i->second->GetDocURL().c_str(),name.c_str() );
fclose(ff);
system( command.c_str() );
found = true;
std::string title;
- typedef std::map<std::string, std::vector<BlackBoxDescriptor*> > IndexType;
+ typedef std::map<std::string,
+ std::vector<BlackBoxDescriptor::Pointer> > IndexType;
IndexType index;
// Builds the index map
PackageMapType::const_iterator i;
for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
{
- Package* pack = i->second.mPackage;
+ Package::Pointer pack = i->second;
if (pack->GetName()=="user") continue;
Package::BlackBoxMapType::const_iterator j;
for (j = pack->GetBlackBoxMap().begin();
}
else
{
- std::vector<BlackBoxDescriptor*> v;
+ std::vector<BlackBoxDescriptor::Pointer> v;
v.push_back(j->second);
index[*k] = v;
}
s << "<p><TABLE cellspacing=0 cellpadding=3>\n";
- std::vector<BlackBoxDescriptor*>::iterator di;
+ std::vector<BlackBoxDescriptor::Pointer>::iterator di;
for (di=ii->second.begin();di!=ii->second.end();++di)
{
std::string pack = (*di)->GetPackage()->GetName();
bbtkDebugDecTab("Kernel",9);
}
+ //==========================================================================
+ std::string Factory::GetObjectName() const
+ {
+ return std::string("Factory");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Factory::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+size_t Factory::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += Factory::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Factory::GetObjectInternalSize() const
+{
+ size_t s = sizeof(Factory);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Factory::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Factory::GetObjectInternalSize();
+
+ PackageMapType::const_iterator i;
+ for (i = mPackageMap.begin(); i!=mPackageMap.end(); ++i )
+ {
+ s += i->second->GetObjectRecursiveSize();
+ }
+ return s;
+ }
+ //==========================================================================
}
Program: bbtk
Module: $RCSfile: bbtkFactory.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.13 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
#ifndef __bbtkFactory_h__
#define __bbtkFactory_h__
-//#include "bbtkBlackBox.h"
#include "bbtkPackage.h"
-#include "bbtkDynamicLibraryHandling.h"
namespace bbtk
{
class Executer;
+ BBTK_FORWARD_DECLARE_POINTER(Executer);
- class BBTK_EXPORT Factory
+ class BBTK_EXPORT Factory : public Object
{
-
+ BBTK_OBJECT_INTERFACE(Factory);
+ typedef Object Superclass;
public:
+ static Pointer New();
- Factory();
- ~Factory();
void GetPackagesList(std::vector<std::string>&);
void LoadPackage( const std::string& name );
void HelpBlackBox(const std::string& name, std::string& package,
bool full=true ) const;
void ShowGraphTypes(const std::string& name) const;
- void InsertPackage( Package* );
- void RemovePackage( Package* );
+ void InsertPackage( Package::Pointer );
+ void RemovePackage( Package::Pointer );
+
+ Package::Pointer GetPackage(const std::string& name) const;
- const Package* GetPackage(const std::string& name) const;
- Package* GetPackage(const std::string& name);
- BlackBox* NewBlackBox(const std::string& type,
+ BlackBox::Pointer NewBlackBox(const std::string& type,
const std::string& name) const;
- BlackBox* NewAdaptor(const DataInfo& typein,
+ BlackBox::Pointer NewAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const;
- BlackBox* NewWidgetAdaptor(const DataInfo& typein,
+ BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const;
std::string& widget,
std::string& adaptor) const;
- Connection* NewConnection(BlackBox* from,
- const std::string& output,
- BlackBox* to,
- const std::string& input) const;
+ Connection::Pointer NewConnection(BlackBox::Pointer from,
+ const std::string& output,
+ BlackBox::Pointer to,
+ const std::string& input) const;
void WriteDotFilePackagesList(FILE *ff);
void CreateHtmlIndex(IndexEntryType type, const std::string& filename);
/// Sets the executer who created the factory (if any)
- void SetExecuter(Executer *e) { mExecuter = e; }
+ void SetExecuter(ExecuterPointer e) { mExecuter = e; }
/// Gets the executer who created the factory (if any)
- Executer* GetExecuter() { return mExecuter; }
+ ExecuterPointer GetExecuter();// { return mExecuter.lock(); }
/// Gets the executer who created the factory (if any) - const
- const Executer* GetExecuter() const { return mExecuter; }
+ // const Executer::Pointer GetExecuter() const { return mExecuter.lock(); }
private:
std::string path);
public:
- /// The structure storing info on a package
- class PackageInfoType
- {
- public :
- /// Ctor
- PackageInfoType() {}
- /// Dtor
- ~PackageInfoType() {}
- /// The pointer on the package
- Package* mPackage;
- /// The handler of the dynamic library
- DynamicLibraryHandler mDynamicLibraryHandler;
- };
+
/// The type of map of packages
- typedef std::map< std::string, PackageInfoType > PackageMapType;
+ typedef std::map< std::string, Package::Pointer > PackageMapType;
const PackageMapType& GetPackageMap() const { return mPackageMap; }
PackageMapType mPackageMap;
/// The executer which created the factory (if any)
- Executer* mExecuter;
+ ExecuterWeakPointer mExecuter;
void CloseAllPackages();
void ClosePackage(PackageMapType::iterator& i);
- /*
- /// SYSTEM METHOD : Global method returning the global factory object pointer
- inline Factory*& GlobalFactoryPointer()
- {
- static Factory* f = 0;
- return f;
- }
-
- /// SYSTEM METHOD : Global method returning the global factory object
- inline Factory* GetGlobalFactory()
- {
- if (!GlobalFactoryPointer())
- {
- GlobalFactoryPointer() = new Factory;
- }
- return GlobalFactoryPointer();
- }
-
- /// SYSTEM METHOD : Deletes the global factory pointer
- inline void DeleteGlobalFactory()
- {
- if (GlobalFactoryPointer())
- {
- delete GlobalFactoryPointer();
- }
- }
-
- inline void LoadPackage( const std::string& name )
- {
- GetGlobalFactory()->LoadPackage(name);
- }
-
- inline void UnLoadPackage( const std::string& name )
- {
- GetGlobalFactory()->UnLoadPackage(name);
- }
-
- inline void PrintPackages(bool details = true, bool adaptors = false)
- {
- GetGlobalFactory()->PrintPackages(details,adaptors);
- }
-
- inline void HelpPackage(const std::string& name, bool adaptors = false)
- {
- GetGlobalFactory()->HelpPackage(name,adaptors);
- }
-
- inline void HelpBlackBox(const std::string& name, bool full=true)
- {
- std::string package;
- GetGlobalFactory()->HelpBlackBox(name, package, full);
- }
-
- inline void HelpBlackBox(const std::string& name, std::string& package,
- bool full=true
- )
- {
- GetGlobalFactory()->HelpBlackBox(name, package, full);
- }
-
-
- inline void ShowGraphTypes(const std::string& name)
- {
- GetGlobalFactory()->ShowGraphTypes(name);
- }
-
- inline void InsertPackage( Package* p)
- {
- GetGlobalFactory()->InsertPackage(p);
- }
-
- inline void RemovePackage( Package* p)
- {
- GetGlobalFactory()->RemovePackage(p);
- }
-
- inline const Package* GetPackage(const std::string& name)
- {
- return GetGlobalFactory()->GetPackage(name);
- }
-
- inline BlackBox* NewBlackBox(const std::string& type,
- const std::string& name)
- {
- return GetGlobalFactory()->NewBlackBox(type,name);
- }
-
- inline BlackBox* NewAdaptor(TypeInfo typein,
- TypeInfo typeout,
- const std::string& name)
- {
- return GetGlobalFactory()->NewAdaptor(typein,typeout,name);
- }
-
- inline Connection* NewConnection(BlackBox* from,
- const std::string& output,
- BlackBox* to,
- const std::string& input)
- {
- return GetGlobalFactory()->NewConnection(from,output,to,input);
- }
-
- inline void WriteDotFilePackagesList(FILE *ff)
- {
- GetGlobalFactory()->WriteDotFilePackagesList(ff);
- }
- */
}// namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkInterpreter.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.59 $
+ Date: $Date: 2008/04/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
namespace bbtk
{
- //Interpreter* Interpreter::mGlobalInterpreter = NULL;
+ //=======================================================================
+ Interpreter::Pointer Interpreter::New(const std::string& cpp_file)
+ {
+ bbtkDebugMessage("Kernel",9,"Interpreter::New()"<<std::endl);
+ return MakePointer(new Interpreter(cpp_file));
+ }
+ //=======================================================================
//=======================================================================
- /**
- *
- */
Interpreter::Interpreter(const std::string& cpp_file)
:
mUser(0),
mCommandLine(false),
mThrow(false)
{
-bufferNb =0;
+
+ bufferNb =0;
bbtk::MessageManager::RegisterMessageType("Echo","Level>0 : Prints the 'echo' commands of the user.\n\tLevel>1 : Prints the command being interpreted",1);
bbtk::MessageManager::RegisterMessageType("Interpreter","Messages of the interpreter",0);
bbtkDebugMessageInc("Interpreter",9,"Interpreter::Interpreter()" <<std::endl);
if (cpp_file.size()!=0)
{
- mExecuter = new bbtk::Transcriptor(cpp_file);
+ mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Transcriptor::New(cpp_file));
}
else
{
- mExecuter = new bbtk::Executer();
+ mExecuter = boost::static_pointer_cast<VirtualExec>(bbtk::Executer::New());
}
- mExecuter->SetInterpreter(this);
+
+ // Lock this pointer or will auto-destruct !!
+ mExecuter->SetInterpreter(MakePointer(this,true));
// For the time being, comment out previous line, and
// uncomment next line to check Transcriptor
info.help = "Shows a graphical view of a bbtk pipeline.\n- BlackBoxName : name of the box to view. Default '.' : current box.\n- BlackBoxNameType : name of the type of box to view, ex : 'workspace')";
mCommandDict[info.keyword] = info;
+ info.keyword = "object";
+ info.argmin = 0;
+ info.argmax = 1;
+ info.code = cObject;
+ info.syntax = "object <object name>";
+ info.help = "Provides debug info on object <object name>";
+ mCommandDict[info.keyword] = info;
+
/*
info.keyword = "workspace";
info.argmin = 1;
*/
Interpreter::~Interpreter()
{
- bbtkDebugMessageInc("Interpreter",9,"Interpreter::~Interpreter()" <<std::endl);
- delete mExecuter;
-
- bbtkDebugDecTab("Interpreter",9);
+ bbtkDebugMessageInc("Interpreter",9,"==> Interpreter::~Interpreter()" <<std::endl);
+ mExecuter = VirtualExec::Pointer();
+ bbtkDebugMessageInc("Interpreter",9,"<== Interpreter::~Interpreter()" <<std::endl);
}
//=======================================================================
break;
case cQuit :
- delete mExecuter;
throw QuitException();
break;
+
+ case cObject :
+ if (words.size()==2) ObjectInfo(words[1]);
+ else ObjectInfo("");
+ break;
/* obsolete
case cWorkspace :
if (words.size() == 2)
// connected and can be adapted from a widget adaptor
// vector which stores the list of inputs of the box which must be connected
std::vector<std::string> in;
- Factory* F = mExecuter->GetFactory();
- if (F==0)
+
+ Factory::Pointer F = mExecuter->GetFactory();
+ /*
+ Package::Pointer user = F->GetPackage("user");
+ */
+ ComplexBlackBoxDescriptor::Pointer workspace = mExecuter->GetWorkspace();
+
+ if (workspace==0)
{
delete s;
- bbtkError("Interpreter::CreateGUI : could not access the executer factory");
+ bbtkError("Interpreter::CreateGUI : could not access the executer workspace");
}
- Package* user = F->GetPackage("user");
- ComplexBlackBoxDescriptor* workspace
- = (ComplexBlackBoxDescriptor*)user->GetBlackBoxMap().find("workspace")->second;
-
- BlackBox* box = workspace->GetPrototype()->bbGetBlackBox(boxname);
+
+
+ /*
+ (ComplexBlackBoxDescriptor::Pointer)(user->GetBlackBoxMap().find("workspace")->second.get());
+ */
+
+ BlackBox::Pointer box = workspace->GetPrototype()->bbGetBlackBox(boxname);
// BlackBox::InputConnectorMapType incm = box->bbGetInputConnectorMap();
int nb = 0;
BlackBox::InputConnectorMapType::iterator i;
// Sets the label of the widget adaptor to the name of the input
(*s) << " set "<<i->first<<".Label "<<i->first<<std::endl;
// Sets the initial value of the widget to the value of the input
- (*s) << " set "<<i->first<<".In \""
+ (*s) << " set "<<i->first<<".In \" "
<<box->bbGetInputAsString(i->first)<<"\""
<< std::endl;
// store the input name
// Sets the label of the widget adaptor to the name of the input
(*s) << " set "<<i->first<<"Widget.Label "<<i->first<<std::endl;
// Sets the initial value of the widget to the value of the input
- (*s) << " set "<<i->first<<"Widget.In \""
+ (*s) << " set "<<i->first<<"Widget.In \" "
<<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
// store the input name
in.push_back(i->first);
// Sets the label of the widget adaptor to the name of the input
(*s) << " set "<<i->first<<".Title "<<i->first<<std::endl;
// Sets the initial value of the widget to the value of the input
- (*s) << " set "<<i->first<<".In \""
+ (*s) << " set "<<i->first<<".In \" "
<<box->bbGetInputAsString(i->first)<<"\""<< std::endl;
// store the input name
in.push_back(i->first);
}
//=======================================================================
+
+
+ //==========================================================================
+ void Interpreter::ObjectInfo(const std::string& name)
+ {
+ Object:: PrintObjectInfo(name);
+ }
+ //==========================================================================
+ //==========================================================================
+ std::string Interpreter::GetObjectName() const
+ {
+ return std::string("Interpreter");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Interpreter::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+size_t Interpreter::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += Interpreter::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Interpreter::GetObjectInternalSize() const
+{
+ size_t s = sizeof(Interpreter);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Interpreter::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Interpreter::GetObjectInternalSize();
+ s += mExecuter->GetObjectRecursiveSize();
+ return s;
+ }
+ //==========================================================================
}//namespace
Program: bbtk
Module: $RCSfile: bbtkInterpreter.h,v $ $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.25 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ Version: $Revision: 1.26 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class WxConsole;
#endif
+ //=======================================================================
class BBTK_EXPORT InterpreterUser
{
public:
};
+ //=======================================================================
- ///
+
+
+ //=======================================================================
class BBTK_EXPORT InterpreterError : public Exception
{
public:
std::string mScriptFile;
int mScriptLine;
};
+ //=======================================================================
- ///
- class BBTK_EXPORT Interpreter
+ //=======================================================================
+ class BBTK_EXPORT Interpreter : public Object
{
-
- private:
-
- /// The enumeration of command codes == Command name
- typedef enum
- {
- cNew,
- cDelete,
- cConnect,
- cExec,
- cPackage,
- cEndPackage,
- cDefine,
- cEndDefine,
- cInput,
- cOutput,
- cSet,
- cConfig, // JPR
- cReset, // EED
- cAuthor,
- cCategory, // JPR
- cDescription,
- cHelp,
- cMessage,
- cInclude,
- cQuit,
- cLoad,
- cUnload,
- cGraph,
- cPrint,
- cIndex,
- cKind, // LG
- cNewGUI, // LG
- cWorkspace // LG
- } CommandCodeType;
-
- /// The structure storing the informations on a command
- typedef struct
- {
- std::string keyword;
- int argmin, argmax;
- CommandCodeType code;
- std::string syntax;
- std::string help;
- } CommandInfoType;
-
- /// The type of dictionnary of commands
- typedef std::map<std::string,CommandInfoType> CommandDictType;
-
+ BBTK_OBJECT_INTERFACE(Interpreter);
+ typedef Object Superclass;
public:
- /// Constructor
- Interpreter(const std::string& cpp_file = "");
-
- /// Destructor
- ~Interpreter();
-
+ static Pointer New(const std::string& cpp_file = "");
typedef enum
{
#endif
/// Gets the Executer
- VirtualExec* GetExecuter() { return mExecuter; }
- /// Gets the Executer (const)
- const VirtualExec* GetExecuter() const { return mExecuter; }
+ VirtualExec::Pointer GetExecuter() const { return mExecuter; }
protected:
+
+ /// The enumeration of command codes == Command name
+ typedef enum
+ {
+ cNew,
+ cDelete,
+ cConnect,
+ cExec,
+ cPackage,
+ cEndPackage,
+ cDefine,
+ cEndDefine,
+ cInput,
+ cOutput,
+ cSet,
+ cConfig, // JPR
+ cReset, // EED
+ cAuthor,
+ cCategory, // JPR
+ cDescription,
+ cHelp,
+ cMessage,
+ cInclude,
+ cQuit,
+ cLoad,
+ cUnload,
+ cGraph,
+ cPrint,
+ cIndex,
+ cKind, // LG
+ cNewGUI, // LG
+ cWorkspace, // LG
+ cObject
+ } CommandCodeType;
+
+ /// The structure storing the informations on a command
+ typedef struct
+ {
+ std::string keyword;
+ int argmin, argmax;
+ CommandCodeType code;
+ std::string syntax;
+ std::string help;
+ } CommandInfoType;
+
+ /// The type of dictionnary of commands
+ typedef std::map<std::string,CommandInfoType> CommandDictType;
+
+
/// Interprets a line
void InterpretLine( const std::string& line, bool &insideComment );
void NewGUI(const std::string& box,
const std::string& instanceName);
+ void ObjectInfo(const std::string& name);
+
private:
+ /// Constructor
+ Interpreter(const std::string& cpp_file = "");
+
/// Opens the file fullPathScriptName
/// includeScriptName is the name as given to the include command
void LoadScript( std::string fullPathScriptName,
void CatchStdException( const std::exception& e );
void CatchUnknownException();
- private:
+
//==================================================================
// ATTRIBUTES
/// The command executer used
- bbtk::VirtualExec* mExecuter;
+ bbtk::VirtualExec::Pointer mExecuter;
/// The user of the interpreter (0 if none)
bbtk::InterpreterUser* mUser;
Program: bbtk
Module: $RCSfile: bbtkMessageManager.cxx,v $
Language: C++
- Date: $Date: 2008/03/20 09:51:28 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
mMessageLevel[key] = 0;
mMessageHelp[key] = "Graphical user interface related messages";
if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+ key = "object";
+ mMessageLevel[key] = 0;
+ mMessageHelp[key] = "object memory related messages";
+ if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
+ key = "package";
+ mMessageLevel[key] = 0;
+ mMessageHelp[key] = "Packages related messages";
+ if (mMaxMessageLength<key.length()) mMaxMessageLength = key.length();
}
--- /dev/null
+#include "bbtkObject.h"
+#include "bbtkMessageManager.h"
+
+namespace bbtk
+{
+
+
+ //=======================================================================
+ Object::ObjectListType Object::mgObjectList;
+ //=======================================================================
+
+ //=======================================================================
+ Object::Object()
+ {
+ }
+ //=======================================================================
+
+
+ //=======================================================================
+ Object::~Object()
+ {
+ }
+ //=======================================================================
+
+ //=======================================================================
+ void Object::InsertInObjectList(Pointer p)
+ {
+ bbtkDebugMessage("object",9,"##> Object::InsertInObjectList(\""
+ <<p->GetObjectName()<<"\" ["<<p<<"])"<<std::endl);
+ boost::weak_ptr<Object> w(p);
+ mgObjectList.insert(w);
+ }
+ //=======================================================================
+
+
+ //=======================================================================
+ void Object::RemoveFromObjectList(WeakPointer p)
+ {
+ bbtkDebugMessage("object",9,"##> Object::RemoveFromObjectList()"
+ <<std::endl);
+ mgObjectList.erase(p);
+
+ }
+ //=======================================================================
+
+
+ //=======================================================================
+ std::string Object::GetObjectName() const
+ {
+ return std::string("**Unknown object**");
+ }
+ //=======================================================================
+
+ //=======================================================================
+ std::string Object::GetObjectInfo() const
+ {
+ return std::string("");
+ }
+ //=======================================================================
+
+ //=======================================================================
+ void Object::PrintObjectListInfo()
+ {
+
+ std::cout
+ << "=============== Living bbtk::Object pointers ========="<<std::endl;
+
+ long n = 0;
+ long u = 0;
+ size_t m = 0;
+ ObjectListType::iterator i;
+ for (i = mgObjectList.begin();
+ i!=mgObjectList.end();
+ ++i)
+ {
+ if (i->use_count() == 0)
+ {
+ u++;
+ }
+ else
+ {
+ Object::Pointer p(i->lock());
+ PrintObjectInfo(p);
+ n++;
+ m += p->GetObjectSize();
+ }
+ }
+ std::cout
+ << "------------------------------------------------------"<<std::endl;
+
+ std::cout << " Total : "<<n<<" objects - "<<m<<" b"<<std::endl;
+ if (u==1)
+ {
+ std::cout<<"* Note : "<<u
+ <<" object in list has 0 ref count, "
+ <<"i.e. destroyed without removing itself from the living objects list ! (this is just an implementation error not a memory leak)"<<std::endl;
+ }
+ else if (u>1)
+ {
+ std::cout<<"* Note : "<<u
+ <<" objects in list have 0 ref count, "
+ <<"i.e. destroyed without removing themselves from the living objects list ! (this is just an implementation error not a memory leak)"<<std::endl;
+ }
+ std::cout
+ << "============ EO Living bbtk::Object pointers ========="<<std::endl;
+
+ }
+ //=======================================================================
+
+ //=======================================================================
+ void Object::PrintObjectInfo(const std::string& name)
+ {
+ long n = 0;
+ ObjectListType::iterator i;
+ for (i = mgObjectList.begin();
+ i!=mgObjectList.end();
+ ++i)
+ {
+ n++;
+ if (i->use_count() == 0) continue;
+ Object::Pointer p(i->lock());
+ if (p->GetObjectName().find(name) != std::string::npos )
+ {
+ std::cout << n << "/" << mgObjectList.size() << " ";
+ PrintObjectInfo(p);
+ }
+ }
+ }
+ //=======================================================================
+
+ //=======================================================================
+ void Object::PrintObjectInfo(const Object::Pointer& p)
+ {
+ std::cout << "* [" << p << "] \t"
+ << p.use_count()-1 << " r \t"
+ << p->GetObjectRecursiveSize() << " ("
+ << p->GetObjectSize() << ") b \t"
+ << p->GetObjectName()
+ << std::endl;
+ std::cout << p->GetObjectInfo();
+ }
+ //=======================================================================
+
+ //=======================================================================
+ /// Objects deleter
+ void Object::Deleter::operator() (Object* p)
+ {
+ std::string name = p->GetObjectName();
+ void* adr = (void*)p;
+ bbtkDebugMessage("object",1,"##> Object::Deleter : deleting \""
+ <<name<<"\" ["<<adr<<"]"<<std::endl);
+ Object::RemoveFromObjectList(mPointer);
+ this->Delete(p);
+ bbtkDebugMessage("object",2,"<## Object::Deleter : \""<<name<<"\" ["
+ <<adr<<"] deleted"<<std::endl);
+ }
+ //=======================================================================
+
+
+
+
+
+
+
+
+
+ //=======================================================================
+ bool StaticInitTime::PrintObjectListInfo = false;
+ //=======================================================================
+ //=======================================================================
+ StaticInitTime::StaticInitTime()
+ {
+ }
+ //=======================================================================
+ //=======================================================================
+ StaticInitTime::~StaticInitTime()
+ {
+ if (PrintObjectListInfo)
+ {
+ std::cout << std::endl
+ << "***************** main ended *******************"
+ << std::endl << std::endl;
+ Object::PrintObjectListInfo();
+ }
+ }
+ //=======================================================================
+ //=======================================================================
+ // The static instance
+ static StaticInitTime i;
+ //=======================================================================
+
+}
--- /dev/null
+/*=========================================================================
+
+ Program: bbtk
+ Module: $RCSfile: bbtkObject.h,v $
+ Language: C++
+ Date: $Date: 2008/04/18 12:59:15 $
+ Version: $Revision: 1.1 $
+
+ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
+ l'Image). All rights reserved. See doc/license.txt or
+ http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ PURPOSE. See the above copyright notices for more information.
+
+=========================================================================*/
+/**
+ *\file
+ *\brief Object : the top class of bbtk class hierarchy
+ *
+ */
+
+#ifndef __bbtkObject_h__
+#define __bbtkObject_h__
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <set>
+
+namespace bbtk
+{
+
+ // The top class of bbtk class hierarchy
+ class Object
+ {
+ public:
+ typedef boost::shared_ptr<Object> Pointer;
+ typedef boost::weak_ptr<Object> WeakPointer;
+
+ Object();
+ virtual ~Object();
+
+ virtual std::string GetObjectName() const;
+ virtual std::string GetObjectInfo() const;
+ virtual size_t GetObjectSize() const { return sizeof(Object); }
+ virtual size_t GetObjectInternalSize() const { return sizeof(Object); }
+ virtual size_t GetObjectRecursiveSize() const { return sizeof(Object); }
+ long GetUseCount() { return mThisPointer.use_count(); }
+
+ static void InsertInObjectList(Pointer);
+ static void RemoveFromObjectList(WeakPointer);
+
+ static void PrintObjectListInfo();
+ static void PrintObjectInfo(const std::string& name);
+ static void PrintObjectInfo(const Pointer& o);
+ /// Default objects deleter : removes object from list on deletion
+ struct Deleter
+ {
+ Deleter() : mPointer() {}
+ virtual void operator() (Object* p);
+ virtual void Delete(Object* p) { delete p; }
+ WeakPointer mPointer;
+ };
+
+ protected:
+ void LockThis() { mThisPointerLocked = mThisPointer.lock(); }
+ void UnLockThis() { mThisPointerLocked = Pointer(); }
+ // Object::Pointer GetThis() const { return mThisPointer.lock(); }
+ template <class U>
+ boost::shared_ptr<U> GetThisPointer() const
+ {
+ return boost::dynamic_pointer_cast<U>(mThisPointer.lock());
+ }
+ template <class U>
+ static boost::shared_ptr<U> MakePointer(U* s, bool lock = false)
+ {
+ if (s->mThisPointer.lock())
+ {
+ boost::shared_ptr<U> p = s->GetThisPointer<U>();
+ if (!lock) s->mThisPointerLocked.reset();
+ return p;
+ }
+ boost::shared_ptr<U> p = boost::shared_ptr<U>(s,Object::Deleter());
+ static_cast<Object::Deleter*>
+ (p._internal_get_deleter(typeid(Object::Deleter)))
+ ->mPointer = p;
+ s->mThisPointer = p;
+ Object::InsertInObjectList(p);
+ if (lock) s->LockThis();
+ return p;
+ }
+ template <class U, class D>
+ static boost::shared_ptr<U> MakePointer(U* s,
+ const D& del,
+ bool lock = false)
+ {
+ if (s->mThisPointer.lock())
+ {
+ boost::shared_ptr<U> p = s->GetThisPointer<U>();
+ if (!lock) s->mThisPointerLocked.reset();
+ return p;
+ }
+ boost::shared_ptr<U> p = boost::shared_ptr<U>(s,del);
+ static_cast<D*>
+ (p._internal_get_deleter(typeid(D)))
+ ->mPointer = p;
+ s->mThisPointer = p;
+ Object::InsertInObjectList(p);
+ if (lock) s->LockThis();
+ return p;
+ }
+
+
+ private:
+ typedef std::set<boost::weak_ptr<Object> > ObjectListType;
+ static ObjectListType mgObjectList;
+ WeakPointer mThisPointer;
+ Pointer mThisPointerLocked;
+
+ };
+
+#define BBTK_OBJECT_DEFINE_SELF(CLASS) public : typedef CLASS Self;
+
+#define BBTK_FORWARD_DECLARE_POINTER(CLASS) \
+ typedef boost::shared_ptr<CLASS> CLASS ## Pointer; \
+ typedef boost::weak_ptr<CLASS> CLASS ## WeakPointer;
+
+
+#define BBTK_OBJECT_MINIMAL_INTERFACE \
+ public: \
+ typedef boost::shared_ptr<Self> Pointer; \
+ typedef boost::weak_ptr<Self> WeakPointer; \
+ friend struct Object::Deleter;
+ //private:
+
+ // does not work : why ?
+ // boost::get_deleter<Deleter,Pointer>(pt)->mPointer = pt;
+ //
+
+#define BBTK_OBJECT_MINIMAL_INTERFACE_WITH_SELF(CLASS) \
+ public : typedef CLASS Self; \
+ BBTK_OBJECT_MINIMAL_INTERFACE;
+
+
+#define BBTK_OBJECT_INTERFACE(CLASS) \
+ BBTK_OBJECT_MINIMAL_INTERFACE_WITH_SELF(CLASS); \
+public: \
+ std::string GetObjectName() const; \
+ std::string GetObjectInfo() const ; \
+ size_t GetObjectSize() const ; \
+ size_t GetObjectInternalSize() const ; \
+ size_t GetObjectRecursiveSize() const ; \
+protected: \
+ CLASS(); \
+ CLASS(const CLASS&); \
+ ~CLASS();
+
+#define BBTK_ABSTRACT_OBJECT_INTERFACE(CLASS) \
+ public : typedef CLASS Self; \
+ BBTK_OBJECT_MINIMAL_INTERFACE; \
+protected: \
+ CLASS(); \
+ CLASS(const CLASS&); \
+ virtual ~CLASS();
+
+ //=======================================================================
+ // A struct with one static instance
+ // just to print object list info after main
+ struct StaticInitTime
+ {
+ StaticInitTime();
+ ~StaticInitTime();
+
+
+ static bool PrintObjectListInfo;
+ private:
+ static Object mObject;
+ };
+
+
+ /*
+ template <class T, class U>
+ inline T BruteForceDownCastPointer(class U p)
+ {
+
+ }
+ */
+
+}// namespace bbtk
+
+#endif
+
Program: bbtk
Module: $RCSfile: bbtkPackage.cxx,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.12 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
namespace bbtk
{
+
+
+
+ //==========================================================================
+ /// Creates a new package
+ Package::Pointer Package::New(const std::string& name,
+ const std::string& author,
+ const std::string& description,
+ const std::string& version,
+ const std::string& BBTKVersion)
+ {
+ bbtkDebugMessage("object",1,"##> Package::New('"<<name<<"',...)"
+ <<bbtkendl);
+ Package::Pointer p = MakePointer(new Package(name,
+ author,
+ description,
+ version,
+ BBTKVersion));
+ bbtkDebugMessage("object",2,"<## Package::New('"<<name<<"',...)"
+ <<bbtkendl);
+ return p;
+ }
+ //==========================================================================
+
//==========================================================================
/// Ctor with the name of the package
Package::Package(const std::string& name,
const std::string& version,
const std::string& BBTKVersion)
:
+ mDynamicLibraryHandler(0),
mName(name),
mAuthor(author),
mDescription(description),
- mVersion(version),
- mBBTKVersion(BBTKVersion)
+ mVersion(version)
{
+ bbtkDebugMessage("object",2,"==> Package::Package('"<<name<<"',...)"
+ <<bbtkendl);
std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir();
char c = default_doc_dir.c_str()[strlen(default_doc_dir.c_str())-1];
std::string url = default_doc_dir;
// std::cout << " url=["<<url<<"]"<<std::endl;
// std::cout << "relurl=["<<relurl<<"]"<<std::endl;
- bbtkDebugMessage("Kernel",7,"Package::Package(\""<<name<<"\")"<<bbtkendl);
+ bbtkDebugMessage("object",2,"<== Package::Package('"<<name<<"',...) OK"
+ <<bbtkendl);
+
}
//==========================================================================
/// Dtor
Package::~Package()
{
- bbtkDebugMessageInc("Kernel",7,"Package::~Package(\""<<mName<<"\")"<<bbtkendl);
- BlackBoxMapType::const_iterator i;
- for (i=mBlackBoxMap.begin();
- i!=mBlackBoxMap.end();
- ++i)
- {
- i->second->UnReference();
- }
- // Adaptors are also stored in the black box map : hence already deleted
+ bbtkDebugMessage("object",2,"==> Package::~Package(\""<<mName<<"\")"<<bbtkendl);
+ bbtkDebugMessage("object",2,"<== Package::~Package(\""<<mName<<"\")"<<bbtkendl);
+ }
+ //==========================================================================
+
+
+ //==========================================================================
+ void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack,
+ const std::string& descname)
+ {
+ // Try to release descriptor
+ bbtkDebugMessage("package",3,"--- Trying to release descriptor '"
+ <<descname<<"'"<<bbtkendl);
+ std::string packname = pack.lock()->GetName();
+
+ Package::BlackBoxMapType::iterator desc =
+ pack.lock()->GetBlackBoxMap().find(descname);
+ if (desc == pack.lock()->GetBlackBoxMap().end())
+ {
+ bbtkDebugMessage("package",3,
+ " Descriptor has already been released"
+ <<bbtkendl);
+ return;
+ }
+ // bbtkDebugMessage("package",3,
+ // " Trying unreferencing it ... "<<std::endl);
+ BlackBoxDescriptor::WeakPointer pdesc = desc->second;
+ desc->second.reset();
+ // if it is dead : remove it
+ if (pdesc.expired())
+ {
+ bbtkDebugMessage("package",2," '"<<packname<<"::"<<descname<<"' Descriptor expired"<<bbtkendl);
+ if (pack.expired())
+ {
+ bbtkDebugMessage("package",2,
+ " ... and caused its package death"
+ <<bbtkendl);
+ return;
+ }
+ desc = pack.lock()->GetBlackBoxMap().find(descname);
+ if (desc != pack.lock()->GetBlackBoxMap().end())
+ pack.lock()->GetBlackBoxMap().erase(desc);
+ }
+ else
+ {
+ bbtkDebugMessage("package",3," ... Descriptor still alive ("
+ <<pdesc.use_count()<<" refs)"
+ <<bbtkendl);
+ pack.lock()->GetBlackBoxMap()[descname] = pdesc.lock();
+ }
+ }
+ //==========================================================================
+
+
+ //==========================================================================
+ /// Release
+ void Package::Release(Package::WeakPointer pack)
+ {
+ std::string packname = pack.lock()->mName;
+ bbtkDebugMessage("package",1,"==> Package::Release('"<<
+ packname<<"')"<<bbtkendl);
+
+ long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0;
+ long ndesc = pack.lock()->GetBlackBoxMap().size();
+ long nrefs = pack.use_count();
+
+ bbtkDebugMessage("package",2," "<<nrefs<<" refs / "
+ <<ndesc<<" descr / dyn="
+ <<dyn<<std::endl);
+
+ // A package is "free" from any external reference iff :
+ // i) It is not dynamically loaded and nrefs == ndesc
+ // (each desc references its package) or
+ // ii) It is dynamically loaded and nrefs == ndesc + 1
+ // (A dynamic library holds a static pointer on the package it contains
+ // which is allocated when the PACKAGENAMEGetPackage() func is called,
+ // and descallocated (reset) by PACKAGENAMEDeletePackage())
+ if (nrefs == ndesc + dyn)
+ {
+ bbtkDebugMessage("package",2,
+ " -> No more external ref : checking descriptors"
+ <<bbtkendl);
+ // We must take care that removing refs on descriptors
+ // can lead to their deletion which can in turn unref
+ // internal boxes which can release their descriptors hence
+ // call Package::ReleaseBlackBoxDescriptor
+ // As a consequence during descriptors release :
+ // 1) The map can change dynamically : we cannot iterate over it
+ // as any iterator can become invalid
+ // 2) The package can auto-destruct : we must test its existence
+ // after each release
+ // We must also take care of not locking the package pointer
+ // or any ref count check in Package::ReleaseBlackBoxDescriptor
+ // would be wrong
+
+ // The list of descriptors names at start
+ std::vector<std::string> descnamelist;
+ BlackBoxMapType::iterator i;
+ for (i=pack.lock()->mBlackBoxMap.begin();
+ i!= pack.lock()->mBlackBoxMap.end();
+ ++i)
+ descnamelist.push_back(i->first);
+
+ // Iterator over the initial names
+ std::vector<std::string>::iterator descname;
+ for (descname=descnamelist.begin();
+ descname!=descnamelist.end();
+ ++descname)
+ {
+ // Is package still alive ?
+ if (pack.expired())
+ {
+ bbtkDebugMessage("package",2,"--- Package::Release('"<<
+ packname
+ <<"') : package expired during release : bailing out"<<bbtkendl);
+ break;
+ }
+
+ PackageReleaseBlackBoxDescriptorInternal(pack,*descname);
+
+ }
+
+ //
+ UnLoadDynamicLibrary(pack);
+ // Unload orphan dl packages
+ Package::UnLoadReleasedDynamicallyLoadedPackages();
+
+
+
+
+ }
+
+ bbtkDebugMessage("package",1,"<== Package::Release('"<<
+ packname<<"')"<<bbtkendl);
+ if (!pack.expired())
+ {
+ long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0;
+ long ndesc = pack.lock()->GetBlackBoxMap().size();
+ long nrefs = pack.use_count();
+
+ bbtkDebugMessage("package",1," ... Package still alive ("
+ <<nrefs<<" refs / "
+ <<ndesc<<" descr / dyn="
+ <<dyn<<")"<<std::endl);
+ }
+ else
+ {
+ bbtkDebugMessage("package",1," ... Package has been released"
+ <<std::endl);
+ }
+ }
+ //==========================================================================
+
+ //==========================================================================
+ /// "Releases" the package
+ /// Signals the package that it can free the given descriptor
+ /// if they are no more used and free itself if it is no
+ /// more used
+ /// Note : Any non-weak pointer on the package must have been freed
+ void Package::ReleaseBlackBoxDescriptor(Package::WeakPointer pack,
+ BlackBoxDescriptor::WeakPointer descr)
+ {
+ std::string packname = pack.lock()->mName;
+ std::string dname = descr.lock()->GetTypeName();
+ bbtkDebugMessage("package",3,"==> Package::ReleaseBlackBoxDescriptor('"<<
+ packname<<"','"<<dname<<"')"<<bbtkendl);
+
+ long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0;
+ long ndesc = pack.lock()->GetBlackBoxMap().size();
+ long nrefs = pack.use_count();
+
+ bbtkDebugMessage("package",3," "<<nrefs<<" refs / "
+ <<ndesc<<" descr / dynamically loaded = "
+ <<dyn<<std::endl);
+
+ // A package is "free" from any external reference iff :
+ // i) It is not dynamically loaded and nrefs == ndesc
+ // (each desc references its package) or
+ // ii) It is dynamically loaded and nrefs == ndesc + 1
+ // (A dynamic library holds a static pointer on the package it contains
+ // which is allocated when the PACKAGENAMEGetPackage() func is called,
+ // and descallocated (reset) by PACKAGENAMEDeletePackage())
+ if (nrefs == ndesc + dyn)
+ {
+ PackageReleaseBlackBoxDescriptorInternal(pack,dname);
+ }
+
+ // If the package is released and dynamically loaded
+ // then put it in the static list mReleasedDynamicallyLoadedPackages
+ UnLoadDynamicLibrary(pack,false);
+
+ bbtkDebugMessage("package",3,"<== Package::ReleaseBlackBoxDescriptor('"<<
+ packname<<"','"<<dname<<"')"<<bbtkendl);
/*
- AdaptorMapType::const_iterator j;
- for (j=mAdaptorMap.begin();
- j!=mAdaptorMap.end();
- ++j)
+ if (!pack.expired())
{
- delete j->second;
+ long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0;
+ long ndesc = pack.lock()->GetBlackBoxMap().size();
+ long nrefs = pack.use_count();
+
+ bbtkDebugMessage("package",3," ... Package still alive ("
+ <<nrefs<<" refs / "
+ <<ndesc<<" descr / dyn="
+ <<dyn<<")"<<std::endl);
}
- */
- bbtkDebugDecTab("Kernel",7);
+ else
+ {
+ bbtkDebugMessage("package",3," ... Package has been released"
+ <<std::endl);
+ }
+ */
+ }
+ //==========================================================================
+
+ //==========================================================================
+ /// Opens a dynamic library which contains a bbtk package
+ /// Returns the handler
+ /// Load the package management symbols from the lib
+ /// returns false if a problem occured hence can be used
+ /// to test that a dyn lib is a valid bbtk package lib
+ /// NB : The BBTK version exported from the library
+ /// is tested against the current bbtk version
+ DynamicLibraryHandler Package::OpenDynamicLibrary
+ ( const std::string& libname,
+ const std::string& package_name,
+ DLGetPackageFunction& getpack,
+ DLDeletePackageFunction& delpack)
+ {
+ bbtkDebugMessage("package",3,"==> Package::OpenDynamicLibrary("
+ <<libname<<")"<<std::endl);
+#if defined(__GNUC__)
+
+ // Open shared lib
+ void *handler;
+ handler = dlopen(libname.c_str(),
+ BBTK_RTLD_TIME | BBTK_RTLD_SCOPE );
+ if (!handler)
+ {
+ bbtkMessage("package",2,
+ "Could not open shared library [" <<libname<<"] : "
+ <<dlerror() << std::endl);
+ return 0;
+ }
+
+ bbtkDebugMessage("package",3,"* Shared lib ["<<libname<<"] open"<<std::endl);
+
+ // Loads the Package bbtk version function
+ std::string getvername(package_name);
+ getvername +=
+ BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
+ DLGetPackageBBTKVersionFunction getbbtkversion
+ = (DLGetPackageBBTKVersionFunction)(dlsym(handler,getvername.c_str()));
+ if (!getbbtkversion)
+ {
+ bbtkDebugMessage("package",3,"***"<<std::endl);
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] is not a valid bbtk package."
+ <<" Symbol ["<<getvername<<"] :"<<dlerror()<< std::endl);
+ dlclose(handler);
+ return 0;
+ }
+
+ bbtkDebugMessage("package",3,"* Symbol ["<<getvername
+ <<"] found"<<std::endl);
+ // version matches ?
+ if (getbbtkversion() != bbtk::GetVersion())
+ {
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] was build with bbtk version "
+ <<getbbtkversion()
+ <<" but the current program runs with version "
+ <<bbtk::GetVersion()<<" : cannot load it"<<std::endl);
+ dlclose(handler);
+ return 0;
+
+ }
+
+ bbtkDebugMessage("package",3,"* Package bbtk version '"<<getbbtkversion()<<"' matches"<<std::endl);
+ // Loads the Package get function
+ std::string getpackname(package_name);
+ getpackname += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_FUNCTION_NAME);
+ getpack = (DLGetPackageFunction)(dlsym(handler, getpackname.c_str()));
+ if (!getpack)
+ {
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] is not a valid bbtk package."
+ <<" Symbol ["<<getpackname<<"] :"<<dlerror()<< std::endl);
+ dlclose(handler);
+ return 0;
+ }
+
+ bbtkDebugMessage("package",3,"* Symbol ["<<getpackname<<"] found"<<std::endl);
+ // Loads the Package delete function
+
+ std::string delpackname(package_name);
+ delpackname += BBTK_STRINGIFY_SYMBOL(BBTK_DEL_PACKAGE_FUNCTION_NAME);
+ delpack = (DLDeletePackageFunction)(dlsym(handler, delpackname.c_str()));
+ if (!delpack)
+ {
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] is not a valid bbtk package."
+ <<" Symbol ["<<delpackname<<"] :"<<dlerror()<< std::endl);
+ dlclose(handler);
+ return 0;
+ }
+ bbtkDebugMessage("package",3,"* Symbol ["<<delpackname<<"] found"<<std::endl);
+#elif defined(_WIN32)
+
+ HINSTANCE handler;
+
+ SetErrorMode(0);
+ // Open shared lib
+ handler = LoadLibrary(libname.c_str());
+ if (!handler)
+ {
+ bbtkMessage("package",2,
+ "Could not open shared library [" <<libname<<"]"
+ << std::endl);
+ return 0;
+ }
+
+ // Loads the Package bbtk version function
+ std::string getvername(package_name);
+ getvername +=
+ BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME);
+ DLGetPackageBBTKVersionFunction getbbtkversion
+ = (DLGetPackageBBTKVersionFunction)(GetProcAdress(handler,
+ getvername.c_str()));
+ if (!getbbtkversion)
+ {
+ FreeLibrary(handler);
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] is not a valid bbtk package."
+ <<" Symbol ["<<getbbtkversion<<"] not found"<< std::endl);
+ return 0;
+ }
+
+ // version matches ?
+ if (getbbtkversion() != bbtk::GetVersion())
+ {
+ FreeLibrary(handler);
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] was build with bbtk version "
+ <<getbbtkversion()
+ <<" but the current program runs with version "
+ <<bbtk::GetVersion()<<" : cannot load it"<<std::endl);
+ return 0;
+
+ }
+
+ // Loads the Package get function
+ std::string getpackname(package_name);
+ getpackname += BBTK_STRINGIFY_SYMBOL(BBTK_GET_PACKAGE_FUNCTION_NAME);
+ getpack = (DLGetPackageFunction)(GetProcAdress(handler, getpackname.c_str()));
+ if (!getpack)
+ {
+ FreeLibrary(handler);
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] is not a valid bbtk package."
+ <<" Symbol ["<<getpackname<<"] not found"<< std::endl);
+ return 0;
+ }
+
+ // Loads the Package delete function
+ std::string delpackname(package_name);
+ delpackname += BBTK_STRINGIFY_SYMBOL(BBTK_DEL_PACKAGE_FUNCTION_NAME);
+ delpack = (DLDeletePackageFunction)(GetProcAdress(handler, delpackname.c_str()));
+ if (!delpack)
+ {
+ FreeLibrary(handler);
+ bbtkMessage("package",2,
+ "Shared library ["<<libname
+ <<"] is not a valid bbtk package."
+ <<" Symbol ["<<delpackname<<"] not found"<< std::endl);
+ return 0;
+ }
+
+#else
+ bbtkError("neither __GNUC__ nor _WIN32 ?!? How did you compile ?");
+#endif
+
+ return handler;
+ }
+ //==========================================================================
+
+ //==========================================================================
+ /// Loads a package from a dynamic library
+ Package::Pointer Package::CreateFromDynamicLibrary(const std::string& libname,
+ const std::string& pkgname,
+ const std::string& path)
+ {
+ bbtkDebugMessage("package",1,"==> Package::CreateFromDynamicLibrary("
+ <<libname<<")"<<std::endl);
+
+ DLGetPackageFunction gf;
+ DLDeletePackageFunction df;
+ DynamicLibraryHandler h = Package::OpenDynamicLibrary(libname,
+ pkgname,
+ gf,df);
+ if (h==0) return Package::Pointer();
+ Package::Pointer p = gf();
+ p->mDynamicLibraryHandler = h;
+ p->mDLDeletePackageFunction = df;
+
+ std::string separator =
+ ConfigurationFile::GetInstance().Get_file_separator ();
+ //BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
+ std::string docreldoc =
+ separator + "bbdoc" + separator + pkgname + separator + "index.html";
+ std::string reldoc =
+ ".." + separator + ".." + docreldoc;
+ std::string doc = path + separator + ".." + separator
+ + BBTK_STRINGIFY_SYMBOL(BBTK_DOC_REL_PATH)
+ + docreldoc;
+
+ p->SetDocURL(doc);
+ p->SetDocRelativeURL(reldoc);
+
+ bbtkDebugMessage("package",1,"<== Package::CreateFromDynamicLibrary("
+ <<libname<<") .. OK"<<std::endl);
+ return p;
+ }
+ //==========================================================================
+
+
+
+
+ //==========================================================================
+ /// UnLoads the package dynamic library (if any)
+ void Package::UnLoadDynamicLibrary(Package::WeakPointer pack, bool doit)
+ {
+ if (pack.expired() || (!pack.lock()->mDynamicLibraryHandler))
+ return;
+
+
+ std::string packname = pack.lock()->GetName();
+ bbtkDebugMessage("package",3,"==> Package::UnLoadDynamicLibrary('"
+ <<packname<<"')"
+ <<std::endl);
+
+ if (!pack.lock()->GetBlackBoxMap().empty())
+ {
+
+ bbtkDebugMessage("package",3," Package not empty ... abort"
+ <<std::endl);
+ return;
+ /*
+ bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : "
+ <<"BlackBoxMap not empty "
+ <<BBTK_INTERNAL_ERROR_MESSAGE);
+ */
+
+ }
+
+ if (pack.use_count()!=1)
+ {
+ bbtkGlobalError("Package::UnLoadDynamicLibrary('"<<packname<<") : "
+ <<"empty dl package with external refs"
+ <<BBTK_INTERNAL_ERROR_MESSAGE);
+ }
+
+ if (doit)
+ {
+ UnLoad(pack);
+ bbtkDebugMessage("package",3," ... dynamic library closed"
+ <<std::endl);
+ }
+ else
+ {
+ mReleasedDynamicallyLoadedPackages.insert(pack);
+ bbtkDebugMessage("package",3,
+ " ... package put in the 'to unload' list"
+ <<std::endl);
+
+ }
+
+ bbtkDebugMessage("package",3,"<== Package::UnLoadDynamicLibrary('"
+ <<packname<<"')"
+ <<std::endl);
+
+ }
+ //==========================================================================
+
+ //==========================================================================
+ /// UnLoads released packages that were loaded dynamically
+ /// see UnLoadDynamicLibrary and ReleaseBlackBoxDescriptor
+ void Package::UnLoadReleasedDynamicallyLoadedPackages()
+ {
+ bbtkDebugMessage("package",2,"==> Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
+
+ std::set<Package::WeakPointer>::iterator i;
+ for (i=mReleasedDynamicallyLoadedPackages.begin();
+ i!=mReleasedDynamicallyLoadedPackages.end();
+ ++i)
+ {
+ if (!i->expired()) UnLoad(*i);
+ }
+ bbtkDebugMessage("package",2,"<== Package::UnLoadReleasedDynamicallyLoadedPackages()"<<std::endl);
}
//==========================================================================
+ //==========================================================================
+ void Package::UnLoad(Package::WeakPointer pack)
+ {
+ std::string packname = pack.lock()->GetName();
+ bbtkDebugMessage("package",2,"==> Package::UnLoad("<<packname<<")"<<std::endl);
+ Package* p = pack.lock().get();
+
+ DynamicLibraryHandler h = p->mDynamicLibraryHandler;
+
+ // deletes the package
+ p->mDLDeletePackageFunction();
+
+ // closes the dl handler
+#if defined(__GNUC__)
+ dlclose(h);
+#elif defined(_WIN32)
+ FreeLibrary(h);
+#endif
+
+ bbtkDebugMessage("package",2," ... dynamic library unloaded"<<std::endl);
+ }
+ //==========================================================================
//==========================================================================
/// Creates an instance of a black box of type <type> with name <name>
- BlackBox* Package::NewBlackBox(const std::string& type,
- const std::string& name) const
+ BlackBox::Pointer Package::NewBlackBox(const std::string& type,
+ const std::string& name) const
{
bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::NewBlackBox(\""<<type<<"\",\""<<name<<"\")"<<bbtkendl);
if (i == mBlackBoxMap.end())
{
bbtkDebugDecTab("Kernel",8);
- return 0;
+ return BlackBox::Pointer();
}
- BlackBox* bb =i->second->CreateInstance(name);
+ BlackBox::Pointer bb =i->second->NewBlackBox(name);
bbtkDebugDecTab("Kernel",8);
return bb;
//==========================================================================
/// Creates an instance of an adaptor of input type <typein> and
/// output type <typeout> with name <name>
- BlackBox* Package::NewAdaptor(const DataInfo& typein,
+ BlackBox::Pointer Package::NewAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const
{
if (i == mAdaptorMap.end())
{
bbtkDebugDecTab("Kernel",8);
- return 0;
+ return BlackBox::Pointer();
}
- BlackBox* bb =i->second->CreateInstance(name);
+ BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name);
bbtkDebugDecTab("Kernel",8);
return bb;
//==========================================================================
/// Creates an instance of an adaptor of input type <typein> and
/// output type <typeout> with name <name>
- BlackBox* Package::NewWidgetAdaptor(const DataInfo& typein,
+ BlackBox::Pointer Package::NewWidgetAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const
{
if (i == mAdaptorMap.end())
{
bbtkDebugDecTab("Kernel",8);
- return 0;
+ return BlackBox::Pointer();
}
- BlackBox* bb =i->second->CreateInstance(name);
+ BlackBox::Pointer bb =i->second.lock()->NewBlackBox(name);
bbtkDebugDecTab("Kernel",8);
return bb;
<<typein<<","
<<typeout<<")"<<bbtkendl);
- AdaptorKey key(typein,typeout,
+ AdaptorKey key(/*typein*/
+ DataInfo(typeid(void),""),
+ typeout,
BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR);
// First try to find a single widget adaptor
AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
bbtkDebugDecTab("Kernel",8);
return false;
}
- adaptor = i->second->GetTypeName();
+ adaptor = i->second.lock()->GetTypeName();
bbtkDebugDecTab("Kernel",8);
return true;
bbtkDebugDecTab("Kernel",8);
return false;
}
- adaptor = i->second->GetTypeName();
+ adaptor = i->second.lock()->GetTypeName();
bbtkDebugDecTab("Kernel",8);
return true;
//==========================================================================
/// Registers a black box descriptor in the package
- bool Package::RegisterBlackBox(BlackBoxDescriptor* d)
+ bool Package::RegisterBlackBox(BlackBoxDescriptor::Pointer d)
{
bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\")"<<std::endl);
}
mBlackBoxMap[d->GetTypeName()] = d;
- d->Reference();
- d->SetPackage(this);
+ // d->Reference();
+ d->SetPackage(GetThisPointer<Package>());
// If it is a default adaptor, also register it in the adaptors map
- if ( (d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR) ||
- (d->GetKind() == BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR) )
+ if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR )
{
bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<<std::endl);
+
TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
DataInfo infoin(typein,d->GetInputDescriptor("In")->GetNature());
DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature());
- bbtkDebugMessage("Kernel",9,"Adaptor "<<infoin<<" to "<<infoout
- <<" - kind="<<d->GetKind()<<std::endl);
-
AdaptorKey key(infoin,infoout,d->GetKind());
-
- AdaptorMapType::const_iterator i = mAdaptorMap.find(key);
+
+ AdaptorMapType::const_iterator i;
+ i = mAdaptorMap.find(key);
if (i == mAdaptorMap.end())
{
mAdaptorMap[key] = d;
// If already an adaptor registered : error
else
{
- if (i->second->GetTypeName() != d->GetTypeName())
+ if (i->second.lock()->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()<<">)");
+ <<i->second.lock()->GetTypeName()<<">)");
+ }
+ }
+ }
+ // If it is a default adaptor, also register it in the adaptors map
+ else if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_WIDGET_ADAPTOR)
+ {
+ bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterBlackBox(\""<<d->GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<<std::endl);
+
+ TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
+ DataInfo infoin(typeid(void),"");
+ DataInfo infoout(typeout,d->GetOutputDescriptor("Out")->GetNature());
+ AdaptorKey key(infoin,infoout,d->GetKind());
+
+ AdaptorMapType::const_iterator i;
+ i = mAdaptorMap.find(key);
+ if (i == mAdaptorMap.end())
+ {
+ mAdaptorMap[key] = d;
+ }
+ // If already an adaptor registered : error
+ else
+ {
+ if (i->second.lock()->GetTypeName() != d->GetTypeName())
+ {
+ bbtkError("Package <"<<GetName()<<
+ "> : trying to register black box <"
+ <<d->GetTypeName()
+ <<"> as default widget adaptor but there is already a default adaptor registered (<"
+ <<i->second.lock()->GetTypeName()<<">)");
}
}
}
+
bbtkDebugDecTab("Kernel",8);
return true;
}
//===================================================================
- //==========================================================================
- /// UnRegisters a black box descriptor from the package
- void Package::UnRegisterBlackBox(const std::string& name)
- {
- bbtkDebugMessageInc("Kernel",8,"Package<"<<GetName()<<">::UnRegisterBlackBox(\""<<name<<"\")"<<std::endl);
- // Looking into the bb map
- BlackBoxMapType::iterator i = mBlackBoxMap.find(name);
- if (i == mBlackBoxMap.end())
- {
- bbtkDebugDecTab("Kernel",8);
- 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);
- if (j != mAdaptorMap.end())
- {
- mAdaptorMap.erase(j);
- }
- */
-
- i->second->UnReference();
-
- bbtkDebugDecTab("Kernel",8);
- }
- //==========================================================================
//==========================================================================
/// Changes the name of a black box type
}
//==========================================================================
- /*
-
- //==========================================================================
- /// Registers an adaptor descriptor in the package
- bool Package::RegisterAdaptor(BlackBoxDescriptor* d)
- {
- bbtkDebugMessage("Kernel",8,"Package<"<<GetName()<<">::RegisterAdaptor(\""<<d->GetTypeName()<<"\")"<<std::endl);
-
- TypeInfo typein = d->GetInputDescriptor("In")->GetTypeInfo();
- TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo();
- AdaptorKey key(typein,typeout);
-
- mAdaptorMap[key] = d;
- return true;
- }
- //==========================================================================
- */
//==========================================================================
s << "<TR><TD style='vertical-align: top;'><b> Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> "
<< GetVersion() << "</TD></TR>\n";
s << "<TR><TD style='vertical-align: top;'><b> bbtk Version </b></TD><TD style='vertical-align: top;'> : </TD><TD style='vertical-align: top;'> "
- << GetBBTKVersion() << "</TD></TR>\n";
+ << bbtk::GetVersion() << "</TD></TR>\n";
s << "</TABLE>\n";
}
bbtkDebugDecTab("Kernel",9);
}
//==========================================================================
+
+ //==========================================================================
+ std::string Package::GetObjectName() const
+ {
+ return std::string("Package '")+mName+std::string("'");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Package::GetObjectInfo() const
+ {
+ std::stringstream i;
+ i << " - "<<mBlackBoxMap.size() << " boxes" << std::endl;
+ if (mDynamicLibraryHandler)
+ {
+ i<< " - Loaded from dynamic library"<<std::endl;
+ }
+ return i.str();
+ }
+ //==========================================================================
+
+
+ //==========================================================================
+ size_t Package::GetObjectSize() const
+ {
+ size_t s = Superclass::GetObjectSize();
+ s += Package::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Package::GetObjectInternalSize() const
+ {
+ size_t s = sizeof(Package);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Package::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Package::GetObjectInternalSize();
+
+ BlackBoxMapType::const_iterator i;
+ for (i = mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i )
+ {
+ s += i->second->GetObjectRecursiveSize();
+ }
+ return s;
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::set<Package::WeakPointer>
+ Package::mReleasedDynamicallyLoadedPackages;
+ //==========================================================================
}
Program: bbtk
Module: $RCSfile: bbtkPackage.h,v $
Language: C++
- Date: $Date: 2008/04/09 11:16:57 $
- Version: $Revision: 1.7 $
+ Date: $Date: 2008/04/18 12:59:15 $
+ 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
#define __bbtkPackage_h__
#include "bbtkBlackBox.h"
+#include "bbtkDynamicLibraryHandling.h"
namespace bbtk
{
- class BBTK_EXPORT Package
+ class Factory;
+ BBTK_FORWARD_DECLARE_POINTER(Factory);
+
+ class BBTK_EXPORT Package : public Object
{
+ BBTK_OBJECT_INTERFACE(Package);
+ typedef Object Superclass;
public:
- Package(const std::string& name,
- const std::string& author,
- const std::string& description,
- const std::string& version,
- const std::string& BBTKVersion);
- ~Package();
+ /// Creates a new package
+ static Pointer New(const std::string& name,
+ const std::string& author,
+ const std::string& description,
+ const std::string& version,
+ const std::string& BBTKVersion);
+ /// Creates a package from a dynamic library
+ static Pointer CreateFromDynamicLibrary(const std::string& libname,
+ const std::string& pkgname,
+ const std::string& path);
+
+ /// UnLoads the package dynamic library
+ /// (if any and if the package is released)
+ /// If doit == false then does not do it but just
+ /// put the package in the list of ReleasedDynamicallyLoadedPackages.
+ /// This is because we cannot close the dl from inside a
+ /// package member method or the program crashes.
+ /// The actual dl close must be done by an external user
+ /// calling UnLoadReleasedDynamicallyLoadedPackages
+ static void UnLoadDynamicLibrary(Package::WeakPointer p, bool doit = true);
+
+ /// UnLoads released packages that were loaded dynamically
+ /// see UnLoadDynamicLibrary and ReleaseBlackBoxDescriptor
+ static void UnLoadReleasedDynamicallyLoadedPackages();
+
+ /// "Releases" the package
+ /// Signals the package that it can free its descriptors
+ /// if they are no more used and frees and unloads the package
+ /// if it is no more used (released)
+ /// Note : Any non-weak pointer on the package must have been freed
+ static void Release(Package::WeakPointer p);
+ /// "Releases" a black box descriptor
+ /// Signals the package that it can free the given descriptor
+ /// if it is no more used and frees and put it the the
+ /// ReleasedDynamicallyLoadedPackages if it is dyn loaded
+ /// and no more used (released)
+ /// Note : Any non-weak pointer on the package must have been freed
+ static void ReleaseBlackBoxDescriptor(Package::WeakPointer p,
+ BlackBoxDescriptor::WeakPointer d);
+
+
+ typedef Package::Pointer (*DLGetPackageFunction)();
+ typedef void (*DLDeletePackageFunction)();
+ typedef const std::string& (*DLGetPackageBBTKVersionFunction)();
+
+ /// Opens a dynamic library which contains a bbtk package
+ /// Returns the handler
+ /// Load the package management symbols from the lib
+ /// returns false if a problem occured hence can be used
+ /// to test that a dyn lib is a valid bbtk package lib
+ /// NB : The BBTK version exported from the library
+ /// is tested against the current bbtk version
+ static DynamicLibraryHandler OpenDynamicLibrary
+ ( const std::string& dynamic_library_path,
+ const std::string& package_name,
+ DLGetPackageFunction&,
+ DLDeletePackageFunction&);
+
+
/// Returns the name of the package
const std::string& GetName() const { return mName; }
/// Returns the version of the package
const std::string& GetVersion() const { return mVersion; }
- /// Returns the version of bbtk used to build the package
- const std::string& GetBBTKVersion() const { return mBBTKVersion; }
-
bool ContainsBlackBox(const std::string& boxname) const;
- BlackBox* NewBlackBox(const std::string& type,
+ BlackBox::Pointer NewBlackBox(const std::string& type,
const std::string& name) const;
- BlackBox* NewAdaptor(const DataInfo& typein,
+ BlackBox::Pointer NewAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const;
- BlackBox* NewWidgetAdaptor(const DataInfo& typein,
+ BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein,
const DataInfo& typeout,
const std::string& name) const;
bool FindAdaptor(const DataInfo& typein,
const DataInfo& typeout,
std::string& adaptor) const;
- bool RegisterBlackBox(BlackBoxDescriptor*);
- void UnRegisterBlackBox(const std::string& name);
-
- // bool RegisterAdaptor(BlackBoxDescriptor*);
+ bool RegisterBlackBox(BlackBoxDescriptor::Pointer);
void PrintBlackBoxes(bool description = false,
bool adaptors = false) const;
void ChangeBlackBoxName( const std::string& oldname,
const std::string& newname );
/// The type of map of descriptors
- typedef std::map< std::string, BlackBoxDescriptor*> BlackBoxMapType;
+ typedef std::map< std::string, BlackBoxDescriptor::Pointer>
+ BlackBoxMapType;
const BlackBoxMapType& GetBlackBoxMap() const { return mBlackBoxMap; }
BlackBoxMapType& GetBlackBoxMap() { return mBlackBoxMap; }
};
/// The type of map of adaptor descriptors
- typedef std::map< AdaptorKey, BlackBoxDescriptor*> AdaptorMapType;
+ typedef std::map< AdaptorKey, BlackBoxDescriptor::WeakPointer> 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); }
+ void AddFactory(FactoryPointer f) { mFactorySet.insert(f); }
/// Removes the factory from the set of factories which use the package
- void RemoveFactory(Factory* f) { mFactorySet.erase(f); }
+ void RemoveFactory(FactoryPointer f) { mFactorySet.erase(f); }
+
+ typedef std::set<FactoryWeakPointer> FactorySet;
/// Gets the set of factories which use the package
- std::set<Factory*>& GetFactorySet() { return mFactorySet; }
+ FactorySet& GetFactorySet() { return mFactorySet; }
/// Gets the set of factories which use the package (const)
- const std::set<Factory*>& GetFactorySet() const { return mFactorySet; }
+ const FactorySet& GetFactorySet() const { return mFactorySet; }
void CheckBoxes() const;
private:
+ /// Default ctor is private : use the static New method
+ // Package() {}
+ /// A Package cannot be copy constructed
+ // Package(const Package&) {}
+ /// Ctor is private : use the static New method
+ Package(const std::string& name,
+ const std::string& author,
+ const std::string& description,
+ const std::string& version,
+ const std::string& BBTKVersion);
+ /// Does unload a package (no test)
+ static void UnLoad(Package::WeakPointer p);
+
+ /// The dynamic library handler of the package if it was loaded from a dl
+ DynamicLibraryHandler mDynamicLibraryHandler;
+ /// The pointer on the delete function of the package
+ /// in case it was loaded from a dynamic library
+ DLDeletePackageFunction mDLDeletePackageFunction;
+
/// The name of the package
std::string mName;
std::string mDescription;
/// The version of the package
std::string mVersion;
- /// The version of the library bbtk used to build the package
- std::string mBBTKVersion;
/// URL of the documentation of the Package (absolute path)
std::string mDocURL;
/// URL of the documentation of the Package
/// The map of black boxes descriptors
BlackBoxMapType mBlackBoxMap;
-
- public:
-
-
- private:
/// The map of adaptors descriptors
AdaptorMapType mAdaptorMap;
/// The set of factories which contain the package
- std::set<Factory*> mFactorySet;
-
+ FactorySet mFactorySet;
+
+ /// The set of released dynamically loaded packages
+ /// to be unloaded explicitely calling
+ /// UnLoadReleasedDynamicallyLoadedPackages
+ static std::set<Package::WeakPointer>
+ mReleasedDynamicallyLoadedPackages;
};
// EO class Package
//====================================================================
#endif // defined(_WIN32)
//====================================================================
+#define BBTK_GET_PACKAGE_FUNCTION_NAME GetPackage
+#define BBTK_DEL_PACKAGE_FUNCTION_NAME DeletePackage
+#define BBTK_GET_PACKAGE_BBTK_VERSION_FUNCTION_NAME GetPackageBBTKVersion
+
+
+
//====================================================================
#define BBTK_DECLARE_PACKAGE(NAME) \
extern "C" \
{ \
- bbtk::Package*& NAME ## GetPackagePointer(); \
- BBTK_PACKAGE_EXPORT void BBTK_CDECL NAME ## DeletePackage(); \
- BBTK_PACKAGE_EXPORT bbtk::Package* BBTK_CDECL NAME ## GetPackage(); \
+ bbtk::Package::Pointer& NAME ## GetPackagePointer(); \
+ BBTK_PACKAGE_EXPORT \
+ void BBTK_CDECL NAME ## DeletePackage (); \
+ BBTK_PACKAGE_EXPORT bbtk::Package::Pointer \
+ BBTK_CDECL NAME ## GetPackage (); \
+ BBTK_PACKAGE_EXPORT const std::string& \
+ BBTK_CDECL NAME ## GetPackageBBTKVersion (); \
}
//====================================================================
#define BBTK_IMPLEMENT_PACKAGE(NAME,AUTHOR,DESCRIPTION,VERSION) \
extern "C" \
{ \
- bbtk::Package*& NAME ## GetPackagePointer() \
+ bbtk::Package::Pointer& NAME ## GetPackagePointer() \
{ \
- static bbtk::Package* u = 0; \
+ static bbtk::Package::Pointer u; \
return u; \
} \
- BBTK_PACKAGE_EXPORT void BBTK_CDECL NAME ## DeletePackage() \
+ BBTK_PACKAGE_EXPORT \
+ void BBTK_CDECL NAME ## DeletePackage () \
{ \
- if (NAME ## GetPackagePointer()) \
- delete NAME ## GetPackagePointer(); \
- NAME ## GetPackagePointer() = 0; \
+ NAME ## GetPackagePointer().reset(); \
} \
- BBTK_PACKAGE_EXPORT bbtk::Package* BBTK_CDECL NAME ## GetPackage() \
+ BBTK_PACKAGE_EXPORT \
+ bbtk::Package::Pointer \
+ BBTK_CDECL NAME ## GetPackage() \
{ \
if (!NAME ## GetPackagePointer()) \
NAME ## GetPackagePointer() = \
- new bbtk::Package(#NAME, \
- AUTHOR, \
- DESCRIPTION, \
- VERSION, \
- BBTK_STRINGIFY_SYMBOL(BBTK_VERSION) \
- ); \
+ bbtk::Package::New(#NAME, \
+ AUTHOR, \
+ DESCRIPTION, \
+ VERSION, \
+ BBTK_STRINGIFY_SYMBOL(BBTK_VERSION) \
+ ); \
return NAME ## GetPackagePointer(); \
} \
+ BBTK_PACKAGE_EXPORT const std::string& \
+ BBTK_CDECL NAME ## GetPackageBBTKVersion () \
+ { return bbtk::GetVersion(); } \
}
//====================================================================
//====================================================================
#define BBTK_ADD_BLACK_BOX_TO_PACKAGE(NAME,CLASS) \
- bool bbDummy##NAME##CLASS = NAME ## GetPackage()->RegisterBlackBox(CLASS::bbDescriptor());
+ bool bbDummy##NAME##CLASS = NAME ## GetPackage () \
+ ->RegisterBlackBox(CLASS ## Descriptor::Instance());
//====================================================================
-//====================================================================
+ //====================================================================
#define BBTK_ADD_TEMPLATE_BLACK_BOX_TO_PACKAGE(NAME,CLASS,TEMPLATE_PARAM) \
- bool bbDummy##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage()->RegisterBlackBox(CLASS<TEMPLATE_PARAM>::bbDescriptor());
+ bool bbDummy##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage () \
+ ->RegisterBlackBox(CLASS ## Descriptor <TEMPLATE_PARAM>::Instance());
+ //====================================================================
+
//====================================================================
-
-//====================================================================
#define BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(NAME,CLASS,T1,T2) \
- bool bbDummy##NAME##CLASS##T1##T2 = NAME ## GetPackage()->RegisterBlackBox(CLASS<T1,T2>::bbDescriptor());
+ bool bbDummy##NAME##CLASS##T1##T2 = NAME ## GetPackage () \
+ ->RegisterBlackBox(CLASS ## Descriptor <T1,T2>::Instance());
//====================================================================
-//====================================================================
-//#define BBTK_ADD_ADAPTOR_TO_PACKAGE(NAME,CLASS) \
-// bool bbDummy##NAME##CLASS = NAME ## GetPackage()->RegisterBlackBox(CLASS::bbDescriptor()); \
-// bool bbDummyAdaptor##NAME##CLASS = NAME ## GetPackage()->RegisterAdaptor(CLASS::bbDescriptor());
-//====================================================================
-
-//====================================================================
-//#define BBTK_ADD_TEMPLATE_ADAPTOR_TO_PACKAGE(NAME,CLASS,TEMPLATE_PARAM) \
-// bool bbDummy##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage()->RegisterBlackBox(CLASS<TEMPLATE_PARAM>::bbDescriptor()); \
-// bool bbDummyAdaptor##NAME##CLASS##TEMPLATE_PARAM = NAME ## GetPackage()->RegisterAdaptor(CLASS<TEMPLATE_PARAM>::bbDescriptor());
-//====================================================================
-
-//====================================================================
-//#define BBTK_ADD_TEMPLATE2_ADAPTOR_TO_PACKAGE(NAME,CLASS,T1,T2) \
-// bool bbDummy##NAME##CLASS##T1##T2 = NAME ## GetPackage()->RegisterBlackBox(CLASS<T1,T2>::bbDescriptor()); \
-// bool bbDummyAdaptor##NAME##CLASS##T1##T2 = NAME ## GetPackage()->RegisterAdaptor(CLASS<T1,T2>::bbDescriptor());
- //====================================================================
}// namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkTranscriptor.cxx,v $ $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
namespace bbtk
{
+ Transcriptor::Pointer Transcriptor::New(const std::string& filename)
+ {
+ return MakePointer(new Transcriptor(filename));
+ }
+
/**
*
*/
- Transcriptor::Transcriptor(std::string filename)
+ Transcriptor::Transcriptor(const std::string& filename)
:
mNoExecMode(false),
mDialogMode(NoDialog)
m_Fp << " e->UnLoadPackage(\"" <<name<<"\");"<<std::endl;
}
+ //==========================================================================
+ std::string Transcriptor::GetObjectName() const
+ {
+ return std::string("Transcriptor");
+ }
+ //==========================================================================
+
+ //==========================================================================
+ std::string Transcriptor::GetObjectInfo() const
+ {
+ std::stringstream i;
+ return i.str();
+ }
+ //==========================================================================
+
+ //==========================================================================
+size_t Transcriptor::GetObjectSize() const
+{
+ size_t s = Superclass::GetObjectSize();
+ s += Transcriptor::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+size_t Transcriptor::GetObjectInternalSize() const
+{
+ size_t s = sizeof(Transcriptor);
+ return s;
+ }
+ //==========================================================================
+ //==========================================================================
+ size_t Transcriptor::GetObjectRecursiveSize() const
+ {
+ size_t s = Superclass::GetObjectRecursiveSize();
+ s += Transcriptor::GetObjectInternalSize();
+ return s;
+ }
+ //==========================================================================
}//namespace
Program: bbtk
Module: $RCSfile: bbtkTranscriptor.h,v $ $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.9 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ Version: $Revision: 1.10 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class /*BBTK_EXPORT*/ Transcriptor : public VirtualExec
{
-
+ BBTK_OBJECT_INTERFACE(Transcriptor);
+ typedef VirtualExec Superclass;
public:
+ static Pointer New(const std::string& filename);
- /// Constructor
- Transcriptor(std::string filename);
-
- /// Destructor
- ~Transcriptor( );
/// Sets the inputs of the workspace :
void SetInputs(const std::map<std::string,std::string>& m) { mInputs = m; }
protected:
private:
+ /// Constructor
+ Transcriptor(const std::string& filename);
/// The input values of the Root ComplexBlackBox
std::map<std::string,std::string> mInputs;
--- /dev/null
+#include "bbtkVirtualExec.h"
+#include "bbtkInterpreter.h"
+
+namespace bbtk
+{
+ VirtualExec::VirtualExec()
+ : mInterpreter()
+ {
+ }
+
+ VirtualExec::~VirtualExec()
+ {
+ }
+
+ Interpreter::Pointer VirtualExec::GetInterpreter()
+ {
+ return mInterpreter.lock();
+ }
+
+
+}
+
Program: bbtk
Module: $RCSfile: bbtkVirtualExec.h,v $ $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
#define __bbtkVirtualExec_h__
#include "bbtkSystem.h"
-//#include "bbtkComplexBlackBox.h"
+#include "bbtkComplexBlackBoxDescriptor.h"
#include "bbtkFactory.h"
-//#include <string>
-//#include <deque>
namespace bbtk
{
class Interpreter;
+ BBTK_FORWARD_DECLARE_POINTER(Interpreter);
- class /*BBTK_EXPORT*/ VirtualExec // All methods are pure virtual
+ class /*BBTK_EXPORT*/ VirtualExec : public Object
{
-
+ BBTK_ABSTRACT_OBJECT_INTERFACE(VirtualExec);
public:
typedef enum
{
}
DialogModeType;
- VirtualExec() : mInterpreter(0) {}
-
- virtual ~VirtualExec() {}
/// Sets the interpreter who uses it
- void SetInterpreter(Interpreter* i) { mInterpreter = i; }
+ void SetInterpreter(InterpreterPointer i) { mInterpreter = i; }
/// Gets the interpreter who uses it
- Interpreter* GetInterpreter() { return mInterpreter; }
+ InterpreterPointer GetInterpreter(); // { return mInterpreter.lock(); }
/// Gets the interpreter who uses it (const)
- const Interpreter* GetInterpreter() const { return mInterpreter; }
+ // const Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
/// Gets the factory used by the executer
- virtual Factory* GetFactory() { return 0; }
+ virtual Factory::Pointer GetFactory() { return Factory::Pointer(); }
/// Gets the factory used by the executer (const)
- virtual const Factory* GetFactory() const { return 0; }
+ // virtual const Factory* GetFactory() const { return 0; }
/// Sets the inputs of the workspace :
virtual void SetInputs(const std::map<std::string,std::string>& m) = 0;
/// Prints the string ... MORE : TO EXPLAIN
virtual void Print(const std::string & message) = 0;
-
+ ComplexBlackBoxDescriptor::Pointer GetWorkspace()
+ { return ComplexBlackBoxDescriptor::Pointer(); }
+
// static const std::string& GetObjectDescription() = 0;
// { static std::string s("VirtualExec"); return s; }
protected:
private:
/// The interpreter which uses it (0 if none)
- Interpreter* mInterpreter;
- /*
- /// Gets the current working black box
- virtual ComplexBlackBoxDescriptor* Current() = 0;
-
- /// Returns true when we are inside a define/endefine block
- // virtual bool InDefinitionBlock() = 0;
-
- //==================================================================
- // ATTRIBUTES
-
- /// The factory used
- // Factory* mFactory;
-
- /// The Root Package
- Package* mPackage;
-
- /// The root ComplexBlackBox, in which operations are done when outside a define/endefine block
- /// Its name in bbi is 'workspace'
- ComplexBlackBoxDescriptor* mRoot;
-
- /// Struct that stores info on user defined complex black boxes
- struct CBBDefinition
- {
- ComplexBlackBoxDescriptor* box;
- std::string package;
- CBBDefinition(ComplexBlackBoxDescriptor* d, const std::string& p )
- : box(d), package(p) {}
- };
-
- /// The stack of current working ComplexBlackBox
- /// (is a stack for nested definitions)
- /// only contains the root when outside a define/endefine block
- std::deque<CBBDefinition> mOpenDefinition;
-
- /// The stack of current working package
- /// (is a stack for nested definitions)
- std::deque<Package*> mOpenPackage;
-
- /// flag which is true when we are inside a Define/EndDefine block
- // bool mDefineFlag;
-
- /// The input values of the Root ComplexBlackBox
- std::map<std::string,std::string> mInputs;
-
- /// no exec mode flag
- bool mNoExecMode;
+ InterpreterWeakPointer mInterpreter;
- /// Dialog mode
- DialogModeType mDialogMode;
- */
};
}
#endif
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
//=========================================================================
- WxBlackBoxWindow::WxBlackBoxWindow(WxBlackBox* box)
+ WxBlackBoxWindow::WxBlackBoxWindow(WxBlackBox::Pointer box)
: mBox(box), mShown(false)
{
bbtkDebugMessage("Wx",9,"WxBlackBoxWindow::WxBlackBoxWindow("<<
//=========================================================================
//=========================================================================
- WxBlackBoxDialog::WxBlackBoxDialog(WxBlackBox* box,
+ WxBlackBoxDialog::WxBlackBoxDialog(WxBlackBox::Pointer box,
wxWindow *parent,
wxString title,
wxSize size)
//=========================================================================
//=========================================================================
- WxBlackBoxFrame::WxBlackBoxFrame(WxBlackBox* box,
+ WxBlackBoxFrame::WxBlackBoxFrame(WxBlackBox::Pointer box,
wxWindow *parent,
wxString title,
wxSize size)
//=========================================================================
//=========================================================================
- WxBlackBoxWidgetEventHandler::WxBlackBoxWidgetEventHandler( WxBlackBox* box,
- wxWindow *widget )
+ WxBlackBoxWidgetEventHandler::
+ WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box,
+ wxWindow *widget )
:
mBox(box),
mWindow(widget)
//=========================================================================
//=========================================================================
//=========================================================================
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(WxBlackBox,AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(WxBlackBox,AtomicBlackBox);
//=========================================================================
//=========================================================================
"-> Output 'Widget' connected : transfering execution to parent"
<<std::endl);
- i->second->GetConnectionVector().front()
+ i->second->GetConnectionVector().front().lock()
->GetBlackBoxTo()->bbExecute(force);
}
//=========================================================================
/// Main processing method of the box.
- IOStatus WxBlackBox::bbBackwardUpdate( Connection* caller )
+ IOStatus WxBlackBox::bbBackwardUpdate( Connection::Pointer caller )
{
bbtkDebugMessageInc("Process",1,
"=> WxBlackBox::bbBackwardUpdate("
"-> Output 'Widget' connected : transfering execution to parent"
<<std::endl);
- i->second->GetConnectionVector().front()
+ i->second->GetConnectionVector().front().lock()
->GetBlackBoxTo()->bbExecute(false);
done = true;
}
bbtkDebugMessage("Process",3,
"-> No widget event handler : creating one"
<<std::endl);
- new WxBlackBoxWidgetEventHandler(this,bbGetOutputWidget());
+ new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
+ bbGetOutputWidget());
}
else if ( ! bbGetWidgetEventHandler()->IsHandlerOf
( bbGetOutputWidget() ) )
"-> Obsolete widget event handler : re-creating one"
<<std::endl);
delete bbGetWidgetEventHandler();
- new WxBlackBoxWidgetEventHandler(this,bbGetOutputWidget());
+ new WxBlackBoxWidgetEventHandler(GetThisPointer<WxBlackBox>(),
+ bbGetOutputWidget());
}
// Sets the name of the wxWindow to the input WinTitle
bbGetOutputWidget()->SetName(bbtk::std2wx(bbGetInputWinTitle()));
bbtkDebugMessage("Process",2,
" Input WinDialog set to true : creating a Dialog"
<<std::endl);
- show = (Window*) new WxBlackBoxDialog( this,
+ show = (Window*) new WxBlackBoxDialog( GetThisPointer<WxBlackBox>(),
bbGetWxParent(),
std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
bbtkDebugMessage("Process",2,
" Input WinDialog set to false : creating a Frame"
<<std::endl);
- show = (Window*) new WxBlackBoxFrame( this,
+ show = (Window*) new WxBlackBoxFrame( GetThisPointer<WxBlackBox>(),
bbGetWxParent(),
std2wx( bbGetInputWinTitle() + " - bbtk (c) CREATIS LRMN"),
wxSize( bbGetInputWinWidth() , bbGetInputWinHeight() ) );
= bbGetOutputConnectorMap().find("Widget");
if ( i->second->GetConnectionVector().size() != 0 )
{
- return ((WxBlackBox*)i->second->GetConnectionVector().front()
- ->GetBlackBoxTo())->bbGetContainingWindow();
+ return boost::static_pointer_cast<WxBlackBox>
+ (i->second->GetConnectionVector().front().lock()->GetBlackBoxTo())
+ ->bbGetContainingWindow();
}
return 0;
}
Program: bbtk
Module: $RCSfile: bbtkWxBlackBox.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//==================================================================
/// Widget black boxes
class BBTK_EXPORT WxBlackBox : public bbtk::AtomicBlackBox
- {
- BBTK_USER_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::AtomicBlackBox);
+ {
+ BBTK_BLACK_BOX_INTERFACE(WxBlackBox,bbtk::AtomicBlackBox);
// BBTK_DECLARE_INPUT(WinParent,WxParentToChildData*);
BBTK_DECLARE_INPUT(WinTitle,std::string);
BBTK_DECLARE_INPUT(WinWidth,int);
//==================================================================
/// Main processing method of the box.
- virtual IOStatus bbBackwardUpdate( Connection* caller );
+ virtual IOStatus bbBackwardUpdate( Connection::Pointer caller );
//==================================================================
class BBTK_EXPORT WxBlackBoxWindow //: public wxWindow
{
public:
- WxBlackBoxWindow(WxBlackBox* box);
+ WxBlackBoxWindow(WxBlackBox::Pointer box);
virtual ~WxBlackBoxWindow();
virtual void bbShow();
virtual void bbHide();
bool bbIsShown() { return mShown; }
- virtual WxBlackBox* bbGetBlackBox() { return mBox; }
+ virtual WxBlackBox::Pointer bbGetBlackBox() { return mBox; }
virtual wxDialog* bbGetDialog() { return 0; }
virtual wxFrame* bbGetFrame() { return 0; }
private:
- WxBlackBox* mBox;
+ WxBlackBox::Pointer mBox;
bool mShown;
};
//==================================================================
class BBTK_EXPORT WxBlackBoxDialog : public wxDialog, public WxBlackBoxWindow
{
public:
- WxBlackBoxDialog(WxBlackBox* box,
+ WxBlackBoxDialog(WxBlackBox::Pointer box,
wxWindow *parent, wxString title, wxSize size);
~WxBlackBoxDialog();
void bbShow();
class BBTK_EXPORT WxBlackBoxFrame : public wxFrame, public WxBlackBoxWindow
{
public:
- WxBlackBoxFrame(WxBlackBox* box,
+ WxBlackBoxFrame(WxBlackBox::Pointer box,
wxWindow *parent, wxString title, wxSize size);
~WxBlackBoxFrame();
void bbShow();
//==================================================================
- /*
- //=================================================================
- /// Class from which a user defined widget associated to a WxBlackBox
- /// should inherit
- class BBTK_EXPORT WxBlackBoxWidget
- {
- public:
- /// Ctor with the WxBlackBox which created it
- WxBlackBoxWidget( WxBlackBox* box);
- /// Dtor
- virtual ~WxBlackBoxWidget();
-
- /// Returns the WxBlackBox which created it
- WxBlackBox* GetBlackBox() { return mBox; }
- /// Returns the WxBlackBox which created it (const)
- const WxBlackBox* GetBlackBox() const { return mBox; }
-
- /// Returns the wxWindow associated to the widget
- virtual wxWindow* GetWxWindow() { return 0; }
-
- virtual bool IsDead() { return false; }
-
- private:
- WxBlackBox* mBox;
- };
- //=================================================================
- */
//=================================================================
// Handles the destroy events of a widget associated to a WxBlackBox
{
public:
/// Ctor with the box and widget
- WxBlackBoxWidgetEventHandler( WxBlackBox* box, wxWindow *widget );
+ WxBlackBoxWidgetEventHandler( WxBlackBox::Pointer box, wxWindow *widget );
/// Dtor
~WxBlackBoxWidgetEventHandler();
/// Returns true iff is the handler for that window
//bool IsDead() { return mDead; }
private:
- WxBlackBox* mBox;
+ WxBlackBox::Pointer mBox;
wxWindow* mWindow;
//bool mDead;
};
//=================================================================
- /*
- //=================================================================
- /// A WxBlackBoxWidget which is a wxPanel also
- class BBTK_EXPORT WxBlackBoxWidgetPanel :
- public wxPanel,
- public WxBlackBoxWidget
-// public WxBlackBoxWidget,
-// public wxPanel
- {
- public:
- /// Ctor with the parent and the WxBlackBox which created it
- WxBlackBoxWidgetPanel(WxBlackBox* box, wxWindow *parent)
- :
- wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
- WxBlackBoxWidget(box)
- {}
-
- /// Returns the top panel of the widget
- wxWindow* GetWxWindow() { return (wxWindow*)(wxPanel*)(this); }
- /// Returns the top panel of the widget
- wxPanel* GetPanel() { return (wxPanel*)(this); }
-
- };
- //=================================================================
- */
} //namespace bbtk
Program: bbtk
Module: $RCSfile: bbtkWxGUIConsole.cxx,v $
Language: C++
- Date: $Date: 2008/03/25 06:22:53 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
// m_mgr = new wxAuiManager(this);
m_mgr.SetManagedWindow(this);
- mInterpreter = new bbtk::Interpreter();
+ mInterpreter = bbtk::Interpreter::New();
mInterpreter->SetUser(this);
mInterpreter->SetCommandLine(true);
//==============
std::string filename = mWxGUIHtmlBrowser->GetCurrentPage();//wx2std(temp);
size_t s = filename.length();
- Interpreter* I = new Interpreter;
+ Interpreter::Pointer I = Interpreter::New();
if ((s>3) && (filename[s-1]=='s')
&& (filename[s-2]=='b')
{
SetStatusText(_T("The current page is not a bbs file : cannot execute it"));
}
-
- delete I;
+
}
//================================================================
std::string command("toolsbbtk/appli/CreatePackage");
bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
- Interpreter* I = new Interpreter;
+ Interpreter::Pointer I = Interpreter::New();
I->InterpretFile(command);
- delete I;
}
//================================================================
{
std::string command("toolsbbtk/appli/CreateBlackBox");
bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
- Interpreter* I = new Interpreter;
+ Interpreter::Pointer I = Interpreter::New();
I->InterpretFile(command);
- delete I;
}
//================================================================
Program: bbtk
Module: $RCSfile: bbtkWxGUIConsole.h,v $
Language: C++
- Date: $Date: 2008/03/25 06:22:53 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
/// Returns the Interpreter used
/// ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT
/// (DIFFERENT WORKSPACES)
- Interpreter* GetInterpreter() { return mInterpreter; }
+ //Interpreter::Pointer GetInterpreter() { return mInterpreter; }
/// Returns the Interpreter used (const)
- const Interpreter* GetInterpreter() const { return mInterpreter; }
+ Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
/// Sets the inputs of the workspace :
/// the map is passed as is to the Executer
private:
wxAuiManager m_mgr;
- Interpreter* mInterpreter;
+ Interpreter::Pointer mInterpreter;
//EED wxNotebook* mwxNotebook;
Program: bbtk
Module: $RCSfile: bbtkWxGUIPackageBrowser.cxx,v $
Language: C++
- Date: $Date: 2008/03/31 13:18:04 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
namespace bbtk
{
//================================================================
- WxGUIPackageBrowserBlackBox::WxGUIPackageBrowserBlackBox(wxWindow* parent,
- WxGUIPackageBrowser* browser,
- BlackBoxDescriptor* descr) :
+ WxGUIPackageBrowserBlackBox::
+ WxGUIPackageBrowserBlackBox(wxWindow* parent,
+ WxGUIPackageBrowser* browser,
+ BlackBoxDescriptor::Pointer descr) :
wxPanel(parent, -1),
mBrowser(browser),
mDescriptor(descr)
WxGUIPackageBrowserUser* user )
: wxPanel(parent, -1),
mUser(user),
- mInterpreter(0)
+ mInterpreter()
{
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
//================================================================
WxGUIPackageBrowser::~WxGUIPackageBrowser()
{
- std::cout << "del interpreter" << std::endl;
- if (mInterpreter) delete mInterpreter;
- std::cout << "ok" << std::endl;
+ // std::cout << "del interpreter" << std::endl;
+ // if (mInterpreter) delete mInterpreter;
+ // std::cout << "ok" << std::endl;
}
//================================================================
//================================================================
void WxGUIPackageBrowser::IncludeAll()
{
- if (!mInterpreter) mInterpreter = new bbtk::Interpreter();
+ if (!mInterpreter) mInterpreter = bbtk::Interpreter::New();
mInterpreter->SetCommandLine(true);
mInterpreter->InterpretLine("include *");
- Factory* F = mInterpreter->GetExecuter()->GetFactory();
+ Factory::Pointer F = mInterpreter->GetExecuter()->GetFactory();
BuildFromFactory(F);
}
//================================================================
//================================================================
- void WxGUIPackageBrowser::BuildFromFactory(Factory* F)
+ void WxGUIPackageBrowser::BuildFromFactory(Factory::Pointer F)
{
#ifndef LINUX
wxTreeMultiWindowInfo wndinfo(wxTMC_BG_ADJUST_CNT, 8, 0);
Factory::PackageMapType::const_iterator i;
for (i=M.begin();i!=M.end();++i)
{
- Package* P = i->second.mPackage;
+ Package::Pointer P = i->second;
wxString packname = std2wx(P->GetName());
if (packname==_T("user")) continue;
wxTreeMultiItem pack = mTree->AddRoot(packname,packname);
Program: bbtk
Module: $RCSfile: bbtkWxGUIPackageBrowser.h,v $
Language: C++
- Date: $Date: 2008/03/28 15:04:10 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
public:
WxGUIPackageBrowserBlackBox(wxWindow* parent,
WxGUIPackageBrowser* browser,
- BlackBoxDescriptor* descr);
+ BlackBoxDescriptor::Pointer descr);
~WxGUIPackageBrowserBlackBox();
private:
WxGUIPackageBrowser* mBrowser;
- BlackBoxDescriptor* mDescriptor;
+ BlackBoxDescriptor::Pointer mDescriptor;
} ;
//================================================================
~WxGUIPackageBrowser();
void IncludeAll();
- void BuildFromFactory(Factory* f);
+ void BuildFromFactory(Factory::Pointer f);
private:
WxGUIPackageBrowserUser* mUser;
- Interpreter* mInterpreter;
+ Interpreter::Pointer mInterpreter;
wxTreeMultiCtrl* mTree;
};
Program: bbtk
Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $
Language: C++
-Date: $Date: 2008/04/09 11:16:57 $
-Version: $Revision: 1.4 $
+Date: $Date: 2008/04/18 12:59:16 $
+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
#endif
}
- void WxGUIBlackBoxList::Insert(BlackBoxDescriptor* d)
+ void WxGUIBlackBoxList::Insert(BlackBoxDescriptor::Pointer d)
{
if (GetColumnCount()!=3)
{
int nID = this->GetItemCount();
kNewItem.SetId(nID);
kNewItem.SetMask(wxLIST_MASK_DATA);
- kNewItem.SetData(d);
- // BlackBoxDescriptor* d2 = (BlackBoxDescriptor*)kNewItem.GetData();
+ // TO DO : STORE SHARED POINTER
+ // kNewItem.SetData(d.get());
+ // BlackBoxDescriptor::Pointer* d2 = (BlackBoxDescriptor::Pointer*)kNewItem.GetData();
// std::cout << "Descr = "<<d<<" = "<<d2<<std::endl;
this->InsertItem(kNewItem);
this->SetItem(nID, 0, std2wx(d->GetPackage()->GetName()) );
info.m_mask = wxLIST_MASK_DATA;
if ( GetItem(info) )
{
- BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
- if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d);
+ // TO DO : STORE SHARED
+ // BlackBoxDescriptor* d = (BlackBoxDescriptor*)(info.GetData());
+ // if (d!=0) mUser->WxGUIBlackBoxListUserOnSelected(d);
}
else
{
WxGUIBlackBoxInfo::WxGUIBlackBoxInfo(wxWindow* parent)
:
wxPanel(parent, -1),
- mDescriptor(0)
+ mDescriptor()
{
wxBoxSizer *sizer = new wxBoxSizer(wxVERTICAL);
//================================================================
- void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor* descr)
+ void WxGUIBlackBoxInfo::UpdateInfo(BlackBoxDescriptor::Pointer descr)
{
// mName->SetLabel(std2wx(descr->GetTypeName()));
WxGUIPackageBrowser2User* user )
: wxPanel(parent, -1),
mUser(user),
- mInterpreter(0)
+ mInterpreter()
{
m_mgr.SetManagedWindow(this);
//================================================================
// User callback when a box is selected in the list
- void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* d)
+ void WxGUIPackageBrowser2::WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer d)
{
mBoxInfo->UpdateInfo(d);
std::string title = d->GetPackage()->GetName()+"::"+d->GetTypeName();
//================================================================
WxGUIPackageBrowser2::~WxGUIPackageBrowser2()
{
- std::cout << "del interpreter" << std::endl;
- if (mInterpreter) delete mInterpreter;
- std::cout << "ok" << std::endl;
+
+ // std::cout << "del interpreter" << std::endl;
+ // if (mInterpreter) delete mInterpreter;
+ // std::cout << "ok" << std::endl;
}
//================================================================
//================================================================
void WxGUIPackageBrowser2::IncludeAll()
{
- if (!mInterpreter) mInterpreter = new bbtk::Interpreter();
+ if (!mInterpreter) mInterpreter =bbtk::Interpreter::New();
mInterpreter->SetCommandLine(true);
mInterpreter->InterpretLine("include *");
- Factory* F = mInterpreter->GetExecuter()->GetFactory();
+ Factory::Pointer F = mInterpreter->GetExecuter()->GetFactory();
BuildFromFactory(F);
}
//================================================================
//================================================================
- void WxGUIPackageBrowser2::BuildFromFactory(Factory* F)
+ void WxGUIPackageBrowser2::BuildFromFactory(Factory::Pointer F)
{
mFactory = F;
RebuildList();
Factory::PackageMapType::const_iterator i;
for (i=M.begin();i!=M.end();++i)
{
- Package* P = i->second.mPackage;
+ Package::Pointer P = i->second;
if (P->GetName() == "user") continue;
Package::BlackBoxMapType::iterator j;
//================================================================
//================================================================
- bool WxGUIPackageBrowser2::IsVisible(BlackBoxDescriptor* d)
+ bool WxGUIPackageBrowser2::IsVisible(BlackBoxDescriptor::Pointer d)
{
// std::cout << " '" << wx2std(mPackageFilter->GetValue())<<"'"<<std::endl;
// std::cout << "vs '" << d->GetPackage()->GetName() << "'"<<std::endl;
Program: bbtk
Module: $RCSfile: bbtkWxGUIPackageBrowser2.h,v $
Language: C++
- Date: $Date: 2008/04/04 09:45:05 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
WxGUIBlackBoxInfo(wxWindow* parent);
~WxGUIBlackBoxInfo();
- void UpdateInfo(BlackBoxDescriptor* descr);
+ void UpdateInfo(BlackBoxDescriptor::Pointer descr);
void InsertInputOutput(wxListCtrl* l, BlackBoxInputOutputDescriptor* i);
private:
BlackBoxDescriptor* mDescriptor;
virtual ~WxGUIBlackBoxListUser() {}
// User callback when a box is selected in the list
- virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* ) {}
+ virtual void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer ) {}
};
//================================================================
void SetUser(WxGUIBlackBoxListUser* u) { mUser = u; }
// add one item to the listctrl in report mode
- void Insert(BlackBoxDescriptor* d);
+ void Insert(BlackBoxDescriptor::Pointer d);
//
void OnColClick(wxListEvent& event);
~WxGUIPackageBrowser2();
void IncludeAll();
- void BuildFromFactory(Factory* f);
+ void BuildFromFactory(Factory::Pointer f);
void RebuildList();
- bool IsVisible(BlackBoxDescriptor* d);
+ bool IsVisible(BlackBoxDescriptor::Pointer d);
void OnFilter(wxCommandEvent&);
// User callback when a box is selected in the list
- void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor* );
+ void WxGUIBlackBoxListUserOnSelected( BlackBoxDescriptor::Pointer );
private:
wxAuiManager m_mgr;
WxGUIPackageBrowser2User* mUser;
- Interpreter* mInterpreter;
- Factory* mFactory;
+ Interpreter::Pointer mInterpreter;
+ Factory::Pointer mFactory;
WxGUIBlackBoxList* mBoxList;
WxGUIBlackBoxInfo* mBoxInfo;
Program: bbtk
Module: $RCSfile: bbtkWxGUIScriptingInterface.cxx,v $
Language: C++
- Date: $Date: 2008/03/25 15:47:54 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
// m_mgr = new wxAuiManager(this);
m_mgr.SetManagedWindow(this);
- mInterpreter = new bbtk::Interpreter();
+ mInterpreter = bbtk::Interpreter::New();
mInterpreter->SetUser(this);
mInterpreter->SetCommandLine(true);
mInterpreter->SetThrow(true);
//================================================================
void WxGUIScriptingInterface::OnMenuCreatePackage(wxCommandEvent& WXUNUSED(event))
{
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 01 \n");
- std::string command("toolsbbtk/appli/CreatePackage");
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 02 \n");
+ std::string command("toolsbbtk/appli/CreatePackage");
bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 03 \n");
- Interpreter* I = new Interpreter;
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 04 \n");
+
+ Interpreter::Pointer I = Interpreter::New();
I->InterpretFile(command);
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 05 \n");
- delete I;
-printf("EED WxGUIScriptingInterface::OnMenuCreatePackage 06 \n");
+
}
//================================================================
{
std::string command("toolsbbtk/appli/CreateBlackBox");
bbtkMessage("Debug",1,"Executing : '"<<command<<"'"<<std::endl);
- Interpreter* I = new Interpreter;
+
+ Interpreter::Pointer I = Interpreter::New();
I->InterpretFile(command);
- delete I;
}
//================================================================
{
std::string doc_path = ConfigurationFile::GetInstance().Get_doc_path();
std::string filepath = doc_path+"/bbdoc/make-index.bbs";
- Interpreter* I = new Interpreter;
-//EED std::cout << "bbi: include "<<filepath<<std::endl;
-//EED I->InterpretFile( filepath );
+ Interpreter::Pointer I = Interpreter::New();
I->InterpretLine( "exec freeze");
I->InterpretLine( "include *");
I->InterpretLine( "index "+doc_path+"/bbdoc/index-category.html Categories");
I->InterpretLine( "index "+doc_path+"/bbdoc/index-adaptors.html Adaptors");
- delete I;
}
//================================================================
Program: bbtk
Module: $RCSfile: bbtkWxGUIScriptingInterface.h,v $
Language: C++
- Date: $Date: 2008/03/25 15:47:54 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:16 $
+ 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
/// Returns the Interpreter used
/// ONLY ONE FOR THE MOMENT BUT IN THE FUTURE CAN BE DIFFERENT
/// (DIFFERENT WORKSPACES)
- Interpreter* GetInterpreter() { return mInterpreter; }
- /// Returns the Interpreter used (const)
- const Interpreter* GetInterpreter() const { return mInterpreter; }
+ Interpreter::Pointer GetInterpreter() const { return mInterpreter; }
/// Sets the inputs of the workspace :
/// the map is passed as is to the Executer
bool WxGUIHtmlBrowserUserOnLinkClicked(const std::string& target);
private:
wxAuiManager m_mgr;
- Interpreter* mInterpreter;
+ Interpreter::Pointer mInterpreter;
//EED wxNotebook* mwxNotebook;
namespace bbitk
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(AnyImageToTypedImage,
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(AnyImageToTypedImage,
bbtk::AtomicBlackBox);
- BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(AnyImageToConstTypedImage,
+ BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(AnyImageToConstTypedImage,
bbtk::AtomicBlackBox);
//====================================================================
template <class itkImageTypePointer>
class AnyImageToTypedImage : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
- bbtk::AtomicBlackBox);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(AnyImageToTypedImage,
+ bbtk::AtomicBlackBox,
+ itkImageTypePointer);
BBTK_DECLARE_INPUT(In,anyImagePointer);
BBTK_DECLARE_OUTPUT(Out,itkImageTypePointer);
BBTK_PROCESS(DoIt);
//=================================================================
// BlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(AnyImageToTypedImage,
+ bbtk::AtomicBlackBox);
BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To"
+bbtk::HumanTypeName<T>());
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
template <class itkImageTypePointer, class itkImageTypeConstPointer>
class AnyImageToConstTypedImage : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
- bbtk::AtomicBlackBox);
+ BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(AnyImageToConstTypedImage,
+ bbtk::AtomicBlackBox,
+ itkImageTypePointer,
+ itkImageTypeConstPointer);
BBTK_DECLARE_INPUT(In,anyImagePointer);
BBTK_DECLARE_OUTPUT(Out,itkImageTypeConstPointer);
BBTK_PROCESS(DoIt);
//=================================================================
// BlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(AnyImageToConstTypedImage,
+ bbtk::AtomicBlackBox);
BBTK_NAME(bbtk::HumanTypeName<anyImagePointer>() + "To" +
bbtk::HumanTypeName<T2>());
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
namespace bbitk
{
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(BinaryThresholdImageFilter,
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(BinaryThresholdImageFilter,
bbtk::AtomicBlackBox);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(BinaryThresholdImageFilterGeneric,
+ BBTK_BLACK_BOX_IMPLEMENTATION(BinaryThresholdImageFilterGeneric,
bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,
BinaryThresholdImageFilterGeneric);
public bbtk::AtomicBlackBox,
public itk::BinaryThresholdImageFilter<T,T>
{
- BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
- bbtk::AtomicBlackBox);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(BinaryThresholdImageFilter,
+ bbtk::AtomicBlackBox,T);
typedef itk::BinaryThresholdImageFilter<T,T> itkParent;
BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
BBTK_DECLARE_ITK_PARAM(itkParent,LowerThreshold,typename T::PixelType);
};
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(BinaryThresholdImageFilter,
+ bbtk::AtomicBlackBox);
BBTK_NAME("BinaryThresholdImageFilter<"+bbtk::TypeName<T>()+">");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DESCRIPTION("Binarizes an image by thresholding (bbification of itk::BinaryThresholdImageFilter)");
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
+ BBTK_BLACK_BOX_INTERFACE(BinaryThresholdImageFilterGeneric,
bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In,anyImagePointer);
BBTK_DECLARE_INPUT(LowerThreshold,double);
<<bbtk::TypeName<T>()<<">()"<<std::endl);
typedef BinaryThresholdImageFilter<T> FilterType;
- FilterType* f = FilterType::bbNew("Temp");
+ typename FilterType::Pointer f = FilterType::New("Temp");
f->bbSetInputIn( this->bbGetInputIn().get<T*>());
f->bbSetInputLowerThreshold ( (typename T::PixelType)
this->bbGetInputLowerThreshold() );
f->bbExecute();
f->bbGetOutputOut()->Register();
this->bbSetOutputOut( f->bbGetOutputOut() );
- f->bbDelete();
+
bbtkDebugDecTab("Core",9);
}
namespace bbitk
{
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ExtractImageFilter,
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ExtractImageFilter,
bbtk::AtomicBlackBox);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExtractImageFilterGeneric,
+ BBTK_BLACK_BOX_IMPLEMENTATION(ExtractImageFilterGeneric,
bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ExtractImageFilterGeneric)
public bbtk::AtomicBlackBox,
public itk::ExtractImageFilter<T,T>
{
- BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilter,bbtk::AtomicBlackBox);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(ExtractImageFilter,
+ bbtk::AtomicBlackBox,
+ T);
typedef itk::ExtractImageFilter<T,T> itkParent;
BBTK_DECLARE_ITK_INPUT(itkParent,In,const T*);
};
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ExtractImageFilter,
+ bbtk::AtomicBlackBox);
BBTK_NAME("ExtractImageFilter<"+bbtk::TypeName<T>()+">");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DESCRIPTION("Decrease the image size by cropping the image to the selected region bounds (bbification of itk::ExtractImageFilter)");
class /*BBTK_EXPORT*/ ExtractImageFilterGeneric
: public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ExtractImageFilterGeneric,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ExtractImageFilterGeneric,
+ bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In,anyImagePointer);
BBTK_DECLARE_INPUT(Region,anyImageRegion);
BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
<<bbtk::TypeName<T>()<<">()"<<std::endl);
typedef T ImageType;
typedef ExtractImageFilter<ImageType> FilterType;
- FilterType* f = FilterType::bbNew("Temp");
+ typename FilterType::Pointer f = FilterType::New("Temp");
f->bbSetInputIn( this->bbGetInputIn().unsafe_get<T*>() );
f->bbSetInputExtractionRegion ( this->bbGetInputRegion().get<typename T::RegionType>() );
f->bbExecute();
f->bbGetOutputOut()->Register();
this->bbSetOutputOut( f->bbGetOutputOut() );
- f->bbDelete();
+ // f->bbDelete();
bbtkDebugDecTab("Core",9);
}
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
+ bbtk::AtomicBlackBox);
//====================================================================
}
using namespace bbstd;
Program: bbtk
Module: $RCSfile: bbitkImageProperties.cxx,v $
Language: C++
- Date: $Date: 2008/02/07 07:58:54 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
namespace bbitk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ImageProperties,bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageProperties);
Program: bbtk
Module: $RCSfile: bbitkImageProperties.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
class ImageProperties : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ImageProperties,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ImageProperties,
+ bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In,anyImagePointer);
BBTK_DECLARE_OUTPUT(TypeName,std::string);
Program: bbtk
Module: $RCSfile: bbitkImageReader.cxx,v $
Language: C++
- Date: $Date: 2008/02/07 07:58:54 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
namespace bbitk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageReader,bbtk::AtomicBlackBox);
-
+ BBTK_BLACK_BOX_IMPLEMENTATION(ImageReader,bbtk::AtomicBlackBox);
+
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageReader);
Program: bbtk
Module: $RCSfile: bbitkImageReader.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
class ImageReader : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ImageReader,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ImageReader,
+ bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(Filename,std::string);
BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
namespace bbitk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageRegionCreator,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ImageRegionCreator,
+ bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageRegionCreator);
class /*BBTK_EXPORT*/ ImageRegionCreator
: public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ImageRegionCreator,bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(Index,std::vector<long>);
BBTK_DECLARE_INPUT(Size,std::vector<long>);
BBTK_DECLARE_OUTPUT(Out,anyImageRegion);
Program: bbtk
Module: $RCSfile: bbitkImageSeriesReader.cxx,v $
Language: C++
- Date: $Date: 2008/02/07 07:58:54 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
namespace bbitk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageSeriesReader,bbtk::AtomicBlackBox);
-
+ BBTK_BLACK_BOX_IMPLEMENTATION(ImageSeriesReader,bbtk::AtomicBlackBox);
+
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageSeriesReader);
Program: bbtk
Module: $RCSfile: bbitkImageSeriesReader.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:30 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
class ImageSeriesReader : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ImageSeriesReader,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ImageSeriesReader,
+ bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(FileNames,std::vector<std::string>);
BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
+ bbtk::AtomicBlackBox);
//====================================================================
//====================================================================
Program: bbtk
Module: $RCSfile: bbitkImageWriter.cxx,v $
Language: C++
- Date: $Date: 2008/02/07 07:58:55 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
namespace bbitk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImageWriter,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ImageWriter,bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ImageWriter);
Program: bbtk
Module: $RCSfile: bbitkImageWriter.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:31 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
class ImageWriter : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ImageWriter,
+ BBTK_BLACK_BOX_INTERFACE(ImageWriter,
bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(Filename,std::string);
namespace bbitk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ResampleImageFilter,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ResampleImageFilter,bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itk,ResampleImageFilter);
}
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ResampleImageFilter,
+ BBTK_BLACK_BOX_INTERFACE(ResampleImageFilter,
bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In,anyImagePointer);
BBTK_DECLARE_INPUT(Spacing,std::vector<double>);
namespace bbitk
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(TypedImageToAnyImage,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(TypedImageToAnyImage,
+ bbtk::AtomicBlackBox);
//====================================================================
template <class itkImageTypePointer>
class TypedImageToAnyImage : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(TypedImageToAnyImage,
- bbtk::AtomicBlackBox);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(TypedImageToAnyImage,
+ bbtk::AtomicBlackBox,
+ itkImageTypePointer);
BBTK_DECLARE_INPUT(In,itkImageTypePointer);
BBTK_DECLARE_OUTPUT(Out,anyImagePointer);
BBTK_PROCESS(DoIt);
//=================================================================
// BlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(TypedImageToAnyImage,
+ bbtk::AtomicBlackBox);
BBTK_NAME(bbtk::HumanTypeName<T>()
+ "To" + bbtk::HumanTypeName<anyImagePointer>());
BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
Program: bbtk
Module: $RCSfile: bbitkvtkitkImage2vtkImageData.cxx,v $
Language: C++
- Date: $Date: 2008/03/03 11:49:17 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
namespace bbitkvtk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(itkImage2vtkImageData,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(itkImage2vtkImageData,bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itkvtk,itkImage2vtkImageData);
Program: bbtk
Module: $RCSfile: bbitkvtkitkImage2vtkImageData.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:31 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
class itkImage2vtkImageData : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(itkImage2vtkImageData,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(itkImage2vtkImageData,
+ bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In,bbitk::anyImagePointer);
BBTK_DECLARE_OUTPUT(Out,vtkImageData*);
Program: bbtk
Module: $RCSfile: bbitkvtkvtkImageData2itkImage.cxx,v $
Language: C++
- Date: $Date: 2008/03/03 11:49:17 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
namespace bbitkvtk
{
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(vtkImageData2itkImage,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(vtkImageData2itkImage,bbtk::AtomicBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(itkvtk,vtkImageData2itkImage);
Program: bbtk
Module: $RCSfile: bbitkvtkvtkImageData2itkImage.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:31 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:50 $
+ 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
class /*BBTK_EXPORT*/ vtkImageData2itkImage : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(vtkImageData2itkImage,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(vtkImageData2itkImage,
+ bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In,vtkImageData*);
BBTK_DECLARE_OUTPUT(Out,bbitk::anyImagePointer);
#include "bbstdPackage.h"
namespace bbstd
{
-
- BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ASCII)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ASCII,bbtk::AtomicBlackBox);
- void ASCII::Process()
- {
- int asciiValue;
- char strTmp[10];
- std::string result("");
- if (bbGetInputIn()!=""){
-
- if (bbGetInputtype()==0){
- std::string commandstr(bbGetInputIn());
- bool ok=true;
- int pos1=0,pos2;
- pos2 = commandstr.find(" ",pos1);
- std::string ccommand;
- while (ok==true)
- {
- if (pos2==-1)
- {
- ok=false;
- ccommand=commandstr.substr(pos1,commandstr.length()-pos1 );
- } else {
- ccommand=commandstr.substr(pos1,pos2-pos1);
- }
- asciiValue = atoi( ccommand.c_str() );
- sprintf(strTmp,"%c",asciiValue);
- result += strTmp;
-
- pos1=pos2+1;
- pos2 = commandstr.find(" ",pos2+1);
- } // while
- } // if type 0
-
- if (bbGetInputtype()==1){
- int i,size=bbGetInputIn().size();
- for (i=0;i<size;i++){
- asciiValue = (int)bbGetInputIn()[i];
- sprintf(strTmp,"%d",asciiValue);
- result +=strTmp;
- if (i!=size-1) {
- result +=" ";
- } // i!=size-1
- } // for
- } // type 1
- }
- bbSetOutputOut( result );
- }
-
- void ASCII::bbUserConstructor()
- {
- bbSetInputIn("");
- bbSetInputtype(0);
- }
-
- void ASCII::bbUserCopyConstructor()
- {
-
- }
-
- void ASCII::bbUserDestructor()
- {
- }
+
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ASCII);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ASCII,bbtk::AtomicBlackBox);
+ void ASCII::Process()
+ {
+ int asciiValue;
+ char strTmp[10];
+ std::string result("");
+ if (bbGetInputIn()!=""){
+
+ if (bbGetInputtype()==0){
+ std::string commandstr(bbGetInputIn());
+ bool ok=true;
+ int pos1=0,pos2;
+ pos2 = commandstr.find(" ",pos1);
+ std::string ccommand;
+ while (ok==true)
+ {
+ if (pos2==-1)
+ {
+ ok=false;
+ ccommand=commandstr.substr(pos1,commandstr.length()-pos1 );
+ } else {
+ ccommand=commandstr.substr(pos1,pos2-pos1);
+ }
+ asciiValue = atoi( ccommand.c_str() );
+ sprintf(strTmp,"%c",asciiValue);
+ result += strTmp;
+
+ pos1=pos2+1;
+ pos2 = commandstr.find(" ",pos2+1);
+ } // while
+ } // if type 0
+
+ if (bbGetInputtype()==1){
+ int i,size=bbGetInputIn().size();
+ for (i=0;i<size;i++){
+ asciiValue = (int)bbGetInputIn()[i];
+ sprintf(strTmp,"%d",asciiValue);
+ result +=strTmp;
+ if (i!=size-1) {
+ result +=" ";
+ } // i!=size-1
+ } // for
+ } // type 1
+ }
+ bbSetOutputOut( result );
+ }
+
+ void ASCII::bbUserConstructor()
+ {
+ bbSetInputIn("");
+ bbSetInputtype(0);
+ }
+
+ void ASCII::bbUserCopyConstructor()
+ {
+
+ }
+
+ void ASCII::bbUserDestructor()
+ {
+ }
}
// EO namespace bbstd
namespace bbstd
{
-class /*BBTK_EXPORT*/ ASCII
- :
- public bbtk::AtomicBlackBox
-{
- BBTK_USER_BLACK_BOX_INTERFACE(ASCII,bbtk::AtomicBlackBox);
-//==================================================================
-/// User callback called in the box contructor
-virtual void bbUserConstructor();
-/// User callback called in the box copy constructor
-virtual void bbUserCopyConstructor();
-/// User callback called in the box destructor
-virtual void bbUserDestructor();
-//==================================================================
- BBTK_DECLARE_INPUT(In,std::string);
- BBTK_DECLARE_INPUT(type,int);
- BBTK_DECLARE_OUTPUT(Out,std::string);
- BBTK_PROCESS(Process);
- void Process();
-};
-
-BBTK_BEGIN_DESCRIBE_BLACK_BOX(ASCII,bbtk::AtomicBlackBox);
+ class /*BBTK_EXPORT*/ ASCII
+ :
+ public bbtk::AtomicBlackBox
+ {
+ BBTK_BLACK_BOX_INTERFACE(ASCII,bbtk::AtomicBlackBox);
+ //==================================================================
+ /// User callback called in the box contructor
+ virtual void bbUserConstructor();
+ /// User callback called in the box copy constructor
+ virtual void bbUserCopyConstructor();
+ /// User callback called in the box destructor
+ virtual void bbUserDestructor();
+ //==================================================================
+ BBTK_DECLARE_INPUT(In,std::string);
+ BBTK_DECLARE_INPUT(type,int);
+ BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_PROCESS(Process);
+ void Process();
+ };
+
+ BBTK_BEGIN_DESCRIBE_BLACK_BOX(ASCII,bbtk::AtomicBlackBox);
BBTK_NAME("ASCII");
BBTK_AUTHOR("eduardo.davila [at] creatis.insa-lyon.fr");
BBTK_DESCRIPTION("ascii codes sequence to string - string to ascii codes sequence");
BBTK_INPUT(ASCII,In,"Input Ascii code or Ascii character",std::string,"");
BBTK_INPUT(ASCII,type,"type (default 0) 0=Ascii codes to string, 1=String to ascii codes",int,"");
BBTK_OUTPUT(ASCII,Out,"Ascii codes sequence or characters sequence",std::string,"");
-BBTK_END_DESCRIBE_BLACK_BOX(ASCII);
+ BBTK_END_DESCRIBE_BLACK_BOX(ASCII);
}
// EO namespace bbstd
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
+ bbtk::AtomicBlackBox);
//====================================================================
//====================================================================
template <class T, class U>
class Cast : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(Cast,bbtk::AtomicBlackBox);
+ BBTK_TEMPLATE2_BLACK_BOX_INTERFACE(Cast,bbtk::AtomicBlackBox,T,U);
BBTK_DECLARE_INPUT(In,T);
BBTK_DECLARE_OUTPUT(Out,U);
BBTK_PROCESS(DoIt);
//=================================================================
// UserBlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(Cast);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE2_BLACK_BOX(Cast,bbtk::AtomicBlackBox);
BBTK_NAME("Cast"+bbtk::HumanTypeName<T1>()+"To"+bbtk::HumanTypeName<T2>());
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DESCRIPTION("Static cast from "+bbtk::HumanTypeName<T1>()+" ("
namespace bbstd
{
- BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ConcatStrings)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ConcatStrings,bbtk::AtomicBlackBox);
-
- void ConcatStrings::bbUserConstructor()
- {
- bbSetInputIn1("");
- bbSetInputIn2("");
- bbSetInputIn3("");
- bbSetInputIn4("");
- bbSetInputIn5("");
- bbSetInputIn6("");
- bbSetInputIn7("");
- bbSetInputIn8("");
- bbSetInputIn9("");
- bbSetInputIn10("");
- }
-
-
- void ConcatStrings::DoProcess()
- {
- bbSetOutputOut( bbGetInputIn1() +
- bbGetInputIn2() +
- bbGetInputIn3() +
- bbGetInputIn4() +
- bbGetInputIn5() +
- bbGetInputIn6() +
- bbGetInputIn7() +
- bbGetInputIn8() +
- bbGetInputIn9() +
- bbGetInputIn10() );
- }
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ConcatStrings);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ConcatStrings,bbtk::AtomicBlackBox);
+
+ void ConcatStrings::bbUserConstructor()
+ {
+ bbSetInputIn1("");
+ bbSetInputIn2("");
+ bbSetInputIn3("");
+ bbSetInputIn4("");
+ bbSetInputIn5("");
+ bbSetInputIn6("");
+ bbSetInputIn7("");
+ bbSetInputIn8("");
+ bbSetInputIn9("");
+ bbSetInputIn10("");
+ }
+
+
+ void ConcatStrings::DoProcess()
+ {
+ bbSetOutputOut( bbGetInputIn1() +
+ bbGetInputIn2() +
+ bbGetInputIn3() +
+ bbGetInputIn4() +
+ bbGetInputIn5() +
+ bbGetInputIn6() +
+ bbGetInputIn7() +
+ bbGetInputIn8() +
+ bbGetInputIn9() +
+ bbGetInputIn10() );
+ }
}
// EO namespace bbstd
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ConcatStrings,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ConcatStrings,bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In1, std::string);
BBTK_DECLARE_INPUT(In2, std::string);
BBTK_DECLARE_INPUT(In3, std::string);
#include "bbtkConfigurationFile.h"
namespace bbstd
{
- BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,Configuration)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(Configuration,bbtk::AtomicBlackBox);
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,Configuration);
+ BBTK_BLACK_BOX_IMPLEMENTATION(Configuration,bbtk::AtomicBlackBox);
void Configuration::bbUserConstructor()
{
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(Configuration,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(Configuration,bbtk::AtomicBlackBox);
BBTK_DECLARE_OUTPUT(BinPath,std::string);
BBTK_DECLARE_OUTPUT(DataPath,std::string);
BBTK_DECLARE_OUTPUT(DocPath,std::string);
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecBbiCommand);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ExecBbiCommand,bbtk::AtomicBlackBox);
void ExecBbiCommand::bbUserConstructor()
{
void ExecBbiCommand::DoProcess()
{
+ /*
// Look for the interpreter
bbtk::Interpreter* I = 0;
bool delete_inter = false;
}
if (delete_inter) delete I;
-
+ */
/* Grrr not works in windows
char * pch;
pch = strtok (bbGetInputIn(),";");
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ExecBbiCommand,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,std::string);
-// BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_BLACK_BOX_INTERFACE(ExecBbiCommand,bbtk::AtomicBlackBox);
+ BBTK_DECLARE_INPUT(In,std::string);
+ // BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(DoProcess);
void DoProcess();
-
+
protected:
virtual void bbUserConstructor();
-
+
};
BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExecBbiCommand,bbtk::AtomicBlackBox);
- BBTK_NAME("ExecBbiCommand");
- BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
- BBTK_DESCRIPTION("Executes bbi commands");
- BBTK_INPUT(ExecBbiCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");
-// BBTK_OUTPUT(ExecBbiCommand,Out,"Concatenated string",std::string);
+ BBTK_NAME("ExecBbiCommand");
+ BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Executes bbi commands");
+ BBTK_INPUT(ExecBbiCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");
+ // BBTK_OUTPUT(ExecBbiCommand,Out,"Concatenated string",std::string);
BBTK_END_DESCRIBE_BLACK_BOX(ExecBbiCommand);
-
+
} // EO namespace bbstd
#endif // __bbstdExecBbiCommand_h_INCLUDED__
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,ExecSystemCommand);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ExecSystemCommand,bbtk::AtomicBlackBox);
void ExecSystemCommand::bbUserConstructor()
{
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ExecSystemCommand,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,std::string);
-// BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_BLACK_BOX_INTERFACE(ExecSystemCommand,bbtk::AtomicBlackBox);
+ BBTK_DECLARE_INPUT(In,std::string);
+ // BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(DoProcess);
void DoProcess();
};
BBTK_BEGIN_DESCRIBE_BLACK_BOX(ExecSystemCommand,bbtk::AtomicBlackBox);
- BBTK_NAME("ExecSystemCommand");
- BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
- BBTK_DESCRIPTION("Execute bbi commands");
- BBTK_INPUT(ExecSystemCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");
-// BBTK_OUTPUT(ExecSystemCommand,Out,"Concatenated string",std::string);
+ BBTK_NAME("ExecSystemCommand");
+ BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
+ BBTK_DESCRIPTION("Execute bbi commands");
+ BBTK_INPUT(ExecSystemCommand,In,"bbi commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");
+ // BBTK_OUTPUT(ExecSystemCommand,Out,"Concatenated string",std::string);
BBTK_END_DESCRIBE_BLACK_BOX(ExecSystemCommand);
-
+
} // EO namespace bbstd
#endif // __bbstdExecSystemCommand_h_INCLUDED__
namespace bbstd
{
-BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MagicBox)
-BBTK_USER_BLACK_BOX_IMPLEMENTATION(MagicBox,bbtk::AtomicBlackBox);
-
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MagicBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(MagicBox,bbtk::AtomicBlackBox);
+
}
// EO namespace bbstd
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,bbtk::Data);
- BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
+ BBTK_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
+ BBTK_DECLARE_INPUT(In,bbtk::Data);
+ BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
BBTK_PROCESS(DoProcess);
void DoProcess() { bbSetOutputOut( bbGetInputIn() ); }
namespace bbstd
{
- BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MakeFileName)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(MakeFileName,bbtk::AtomicBlackBox);
-
- void MakeFileName::bbUserConstructor()
- {
- bbSetInputDirectory("");
- bbSetInputFile("");
- bbSetInputExtent("");
- }
-
- void MakeFileName::DoProcess()
- {
- std::string fileSep = bbtk::ConfigurationFile::GetInstance().Get_file_separator();
- std::string fullFileName = bbGetInputDirectory();
- if ( fullFileName.c_str()[fullFileName.size()-1] != '/' && fullFileName.c_str()[fullFileName.size()-1] != '\\' )
- fullFileName += fileSep;
- fullFileName += bbGetInputFile();
- if ( bbGetInputExtent() != "")
- if ( bbGetInputExtent()[0] != '.' )
- fullFileName += ".";
- fullFileName += bbGetInputExtent();
- bbSetOutputOut( fullFileName );
- }
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MakeFileName);
+ BBTK_BLACK_BOX_IMPLEMENTATION(MakeFileName,bbtk::AtomicBlackBox);
+
+ void MakeFileName::bbUserConstructor()
+ {
+ bbSetInputDirectory("");
+ bbSetInputFile("");
+ bbSetInputExtent("");
+ }
+
+ void MakeFileName::DoProcess()
+ {
+ std::string fileSep = bbtk::ConfigurationFile::GetInstance().Get_file_separator();
+ std::string fullFileName = bbGetInputDirectory();
+ if ( fullFileName.c_str()[fullFileName.size()-1] != '/' && fullFileName.c_str()[fullFileName.size()-1] != '\\' )
+ fullFileName += fileSep;
+ fullFileName += bbGetInputFile();
+ if ( bbGetInputExtent() != "")
+ if ( bbGetInputExtent()[0] != '.' )
+ fullFileName += ".";
+ fullFileName += bbGetInputExtent();
+ bbSetOutputOut( fullFileName );
+ }
}
// EO namespace bbstd
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(MakeFileName,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(Directory,std::string);
- BBTK_DECLARE_INPUT(File,std::string);
- BBTK_DECLARE_INPUT(Extent,std::string);
- BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_BLACK_BOX_INTERFACE(MakeFileName,bbtk::AtomicBlackBox);
+ BBTK_DECLARE_INPUT(Directory,std::string);
+ BBTK_DECLARE_INPUT(File,std::string);
+ BBTK_DECLARE_INPUT(Extent,std::string);
+ BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(DoProcess);
void DoProcess();
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(Relay,
+ bbtk::AtomicBlackBox);
//====================================================================
-
+
//====================================================================
// Standard relays
using namespace std;
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(Relay,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,T);
- BBTK_DECLARE_OUTPUT(Out,T);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(Relay,bbtk::AtomicBlackBox,T);
+ BBTK_DECLARE_INPUT(In,T);
+ BBTK_DECLARE_OUTPUT(Out,T);
BBTK_PROCESS(Process);
protected:
void Process() { bbSetOutputOut ( bbGetInputIn() ); }
//=======================================================================
//=======================================================================
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(Relay);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(Relay,bbtk::AtomicBlackBox);
BBTK_NAME(bbtk::HumanTypeName<T>()+"Relay");
BBTK_AUTHOR("laurent.guigues at creatis.insa-lyon.fr");
BBTK_CATEGORY("misc");
namespace bbstd
{
- BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,StringSelect)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(StringSelect,bbtk::AtomicBlackBox);
-
- void StringSelect::bbUserConstructor()
- {
- bbSetInputIn(0);
- bbSetInputIn0("");
- bbSetInputIn1("");
- bbSetInputIn2("");
- bbSetInputIn3("");
- bbSetInputIn4("");
- bbSetInputIn5("");
- bbSetInputIn6("");
- bbSetInputIn7("");
- bbSetInputIn8("");
- bbSetInputIn9("");
- }
-
-
-
- void StringSelect::DoProcess()
- {
- if (bbGetInputIn()==0) bbSetOutputOut( bbGetInputIn0() );
- else if (bbGetInputIn()==1) bbSetOutputOut( bbGetInputIn1() );
- else if (bbGetInputIn()==2) bbSetOutputOut( bbGetInputIn2() );
- else if (bbGetInputIn()==3) bbSetOutputOut( bbGetInputIn3() );
- else if (bbGetInputIn()==4) bbSetOutputOut( bbGetInputIn4() );
- else if (bbGetInputIn()==5) bbSetOutputOut( bbGetInputIn5() );
- else if (bbGetInputIn()==6) bbSetOutputOut( bbGetInputIn6() );
- else if (bbGetInputIn()==7) bbSetOutputOut( bbGetInputIn7() );
- else if (bbGetInputIn()==8) bbSetOutputOut( bbGetInputIn8() );
- else if (bbGetInputIn()==9) bbSetOutputOut( bbGetInputIn9() );
-
- }
+ BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,StringSelect)
+ BBTK_BLACK_BOX_IMPLEMENTATION(StringSelect,bbtk::AtomicBlackBox);
+
+ void StringSelect::bbUserConstructor()
+ {
+ bbSetInputIn(0);
+ bbSetInputIn0("");
+ bbSetInputIn1("");
+ bbSetInputIn2("");
+ bbSetInputIn3("");
+ bbSetInputIn4("");
+ bbSetInputIn5("");
+ bbSetInputIn6("");
+ bbSetInputIn7("");
+ bbSetInputIn8("");
+ bbSetInputIn9("");
+ }
+
+
+
+ void StringSelect::DoProcess()
+ {
+ if (bbGetInputIn()==0) bbSetOutputOut( bbGetInputIn0() );
+ else if (bbGetInputIn()==1) bbSetOutputOut( bbGetInputIn1() );
+ else if (bbGetInputIn()==2) bbSetOutputOut( bbGetInputIn2() );
+ else if (bbGetInputIn()==3) bbSetOutputOut( bbGetInputIn3() );
+ else if (bbGetInputIn()==4) bbSetOutputOut( bbGetInputIn4() );
+ else if (bbGetInputIn()==5) bbSetOutputOut( bbGetInputIn5() );
+ else if (bbGetInputIn()==6) bbSetOutputOut( bbGetInputIn6() );
+ else if (bbGetInputIn()==7) bbSetOutputOut( bbGetInputIn7() );
+ else if (bbGetInputIn()==8) bbSetOutputOut( bbGetInputIn8() );
+ else if (bbGetInputIn()==9) bbSetOutputOut( bbGetInputIn9() );
+
+ }
}
// EO namespace bbstd
:
public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(StringSelect,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,int);
- BBTK_DECLARE_INPUT(In0,std::string);
- BBTK_DECLARE_INPUT(In1,std::string);
- BBTK_DECLARE_INPUT(In2,std::string);
- BBTK_DECLARE_INPUT(In3,std::string);
- BBTK_DECLARE_INPUT(In4,std::string);
- BBTK_DECLARE_INPUT(In5,std::string);
- BBTK_DECLARE_INPUT(In6,std::string);
- BBTK_DECLARE_INPUT(In7,std::string);
- BBTK_DECLARE_INPUT(In8,std::string);
- BBTK_DECLARE_INPUT(In9,std::string);
- BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_BLACK_BOX_INTERFACE(StringSelect,bbtk::AtomicBlackBox);
+ BBTK_DECLARE_INPUT(In,int);
+ BBTK_DECLARE_INPUT(In0,std::string);
+ BBTK_DECLARE_INPUT(In1,std::string);
+ BBTK_DECLARE_INPUT(In2,std::string);
+ BBTK_DECLARE_INPUT(In3,std::string);
+ BBTK_DECLARE_INPUT(In4,std::string);
+ BBTK_DECLARE_INPUT(In5,std::string);
+ BBTK_DECLARE_INPUT(In6,std::string);
+ BBTK_DECLARE_INPUT(In7,std::string);
+ BBTK_DECLARE_INPUT(In8,std::string);
+ BBTK_DECLARE_INPUT(In9,std::string);
+ BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(DoProcess);
void DoProcess();
-
+
protected:
virtual void bbUserConstructor();
-
+
};
//=======================================================================
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringTo,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringTo,
+ bbtk::AtomicBlackBox);
//====================================================================
//====================================================================
template <class T>
class StringTo : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(StringTo,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,std::string);
- BBTK_DECLARE_OUTPUT(Out,T);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(StringTo,bbtk::AtomicBlackBox,T);
+ BBTK_DECLARE_INPUT(In,std::string);
+ BBTK_DECLARE_OUTPUT(Out,T);
BBTK_PROCESS(DoIt);
void DoIt();
};
//=================================================================
// BlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringTo);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringTo,bbtk::AtomicBlackBox);
BBTK_NAME("StringTo"+bbtk::HumanTypeName<T>());
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DEFAULT_ADAPTOR();
namespace bbstd
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringToVector,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(StringToVector,
+ bbtk::AtomicBlackBox);
//====================================================================
template <class T>
class StringToVector : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(StringToVector,bbtk::AtomicBlackBox);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(StringToVector,bbtk::AtomicBlackBox,T);
BBTK_DECLARE_INPUT(In,std::string);
BBTK_DECLARE_OUTPUT(Out,std::vector<T>);
BBTK_PROCESS(DoIt);
//=================================================================
// BlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(StringToVector,bbtk::AtomicBlackBox);
BBTK_NAME("StringTo"+bbtk::HumanTypeName<std::vector<T> >());
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DEFAULT_ADAPTOR();
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
+ bbtk::AtomicBlackBox);
//====================================================================
//====================================================================
template <class T>
class ToString : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ToString,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,T);
- BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(ToString,bbtk::AtomicBlackBox,T);
+ BBTK_DECLARE_INPUT(In,T);
+ BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(DoIt);
void DoIt();
};
//=================================================================
// BlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ToString);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(ToString,bbtk::AtomicBlackBox);
BBTK_NAME(bbtk::HumanTypeName<T>()+"ToString");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DEFAULT_ADAPTOR();
namespace bbstd
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(VectorToString,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(VectorToString,
+ bbtk::AtomicBlackBox);
//====================================================================
template <class T>
class VectorToString : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(VectorToString,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,std::vector<T>);
- BBTK_DECLARE_INPUT(Separator,std::string);
- BBTK_DECLARE_OUTPUT(Out,std::string);
+ BBTK_TEMPLATE_BLACK_BOX_INTERFACE(VectorToString,bbtk::AtomicBlackBox,T);
+ BBTK_DECLARE_INPUT(In,std::vector<T>);
+ BBTK_DECLARE_INPUT(Separator,std::string);
+ BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(DoIt);
void DoIt();
virtual void bbUserConstructor();
//=================================================================
// BlackBox description
- BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString);
+ BBTK_BEGIN_DESCRIBE_TEMPLATE_BLACK_BOX(VectorToString,bbtk::AtomicBlackBox);
BBTK_NAME(bbtk::HumanTypeName<std::vector<T> >()+"ToString");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_DEFAULT_ADAPTOR();
Program: bbtk
Module: $RCSfile: bbvtkImageDataToString.cxx,v $
Language: C++
- Date: $Date: 2008/02/15 08:46:19 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
namespace bbstd
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE_IMPLEMENTATION(ToString,
+ bbtk::AtomicBlackBox);
//====================================================================
Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.cxx,v $
Language: C++
- Date: $Date: 2008/04/01 14:26:22 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
namespace bbstd
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
+ bbtk::AtomicBlackBox);
//====================================================================
}
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,ImagePlanes)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ImagePlanes,bbtk::AtomicBlackBox);
Program: bbtk
Module: $RCSfile: bbvtkImagePlanes.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
class /*BBTK_EXPORT*/ ImagePlanes : public bbtk::AtomicBlackBox
{
public:
- BBTK_USER_BLACK_BOX_INTERFACE(ImagePlanes,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ImagePlanes,bbtk::AtomicBlackBox);
// BBTK_DECLARE_INPUT(Contour,int);
BBTK_DECLARE_INPUT(In,vtkImageData *);
BBTK_DECLARE_OUTPUT(PlaneX,vtkImagePlaneWidget*);
Program: bbtk
Module: $RCSfile: bbvtkIsoSurfaceExtractor.cxx,v $
Language: C++
- Date: $Date: 2008/03/19 13:30:18 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
namespace bbvtk
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,IsoSurfaceExtractor)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
void IsoSurfaceExtractor::bbUserConstructor()
{
Program: bbtk
Module: $RCSfile: bbvtkIsoSurfaceExtractor.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
vtkActor *vtkactor;
- BBTK_USER_BLACK_BOX_INTERFACE(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(IsoSurfaceExtractor,bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(In,vtkImageData *);
// BBTK_DECLARE_INPUT(InVtkObject,vtkObject *);
Program: bbtk
Module: $RCSfile: bbvtkMIPCreator.cxx,v $
Language: C++
- Date: $Date: 2008/03/19 13:30:18 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MIPCreator)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(MIPCreator,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(MIPCreator,bbtk::AtomicBlackBox);
Program: bbtk
Module: $RCSfile: bbvtkMIPCreator.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
class /*BBTK_EXPORT*/ MIPCreator : public bbtk::AtomicBlackBox
{
public:
- BBTK_USER_BLACK_BOX_INTERFACE(MIPCreator,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(MIPCreator,bbtk::AtomicBlackBox);
// BBTK_DECLARE_INPUT(Contour,int);
BBTK_DECLARE_INPUT(In,vtkImageData *);
BBTK_DECLARE_INPUT(Shift,int);
Program: bbtk
Module: $RCSfile: bbvtkMarchingCubes.cxx,v $
Language: C++
- Date: $Date: 2008/02/13 08:21:38 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(vtk,MarchingCubes)
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(MarchingCubes,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(MarchingCubes,bbtk::AtomicBlackBox);
} // EO namespace bbvtk
Program: bbtk
Module: $RCSfile: bbvtkMarchingCubes.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
public bbtk::AtomicBlackBox,
public vtkMarchingCubes
{
- BBTK_USER_BLACK_BOX_INTERFACE(MarchingCubes,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(MarchingCubes,bbtk::AtomicBlackBox);
BBTK_DECLARE_VTK_INPUT(vtkMarchingCubes,In,vtkImageData *);
BBTK_DECLARE_VTK_OUTPUT(vtkMarchingCubes,Out,vtkPolyData *);
Program: bbtk
Module: $RCSfile: bbwxColourSelector.cxx,v $
Language: C++
- Date: $Date: 2008/03/21 10:09:11 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ColourSelector);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ColourSelector,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ColourSelector,bbtk::AtomicBlackBox);
void ColourSelector::bbUserConstructor()
{
Program: bbtk
Module: $RCSfile: bbwxColourSelector.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
//=================================================================
class /*BBTK_EXPORT*/ ColourSelector : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ColourSelector,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ColourSelector,bbtk::AtomicBlackBox);
BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(Process);
// BBTK_CREATE_WIDGET(CreateWidget);
Program: bbtk
Module: $RCSfile: bbwxColourSelectorButton.cxx,v $
Language: C++
- Date: $Date: 2008/03/10 06:24:13 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
//--------------------------------------------------------------------------
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(ColourSelectorButton,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(ColourSelectorButton,bbtk::WxBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ColourSelectorButton);
void ColourSelectorButton::bbUserConstructor()
Program: bbtk
Module: $RCSfile: bbwxColourSelectorButton.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
// The black box
class /*BBTK_EXPORT*/ ColourSelectorButton : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(ColourSelectorButton,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(ColourSelectorButton,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(In,std::string);
BBTK_DECLARE_OUTPUT(Out,std::string);
BBTK_PROCESS(Process);
Program: bbtk
Module: $RCSfile: bbwxCommandButton.cxx,v $
Language: C++
- Date: $Date: 2008/03/26 14:47:37 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
void CommandButtonWidget::OnCommandButton( wxEvent& )
{
// Look for the interpreter
- bbtk::Interpreter* I = 0;
+ bbtk::Interpreter::Pointer I;
if (mBox->bbGetParent() != 0)
{
- bbtk::Factory* f =
- ((bbtk::ComplexBlackBoxDescriptor*)mBox->bbGetParent()
- ->bbGetDescriptor())->GetFactory();
+ bbtk::Factory::Pointer f = boost::dynamic_pointer_cast<bbtk::ComplexBlackBoxDescriptor>(mBox->bbGetParent()->bbGetDescriptor())->GetFactory();
if ((f != 0)&&
(f->GetExecuter()))
{
if (I==0)
{
// bbtkError("ExecBbiCommand::DoProcess() : could not find interpreter");
- I = new bbtk::Interpreter();
+ I = bbtk::Interpreter::New();
}
std::string commandstr(mBox->bbGetInputIn());
//--------------------------------------------------------------------------
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(CommandButton,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(CommandButton,bbtk::WxBlackBox);
void CommandButton::bbUserConstructor()
{
Program: bbtk
Module: $RCSfile: bbwxCommandButton.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
class /*BBTK_EXPORT*/ CommandButton : public bbtk::WxBlackBox
{
friend class CommandButtonWidget;
- BBTK_USER_BLACK_BOX_INTERFACE(CommandButton,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(CommandButton,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(In, std::string );
BBTK_DECLARE_INPUT(Label, std::string );
BBTK_DECLARE_INPUT(Colour, std::vector<double> );
Program: bbtk
Module: $RCSfile: bbwxDirectorySelector.cxx,v $
Language: C++
- Date: $Date: 2008/03/17 07:04:09 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,DirectorySelector);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(DirectorySelector,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(DirectorySelector,bbtk::AtomicBlackBox);
void DirectorySelector::Process()
Program: bbtk
Module: $RCSfile: bbwxDirectorySelector.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
//=================================================================
class /*BBTK_EXPORT*/ DirectorySelector : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(DirectorySelector,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(DirectorySelector,bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(Title,std::string);
BBTK_DECLARE_INPUT(Message,std::string);
BBTK_DECLARE_INPUT(DefaultDir,std::string);
Program: bbtk
Module: $RCSfile: bbwxFileSelector.cxx,v $
Language: C++
- Date: $Date: 2008/02/15 12:47:18 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,FileSelector);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(FileSelector,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(FileSelector,bbtk::AtomicBlackBox);
void FileSelector::Process()
Program: bbtk
Module: $RCSfile: bbwxFileSelector.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
//=================================================================
class /*BBTK_EXPORT*/ FileSelector : public bbtk::AtomicBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(FileSelector,bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(FileSelector,bbtk::AtomicBlackBox);
BBTK_DECLARE_INPUT(Title,std::string);
BBTK_DECLARE_INPUT(Message,std::string);
BBTK_DECLARE_INPUT(DefaultDir,std::string);
Program: bbtk
Module: $RCSfile: bbwxInputText.cxx,v $
Language: C++
- Date: $Date: 2008/02/15 12:47:18 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
//--------------------------------------------------------------------------
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WxBlackBox);
Program: bbtk
Module: $RCSfile: bbwxInputText.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
class /*BBTK_EXPORT*/ InputText : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(InputText,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(InputText,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(In,std::string);
BBTK_DECLARE_INPUT(Title,std::string);
BBTK_DECLARE_OUTPUT(Out,std::string);
Program: bbtk
Module: $RCSfile: bbwxLayoutLine.cxx,v $
Language: C++
- Date: $Date: 2008/03/10 10:01:15 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:52 $
+ 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
namespace bbwx
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx, LayoutLine);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(LayoutLine,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(LayoutLine,bbtk::WxBlackBox);
void LayoutLine::bbUserConstructor()
{
Program: bbtk
Module: $RCSfile: bbwxLayoutLine.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
class /*BBTK_EXPORT*/ LayoutLine : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(LayoutLine,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(LayoutLine,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(Widget1,wxWindow*);
BBTK_DECLARE_INPUT(Widget2,wxWindow*);
BBTK_DECLARE_INPUT(Widget3,wxWindow*);
Program: bbtk
Module: $RCSfile: bbwxLayoutSplit.cxx,v $
Language: C++
- Date: $Date: 2008/02/15 12:24:43 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
namespace bbwx
{
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,LayoutSplit);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(LayoutSplit,bbtk::WxBlackBox);
void LayoutSplit::bbUserConstructor()
{
Program: bbtk
Module: $RCSfile: bbwxLayoutSplit.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
class LayoutSplit : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(LayoutSplit,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(LayoutSplit,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(Widget1,wxWindow*);
BBTK_DECLARE_INPUT(Widget2,wxWindow*);
BBTK_DECLARE_INPUT(Orientation,std::string);
Program: bbtk
Module: $RCSfile: bbwxLayoutTab.cxx,v $
Language: C++
- Date: $Date: 2008/02/19 18:31:36 $
- Version: $Revision: 1.1 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx , LayoutTab);
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(LayoutTab,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(LayoutTab,bbtk::WxBlackBox);
void LayoutTab::bbUserConstructor()
{
Program: bbtk
Module: $RCSfile: bbwxLayoutTab.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
class /*BBTK_EXPORT*/ LayoutTab : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(LayoutTab,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(LayoutTab,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(Widget1,wxWindow*);
BBTK_DECLARE_INPUT(Widget2,wxWindow*);
BBTK_DECLARE_INPUT(Widget3,wxWindow*);
Program: bbtk
Module: $RCSfile: bbwxRadioButton.cxx,v $
Language: C++
- Date: $Date: 2008/02/14 20:26:54 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
//--------------------------------------------------------------------------
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(RadioButton,bbtk::WxBlackBox);
void RadioButton::bbUserConstructor()
Program: bbtk
Module: $RCSfile: bbwxRadioButton.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
class /*BBTK_EXPORT*/ RadioButton : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(RadioButton,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(RadioButton,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(In,int);
BBTK_DECLARE_INPUT(In0,std::string);
BBTK_DECLARE_INPUT(In1,std::string);
Program: bbtk
Module: $RCSfile: bbwxSlider.cxx,v $
Language: C++
- Date: $Date: 2008/03/10 12:28:43 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(Slider,bbtk::WxBlackBox);
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,Slider);
//--------------------------------------------------------------------------
Program: bbtk
Module: $RCSfile: bbwxSlider.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:32 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ Version: $Revision: 1.11 $
Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
l'Image). All rights reserved. See Doc/License.txt or
class /*BBTK_EXPORT*/ Slider : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(Slider,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(Slider,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(In,int);
BBTK_DECLARE_INPUT(Min,int);
BBTK_DECLARE_INPUT(Max,int);
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.cxx,v $
Language: C++
- Date: $Date: 2008/03/10 12:28:44 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
//--------------------------------------------------------------------------
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(Viewer2D,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(Viewer2D,bbtk::WxBlackBox);
void Viewer2D::Process()
Program: bbtk
Module: $RCSfile: bbwxvtkViewer2D.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:33 $
- Version: $Revision: 1.3 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
class /*BBTK_EXPORT*/ Viewer2D : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(Viewer2D,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(Viewer2D,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(Slice,int);
BBTK_DECLARE_INPUT(Orientation,int);
BBTK_DECLARE_INPUT(In,vtkImageData *);
Program: bbtk
Module: $RCSfile: bbwxvtkViewer3D.cxx,v $
Language: C++
- Date: $Date: 2008/04/01 14:26:23 $
- Version: $Revision: 1.2 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
//--------------------------------------------------------------------------
- BBTK_USER_BLACK_BOX_IMPLEMENTATION(Viewer3D,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_IMPLEMENTATION(Viewer3D,bbtk::WxBlackBox);
void Viewer3D::bbUserConstructor()
{
Program: bbtk
Module: $RCSfile: bbwxvtkViewer3D.h,v $
Language: C++
- Date: $Date: 2008/04/08 06:59:33 $
- Version: $Revision: 1.4 $
+ Date: $Date: 2008/04/18 12:59:53 $
+ 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
class /*BBTK_EXPORT*/ Viewer3D : public bbtk::WxBlackBox
{
- BBTK_USER_BLACK_BOX_INTERFACE(Viewer3D,bbtk::WxBlackBox);
+ BBTK_BLACK_BOX_INTERFACE(Viewer3D,bbtk::WxBlackBox);
BBTK_DECLARE_INPUT(In1, vtkProp3D *);
BBTK_DECLARE_INPUT(In2, vtkProp3D *);
BBTK_DECLARE_INPUT(In3, vtkProp3D *);
namespace bbstd
{
//====================================================================
- BBTK_USER_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
- bbtk::AtomicBlackBox);
+ BBTK_BLACK_BOX_TEMPLATE2_IMPLEMENTATION(Cast,
+ bbtk::AtomicBlackBox);
//====================================================================