/*========================================================================= Program: bbtk Module: $RCSfile: bbtkAtomicBlackBox.h,v $ Language: C++ Date: $Date: 2008/02/07 11:06:37 $ Version: $Revision: 1.1 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =========================================================================*/ /** * \file * \brief class bbtk::AtomicBlackBox : ancestor of all user defined (concrete) black boxes which are atomic (vs. complex boxes which are made up of other (atomic or complex) boxes). */ /** * \class bbtk::AtomicBlackBox * \brief Ancestor of all user defined (concrete) black boxes which are atomic (vs. complex boxes which are made up of other (atomic or complex) boxes). */ #ifndef __bbtkAtomicBlackBox_h__ #define __bbtkAtomicBlackBox_h__ #include "bbtkBlackBox.h" #include "bbtkAtomicBlackBoxDescriptor.h" namespace bbtk { //================================================================== class BBTK_EXPORT AtomicBlackBox : public bbtk::BlackBox { //================================================================== public: //================================================================== /// Gets the output Data of a given label Data bbGetOutput( const std::string &label ); /// Gets the input Data of a given label Data bbGetInput( const std::string &label ); /// Sets the data of the output called void bbSetOutput( const std::string &name, Data data); /// Sets the data of the input called void bbSetInput( const std::string &name, Data data, bool setModified = true); /// Sets the data of the input called void bbBruteForceSetInputPointer( const std::string &name, void* data, bool setModified = true); //================================================================== //================================================================== /// Destructor virtual ~AtomicBlackBox(); //================================================================== //================================================================== protected: //================================================================== /// Constructor with the AtomicBlackBox's instance name AtomicBlackBox(const std::string &name, bool alloc = true); /// Constructor from an existing box (copy) with a new instance name AtomicBlackBox(AtomicBlackBox& from, const std::string &name, bool alloc = true); //================================================================== public: //================================================================== /// Recursive pipeline processing in backward direction /// (recursion is in backward direction however execution always goes forward). /// /// \returns The final status of the box (UPTODATE or MODIFIED) /// /// First checks that re-processing is needed (either Status==MODIFIED or InputProcessMode==Always) /// then : /// - updates its inputs by calling bbUpdateInputs (which recursively calls bbBackwardUpdate on amont boxes) /// - calls bbProcess which here simply calls the user callback bbUserProcess which does the actual processing. /// bbProcess is overloaded in WxBlackBox to handle widget creation and show IOStatus bbBackwardUpdate(Connection* caller); //================================================================== //================================================================== protected: //================================================================== /// Calls the user defined processing method. /// Overloaded in WxBlackBox to handle widget creation and show virtual void bbProcess() { this->bbUserProcess(); } //================================================================== //================================================================== /// User callback which computes the outputs as a function of the inputs. /// It is assumed to be deterministic and thus is only called is the inputs have changed /// (i.e. if the black box is marked as modified) virtual void bbUserProcess() { bbtkWarning("AtomicBlackBox::bbUserProcess() not overloaded for box '" <