From: guigues Date: Mon, 8 Jun 2009 14:49:58 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: EED.02Oct2009~31 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=664e5cdbbcaf3dafa5fc9f206a7094248c289d5a;p=bbtk.git *** empty log message *** --- diff --git a/kernel/appli/bbi/bbi.cxx b/kernel/appli/bbi/bbi.cxx index 76aaef3..16cbb8f 100644 --- a/kernel/appli/bbi/bbi.cxx +++ b/kernel/appli/bbi/bbi.cxx @@ -194,7 +194,7 @@ bool wxBBIApp::OnInit( ) if (help_on_script) { std::string package; - I->GetInterpreter()->GetExecuter()->GetFactory()->HelpBlackBox("workspace",package,false); + I->GetInterpreter()->GetExecuter()->GetFactory()->PrintHelpDescriptor("workspace",package,false); } /* @@ -281,9 +281,9 @@ int main(int argc, char* argv[]) { I->SetNoExecMode(false); std::string package; - I->GetExecuter()->GetFactory()->HelpBlackBox("workspace", - package, - false); + I->GetExecuter()->GetFactory()->PrintHelpDescriptor("workspace", + package, + false); } if (cmdline.input_file.size()==0) I->CommandLineInterpreter(); diff --git a/kernel/cmake/BBTKBuildDoxygenDoc.cmake b/kernel/cmake/BBTKBuildDoxygenDoc.cmake index 02d6578..0d03d68 100644 --- a/kernel/cmake/BBTKBuildDoxygenDoc.cmake +++ b/kernel/cmake/BBTKBuildDoxygenDoc.cmake @@ -46,6 +46,15 @@ MACRO(BBTK_BUILD_DOXYGEN_DOC NAME INPUT DOC_RELATIVE_INSTALL_PATH PREDEFINED) @ONLY IMMEDIATE ) + FILE(GLOB HTML RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.html") + FOREACH(file ${HTML}) + CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/${file} + ${DOXYGEN_OUTPUT}/${DOXYGEN_HTML_OUTPUT}/${file} + COPYONLY IMMEDIATE + ) + ENDFOREACH(file ${HTML}) + ADD_CUSTOM_COMMAND( OUTPUT ${DOXYGEN_OUTPUT}/${DOXYGEN_HTML_OUTPUT}/index.html @@ -53,7 +62,7 @@ MACRO(BBTK_BUILD_DOXYGEN_DOC NAME INPUT DOC_RELATIVE_INSTALL_PATH PREDEFINED) ${DOXYGEN} ARGS ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.txt - # DEPENDS bbtk bbi + DEPENDS DoxyMainPage.txt.in ) ADD_CUSTOM_TARGET(doxygen_${NAME} ALL diff --git a/kernel/doc/bbtkDoxygen/CMakeLists.txt b/kernel/doc/bbtkDoxygen/CMakeLists.txt index 4218956..fe9119d 100755 --- a/kernel/doc/bbtkDoxygen/CMakeLists.txt +++ b/kernel/doc/bbtkDoxygen/CMakeLists.txt @@ -12,6 +12,11 @@ CONFIGURE_FILE( ${CMAKE_CURRENT_BINARY_DIR}/DoxyMainPage.txt @ONLY IMMEDIATE ) +CONFIGURE_FILE( + ${CMAKE_CURRENT_SOURCE_DIR}/BlackBox.html + ${CMAKE_CURRENT_BINARY_DIR}/BlackBox.html + IMMEDIATE + ) SET(INPUT ${CMAKE_CURRENT_BINARY_DIR}/DoxyMainPage.txt @@ -24,7 +29,7 @@ BBTK_BUILD_DOXYGEN_DOC( "BBTK" "${INPUT}" "bbtk" - "${DOXYGEN_DOC_PREDEFINED}" + "${CREA_DEFINITIONS}" ) MESSAGE(STATUS "=======================================") diff --git a/kernel/doc/bbtkDoxygen/DoxyMainPage.txt.in b/kernel/doc/bbtkDoxygen/DoxyMainPage.txt.in index 94c4c71..2019718 100644 --- a/kernel/doc/bbtkDoxygen/DoxyMainPage.txt.in +++ b/kernel/doc/bbtkDoxygen/DoxyMainPage.txt.in @@ -3,10 +3,8 @@ \htmlonly -"A black box is any system in which only the input and output characteristics are of interest - without regard to its internal mechanism or structure" (from wikipedia ) -
  • - Coding Style + Black boxes
  • \endhtmlonly diff --git a/kernel/src/bbtkBlackBox.cxx b/kernel/src/bbtkBlackBox.cxx index 316f8cb..c74b2e9 100644 --- a/kernel/src/bbtkBlackBox.cxx +++ b/kernel/src/bbtkBlackBox.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBox.cxx,v $ Language: C++ - Date: $Date: 2009/05/28 14:22:09 $ - Version: $Revision: 1.47 $ + Date: $Date: 2009/06/08 14:50:02 $ + Version: $Revision: 1.48 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -169,7 +169,6 @@ namespace bbtk //========================================================================= - /// Returns the name with the name of the parent prepended if any std::string BlackBox::bbGetNameWithParent() const { if (bbmParent.lock()) @@ -184,7 +183,6 @@ namespace bbtk //========================================================================= //========================================================================= - /// Prints the Help on the BlackBox type void BlackBox::bbGetHelp(bool full) const { bbGetDescriptor()->GetHelp(full); @@ -193,7 +191,6 @@ namespace bbtk //========================================================================= - /// Returns true if the UserBlackBox has an input of name name bool BlackBox::bbHasInput(const std::string& name) const { bbtkBlackBoxDebugMessage("kernel",8, @@ -209,7 +206,6 @@ namespace bbtk //========================================================================= - /// Returns true if the UserBlackBox has an output of name name bool BlackBox::bbHasOutput(const std::string& name) const { bbtkBlackBoxDebugMessage("kernel",8,"BlackBox::bbHasOutput(\"" @@ -224,7 +220,6 @@ namespace bbtk //========================================================================= - /// Gets the output type of a given name TypeInfo BlackBox::bbGetOutputType( const std::string &name ) const { bbtkBlackBoxDebugMessage("kernel",8, @@ -238,7 +233,6 @@ namespace bbtk //========================================================================= //========================================================================= - /// Gets the input type of a given name TypeInfo BlackBox::bbGetInputType( const std::string &name ) const { bbtkBlackBoxDebugMessage("kernel",8, @@ -253,7 +247,6 @@ namespace bbtk //========================================================================= - /// Allocates the i/o connectors of the black box void BlackBox::bbAllocateConnectors() { bbtkBlackBoxDebugMessage("kernel",8, @@ -286,7 +279,6 @@ namespace bbtk //========================================================================= - /// Desallocates the i/o connectors of the black box void BlackBox::bbDesallocateConnectors() { bbtkBlackBoxDebugMessage("kernel",8, @@ -315,7 +307,6 @@ namespace bbtk //========================================================================= - /// Copies the input / output values from another box void BlackBox::bbCopyIOValues(BlackBox& from) { bbtkBlackBoxDebugMessage("kernel",1, @@ -365,19 +356,6 @@ namespace bbtk - //========================================================================= - /// User overloadable destruction method of a black box - void BlackBox::bbUserDelete() - { - bbtkBlackBoxDebugMessage("process",5, - "=> BlackBox::bbUserDelete()" - <<" : not overloaded; using standard deletion" - < BlackBox::bbSetInputChangeTime("<SetChangeTime(t) ) - { - bool was_up_to_date = bbIsUpToDate(); - // If new time is greater than the old max time of inputs - if ( mMaxInputChangeTime.Set(t) ) - { - // If the box turned out-of-date - if ( was_up_to_date && bbIsOutOfDate() ) - { - // - if ( ( bbBoxProcessModeIsReactive() || - (c==bbGetInputConnectorMap().find("BoxExecute")->second)) - && (bbCanReact() ) ) - { - bbtkBlackBoxDebugMessage("change",2, - "an input of " - <() ); - } - // Have to propagate the modification to aval boxes - OutputConnectorMapType::iterator i; - for (i = bbGetOutputConnectorMap().begin(); - i != bbGetOutputConnectorMap().end(); - ++i) - { - i->second->SetChangeTime(t); - } - // update the MinOutputChangeTime - mMinOutputChangeTime.Set(t); - } - } - } - } - //========================================================================= - - //========================================================================= - /// Sets the ChangeTime of output - void BlackBox::bbSetOutputChangeTime(BlackBoxOutputConnector* c, - const ChangeTime& t) - { - bbtkBlackBoxDebugMessage("change",1, - "==> BlackBox::bbSetOutputChangeTime("<SetChangeTime(t); - // c->GetChangeTime() = t; - // bbUpdateMinOutputChangeTime(t); - // propagate - - } - //========================================================================= - */ - - /* - //========================================================================= - void BlackBox::bbUpdateMaxInputChangeTime(const ChangeTime& t) - { - - - if ( t > mMaxInputChangeTime ) - { - mMaxInputChangeTime = t; - if ( mMinOutputChangeTime > mMaxInputChangeTime ) - { - - } - } - - } - //========================================================================= - - //========================================================================= - void bbUpdateMinOutputChangeTime(const ChangeTime& t) - { - ChangeTime old = mMinOutputChangeTime; - mMinOutputChangeTime = MAXLONG; - OutputConnectorMapType::iterator i; - for (i = bbGetOutputConnectorMap.begin(); - i != bbGetOutputConnectorMap.end(); - ++i) - { - if (i->second->GetChangeTime() < mMinOutputChangeTime) - mMinOutputChangeTime = i->second->GetChangeTime(); - } - if ( mMinOutputChangeTime < old ) - { - } - - } - //========================================================================= - */ - //========================================================================= - /// Signals that the BlackBox has been modified through - /// the input connector c - /// and propagates it downward - /// ** NOT USER INTENDED ** void BlackBox::bbSetStatusAndPropagate(BlackBoxInputConnector* c, IOStatus s) { @@ -785,7 +653,6 @@ namespace bbtk //========================================================================= - /// Main recursive processing method of the box. void BlackBox::bbRecursiveExecute( Connection::Pointer caller ) { bbtkBlackBoxDebugMessage("process",3, @@ -867,9 +734,6 @@ namespace bbtk //========================================================================= - /// Updates the BlackBox inputs - /// Calls RecursiveExecute on all BlackBoxInputConnector - /// \returns The maximum of final IOStatus after each input update IOStatus BlackBox::bbUpdateInputs() { bbtkBlackBoxDebugMessage("process",4, @@ -912,8 +776,7 @@ namespace bbtk //========================================================================= //================================================================== - /// Computes the final IOStatus of inputs and outputs after processing - void BlackBox::bbComputePostProcessStatus() + void BlackBox::bbComputePostProcessStatus() { bbtkBlackBoxDebugMessage("process",4, "=> BlackBox::bbComputePostProcessStatus()" @@ -957,7 +820,6 @@ namespace bbtk //================================================================== //========================================================================= - /// Connects the input to the connection c void BlackBox::bbConnectInput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, @@ -985,7 +847,6 @@ namespace bbtk //========================================================================= - /// Connects the output to the connection c void BlackBox::bbConnectOutput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, @@ -1010,8 +871,7 @@ namespace bbtk //========================================================================= - /// Disconnects the input from the connection c - void BlackBox::bbDisconnectInput( const std::string& name, Connection* c) + void BlackBox::bbDisconnectInput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, @@ -1043,8 +903,7 @@ namespace bbtk //========================================================================= - /// Disconnects the output from the connection c - void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c) + void BlackBox::bbDisconnectOutput( const std::string& name, Connection* c) { bbtkBlackBoxDebugMessage("connection",2, "==> BlackBox::bbDisconnectOutput(\""< InputConnectorMapType; + //================================================================== - /// Returns the pointer on the descriptor of the box - virtual BlackBoxDescriptor::Pointer bbGetDescriptor() const = 0; + //================================================================== + /// @name Pipeline processing methods + /// Methods which participate to pipeline processing. + //@{ + /// Main processing method of the box. + virtual void bbExecute(bool force = false); + //@} + //================================================================== + + + + + + //================================================================== /// Returns a pointer on a clone of the box with name virtual BlackBox::Pointer bbClone(const std::string& name) = 0; + //================================================================== + - /// User overloadable destruction method of a black box - virtual void bbUserDelete(); + //================================================================== + /// @name General accessors + /// Methods which give access to general informations on the box + //@{ + + /// Returns the pointer on the descriptor of the box + virtual BlackBoxDescriptor::Pointer bbGetDescriptor() const = 0; /// Returns the Name of the Type of the BlackBox const std::string& bbGetTypeName() const @@ -118,78 +141,93 @@ namespace bbtk /// Returns the parent of the BlackBox, i.e the BlackBox that contains it (0 if none) BlackBox::Pointer bbGetParent() const { return bbmParent.lock(); } + + //@} + //================================================================== - - /// Main processing method of the box. - virtual void bbExecute(bool force = false); - - - + //================================================================== + /// @name Inputs/Outputs related methods + /// Methods related to the box inputs and outputs + //@{ /// Returns true iff the BlackBox has an input of name label virtual bool bbHasInput(const std::string& label) const; - /// Returns true iff the BlackBox has an output of name label - virtual bool bbHasOutput(const std::string& label) const; - /// Gets the input type of a given label virtual TypeInfo bbGetInputType( const std::string &label ) const; - /// Gets the output type of a given label - virtual TypeInfo bbGetOutputType( const std::string &label ) const; - + /// Gets the status of the input called + IOStatus bbGetInputStatus( const std::string &name ) const + { return mInputConnectorMap.find(name)->second->GetStatus(); } /// Gets the data of the input called virtual Data bbGetInput( const std::string &name ) = 0; - /// Gets the data of the output called - virtual Data bbGetOutput( const std::string &name ) = 0; + /// Gets the data of the input called as a string using an Adaptor if possible (else returns empty string) + std::string bbGetInputAsString( const std::string &input); - /// Sets the data of the input called . + + /// Sets the data of the input called . /// If update_time is false then does not update ChangeTime of input virtual void bbSetInput( const std::string &name, Data data, bool update_time = true ) = 0; + /// [SYSTEM]: Sets the data of the input called which **MUST* be a pointer virtual void bbBruteForceSetInputPointer( const std::string &name, void* data, bool update_time = true) =0; + + + /// Returns true iff the BlackBox has an output of name label + virtual bool bbHasOutput(const std::string& label) const; + /// Gets the output type of a given label + virtual TypeInfo bbGetOutputType( const std::string &label ) const; + /// Gets the data of the output called + virtual Data bbGetOutput( const std::string &name ) = 0; + /// Gets the data of the output called as a string using an Adaptor if possible (else returns empty string) + std::string bbGetOutputAsString( const std::string &output ); //,Factory *factory); + /// Sets the data of the output called virtual void bbSetOutput( const std::string &name, Data data) = 0; - /// Gets the status of the input called - IOStatus bbGetInputStatus( const std::string &name ) const - { return mInputConnectorMap.find(name)->second->GetStatus(); } - /// Returns the input connectors map InputConnectorMapType& bbGetInputConnectorMap() { return mInputConnectorMap; } - /// Returns the output connectors map - OutputConnectorMapType& bbGetOutputConnectorMap() - { return mOutputConnectorMap; } /// Returns the input connectors map (const) const InputConnectorMapType& bbGetInputConnectorMap() const { return mInputConnectorMap; } + /// Returns the input connector + BlackBoxInputConnector& bbGetInputConnector(const std::string& n) + { return *(mInputConnectorMap.find(n)->second); } + /// Returns the input connector (const) + const BlackBoxInputConnector& bbGetInputConnector(const std::string& n) const + { return *(mInputConnectorMap.find(n)->second); } + + + /// Returns the output connectors map + OutputConnectorMapType& bbGetOutputConnectorMap() + { return mOutputConnectorMap; } /// Returns the output connectors map (const) const OutputConnectorMapType& bbGetOutputConnectorMap() const { return mOutputConnectorMap; } - - /// Returns the input connector - BlackBoxInputConnector& bbGetInputConnector(const std::string& n) - { return *(mInputConnectorMap.find(n)->second); } /// Returns the output connector BlackBoxOutputConnector& bbGetOutputConnector(const std::string& n) { return *(mOutputConnectorMap.find(n)->second); } - /// Returns the input connector (const) - const BlackBoxInputConnector& bbGetInputConnector(const std::string& n) const - { return *(mInputConnectorMap.find(n)->second); } - /// Returns the output connector (const) + /// Returns the output connector (const) const BlackBoxOutputConnector& bbGetOutputConnector(const std::string& n) const { return *(mOutputConnectorMap.find(n)->second); } - - + //@} + //================================================================== /// Prints the Help on the BlackBox type virtual void bbGetHelp(bool full=true) const; + + + //================================================================== + /// @name Output signals / observers related methods + /// Methods related to signals emitted by outputs and the + //@{ + //================================================================== /// Adds the function f to the list of functions to call when /// the output changes. @@ -243,99 +281,53 @@ namespace bbtk output_name, bool reaction = true); //================================================================== + //@} - //================================================================== - /// User can redefine this method to set - /// the default values of the box inputs and outputs - /// (it is called in the box constructor) - virtual void bbUserSetDefaultValues() {} - - /// User can redefine this method to initialize what must be - /// initialized for the box to work, for example allocate dynamic data. - /// It is called once and only once before any call to bbUserCreateWidget - /// or bbUserProcess. - /// What has been allocated here must be desalocated in - /// bbFinalizeProcessing - virtual void bbUserInitializeProcessing() {} - - /// User must redefine this method to uninitialize what has been - /// initialized in bbUserInitializeProcessing, - /// typically desallocate memory that has been allocated dynamically. - /// It is called in the box destructor if and only if (iff) - /// bbUserInitializeProcessing has been called previously. - virtual void bbUserFinalizeProcessing() {} - - - /// Initializes processing IF NEEDED. - /// Calls bbRecursiveInitializeProcessing if the box is in - /// "uninitialized" state and put it in "initialized" state. - /// On construction, boxes are "uninitialized". - /// See also bbFinalizeProcessing - void bbInitializeProcessing(); - - /// Finalizes processing IF NEEDED. - /// Calls bbRecursiveFinalizeProcessing if the box is in - /// "initialized" state and put it in "uninitialized" state. - /// On construction, boxes are "uninitialized". - /// See also bbInitializeProcessing - void bbFinalizeProcessing(); - - /// Abstract prototype of the method which - /// Recursively calls itself for the parent black box and then - /// calls bbUserInitializeProcessing for its own class. - /// It is redefined in each black box descendant. - /// Allows to call bbUserInitializeProcessing for all inherited classes - /// (like a constructor does) - virtual void bbRecursiveInitializeProcessing() {} - /// Abstract prototype of the method which - /// calls bbUserFinalizeProcessing for its own class and then - /// recursively calls itself for the parent black box. - /// It is redefined in each black box descendant. - /// Allows to call bbUserFinalizeProcessing for all inherited classes - /// (like a destructor does) - virtual void bbRecursiveFinalizeProcessing() {} //================================================================== - - - //================================================================== - // Common inputs / outputs to all boxes - /// Returns the value of the input "BoxProcessMode" + /// @name Common inputs / outputs to all boxes + //@{ + /// Returns the value of the input 'BoxProcessMode' std::string bbGetInputBoxProcessMode() { return bbmBoxProcessMode; } - /// Sets the value of the input "BoxProcessMode" + /// Sets the value of the input 'BoxProcessMode' void bbSetInputBoxProcessMode(std::string a) { bbmBoxProcessMode = a; } + /// The possible values of the input 'BoxProcessMode' typedef enum { Pipeline, Always, Reactive } - BoxProcessModeValue; + BoxProcessModeValue; /// Returns the "decoded" value of the input "BoxProcessMode" BoxProcessModeValue bbGetBoxProcessModeValue() const; - + /// Returns true iff the input 'BoxProcessMode' is set to 'Reactive' (or a synonym) virtual bool bbBoxProcessModeIsReactive() const; - + /// Returns true iff the input 'BoxProcessMode' is set to 'Always' (or a synonym) virtual bool bbBoxProcessModeIsAlways() const; - /// Returns the value of the input "Execute" + /// Returns the value of the input 'BoxExecute' Void bbGetInputBoxExecute() { return Void(); } - /// Sets the value of the input "Execute" + /// Sets the value of the input 'BoxExecute' void bbSetInputBoxExecute(Void = 0) {} - /// Returns the value of the output "Change" + /// Returns the value of the output 'BoxChange' Void bbGetOutputBoxChange() { return Void(); } - /// Sets the value of the output "Change" : signal a modification - void bbSetOutputBoxChange(Void = 0) { } //bbSetModifiedStatus(); } - + /// Sets the value of the output 'BoxChange' + void bbSetOutputBoxChange(Void = 0) { } + //@} //================================================================== - //================================================================== + + + virtual void bbPrintHelp(BlackBox::Pointer parentblackbox, + int detail, int level + ); /// Does nothing here : overloaded in ComplexBlackBox void bbInsertHTMLGraph( std::ofstream& s, @@ -346,6 +338,57 @@ namespace bbtk bool relative_link ) {} + + //================================================================== + /// @name Window related methods + //@{ + virtual void bbSetShown(bool) {} + virtual bool bbIsShown() { return false; } + //@} + //================================================================== + + protected: + + + + //================================================================== + /// @name User redefinable methods + /// Virtual methods which can be redefined by inherited classes + //@{ + + + //================================================================== + /// User can redefine this method to set + /// the default values of the box inputs and outputs + /// (it is called in the box constructor) + virtual void bbUserSetDefaultValues() {} + + /// User can redefine this method to initialize what must be + /// initialized for the box to work, for example allocate dynamic data. + /// It is called once and only once before any call to bbUserCreateWidget + /// or bbUserProcess. + /// What has been allocated here must be desalocated in + /// bbFinalizeProcessing + virtual void bbUserInitializeProcessing() {} + + /// User must redefine this method to uninitialize what has been + /// initialized in bbUserInitializeProcessing, + /// typically desallocate memory that has been allocated dynamically. + /// It is called in the box destructor if and only if (iff) + /// bbUserInitializeProcessing has been called previously. + virtual void bbUserFinalizeProcessing() {} + /// + virtual void bbUserOnShow() {} + + //================================================================== + // @} + //================================================================== + + + + + //================================================================== + /// Write Graphviz-dot description in file. /// Here dumps a single box description (i/o) but overloaded /// in ComplexBlackBox to dump the internal pipeline representation @@ -365,22 +408,15 @@ namespace bbtk int detail, int level); - 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::Pointer bbFindBlackBox(const std::string &blackboxname) + virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname) { return BlackBox::Pointer();} virtual void Check(bool recursive = true); - virtual void bbSetShown(bool) {} - virtual bool bbIsShown() { return false; } - virtual void bbUserOnShow() {} - protected: + + //================================================================== // PROTECTED PART : ACCESSIBLE TO THE BlackBox DEVELOPER // (IN INHERITED CLASSES) @@ -391,43 +427,11 @@ namespace bbtk //================================================================== - //================================================================== - /// Signals that the input whose connector is c has changed - /// and propagates the info downward - /// ** NOT USER INTENDED ** - virtual void bbSetStatusAndPropagate(BlackBoxInputConnector* c, - IOStatus s); - //================================================================== - - private: - //================================================================== - friend class Connection; - friend class ComplexBlackBox; - - /// Sets the parent of the BlackBox - void bbSetParent(BlackBox::Pointer p) { bbmParent = p; } - - - /// Connects the input to the connection c - virtual void bbConnectInput( const std::string& name, - Connection* c); - /// Connects the output to the connection c - virtual void bbConnectOutput( const std::string& name, - Connection* c); - /// Disconnects the input from the connection c - virtual void bbDisconnectInput( const std::string& name, - Connection* c); - /// Disconnects the output from the connection c - virtual void bbDisconnectOutput( const std::string& name, - Connection* c); //================================================================== - protected: /// @name Pipeline processing methods /// Methods which participate to pipeline processing. //@{ - - //================================================================== /// Recursive execution method /// @@ -475,46 +479,139 @@ namespace bbtk //================================================================== /// Computes the final IOStatus of inputs and outputs after processing void bbComputePostProcessStatus(); + //@} + //================================================================== + + + //================================================================== + /// Signals that the input whose connector is c has changed + /// and propagates the info downward + /// ** NOT USER INTENDED ** + virtual void bbSetStatusAndPropagate(BlackBoxInputConnector* c, + IOStatus s); + //================================================================== + + + + //================================================================== + /// @name Box con(des)struction / initi(fin)alization methods + //@{ + + //================================================================== + /// Allocates the i/o connectors of the black box + virtual void bbAllocateConnectors(); + /// Desallocates the i/o connectors of the black box + virtual void bbDesallocateConnectors(); + /// Copies the values of the inputs/output from the BlackBox from + virtual void bbCopyIOValues(BlackBox& from); + //================================================================== + + //================================================================== + /// Initializes processing IF NEEDED. + /// Calls bbRecursiveInitializeProcessing if the box is in + /// "uninitialized" state and put it in "initialized" state. + /// On construction, boxes are "uninitialized". + /// See also bbFinalizeProcessing + void bbInitializeProcessing(); + + /// Finalizes processing IF NEEDED. + /// Calls bbRecursiveFinalizeProcessing if the box is in + /// "initialized" state and put it in "uninitialized" state. + /// On construction, boxes are "uninitialized". + /// See also bbInitializeProcessing + void bbFinalizeProcessing(); + + /// Abstract prototype of the method which + /// Recursively calls itself for the parent black box and then + /// calls bbUserInitializeProcessing for its own class. + /// It is redefined in each black box descendant. + /// Allows to call bbUserInitializeProcessing for all inherited classes + /// (like a constructor does) + virtual void bbRecursiveInitializeProcessing() {} + + + /// Abstract prototype of the method which + /// calls bbUserFinalizeProcessing for its own class and then + /// recursively calls itself for the parent black box. + /// It is redefined in each black box descendant. + /// Allows to call bbUserFinalizeProcessing for all inherited classes + /// (like a destructor does) + virtual void bbRecursiveFinalizeProcessing() {} //================================================================== //@} - public: + //================================================================== + + + + + private: + //================================================================== + friend class Connection; + friend class ComplexBlackBox; + + /// Sets the parent of the BlackBox + void bbSetParent(BlackBox::Pointer p) { bbmParent = p; } + + //================================================================== + /// @name Input/output connection/disconnection + /// INTERNAL METHODS used by a Connection to connect/disconnect + /// itself to the i/o connectors of the box + //@{ + + /// Connects the input to the connection c + virtual void bbConnectInput( const std::string& name, + Connection* c); + /// Connects the output to the connection c + virtual void bbConnectOutput( const std::string& name, + Connection* c); + /// Disconnects the input from the connection c + virtual void bbDisconnectInput( const std::string& name, + Connection* c); + /// Disconnects the output from the connection c + virtual void bbDisconnectOutput( const std::string& name, + Connection* c); + //@} + //================================================================== + /// Returns true if the box can "react", + /// which means execute in response to an input change + virtual bool bbCanReact() const; + + + + //================================================================== + /// @name Manage the execution + //@{ static bool bbGlobalGetSomeBoxExecuting(); static void bbGlobalSetSomeBoxExecuting(bool b); static void bbGlobalSetFreezeExecution(bool b); static bool bbGlobalGetFreezeExecution(); - /// Returns true if the box can "react", - /// which means execute in response to an input change - virtual bool bbCanReact() const; + static void bbGlobalAddToExecutionList( BlackBox::Pointer b ); + static void bbGlobalProcessExecutionList(); + + //@} /// Returns true iff the box is executing bool bbGetExecuting() const { return bbmExecuting; } - - protected: - static void bbGlobalAddToExecutionList( BlackBox::Pointer b ); - static void bbGlobalProcessExecutionList(); /// Sets the bbmExecuting bool returned by bbGetExecuting void bbSetExecuting(bool b) { bbmExecuting = b; } + + + protected: + //================================================================== protected: - //================================================================== - /// Allocates the i/o connectors of the black box - virtual void bbAllocateConnectors(); - /// Desallocates the i/o connectors of the black box - virtual void bbDesallocateConnectors(); - /// Copies the values of the inputs/output from the BlackBox from - virtual void bbCopyIOValues(BlackBox& from); - //================================================================== - //================================================================== - // 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 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 @@ -526,6 +623,7 @@ namespace bbtk //================================================================== //================================================================== + /// Like Object::MakePointer but returns a boost::shared_pointer which uses a BlackBox::Deleter to delete the object instead of the default Object::Deleter template static boost::shared_ptr MakeBlackBoxPointer(U* s, bool lock = false) { @@ -534,6 +632,10 @@ namespace bbtk //================================================================== //================================================================== + /// Effective deletion method called by the Deleter. + /// The default implementation is to issue 'delete this' + /// but it can be redefined in inherited classes to handle special deletion mechanisms (e.g. ref counting, private destructors, such as vtk objects deletion with method Delete, etc.). + /// \return The number of remaining references on the object after the call (if meaningfull...): used by bbtk to warn a user if another smart pointing system is still holding the object... virtual int bbDelete() { delete this; return 0; } //================================================================== diff --git a/kernel/src/bbtkBlackBoxInputConnector.cxx b/kernel/src/bbtkBlackBoxInputConnector.cxx index 5180428..a2355de 100644 --- a/kernel/src/bbtkBlackBoxInputConnector.cxx +++ b/kernel/src/bbtkBlackBoxInputConnector.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBoxInputConnector.cxx,v $ Language: C++ - Date: $Date: 2009/05/28 08:12:05 $ - Version: $Revision: 1.10 $ + Date: $Date: 2009/06/08 14:50:02 $ + Version: $Revision: 1.11 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -39,13 +39,38 @@ namespace bbtk { + + //======================================================================== + /// The Pimpl + class BlackBoxInputConnector::Pimpl + { + public: + Pimpl() : mConnection(0), mStatus(MODIFIED) {} + + /// + BlackBoxWeakPointer mBox; + /// The connection plugged into the input + Connection* mConnection; + /// The status of the input (UPTODATE | MODIFIED | OUTOFDATE) + IOStatus mStatus; + + }; + //======================================================================== + + //======================================================================== + BBTK_IMPL_PIMPL(BlackBoxInputConnector) + //======================================================================== + + //======================================================================== BlackBoxInputConnector::BlackBoxInputConnector(BlackBox::Pointer b) - : mBox(b), mConnection(0), mStatus(MODIFIED) + //: mBox(b), mConnection(0), mStatus(MODIFIED) { bbtkDebugMessage("kernel",9, "["<bbGetName() <<"] BlackBoxInputConnector()"<mBox = b; } //======================================================================== @@ -53,19 +78,64 @@ namespace bbtk BlackBoxInputConnector::~BlackBoxInputConnector() { bbtkDebugMessage("kernel",9, - "[NULL"//<bbGetName() - <<"] ~BlackBoxInputConnector()" + "[DEAD BOX] ~BlackBoxInputConnector()" <mConnection; + } + //======================================================================== + + + //======================================================================== + /// Returns true iff a connection is connected to it + bool BlackBoxInputConnector::IsConnected() const + { + return (p->mConnection != 0); + } + //======================================================================== + + + //======================================================================== + /// Returns the status of the input + IOStatus BlackBoxInputConnector::GetStatus() const + { + return p->mStatus; + } + //======================================================================== + + //======================================================================== + /// Sets the status of the input + void BlackBoxInputConnector::SetStatus(IOStatus s) + { + p->mStatus = s; + } + //======================================================================== + + + + //======================================================================== + /// Returns the black box which owns the connector + BlackBoxPointer BlackBoxInputConnector::GetBlackBox() const + { + return p->mBox.lock(); + } + + //======================================================================== + //======================================================================== void BlackBoxInputConnector::SetConnection(Connection* c) { bbtkDebugMessage("kernel",9, - "["<bbGetName() + "["<mBox.lock()->bbGetName() <<"] BlackBoxInputConnector::SetConnection("<mConnection = c; } //======================================================================== @@ -73,10 +143,10 @@ namespace bbtk void BlackBoxInputConnector::UnsetConnection(Connection* c) { bbtkDebugMessage("kernel",9, - "["<bbGetName() + "["<mBox.lock()->bbGetName() <<"] BlackBoxInputConnector::UnsetConnection(" <mConnection = 0; } //======================================================================== @@ -86,20 +156,20 @@ namespace bbtk // If connected and OUTOFDATE : recursive update // Post-update status is updated by the connection // (either MODIFIED or OUTOFDATE) - if ( mConnection && (mStatus == OUTOFDATE) ) + if ( p->mConnection && (p->mStatus == OUTOFDATE) ) { - mConnection->RecursiveExecute(); + p->mConnection->RecursiveExecute(); } else { - if (!mBox.expired()) - bbtkDebugMessage("process",5,"["<bbGetName() + if (!p->mBox.expired()) + bbtkDebugMessage("process",5,"["<mBox.lock()->bbGetName() <<"] --> BlackBoxInputConnector::RecursiveExecute() : " <<"No connection or input not Out-of-date : nothing to do" < BlackBoxInputConnector::RecursiveExecute() : " + bbtkDebugMessage("process",5, + "[DEAD BOX] --> BlackBoxInputConnector::RecursiveExecute() : " <<"No connection or input not Out-of-date : nothing to do" < namespace bbtk @@ -58,38 +59,37 @@ namespace bbtk BlackBoxInputConnector(BlackBoxPointer b); /// Dtor ~BlackBoxInputConnector(); + /// Sets a connection void SetConnection(Connection* c); /// Unsets the connection /// The parameter is USELESS today but would be useful if we allow multiple connections on inputs void UnsetConnection(Connection* c); - - // Recursive execution - void RecursiveExecute(); - /// Returns the connection plugged into this input (const) - Connection* GetConnection() const { return mConnection; } + Connection* GetConnection() const; /// Returns true iff a connection is connected to it - bool IsConnected() const { return (mConnection != 0); } + bool IsConnected() const; + // Recursive execution + void RecursiveExecute(); + + /// Returns the status of the input - IOStatus GetStatus() const { return mStatus; } + IOStatus GetStatus() const; /// Sets the status of the input - void SetStatus(IOStatus s) { mStatus = s; } - + void SetStatus(IOStatus s); - /// Returns the black box which owns the connector - BlackBoxPointer GetBlackBox() const { return mBox.lock(); } - private: - /// - BlackBoxWeakPointer mBox; - /// The connection plugged into the input - Connection* mConnection; - /// The status of the input (UPTODATE | MODIFIED | OUTOFDATE) - IOStatus mStatus; + BlackBoxPointer GetBlackBox() const; + + + /// Private implementation + BBTK_DECLARE_PIMPL(BlackBoxInputConnector); + private: + /// Purposedly not implemented + BlackBoxInputConnector(const BlackBoxInputConnector&); }; } diff --git a/kernel/src/bbtkBlackBoxOutputConnector.cxx b/kernel/src/bbtkBlackBoxOutputConnector.cxx index 6631657..e6ba06c 100644 --- a/kernel/src/bbtkBlackBoxOutputConnector.cxx +++ b/kernel/src/bbtkBlackBoxOutputConnector.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $ Language: C++ - Date: $Date: 2009/05/28 08:12:05 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009/06/08 14:50:03 $ + Version: $Revision: 1.13 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -42,14 +42,39 @@ namespace bbtk { + //======================================================================== + /// The Pimpl + class BlackBoxOutputConnector::Pimpl + { + public: + Pimpl() : mStatus(OUTOFDATE) {} + Pimpl(const Pimpl&) {} + /// + BlackBoxWeakPointer mBox; + /// The vector of output connections + ConnectionVector mConnection; + /// The status of the output + IOStatus mStatus; + /// The output changed signal + BlackBox::OutputChangeSignalType mChangeSignal; + + + }; + //======================================================================== + + //======================================================================== + BBTK_IMPL_PIMPL(BlackBoxOutputConnector) + //======================================================================== + + //====================================================================== BlackBoxOutputConnector::BlackBoxOutputConnector(BlackBox::Pointer b) - : mBox(b), - mStatus(OUTOFDATE) { bbtkDebugMessage("kernel",9, "["<bbGetName() <<"] BlackBoxOutputConnector()"<mBox = b; } //====================================================================== @@ -58,8 +83,7 @@ namespace bbtk BlackBoxOutputConnector::~BlackBoxOutputConnector() { bbtkDebugMessage("kernel",9, - "[NULL"//<bbGetName() - <<"] ==> ~BlackBoxOutputConnector()" + "[DEAD BOX] ==> ~BlackBoxOutputConnector()" <mConnection.clear(); + PimplDestruct(); + bbtkDebugMessage("kernel",9, - "[NULL"//<bbGetName() - <<"] <== ~BlackBoxOutputConnector()" + "[DEAD BOX] <== ~BlackBoxOutputConnector()" <bbGetName() + "["<mBox.lock()->bbGetName() <<"] BlackBoxOutputConnector::SetConnection(" <mConnection.push_back(c); // AddChangeObserver(boost::bind(&Connection::SignalChange,c)); } //====================================================================== @@ -93,13 +118,13 @@ namespace bbtk //====================================================================== void BlackBoxOutputConnector::UnsetConnection(Connection* c) { - bbtkDebugMessage("kernel",9,"["<bbGetName() + bbtkDebugMessage("kernel",9,"["<mBox.lock()->bbGetName() <<"] BlackBoxOutputConnector::UnsetConnection(" <bbGetFullName() + bbtkInternalError(p->mBox.lock()->bbGetFullName() <<": BlackBoxOutputConnector::UnsetConnection(" <mConnection.begin(); + i!=p->mConnection.end(); ++i) { if (*i==c) break; } - if (i==mConnection.end()) + if (i==p->mConnection.end()) { - bbtkInternalError(mBox.lock()->bbGetFullName() + bbtkInternalError(p->mBox.lock()->bbGetFullName() <<": BlackBoxOutputConnector::UnsetConnection(" <mConnection.erase(i); // RemoveChangeObserver(boost::bind(&Connection::SignalChange,c)); } //====================================================================== + + //====================================================================== + const BlackBoxOutputConnector::ConnectionVector& + BlackBoxOutputConnector::GetConnectionVector() const + { + return p->mConnection; + } + //====================================================================== + + //====================================================================== + /// Returns the status of the input + IOStatus BlackBoxOutputConnector::GetStatus() const + { + return p->mStatus; + } + //====================================================================== + //====================================================================== + /// Sets the status of the input + void BlackBoxOutputConnector::SetStatus( IOStatus s ) + { + p->mStatus = s; + } + //====================================================================== - //====================================================================== + //====================================================================== void BlackBoxOutputConnector::SignalChange( BlackBox::Pointer box, const std::string& output ) { @@ -146,7 +194,7 @@ namespace bbtk // std::cout<<"BlackBoxOutputConnector::SignalChange(" // <bbGetName()<<",'" // <mChangeSignal(box,output,s); bbtkDebugMessage("change",2, "["<bbGetName() @@ -156,66 +204,12 @@ namespace bbtk < BlackBoxOutputConnector::SetModifiedStatus() [" - <SetModifiedStatus(); - } - - - } - */ - /* - //====================================================================== - void BlackBoxOutputConnector::SetChangeTime(const ChangeTime& t) - { - bbtkDebugMessage("change",2, - "==> BlackBoxOutputConnector::SetChangeTime("< BlackBoxOutputConnector::SetChangeTimetoCurrentTime() [" - < BlackBoxOutputConnector::SetChangeTimetoCurrentTime() [" - <mChangeSignal.connect(f); } //====================================================================== diff --git a/kernel/src/bbtkBlackBoxOutputConnector.h b/kernel/src/bbtkBlackBoxOutputConnector.h index d40703d..5324885 100644 --- a/kernel/src/bbtkBlackBoxOutputConnector.h +++ b/kernel/src/bbtkBlackBoxOutputConnector.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkBlackBoxOutputConnector.h,v $ Language: C++ - Date: $Date: 2009/05/28 08:12:05 $ - Version: $Revision: 1.9 $ + Date: $Date: 2009/06/08 14:50:03 $ + Version: $Revision: 1.10 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -41,78 +41,47 @@ #ifndef __bbtkBlackBoxOutputConnector_h__ #define __bbtkBlackBoxOutputConnector_h__ +#include "bbtkPimpl.h" #include "bbtkConnection.h" #include "bbtkBlackBox.h" #include "bbtkMessageManager.h" #include -// Change time management -//#include - -// Signal/slot mechanism for output change events -//#include -//#include namespace bbtk { - // class BlackBox; - // BBTK_FORWARD_DECLARE_POINTER(BlackBox); - - // void operator (void*)(ChangeCallbackType t) { return (void*)t; }; -/* - typedef void (*ChangeSignalFunctionType)(BlackBoxOutputConnector*); - bool operator==(void (*sg1)(BlackBoxOutputConnector*), - void (*sg2)(BlackBoxOutputConnector*)) - { return sg1==sg2;} -*/ -/* - bool operator==(boost::function1 >,boost::function1 >) - { - } -*/ - //boost::function >] class BBTK_EXPORT BlackBoxOutputConnector { public: - // typedef boost::signals::trackable ChangeObserverType; - // typedef boost::signal ChangeSignalType; - // typedef ChangeSignalType::slot_function_type ChangeCallbackType; - + typedef BlackBox::OutputChangeCallbackType OutputChangeCallbackType; + /// Ctor BlackBoxOutputConnector(BlackBoxPointer b); + /// Dtor ~BlackBoxOutputConnector(); + /// Sets a connection void SetConnection(Connection* c); + /// Unsets the connection void UnsetConnection(Connection* c); + /// The type of vector of output connections typedef std::vector ConnectionVector; - const ConnectionVector& GetConnectionVector() const { return mConnection; } + /// Returns the vector of connection plugged into this output (const) + const ConnectionVector& GetConnectionVector() const; + + /// Returns the status of the input + IOStatus GetStatus() const; + /// Sets the status of the input + void SetStatus( IOStatus s ); - IOStatus GetStatus() const { return mStatus; } - void SetStatus( IOStatus s ) { mStatus = s; } + /// Signals the change observers that the output has changed void SignalChange( BlackBox::Pointer box, const std::string& output ); - // void SetModifiedStatus(); - - /// Returns the ChangeTime of the output (const) - // const ChangeTime& GetChangeTime() const { return mChangeTime; } - /// Returns the ChangeTime of the output - // ChangeTime& GetChangeTime() { return mChangeTime; } - - /// To be called when the output has changed - /// (sets the ChangeTime to current time and - /// signals the change to observers) - // void SetChangeTime(const ChangeTime&); - - /// To be called when the output has changed - /// (sets the ChangeTime to current time and - /// signals the change to observers) - // void SetChangeTimeToCurrentTime(); - /// Adds the function f to the list of functions to call when /// the output changes. void AddChangeObserver(OutputChangeCallbackType f); @@ -121,16 +90,12 @@ namespace bbtk /// the output changes (TO WRITE) void RemoveChangeObserver(OutputChangeCallbackType f); - + /// Private implementation + BBTK_DECLARE_PIMPL(BlackBoxOutputConnector); + private: - /// - BlackBoxWeakPointer mBox; - /// The vector of output connections - ConnectionVector mConnection; - /// The status of the output - IOStatus mStatus; - /// The output changed signal - BlackBox::OutputChangeSignalType mChangeSignal; + /// Purposedly not implemented + BlackBoxOutputConnector(const BlackBoxOutputConnector&); }; diff --git a/kernel/src/bbtkExecuter.cxx b/kernel/src/bbtkExecuter.cxx index 91054a3..39a3d00 100644 --- a/kernel/src/bbtkExecuter.cxx +++ b/kernel/src/bbtkExecuter.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkExecuter.cxx,v $ Language: C++ - Date: $Date: 2009/05/28 08:12:05 $ - Version: $Revision: 1.30 $ + Date: $Date: 2009/06/08 14:50:03 $ + Version: $Revision: 1.31 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -114,7 +114,7 @@ namespace bbtk { bbtkDebugMessage("kernel",9,"==> Executer::Reset()" <CheckPackages(); + // GetFactory()->Check(); mOpenDefinition.clear(); mOpenPackage.clear(); @@ -142,7 +142,7 @@ namespace bbtk r->AddToDescription("User's workspace"); mOpenDefinition.push_back(CBBDefinition(r,"user")); // Register it into the user package - p->RegisterBlackBox(r); + p->Register(r); mRootCBB = r; // Object::PrintObjectListInfo(); @@ -156,7 +156,7 @@ namespace bbtk /// changes the workspace name void Executer::SetWorkspaceName( const std::string& n ) { - GetUserPackage()->ChangeBlackBoxName( GetWorkspace()->GetTypeName(), n ); + GetUserPackage()->ChangeDescriptorName( GetWorkspace()->GetTypeName(), n ); } //======================================================================= @@ -253,7 +253,8 @@ namespace bbtk { p = mOpenPackage.back().lock(); } - p->RegisterBlackBox(GetCurrentDescriptor()); + // Register the descriptor in the current package + p->Register(GetCurrentDescriptor()); bbtkDebugMessage("kernel",9,"<== Executer::EndDefine(\"" <GetTypeName()<<"\")" @@ -501,9 +502,11 @@ namespace bbtk } //======================================================================= + + //======================================================================= /// prints the list of the boxes of the current descriptor - void Executer::PrintBoxes() + void Executer::PrintHelpListBoxes() { bbtkMessage("help",1,"The black box descriptor \"" <GetTypeName()<<"\" contains : "<bbShowRelations(blackbox,detail,level); //,mFactory); + blackbox->bbPrintHelp(blackbox,detail,level); //,mFactory); } if (!found) { - bbtkError("Blackbox Name not found.. <" <"); + bbtkError("box with name '" <first << std::endl); if (details) { - i->second->PrintBlackBoxes(false,adaptors); + i->second->PrintHelpListDescriptors(false,adaptors); } } @@ -410,9 +409,10 @@ namespace bbtk //=================================================================== /// Displays help on a package - void Factory::HelpPackage(const std::string& name, bool adaptors) const + void Factory::PrintHelpPackage(const std::string& name, bool adaptors) const { - bbtkDebugMessageInc("kernel",9,"Factory::HelpPackage(\""<second->GetDescription()<second->GetNumberOfBlackBoxes()>0) + if (i->second->GetNumberOfDescriptors()>0) { bbtkMessage("help",1, "Black boxes : "<second->PrintBlackBoxes(true,adaptors); + i->second->PrintHelpListDescriptors(true,adaptors); } else { @@ -456,20 +456,21 @@ namespace bbtk //=================================================================== /// Prints help on the black box of type /// Returns the package to which it belongs - void Factory::HelpBlackBox(const std::string& name, + void Factory::PrintHelpDescriptor(const std::string& name, std::string& package, bool full) const { - bbtkDebugMessageInc("kernel",9,"Factory::HelpBlackBox(\""<second->ContainsBlackBox(name)) + if (i->second->ContainsDescriptor(name)) { - i->second->HelpBlackBox(name,full); + i->second->PrintHelpDescriptor(name,full); package = i->second->GetName(); found = true; } @@ -784,14 +785,14 @@ namespace bbtk //=================================================================== - void Factory::CheckPackages() const + void Factory::Check() const { bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this <second->CheckBoxes(); + i->second->Check(); } bbtkMessage("debug",1,"****** Checking Factory "<<(void*)this <<" ... OK"<second->ContainsBlackBox(name)) - { + if (i->second->ContainsDescriptor(name)) + { std::string separator = ConfigurationFile::GetInstance().Get_file_separator (); - - // Don't pollute the file store with "temp_dir" directories ... + + // Don't pollute the file store with "temp_dir" directories ... std::string default_doc_dir = ConfigurationFile::GetInstance().Get_default_temp_dir(); std::string directory = "\"" + default_doc_dir + separator + "temp_dir" +separator + "\""; std::string filename2 = default_doc_dir + separator + "temp_dir" + separator + "tmp.html"; - + #if defined(_WIN32) - std::string command("start \"Titre\" /D "); + std::string command("start \"Titre\" /D "); #else - std::string command("gnome-open "); + std::string command("gnome-open "); #endif - command=command + directory +" tmp.html"; - FILE *ff; - ff=fopen(filename2.c_str(),"w"); - - fprintf(ff,"TMP \n"); - - - //fprintf(ff, "Link\n", i->second->GetDocURL().c_str(),name.c_str() ); - fclose(ff); - system( command.c_str() ); - found = true; - } + command=command + directory +" tmp.html"; + FILE *ff; + ff=fopen(filename2.c_str(),"w"); + + fprintf(ff,"TMP \n"); + + + //fprintf(ff, "Link\n", i->second->GetDocURL().c_str(),name.c_str() ); + fclose(ff); + system( command.c_str() ); + found = true; + } } - + bbtkDebugDecTab("kernel",9); if (!found) { - bbtkError("No package of the factory contains any black box <" - <"); + bbtkError("No package of the factory contains any black box <" + <"); } } @@ -890,9 +891,9 @@ namespace bbtk { Package::Pointer pack = i->second; if (pack->GetName()=="user") continue; - Package::BlackBoxMapType::const_iterator j; - for (j = pack->GetBlackBoxMap().begin(); - j!= pack->GetBlackBoxMap().end(); + Package::DescriptorMapType::const_iterator j; + for (j = pack->GetDescriptorMap().begin(); + j!= pack->GetDescriptorMap().end(); ++j) { diff --git a/kernel/src/bbtkFactory.h b/kernel/src/bbtkFactory.h index a686fa4..33d8861 100644 --- a/kernel/src/bbtkFactory.h +++ b/kernel/src/bbtkFactory.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkFactory.h,v $ Language: C++ - Date: $Date: 2008/10/17 08:18:13 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009/06/08 14:50:03 $ + Version: $Revision: 1.17 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -57,21 +57,45 @@ namespace bbtk public: static Pointer New(); - + // @name Packages management + //@{ + /// Pushes back the names of the Package s which are in the Factory void GetPackagesList(std::vector&); + /// Loads a dynamic library which contains a Package void LoadPackage( const std::string& name ); + /// Unloads a Package which was loaded from a dynamic library void UnLoadPackage( const std::string& name ); - void PrintPackages(bool details = true, bool adaptors = false) const; - void HelpPackage(const std::string& name, bool adaptors = false) const; - void HelpBlackBox(const std::string& name, std::string& package, - bool full=true ) const; - void ShowGraphTypes(const std::string& name) const; + /// Inserts a Package in the Factory void InsertPackage( Package::Pointer ); + /// Removess a Package from the Factory void RemovePackage( Package::Pointer ); - + /// Returns the pointer on a Package provided by name Package::Pointer GetPackage(const std::string& name) const; - + /// The type of map of packages + typedef std::map< std::string, Package::Pointer > PackageMapType; + /// Returns the map of Packages + const PackageMapType& GetPackageMap() const { return mPackageMap; } + //@} + + // @name Methods which print help + //@{ + /// Prints the list of Package + void PrintHelpListPackages(bool details = true, + bool adaptors = false) const; + /// Prints help on a particular Package + void PrintHelpPackage(const std::string& name, + bool adaptors = false) const; + /// Prints help on a BlackBoxDescriptor + void PrintHelpDescriptor(const std::string& name, + std::string& package, + bool full=true ) const; + void ShowGraphTypes(const std::string& name) const; + // @} + + + /// @name Object creation methods + //@{ BlackBox::Pointer NewBlackBox(const std::string& type, const std::string& name) const; @@ -83,6 +107,15 @@ namespace bbtk const DataInfo& typeout, const std::string& name) const; + Connection::Pointer NewConnection(BlackBox::Pointer from, + const std::string& output, + BlackBox::Pointer to, + const std::string& input) const; + //@} + + /// @name Package inspection methods + /// Allow to test if an Adaptor is present in the packages WITHOUT instanciating it + //@{ bool FindAdaptor(const DataInfo& typein, const DataInfo& typeout, std::string& adaptor) const; @@ -95,17 +128,14 @@ namespace bbtk const DataInfo& typeout, std::string& widget, std::string& adaptor) const; - - Connection::Pointer NewConnection(BlackBox::Pointer from, - const std::string& output, - BlackBox::Pointer to, - const std::string& input) const; - + //@} + void WriteDotFilePackagesList(FILE *ff); + /// Releases all the packages of the Factory void Reset(); - void CheckPackages() const; + void Check() const; typedef enum { @@ -127,24 +157,16 @@ namespace bbtk private: - bool DoLoadPackage(std::string libname, - std::string pkgname, - std::string path); - - public: - /// The type of map of packages - typedef std::map< std::string, Package::Pointer > PackageMapType; - - const PackageMapType& GetPackageMap() const { return mPackageMap; } - - private: /// The map of packages PackageMapType mPackageMap; /// The executer which created the factory (if any) ExecuterWeakPointer mExecuter; + bool DoLoadPackage(std::string libname, + std::string pkgname, + std::string path); void CloseAllPackages(); void ClosePackage(PackageMapType::iterator& i); diff --git a/kernel/src/bbtkInterpreter.cxx b/kernel/src/bbtkInterpreter.cxx index a9b480f..8e87d7a 100644 --- a/kernel/src/bbtkInterpreter.cxx +++ b/kernel/src/bbtkInterpreter.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkInterpreter.cxx,v $ Language: C++ - Date: $Date: 2009/05/28 08:12:06 $ - Version: $Revision: 1.85 $ + Date: $Date: 2009/06/08 14:50:03 $ + Version: $Revision: 1.86 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -1593,7 +1593,7 @@ void Interpreter::Help(const std::vector& words) { if (words[1]=="packages") { - GetExecuter()->GetFactory()->PrintPackages(true); + GetExecuter()->GetFactory()->PrintHelpListPackages(true); return; } try @@ -1604,7 +1604,7 @@ void Interpreter::Help(const std::vector& words) { try { - GetExecuter()->GetFactory()->HelpPackage(words[1]); + GetExecuter()->GetFactory()->PrintHelpPackage(words[1]); if ( mUser != 0 ) { std::string url = @@ -1621,7 +1621,8 @@ void Interpreter::Help(const std::vector& words) try { std::string package; - GetExecuter()->GetFactory()->HelpBlackBox(words[1],package); + GetExecuter()->GetFactory()->PrintHelpDescriptor(words[1], + package); if ( mUser != 0 ) { std::string url = @@ -1638,7 +1639,7 @@ void Interpreter::Help(const std::vector& words) { try { - GetExecuter()->ShowRelations(words[1],"0","9999"); + GetExecuter()->PrintHelpBlackBox(words[1],"0","9999"); } catch (bbtk::Exception h){ bbtkError("\""<& words) { if ( words[1]=="packages" ) { - GetExecuter()->GetFactory()->PrintPackages(true,true); + GetExecuter()->GetFactory()->PrintHelpListPackages(true,true); return; } try { - GetExecuter()->GetFactory()->HelpPackage(words[1],true); + GetExecuter()->GetFactory()->PrintHelpPackage(words[1],true); } catch (bbtk::Exception f) { @@ -2274,7 +2275,7 @@ void Interpreter::NewGUI(const std::string& boxname, { // int o = MessageManager::GetMessageLevel("debug"); // if (o<2) MessageManager::SetMessageLevel("debug",2); - mVirtualExecuter->GetFactory()->CheckPackages(); + mVirtualExecuter->GetFactory()->Check(); // MessageManager::SetMessageLevel("debug",o); } } diff --git a/kernel/src/bbtkPackage.cxx b/kernel/src/bbtkPackage.cxx index ebd5ddf..05d5d1f 100644 --- a/kernel/src/bbtkPackage.cxx +++ b/kernel/src/bbtkPackage.cxx @@ -3,8 +3,8 @@ Program: bbtk Module: $RCSfile: bbtkPackage.cxx,v $ Language: C++ - Date: $Date: 2009/05/28 14:22:10 $ - Version: $Revision: 1.29 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.30 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -118,49 +118,49 @@ namespace bbtk //========================================================================== - void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack, - const std::string& descname) - { - // Try to release descriptor - std::string packname = pack.lock()->GetName(); - - bbtkDebugMessage("package",5,"--- Releasing descriptor '" - <GetBlackBoxMap().find(descname); - if (desc == pack.lock()->GetBlackBoxMap().end()) - { - bbtkDebugMessage("package",5, - " Descriptor has already been released" + void PackageReleaseBlackBoxDescriptorInternal(Package::WeakPointer pack, + const std::string& descname) + { + // Try to release descriptor + std::string packname = pack.lock()->GetName(); + + bbtkDebugMessage("package",5,"--- Releasing descriptor '" + <GetDescriptorMap().find(descname); + if (desc == pack.lock()->GetDescriptorMap().end()) + { + bbtkDebugMessage("package",5, + " Descriptor has already been released" <second; - desc->second.reset(); - // if it is dead : remove it - if (pdesc.expired()) - { - bbtkDebugMessage("package",2," ==> '"<second; + desc->second.reset(); + // if it is dead : remove it + if (pdesc.expired()) + { + bbtkDebugMessage("package",2," ==> '"<GetBlackBoxMap().find(descname); - if (desc != pack.lock()->GetBlackBoxMap().end()) pack.lock()->GetBlackBoxMap().erase(desc); - } else { //pdesc.expired - bbtkDebugMessage("package",5," ... Descriptor still alive (" - <GetBlackBoxMap()[descname] = pdesc.lock(); - } // pdesc.expired - } + <GetDescriptorMap().find(descname); + if (desc != pack.lock()->GetDescriptorMap().end()) pack.lock()->GetDescriptorMap().erase(desc); + } else { //pdesc.expired + bbtkDebugMessage("package",5," ... Descriptor still alive (" + <GetDescriptorMap()[descname] = pdesc.lock(); + } // pdesc.expired + } //========================================================================== @@ -173,7 +173,7 @@ namespace bbtk packname<<"')"<mDynamicLibraryHandler ? 1:0; - long ndesc = pack.lock()->GetBlackBoxMap().size(); + long ndesc = pack.lock()->GetDescriptorMap().size(); long nrefs = pack.use_count(); bbtkDebugMessage("package",5," "< descnamelist; - BlackBoxMapType::iterator i; - for (i=pack.lock()->mBlackBoxMap.begin(); - i!= pack.lock()->mBlackBoxMap.end(); + DescriptorMapType::iterator i; + for (i=pack.lock()->mDescriptorMap.begin(); + i!= pack.lock()->mDescriptorMap.end(); ++i) descnamelist.push_back(i->first); @@ -229,7 +229,7 @@ namespace bbtk } #if defined(MACOSX) - BlackBoxDescriptor::Pointer desc = pack.lock()->mBlackBoxMap[*descname]; + BlackBoxDescriptor::Pointer desc = pack.lock()->mDescriptorMap[*descname]; if ( (dyn==0) || (boost::dynamic_pointer_cast(desc)) ) PackageReleaseBlackBoxDescriptorInternal(pack,*descname); #else @@ -256,7 +256,7 @@ namespace bbtk if (!pack.expired()) { long dyn = pack.lock()->mDynamicLibraryHandler ? 1:0; - long ndesc = pack.lock()->GetBlackBoxMap().size(); + long ndesc = pack.lock()->GetDescriptorMap().size(); long nrefs = pack.use_count(); bbtkDebugMessage("package",1," ... Package still alive (" @@ -289,7 +289,7 @@ namespace bbtk <mDynamicLibraryHandler ? 1:0; - long ndesc = pack.lock()->GetBlackBoxMap().size(); + long ndesc = pack.lock()->GetDescriptorMap().size(); long nrefs = pack.use_count(); bbtkDebugMessage("package",5," "<mDynamicLibraryHandler ? 1:0; - long ndesc = pack.lock()->GetBlackBoxMap().size(); + long ndesc = pack.lock()->GetDescriptorMap().size(); long nrefs = pack.use_count(); bbtkDebugMessage("package",3," ... Package still alive (" @@ -582,7 +582,7 @@ namespace bbtk <GetBlackBoxMap().empty()) + if (!pack.lock()->GetDescriptorMap().empty()) { bbtkDebugMessage("package",5," Package not empty ... abort" @@ -590,7 +590,7 @@ namespace bbtk return; /* bbtkGlobalError("Package::UnLoadDynamicLibrary('"<::NewBlackBox(\""<::RegisterBlackBox(\""<GetTypeName()<<"\")"<::Register(\""<GetTypeName()<<"\")"<GetTypeName()); - if (i!=mBlackBoxMap.end()) + DescriptorMapType::iterator i = mDescriptorMap.find(d->GetTypeName()); + if (i!=mDescriptorMap.end()) { bbtkWarning("Package<"< : Trying to register box type <" <GetTypeName()<<"> which is already in the package"); return false; } - mBlackBoxMap[d->GetTypeName()] = d; + mDescriptorMap[d->GetTypeName()] = d; // d->Reference(); d->SetPackage(GetThisPointer()); // If it is a default adaptor, also register it in the adaptors map if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_ADAPTOR ) { - bbtkDebugMessage("kernel",8,"Package<"<::RegisterBlackBox(\""<GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<::Register(\""<GetTypeName()<<"\") : The box is an adaptor, inserting it in adaptors map ..."<GetInputDescriptor("In")->GetTypeInfo(); TypeInfo typeout = d->GetOutputDescriptor("Out")->GetTypeInfo(); @@ -877,7 +877,7 @@ namespace bbtk // If it is a default adaptor, also register it in the adaptors map else if ( d->GetKind() == BlackBoxDescriptor::DEFAULT_GUI) { - bbtkDebugMessage("kernel",8,"Package<"<::RegisterBlackBox(\""<GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<::Register(\""<GetTypeName()<<"\") : The box is a widget adaptor, inserting it in adaptors map ..."<GetOutputDescriptor("Out")->GetTypeInfo(); DataInfo infoin(typeid(void),""); @@ -912,13 +912,13 @@ namespace bbtk //========================================================================== //=================================================================== - void Package::CheckBoxes() const + void Package::Check() const { bbtkMessage("debug",1,"****** Checking Package "<<(void*)this <<" ["<second->Check(true); @@ -931,20 +931,22 @@ namespace bbtk //========================================================================== /// Changes the name of a black box type - void Package::ChangeBlackBoxName( const std::string& oldname, const std::string& newname ) + void Package::ChangeDescriptorName( const std::string& oldname, const std::string& newname ) { - bbtkDebugMessageInc("kernel",8,"Package<"<::ChangeBlackBoxName(\""<::ChangeDescriptorName(\""< does not contains the black box <"<"); + bbtkError("ChangeDescriptorName : The package <"< does not contains the black box <"<"); } i->second->SetTypeName(newname); - mBlackBoxMap[newname] = i->second; - mBlackBoxMap.erase(i); + mDescriptorMap[newname] = i->second; + mDescriptorMap.erase(i); bbtkDebugDecTab("kernel",8); } @@ -953,17 +955,16 @@ namespace bbtk //========================================================================== - /// Displays the list of black boxes of the package - void Package::PrintBlackBoxes(bool description, bool adaptors) const + void Package::PrintHelpListDescriptors(bool description, bool adaptors) const { unsigned int lmax = 0; std::vector names; std::vector kinds; std::vector descrs; - BlackBoxMapType::const_iterator i; - for (i=mBlackBoxMap.begin(); - i!=mBlackBoxMap.end(); + DescriptorMapType::const_iterator i; + for (i=mDescriptorMap.begin(); + i!=mDescriptorMap.end(); ++i) { if ( adaptors || @@ -1025,11 +1026,11 @@ namespace bbtk //========================================================================== /// Displays the list of adaptors of the package - void Package::PrintAdaptors(bool description) const + void Package::PrintHelpListAdaptors(bool description) const { - BlackBoxMapType::const_iterator i; - for (i=mBlackBoxMap.begin(); - i!=mBlackBoxMap.end(); + DescriptorMapType::const_iterator i; + for (i=mDescriptorMap.begin(); + i!=mDescriptorMap.end(); ++i) { if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD ) @@ -1072,14 +1073,15 @@ namespace bbtk //========================================================================== //========================================================================== - /// Prints help on a black box - void Package::HelpBlackBox(const std::string& name, bool full) const + /// Prints help on a black box descriptor + void Package::PrintHelpDescriptor(const std::string& name, bool full) const { - bbtkDebugMessageInc("kernel",8,"Package<"<::HelpBlackBox(\"" + bbtkDebugMessageInc("kernel",8,"Package<"<::PrintHelpDescriptor(\"" < does not contains the black box <"<"); @@ -1094,13 +1096,14 @@ namespace bbtk //========================================================================== /// Returns true iff the package contains the box of name boxname - bool Package::ContainsBlackBox(const std::string& name) const + bool Package::ContainsDescriptor(const std::string& name) const { - bbtkDebugMessageInc("kernel",8,"Package<"<::HelpBlackBox(\"" + bbtkDebugMessageInc("kernel",8,"Package<"<::ContainsDescriptor(\"" <\n"; - BlackBoxMapType::const_iterator i; - for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end(); ++i) + DescriptorMapType::const_iterator i; + for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end(); ++i) { if ( i->second->GetKind() != BlackBoxDescriptor::STANDARD) continue; @@ -1259,9 +1262,9 @@ namespace bbtk s << "

    Adaptors : \n"; s << "

      \n"; - // BlackBoxMapType::const_iterator i; + // DescriptorMapType::const_iterator i; s << "

    \n"; - for (i=mBlackBoxMap.begin(); i!=mBlackBoxMap.end();++i) + for (i=mDescriptorMap.begin(); i!=mDescriptorMap.end();++i) { if ( i->second->GetKind() == BlackBoxDescriptor::STANDARD) continue; @@ -1313,8 +1316,8 @@ namespace bbtk dir = filename.substr(0,slash_position); } - for (i=mBlackBoxMap.begin(); - i!=mBlackBoxMap.end(); + for (i=mDescriptorMap.begin(); + i!=mDescriptorMap.end(); ++i) { i->second->InsertHtmlHelp(s,detail,level,dir,relative_link); @@ -1353,7 +1356,7 @@ namespace bbtk std::string Package::GetObjectInfo() const { std::stringstream i; - i << " - "<second->GetObjectRecursiveSize(); } diff --git a/kernel/src/bbtkPackage.h b/kernel/src/bbtkPackage.h index 4b8d649..419f3fe 100644 --- a/kernel/src/bbtkPackage.h +++ b/kernel/src/bbtkPackage.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkPackage.h,v $ Language: C++ - Date: $Date: 2009/05/28 08:26:59 $ - Version: $Revision: 1.14 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.15 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -92,6 +92,11 @@ namespace bbtk /// 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); + + + /// Registers the BlackBoxDescriptor in the Package + bool Register(BlackBoxDescriptor::Pointer); + /// "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 @@ -135,33 +140,44 @@ namespace bbtk /// Returns the version of the package const std::string& GetVersion() const { return mVersion; } - bool ContainsBlackBox(const std::string& boxname) const; + /// Returns true iff the package contains a BlackBoxDescriptor + /// with the name provided + bool ContainsDescriptor(const std::string& name) const; - + /// Creates a new BlackBox of given type with name name BlackBox::Pointer NewBlackBox(const std::string& type, const std::string& name) const; - + + /// Creates a new adaptor BlackBox for the given input and output types + /// with name name BlackBox::Pointer NewAdaptor(const DataInfo& typein, - const DataInfo& typeout, - const std::string& name) const; + const DataInfo& typeout, + const std::string& name) const; + /// Creates a new widget adaptor BlackBox + /// for the given input and output types + /// with name name BlackBox::Pointer NewWidgetAdaptor(const DataInfo& typein, - const DataInfo& typeout, - const std::string& name) const; + const DataInfo& typeout, + const std::string& name) const; bool FindAdaptor(const DataInfo& typein, - const DataInfo& typeout, - std::string& adaptor) const; + const DataInfo& typeout, + std::string& adaptor) const; bool FindWidgetAdaptor(const DataInfo& typein, const DataInfo& typeout, std::string& adaptor) const; - bool RegisterBlackBox(BlackBoxDescriptor::Pointer); - void PrintBlackBoxes(bool description = false, - bool adaptors = false) const; - void PrintAdaptors(bool description = false) const; - void HelpBlackBox(const std::string& name, bool full=true) const; + /// Displays the list of black box descriptors of the package + void PrintHelpListDescriptors(bool description = false, + bool adaptors = false) const; + /// Displays the list of adaptors of the package + void PrintHelpListAdaptors(bool description = false) const; + /// Prints help on a particular Descriptor + void PrintHelpDescriptor(const std::string& name, bool full=true) const; + + void CreateHtmlPage(const std::string& filename, const std::string& caller = "?", const std::string& source = "?", @@ -178,16 +194,16 @@ namespace bbtk const std::string& GetDocRelativeURL() const { return mDocRelativeURL; } - unsigned int GetNumberOfBlackBoxes() const { return mBlackBoxMap.size(); } + unsigned int GetNumberOfDescriptors() const { return mDescriptorMap.size(); } - /// Changes the name of a black box type - void ChangeBlackBoxName( const std::string& oldname, - const std::string& newname ); + /// Changes the name of a descriptor + void ChangeDescriptorName( const std::string& oldname, + const std::string& newname ); /// The type of map of descriptors typedef std::map< std::string, BlackBoxDescriptor::Pointer> - BlackBoxMapType; - const BlackBoxMapType& GetBlackBoxMap() const { return mBlackBoxMap; } - BlackBoxMapType& GetBlackBoxMap() { return mBlackBoxMap; } + DescriptorMapType; + const DescriptorMapType& GetDescriptorMap() const { return mDescriptorMap; } + DescriptorMapType& GetDescriptorMap() { return mDescriptorMap; } /// The type of key in the map of adaptor descriptors class AdaptorKey @@ -237,7 +253,7 @@ namespace bbtk /// Gets the set of factories which use the package (const) const FactorySet& GetFactorySet() const { return mFactorySet; } - void CheckBoxes() const; + void Check() const; private: /// Default ctor is private : use the static New method @@ -276,7 +292,7 @@ namespace bbtk std::string mDocRelativeURL; /// The map of black boxes descriptors - BlackBoxMapType mBlackBoxMap; + DescriptorMapType mDescriptorMap; /// The map of adaptors descriptors AdaptorMapType mAdaptorMap; @@ -375,19 +391,19 @@ namespace bbtk //==================================================================== #define BBTK_ADD_BLACK_BOX_TO_PACKAGE(NAME,CLASS) \ bool bbDummy##NAME##CLASS = NAME ## GetPackage () \ - ->RegisterBlackBox(CLASS ## Descriptor::Instance()); + ->Register(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 ## Descriptor ::Instance()); + ->Register(CLASS ## Descriptor ::Instance()); //==================================================================== //==================================================================== #define BBTK_ADD_TEMPLATE2_BLACK_BOX_TO_PACKAGE(NAME,CLASS,T1,T2) \ bool bbDummy##NAME##CLASS##T1##T2 = NAME ## GetPackage () \ - ->RegisterBlackBox(CLASS ## Descriptor ::Instance()); + ->Register(CLASS ## Descriptor ::Instance()); //==================================================================== diff --git a/kernel/src/bbtkQtBlackBoxDialogParent.h b/kernel/src/bbtkQtBlackBoxDialogParent.h deleted file mode 100644 index 95f5a87..0000000 --- a/kernel/src/bbtkQtBlackBoxDialogParent.h +++ /dev/null @@ -1,20 +0,0 @@ -#include - -namespace bbtk -{ - class QtBlackBoxDialogParent : public WidgetBlackBoxWindow, - public QDialog - { - public: - QtBlackBoxDialogParent(QtBlackBox::Pointer box, - QWidget *parent) - : - WidgetBlackBoxWindow(box), - QDialog( parent ) - { - - } - - }; - -} diff --git a/kernel/src/bbtkSystem.h b/kernel/src/bbtkSystem.h index 740dcb9..cef7b64 100644 --- a/kernel/src/bbtkSystem.h +++ b/kernel/src/bbtkSystem.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkSystem.h,v $ Language: C++ - Date: $Date: 2009/05/25 12:48:57 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.14 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -246,3 +246,14 @@ namespace bbtk #ifdef _MSC_VER # define access _access #endif + + + + +//=========================================================== +// Define the groups (modules) for doxygen documentation +/** + * \defgroup box Black boxes related classes + * \defgroup interface Graphical User Interface components + * \defgroup data Data +*/ diff --git a/kernel/src/bbtkTranscriptor.cxx b/kernel/src/bbtkTranscriptor.cxx index 69e3456..9f73066 100644 --- a/kernel/src/bbtkTranscriptor.cxx +++ b/kernel/src/bbtkTranscriptor.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkTranscriptor.cxx,v $ Language: C++ - Date: $Date: 2009/05/28 08:12:06 $ - Version: $Revision: 1.16 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.17 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -269,7 +269,7 @@ namespace bbtk } /// prints the list of the boxes of the current descriptor - void Transcriptor::PrintBoxes() + void Transcriptor::PrintHelpListBoxes() { m_Fp << " e->PrintBoxes( );" << std::endl; } @@ -301,7 +301,7 @@ namespace bbtk } -void Transcriptor::ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) +void Transcriptor::PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) { } diff --git a/kernel/src/bbtkTranscriptor.h b/kernel/src/bbtkTranscriptor.h index dba498b..ca0a547 100644 --- a/kernel/src/bbtkTranscriptor.h +++ b/kernel/src/bbtkTranscriptor.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkTranscriptor.h,v $ Language: C++ - Date: $Date: 2008/12/12 12:11:21 $ - Version: $Revision: 1.13 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.14 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -165,7 +165,7 @@ namespace bbtk void Description(const std::string & d); /// prints the list off the boxes of the current box - void PrintBoxes(); + void PrintHelpListBoxes(); /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path std::string ShowGraph(const std::string &nameblackbox, @@ -179,8 +179,8 @@ namespace bbtk /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true); - /// Description of the actual pipeline - void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr); + /// Prints help on a black box + void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr); void Reset(); diff --git a/kernel/src/bbtkVirtualExec.h b/kernel/src/bbtkVirtualExec.h index d09ed5a..73010f2 100644 --- a/kernel/src/bbtkVirtualExec.h +++ b/kernel/src/bbtkVirtualExec.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkVirtualExec.h,v $ Language: C++ - Date: $Date: 2008/12/12 12:11:21 $ - Version: $Revision: 1.18 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.19 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -172,10 +172,10 @@ namespace bbtk /// The description string which explains what does the ComplexBox virtual void Description(const std::string &d) = 0; - /// prints the list off the boxes of the current box - virtual void PrintBoxes() = 0; + /// prints the list of the boxes of the current box + virtual void PrintHelpListBoxes() = 0; - /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path + /// Generate a HTML file with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path virtual std::string ShowGraph(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr, @@ -187,8 +187,8 @@ namespace bbtk /// Generate a HTML with a gif file with the actual pipeline (Graphviz-dot needed). Returns the file path virtual std::string ShowGraphInstances(const std::string &nameblackbox, int detail, int level, bool system_display=true) = 0; - /// Description of the actual pipeline - virtual void ShowRelations(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0; + /// Prints help on a black box + virtual void PrintHelpBlackBox(const std::string &nameblackbox, const std::string &detailStr, const std::string &levelStr) = 0; virtual void Reset() = 0; diff --git a/kernel/src/bbtkWidgetBlackBox.h b/kernel/src/bbtkWidgetBlackBox.h index 20dc069..fc09745 100644 --- a/kernel/src/bbtkWidgetBlackBox.h +++ b/kernel/src/bbtkWidgetBlackBox.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkWidgetBlackBox.h,v $ Language: C++ - Date: $Date: 2009/05/28 08:12:06 $ - Version: $Revision: 1.4 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.5 $ ========================================================================*/ @@ -94,7 +94,6 @@ namespace bbtk bool bbIsOutputWidgetConnected(); //================================================================== - void bbSetShown(bool); bool bbIsShown(); //================================================================== @@ -111,7 +110,7 @@ namespace bbtk protected: - + void bbSetShown(bool); //================================================================== /// Convenient method for layout widgets which creates and returns diff --git a/kernel/src/bbtkWxGUIPackageBrowser2.cxx b/kernel/src/bbtkWxGUIPackageBrowser2.cxx index 00a8c09..1593d3d 100644 --- a/kernel/src/bbtkWxGUIPackageBrowser2.cxx +++ b/kernel/src/bbtkWxGUIPackageBrowser2.cxx @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbtkWxGUIPackageBrowser2.cxx,v $ Language: C++ - Date: $Date: 2009/02/11 11:35:20 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009/06/08 14:50:04 $ + Version: $Revision: 1.13 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -992,9 +992,9 @@ namespace bbtk Package::Pointer P = i->second; if (P->GetName() == "user") continue; - Package::BlackBoxMapType::iterator j; - for (j=P->GetBlackBoxMap().begin(); - j!=P->GetBlackBoxMap().end(); + Package::DescriptorMapType::iterator j; + for (j=P->GetDescriptorMap().begin(); + j!=P->GetDescriptorMap().end(); ++j) { // std::cout << "Insert "<second->GetTypeName()< MagicBox::bbSetStatusAndPropagate(input," - <IsConnected()) - { - std::string do_input = c->GetConnection()->GetBlackBoxToInput(); - c->GetConnection()->TransferData(); - bbSetOutputOut( bbGetInput(do_input) ); - } - mCanSet = false; - } - BlackBox::bbSetStatusAndPropagate(c,s); - } void MagicBox::bbUserSetDefaultValues() { - mCanSet = true; } void MagicBox::bbUserInitializeProcessing() { @@ -69,7 +49,7 @@ namespace bbstd } void MagicBox::DoProcess() { - mCanSet = true; + bbSetOutputOut( bbGetInputIn() ); } BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,MagicBox); diff --git a/packages/std/src/bbstdMagicBox.h b/packages/std/src/bbstdMagicBox.h index ec5a169..4f0bebe 100644 --- a/packages/std/src/bbstdMagicBox.h +++ b/packages/std/src/bbstdMagicBox.h @@ -2,8 +2,8 @@ Program: bbtk Module: $RCSfile: bbstdMagicBox.h,v $ Language: C++ - Date: $Date: 2009/05/14 14:43:38 $ - Version: $Revision: 1.12 $ + Date: $Date: 2009/06/08 14:50:06 $ + Version: $Revision: 1.13 $ =========================================================================*/ /* --------------------------------------------------------------------- @@ -37,15 +37,6 @@ 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 @@ -53,28 +44,13 @@ public: \ public bbtk::AtomicBlackBox { BBTK_BLACK_BOX_INTERFACE(MagicBox,bbtk::AtomicBlackBox); - 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_INPUT(In,bbtk::Data); BBTK_DECLARE_OUTPUT(Out,bbtk::Data); BBTK_PROCESS(DoProcess); void DoProcess(); - protected: - // virtual void bbUserConstructor(); - virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c, - bbtk::IOStatus s); - bool mCanSet; }; //================================================================== -#undef BBTK_MB_DECLARE_INPUT //================================================================== // We have to create a particular SetFunctor for MagicBox because @@ -117,33 +93,14 @@ public: \ }; //=========================================================================== -#define MAGIC_BOX_INPUT(NAME) \ - AddInputDescriptor \ - (new bbtk::AtomicBlackBoxInputDescriptor \ - (typeid(MagicBoxDescriptor), \ - #NAME,"Input data","", \ - new bbtk::AtomicBlackBoxTGetFunctor \ - (&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. 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) - - /* + 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 (new bbtk::AtomicBlackBoxInputDescriptor (typeid(MagicBoxDescriptor), @@ -151,7 +108,7 @@ public: \ new bbtk::AtomicBlackBoxTGetFunctor (&MagicBox::bbGetInputIn), new MagicBoxSetFunctor (&MagicBox::bbSetInputIn) ) ); - */ + AddOutputDescriptor (new bbtk::AtomicBlackBoxOutputDescriptor (typeid(MagicBoxDescriptor), diff --git a/packages/std/src/bbstdSharedMemory.cxx b/packages/std/src/bbstdSharedMemory.cxx new file mode 100644 index 0000000..778e4c1 --- /dev/null +++ b/packages/std/src/bbstdSharedMemory.cxx @@ -0,0 +1,86 @@ +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbstdSharedMemory.cxx,v $ + Language: C++ + Date: $Date: 2009/06/08 14:50:06 $ + Version: $Revision: 1.1 $ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + + +#include "bbstdSharedMemory.h" +#include "bbstdPackage.h" +#include "bbtkBlackBoxOutputConnector.h" +using namespace bbtk; + +namespace bbstd +{ + + void SharedMemory::bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c, + bbtk::IOStatus s) + { + bbtkDebugMessageInc("change",5, + "=> SharedMemory::bbSetStatusAndPropagate(input," + <IsConnected()) + { + bbtkDebugMessageInc("change",5,"Input connected"<GetConnection()->TransferData(); + // Get the name of the input which changed + std::string input_name = c->GetConnection()->GetBlackBoxToInput(); + // Set the output to the value of the input which changed + bbSetOutputOut( bbGetInput(input_name) ); + } + // No more change allowed + mCanSet = false; + } + BlackBox::bbSetStatusAndPropagate(c,s); + } + + void SharedMemory::bbUserSetDefaultValues() + { + mCanSet = true; + } + void SharedMemory::bbUserInitializeProcessing() + { + } + void SharedMemory::bbUserFinalizeProcessing() + { + } + void SharedMemory::DoProcess() + { + mCanSet = true; + } + + BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,SharedMemory); + BBTK_BLACK_BOX_IMPLEMENTATION(SharedMemory,bbtk::AtomicBlackBox); + +} +// EO namespace bbstd diff --git a/packages/std/src/bbstdSharedMemory.h b/packages/std/src/bbstdSharedMemory.h new file mode 100644 index 0000000..f012e78 --- /dev/null +++ b/packages/std/src/bbstdSharedMemory.h @@ -0,0 +1,168 @@ +/*========================================================================= + Program: bbtk + Module: $RCSfile: bbstdSharedMemory.h,v $ + Language: C++ + Date: $Date: 2009/06/08 14:50:06 $ + Version: $Revision: 1.1 $ +=========================================================================*/ + +/* --------------------------------------------------------------------- + +* Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale) +* Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux +* +* This software is governed by the CeCILL-B license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL-B +* license as circulated by CEA, CNRS and INRIA at the following URL +* http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +* or in the file LICENSE.txt. +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited +* liability. +* +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL-B license and that you accept its terms. +* ------------------------------------------------------------------------ */ + + +#ifndef __bbstdSharedMemory_h_INCLUDED_H__ +#define __bbstdSharedMemory_h_INCLUDED_H__ + +#include "bbtkAtomicBlackBox.h" +#include "bbstd_EXPORT.h" + +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 SharedMemory + : + public bbtk::AtomicBlackBox + { + BBTK_BLACK_BOX_INTERFACE(SharedMemory,bbtk::AtomicBlackBox); + 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(); + protected: + // virtual void bbUserConstructor(); + virtual void bbSetStatusAndPropagate(bbtk::BlackBoxInputConnector* c, + bbtk::IOStatus s); + bool mCanSet; + }; + //================================================================== + +#undef BBTK_MB_DECLARE_INPUT + + //================================================================== + // We have to create a particular SetFunctor for SharedMemory because + // its input is of type bbtk::Data (i.e. any) and : + // 1) an any cannot store an any (construction with an any invokes the copy constr.) + // 2) we cannot invoke the Set method with the content of the any because + // it expects an any + // hence the Set method of the functor **MUST NOT** extract the + // content of the Data prior to invoking the set method of the box + class SharedMemorySetFunctor : public bbtk::AtomicBlackBoxSetFunctor + { + public: + /// Type of pointer on a UBB::Set method + typedef void (SharedMemory::*SetMethodPointerType)(bbtk::Data); + + /// Construction with the pointer on the Set method + SharedMemorySetFunctor(SetMethodPointerType s) : + mSetMethodPointer(s) + { + } + + /// Concrete application of the Set method of object o + void Set(bbtk::AtomicBlackBox* o, const bbtk::Data& d) + { + bbtkDebugMessage("data",9,"SharedMemorySetfunctor::Set("<< + bbtk::HumanTypeName(d.type())<< + ")"<*mSetMethodPointer)(d); + } + + /// + bbtk::TypeInfo GetTypeInfo() const { return typeid(bbtk::Data); } + std::string GetTypeName() const { return bbtk::TypeName(); } + std::string GetHumanTypeName() const { return bbtk::HumanTypeName(); } + bool IsPointerType() const { return false; } + void BruteForceSetPointer(bbtk::AtomicBlackBox*, void*) {} + private: + /// Pointer on the Set method + SetMethodPointerType mSetMethodPointer; + }; + //=========================================================================== + +#define MAGIC_BOX_INPUT(NAME) \ + AddInputDescriptor \ + (new bbtk::AtomicBlackBoxInputDescriptor \ + (typeid(SharedMemoryDescriptor), \ + #NAME,"Input data","", \ + new bbtk::AtomicBlackBoxTGetFunctor \ + (&SharedMemory::bbGetInput ## NAME), \ + new SharedMemorySetFunctor (&SharedMemory::bbSetInput ## NAME) ) ); + + //=========================================================================== + BBTK_BEGIN_DESCRIBE_BLACK_BOX(SharedMemory,bbtk::AtomicBlackBox); + BBTK_NAME("SharedMemory"); + BBTK_AUTHOR("laurent.guigues@creatis.insa-lyon.fr"); + BBTK_CATEGORY("misc"); + BBTK_DESCRIPTION("Implements a memory which can be shared by different boxes. The value of the output is the value of the lower index input which has changed. 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(SharedMemoryDescriptor), + "In","Input data","", + new bbtk::AtomicBlackBoxTGetFunctor + (&SharedMemory::bbGetInputIn), + new SharedMemorySetFunctor (&SharedMemory::bbSetInputIn) ) ); + */ + AddOutputDescriptor + (new bbtk::AtomicBlackBoxOutputDescriptor + (typeid(SharedMemoryDescriptor), + "Out","Output data","", + new bbtk::AtomicBlackBoxTGetFunctor + (&SharedMemory::bbGetOutputOut), + new SharedMemorySetFunctor (&SharedMemory::bbSetOutputOut) ) ); + BBTK_END_DESCRIBE_BLACK_BOX(SharedMemory); + //=========================================================================== + +} +// namespace bbstd + +#endif // __bbstdSharedMemory_h_INCLUDED_H__ diff --git a/packages/wx/bbs/appli/exampleSynchronizeWidgets.bbs b/packages/wx/bbs/appli/exampleSynchronizeWidgets.bbs index 1a46524..21b5a4b 100644 --- a/packages/wx/bbs/appli/exampleSynchronizeWidgets.bbs +++ b/packages/wx/bbs/appli/exampleSynchronizeWidgets.bbs @@ -10,7 +10,7 @@ new Slider slider2 new Slider slider3 new Slider slider4 new LayoutLine layout -new MagicBox position +new SharedMemory position set position.In 20 set position.BoxProcessMode Reactive @@ -29,8 +29,5 @@ 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