Program: bbtk
Module: $RCSfile: bbtkAny.h,v $
Language: C++
- Date: $Date: 2009/01/07 13:08:19 $
- Version: $Revision: 1.6 $
+ Date: $Date: 2009/03/30 14:42:16 $
+ Version: $Revision: 1.7 $
=========================================================================*/
/* ---------------------------------------------------------------------
/// Returns true iff the contained type is a pointer
inline bool contains_pointer()
{
- return content->is_pointer() ;
+ return content ? content->is_pointer() : false;
}
/// Returns true iff the contained type is t
Program: bbtk
Module: $RCSfile: bbtkBlackBox.cxx,v $
Language: C++
- Date: $Date: 2009/03/23 13:06:41 $
- Version: $Revision: 1.40 $
+ Date: $Date: 2009/03/30 14:42:16 $
+ Version: $Revision: 1.41 $
=========================================================================*/
/* ---------------------------------------------------------------------
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 )
Program: bbtk
Module: $RCSfile: bbtkConnection.cxx,v $
Language: C++
- Date: $Date: 2008/12/11 09:50:35 $
- Version: $Revision: 1.19 $
+ Date: $Date: 2009/03/30 14:42:16 $
+ Version: $Revision: 1.20 $
=========================================================================*/
/* ---------------------------------------------------------------------
{
if ( from->bbGetOutputType(output) == typeid(Data) )
{
- bbtkWarning("Connection '"
- <<GetFullName()
- <<"' : '"<<from->bbGetName()<<"."<<output
+ bbtkWarning("Connection: '"<<from->bbGetName()<<"."<<output
<<"' is of type <"
<<HumanTypeName<Data>()
<<"> : type compatibility with '"
"===> Connection::RecursiveExecute() ["
<<GetFullName()<<"]"<<std::endl);
+ /*
+ // If box from already executing : nothing to do
+ if (mFrom->bbGetExecuting())
+ {
+ bbtkDebugMessage("process",3,
+ " -> "<<mFrom->bbGetName()
+ <<" already executing : abort"<<std::endl);
+ return;
+
+ }
+ */
+
mFrom->bbRecursiveExecute(GetThisPointer<Connection>());
TransferData();
<<HumanTypeName(mTo->bbGetInputType(mInput))
<<">"<<std::endl);
+ // 0) If from any contents void : nothing to do
+ if (mFrom->bbGetOutput(mOutput).type() == typeid(void))
+ {
+ bbtkDebugMessage("data",3,
+ " -> Source is void : nothing to transfer!"<<std::endl);
+ }
// 1) Test strict type matching between any content and target
- if (mFrom->bbGetOutput(mOutput)
+ else if (mFrom->bbGetOutput(mOutput)
.contains( mTo->bbGetInputType(mInput) ) )
{
bbtkDebugMessage("data",3,
Program: bbtk
Module: $RCSfile: bbtkConnection.h,v $
Language: C++
- Date: $Date: 2008/12/11 09:50:35 $
- Version: $Revision: 1.11 $
+ Date: $Date: 2009/03/30 14:42:16 $
+ Version: $Revision: 1.12 $
=========================================================================*/
/* ---------------------------------------------------------------------
/// Sets the members but does not test compatibility (used by bbtk::AdaptiveConnection)
// Connection(BlackBox* from, const std::string& output,
// BlackBox* to, const std::string& input, int );
-
+ public:
void TransferData();
private:
Program: bbtk
Module: $RCSfile: bbtkExecuter.cxx,v $
Language: C++
- Date: $Date: 2009/01/27 14:22:56 $
- Version: $Revision: 1.27 $
+ Date: $Date: 2009/03/30 14:42:16 $
+ Version: $Revision: 1.28 $
=========================================================================*/
/* ---------------------------------------------------------------------
BlackBox::Pointer b = GetCurrentDescriptor()->GetPrototype()->bbGetBlackBox(box);
// Looks for the adaptor
- if ( b->bbGetInputType(input) != typeid(std::string) )
+ if ( ( b->bbGetInputType(input) != typeid(bbtk::any<bbtk::thing>) )&&
+ ( b->bbGetInputType(input) != typeid(std::string) ) )
{
BlackBox::Pointer a =
GetFactory()->NewAdaptor(typeid(std::string),
Program: bbtk
Module: $RCSfile: bbstdMagicBox.cxx,v $
Language: C++
- Date: $Date: 2008/10/17 08:18:26 $
- Version: $Revision: 1.5 $
+ Date: $Date: 2009/03/30 14:42:23 $
+ Version: $Revision: 1.6 $
=========================================================================*/
/* ---------------------------------------------------------------------
#include "bbstdMagicBox.h"
#include "bbstdPackage.h"
+#include "bbtkBlackBoxOutputConnector.h"
+using namespace bbtk;
+
namespace bbstd
{
+ void MagicBox::bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
+ bbtk::IOStatus s)
+ {
+ bbtkDebugMessageInc("change",5,
+ "=> MagicBox::bbSetStatusAndPropagate(input,"
+ <<GetIOStatusString(s)<<") ["
+ <<bbGetFullName()<<"]"<<std::endl);
+ if (mCanSet)
+ {
+ if (c->IsConnected())
+ {
+ std::string do_input = c->GetConnection()->GetBlackBoxToInput();
+ c->GetConnection()->TransferData();
+ bbSetOutputOut( bbGetInput(do_input) );
+ }
+ mCanSet = false;
+ }
+ BlackBox::bbSetStatusAndPropagate(c,s);
+ }
+
+ void MagicBox::DoProcess()
+ {
+ mCanSet = true;
+ }
+
BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MagicBox);
BBTK_BLACK_BOX_IMPLEMENTATION(MagicBox,bbtk::AtomicBlackBox);
Program: bbtk
Module: $RCSfile: bbstdMagicBox.h,v $
Language: C++
- Date: $Date: 2008/12/12 08:55:21 $
- Version: $Revision: 1.10 $
+ Date: $Date: 2009/03/30 14:42:23 $
+ Version: $Revision: 1.11 $
=========================================================================*/
/* ---------------------------------------------------------------------
namespace bbstd
{
+#define BBTK_MB_DECLARE_INPUT(NAME,TYPE) \
+ protected: \
+ TYPE bbmInput##NAME; \
+public: \
+ TYPE bbGetInput##NAME () \
+ { return bbmInput##NAME; } \
+ void bbSetInput##NAME (TYPE d) \
+ { bbmInput##NAME = d; \
+ if (mCanSet) { bbSetOutputOut(d); mCanSet = false; } }
+
//==================================================================
class bbstd_EXPORT MagicBox
:
public bbtk::AtomicBlackBox
{
BBTK_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox);
- BBTK_DECLARE_INPUT(In,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In1,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In2,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In3,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In4,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In5,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In6,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In7,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In8,bbtk::Data);
+ BBTK_MB_DECLARE_INPUT(In9,bbtk::Data);
BBTK_DECLARE_OUTPUT(Out,bbtk::Data);
BBTK_PROCESS(DoProcess);
- void DoProcess() { bbSetOutputOut( bbGetInputIn() ); }
-
+ void DoProcess();
protected:
// virtual void bbUserConstructor();
-
- };
+ virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c,
+ bbtk::IOStatus s);
+ bool mCanSet;
+ virtual void bbUserConstructor() { mCanSet = true; }
+
+ };
//==================================================================
-
+#undef BBTK_MB_DECLARE_INPUT
+
//==================================================================
// We have to create a particular SetFunctor for MagicBox because
// its input is of type bbtk::Data (i.e. any) and :
/// Concrete application of the Set method of object o
void Set(bbtk::AtomicBlackBox* o, const bbtk::Data& d)
{
- bbtkDebugMessage("Data",9,"MagicBoxSetfunctor::Set()"<<std::endl);
+ bbtkDebugMessage("data",9,"MagicBoxSetfunctor::Set("<<
+ bbtk::HumanTypeName(d.type())<<
+ ")"<<std::endl);
(((MagicBox*)o)->*mSetMethodPointer)(d);
}
SetMethodPointerType mSetMethodPointer;
};
//===========================================================================
-
+
+#define MAGIC_BOX_INPUT(NAME) \
+ AddInputDescriptor \
+ (new bbtk::AtomicBlackBoxInputDescriptor \
+ (typeid(MagicBoxDescriptor), \
+ #NAME,"Input data","", \
+ new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data> \
+ (&MagicBox::bbGetInput ## NAME), \
+ new MagicBoxSetFunctor (&MagicBox::bbSetInput ## NAME) ) );
//===========================================================================
BBTK_BEGIN_DESCRIBE_BLACK_BOX(MagicBox,bbtk::AtomicBlackBox);
BBTK_NAME("MagicBox");
BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr");
BBTK_CATEGORY("misc");
- BBTK_DESCRIPTION("Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time.");
- AddInputDescriptor
+ BBTK_DESCRIPTION("Takes *any kind* of data and copies it to its output. Is a magic box as any box output can be plugged into it and its output can be plugged into any other box input (dynamic type checking, see below), hence it can be put between **any** two boxes. Type matching between its output and the input of the box(es) to which it is connected is made at *run-time*. The pipeline will be executed if the data types : i) match exactly ii) can be transformed by an adaptor iii) are related pointers, i.e. if the output pointer can be upcasted (static_cast) or downcasted (dynamic_cast) to an input type pointer (see the bbtk::any output connection rule in the guide for details). Important uses of the MagicBox are : 1) performing run-time pointer cast, either upward or backward an object hierarchy 2) perform data adaptation (adaptor creation) at run-time vs. pipeline creation time. Any has now 9 more inputs and the value of the output is the value of the lower index input which has changed. This functionality is used to implement a memory which can be written by different boxes. The current value of the memory (the output) is that of the last input which has changed, i.e. has 'written' the memory. It is used for example for synchronization issues between boxes.");
+ MAGIC_BOX_INPUT(In)
+ MAGIC_BOX_INPUT(In1)
+ MAGIC_BOX_INPUT(In2)
+ MAGIC_BOX_INPUT(In3)
+ MAGIC_BOX_INPUT(In4)
+ MAGIC_BOX_INPUT(In5)
+ MAGIC_BOX_INPUT(In6)
+ MAGIC_BOX_INPUT(In7)
+ MAGIC_BOX_INPUT(In8)
+ MAGIC_BOX_INPUT(In9)
+
+ /*
+ AddInputDescriptor
(new bbtk::AtomicBlackBoxInputDescriptor
(typeid(MagicBoxDescriptor),
"In","Input data","",
new bbtk::AtomicBlackBoxTGetFunctor<MagicBox,bbtk::Data,bbtk::Data>
(&MagicBox::bbGetInputIn),
new MagicBoxSetFunctor (&MagicBox::bbSetInputIn) ) );
+ */
AddOutputDescriptor
(new bbtk::AtomicBlackBoxOutputDescriptor
(typeid(MagicBoxDescriptor),
--- /dev/null
+description "Show how to synchronize multiple sliders (when one changes all the others are updated)"
+author "laurent.guigues@creatis.insa-lyon.fr"
+category "example"
+
+load wx
+load std
+
+new Slider slider1
+new Slider slider2
+new Slider slider3
+new Slider slider4
+new LayoutLine layout
+new MagicBox position
+
+set position.In 20
+set position.BoxProcessMode Reactive
+
+connect slider1.Out position.In1
+connect slider2.Out position.In2
+connect slider3.Out position.In3
+connect slider4.Out position.In4
+connect position.Out slider1.In
+connect position.Out slider2.In
+connect position.Out slider3.In
+connect position.Out slider4.In
+
+connect slider1.Widget layout.Widget1
+connect slider2.Widget layout.Widget2
+connect slider3.Widget layout.Widget3
+connect slider4.Widget layout.Widget4
+
+//message process 3
+//message change 1
+//message data 1
+exec layout
+
Program: bbtk
Module: $RCSfile: bbwxSlider.cxx,v $
Language: C++
- Date: $Date: 2009/03/19 08:08:14 $
- Version: $Revision: 1.20 $
+ Date: $Date: 2009/03/30 14:42:28 $
+ Version: $Revision: 1.21 $
=========================================================================*/
/* ---------------------------------------------------------------------
void OnResolutionOfSlider(wxScrollEvent& event);
// Accessors
+ void SetValue(int v) { mwxSlider->SetValue(v); }
int GetValue() { return mwxSlider->GetValue(); }
void SetRange(int min, int max);
// Update the texts which display the min/max/current values of the slider
//--------------------------------------------------------------------------
void Slider::Process()
{
+ bbtkDebugMessage("process",3,
+ "Slider "<<bbGetName()<<" input="
+ <<bbGetInputIn()<<std::endl);
+
bbSetOutputOut( bbGetInputIn() );
+ if (bbGetOutputWidget()!=0)
+ {
+ ((SliderWidget*)bbGetOutputWidget())->SetValue(bbGetInputIn());
+ }
}
void Slider::CreateWidget(wxWindow* parent)