Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2008/12/11 09:50:35 $
- Version: $Revision: 1.37 $
+ Date: $Date: 2009/05/18 10:45:40 $
+ Version: $Revision: 1.45 $
=========================================================================*/
/* ---------------------------------------------------------------------
#include "bbtkConfigurationFile.h"
#include "bbtkWxBlackBox.h"
+#include "bbtkWx.h"
#include <fstream>
//#include <vector>
static std::set<BlackBox::WeakPointer> bbmgExecutionList;
//=========================================================================
+
BlackBox::Deleter::Deleter()
{
}
//=========================================================================
//=========================================================================
- void BlackBox::Deleter::Delete(Object* p)
+ int BlackBox::Deleter::Delete(Object* p)
{
BlackBox* b = dynamic_cast<BlackBox*>(p);
if (!b)
BlackBoxDescriptor::WeakPointer desc = b->bbGetDescriptor();
bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : deleting black box"<<std::endl);
- b->bbDelete();
+ int refs = b->bbDelete();
- bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor ["<<desc.lock()<<"]"<<std::endl);
+ bbtkDebugMessage("object",2,"##> BlackBox::Deleter(\""<<name<<"\") : releasing descriptor"<<std::endl);
if (!desc.expired())
{
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);
+ return refs;
}
//=========================================================================
BlackBox::BlackBox(const std::string &name)
:
// bbmStatus(MODIFIED),
+ bbmInitialized(false),
bbmExecuting(false),
bbmName(name),
bbmBoxProcessMode("Pipeline"),
BlackBox::BlackBox(BlackBox& from, const std::string &name)
:
// bbmStatus(from.bbmStatus),
- bbmExecuting(false),
- bbmName(name),
- bbmBoxProcessMode(from.bbmBoxProcessMode),
- bbmParent()
-
+ bbmInitialized(false),
+ bbmExecuting(false),
+ bbmName(name),
+ bbmBoxProcessMode(from.bbmBoxProcessMode),
+ bbmParent()
+
{
bbtkDebugMessage("object",4,"==> BlackBox::BlackBox("
<<from.bbGetFullName()<<",\""
bool BlackBox::bbCanReact() const
{
return ( bbGlobalGetSomeBoxExecuting()
-#ifdef _USE_WXWIDGETS_
+#ifdef USE_WXWIDGETS
|| Wx::IsSomeWindowAlive()
#endif
);
if ( (p == "2") ||
(p == "R") || (p == "r") ||
(p == "Reactive") || (p == "reactive") ) return Reactive;
+ /*
+ if ( (p == "3") ||
+ (p == "F") || (p == "f") ||
+ (p == "Flash") || (p == "flash") ) return Flash;
+ */
bbtkError(bbGetFullName()<<" : BoxProcessMode value '"<<p
<<"' unknown. Possible values : "
<<"'0'/'P'/'p'/'Pipeline'/'pipeline' | "
<<"'1'/'A'/'a'/'Always'/'always' | "
- <<"'2'/'R'/'r'/'Reactive'/'reactive'"<<std::endl);
+ <<"'2'/'R'/'r'/'Reactive'/'reactive'"
+ // <<"'3'/'F'/'f'/'Flash'/'flash'"
+ <<std::endl);
}
//=========================================================================
if (s==UPTODATE) bbtkError("bbSetStatusAndPropagate with status UPTODATE!");
c->SetStatus(s);
+
+ // Flash reaction
+ /*
+ if (bbGetBoxProcessModeValue() == Flash)
+ {
+ this->bbExecute();
+ }
+ */
+
OutputConnectorMapType::const_iterator o;
for ( o = bbGetOutputConnectorMap().begin();
o != bbGetOutputConnectorMap().end(); ++o )
}
//=========================================================================
+ //=========================================================================
+ void BlackBox::bbInitializeProcessing()
+ {
+ std::cout << "INIT BEFORE TEST"<<bbGetFullName()<<std::endl;
+ if (!bbmInitialized)
+ {
+ std::cout << "INIT "<<bbGetFullName()<<std::endl;
+ this->bbRecursiveInitializeProcessing();
+ bbmInitialized = true;
+ }
+ }
+ //=========================================================================
+
+ //=========================================================================
+ void BlackBox::bbFinalizeProcessing()
+ {
+ if (bbmInitialized)
+ {
+ std::cout << "FINI "<<bbGetFullName()<<std::endl;
+ this->bbRecursiveFinalizeProcessing();
+ bbmInitialized = false;
+ }
+ }
+ //=========================================================================
+
//=========================================================================
/// Main recursive processing method of the box.
void BlackBox::bbRecursiveExecute( Connection::Pointer caller )
" -> already executing : abort"<<std::endl);
return;
}
+
+ // If not initialized do it
+ bbInitializeProcessing();
bbSetExecuting(true);
bool wasExecuting = bbGlobalGetSomeBoxExecuting();
bbGlobalSetSomeBoxExecuting(true);
-
+
+ // Creates the window if the black box has one
+ this->bbCreateWindow();
+
// Updates its inputs
IOStatus s = bbUpdateInputs();
if ( (s != UPTODATE) ||
bbBoxProcessModeIsAlways() )
{
- // Displays the window (WxBlackbox)
- // bbShowWindow(caller);
+ // Displays the window (WxBlackbox)
+ // bbShowWindow(caller);
- // Actual processing (virtual)
- this->bbProcess();
+ // Actual processing (virtual)
+ this->bbProcess();
- // Update the I/O statuses
- bbComputePostProcessStatus();
+ // Update the I/O statuses
+ bbComputePostProcessStatus();
}
else
{
<<std::endl);
}
+ // Shows the window if the black box has one
+ this->bbShowWindow();
+
+
bbtkDebugMessage("process",3,
"<= BlackBox::bbRecursiveExecute() ["
<<bbGetFullName()<<"]"<<std::endl);