bbtkComplexBlackBox.h

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkComplexBlackBox.h,v $
00004   Language:  C++
00005   Date:      $Date: 2008/10/17 08:18:12 $
00006   Version:   $Revision: 1.5 $
00007 =========================================================================*/
00008 
00009 /* ---------------------------------------------------------------------
00010 
00011 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
00012 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
00013 *
00014 *  This software is governed by the CeCILL-B license under French law and 
00015 *  abiding by the rules of distribution of free software. You can  use, 
00016 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
00017 *  license as circulated by CEA, CNRS and INRIA at the following URL 
00018 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
00019 *  or in the file LICENSE.txt.
00020 *
00021 *  As a counterpart to the access to the source code and  rights to copy,
00022 *  modify and redistribute granted by the license, users are provided only
00023 *  with a limited warranty  and the software's author,  the holder of the
00024 *  economic rights,  and the successive licensors  have only  limited
00025 *  liability. 
00026 *
00027 *  The fact that you are presently reading this means that you have had
00028 *  knowledge of the CeCILL-B license and that you accept its terms.
00029 * ------------------------------------------------------------------------ */                                                                         
00030 
00031 
00032 
00043 #ifndef __bbtkComplexBlackBox_h__
00044 #define __bbtkComplexBlackBox_h__
00045 
00046 #include "bbtkBlackBox.h"
00047 #include "bbtkComplexBlackBoxDescriptor.h"
00048 //#include "bbtkComplexBlackBoxInputDescriptor.h"
00049 //#include "bbtkComplexBlackBoxOutputDescriptor.h"
00050 #include <list>
00051 
00052 namespace bbtk
00053 {
00054 
00055 
00056  
00057   //==================================================================
00058   class BBTK_EXPORT ComplexBlackBox : public bbtk::BlackBox
00059   {
00060     BBTK_OBJECT_INTERFACE(ComplexBlackBox);
00061     friend class ComplexBlackBoxDescriptor;
00062     typedef BlackBox Superclass;
00063   public: 
00064     //==================================================================
00065     // PUBLIC PART : ACCESSIBLE TO THE END-USER
00067     BlackBoxDescriptor::Pointer bbGetDescriptor() const { return mDescriptor.lock(); }
00069     //BlackBox* bbNew(const std::string& name);
00071     BlackBox::Pointer bbClone(const std::string& name);
00072 
00074     void Clear();
00076     void SetAsPrototype() { mLockedDescriptor.reset(); }
00078     bool IsAPrototype() const { return (!mLockedDescriptor); }
00079 
00080     std::string bbGetNameWithParent() const;
00081 
00082     void bbExecute(bool force = false);
00083   
00084     Data bbGetOutput( const std::string &label );
00085     Data bbGetInput ( const std::string &label );
00086     void bbSetOutput( const std::string &name, Data data);
00087     void bbSetInput ( const std::string &name, Data data,
00088                       bool setModified = true);
00089     void bbBruteForceSetInputPointer( const std::string &name, 
00090                                       void* data, 
00091                                       bool setModified = true);
00092 
00094     virtual void bbConnectInput( const std::string& name, Connection* c);
00096     virtual void bbConnectOutput( const std::string& name, Connection* c);
00097 
00098     BlackBox::Pointer bbGetBlackBox( const std::string& name );
00099 
00101     typedef std::map<std::string, BlackBox::Pointer> BlackBoxMapType;
00102 
00103     const BlackBoxMapType& bbGetBlackBoxMap() { return mBlackBoxMap; }
00104 
00105     void bbPrintBlackBoxes();
00106 
00114     void bbInsertHTMLGraph(  std::ofstream& s, 
00115                              int detail, 
00116                              int level,
00117                              bool instanceOrtype,
00118                              const std::string& output_dir,
00119                              bool relative_link );
00120 
00124     virtual void bbWriteDotFileBlackBox(FILE *ff,
00125                                         BlackBox::Pointer parentblackbox, 
00126                                         int detail, int level,
00127                                         bool instanceOrtype,
00128                                         bool relative_link );
00129     
00130     virtual void bbWriteDotInputOutputName(FILE *ff,
00131                                            bool inputoutput, 
00132                                            int detail, int level);
00133     
00134     virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname);
00135     
00136 
00137     void Check(bool recursive=true);
00138 
00139        
00140 
00141   protected:
00142     //==================================================================
00143     // PROTECTED PART : ACCESSIBLE TO ComplexBlackBoxDescriptor
00144     static ComplexBlackBox::Pointer 
00145     New(const std::string &name,
00146         ComplexBlackBoxDescriptor::Pointer desc);
00147                                  
00148   private:                       
00150     ComplexBlackBox(const std::string &name,
00151                     ComplexBlackBoxDescriptor::Pointer desc);
00153     ComplexBlackBox(ComplexBlackBox& from, const std::string &name);
00154     
00155   public:
00156     IOStatus bbBackwardUpdate(Connection::Pointer caller);
00157     //  void bbForwardUpdate(Connection* caller);
00158     void bbSetModifiedStatus(BlackBoxInputConnector* c);
00159 
00160   protected:
00161   
00162 
00163 
00164     void bbAddBlackBox( BlackBox::Pointer );
00165     void bbAddToExecutionList( const std::string& name );
00166     void bbUnsafeAddBlackBox( BlackBox::Pointer );
00167     void bbRemoveBlackBox( const std::string& name, 
00168                            bool remove_connections = true);
00169     void bbAddConnection( Connection::Pointer );
00170     
00171     //    void RemoveConnection( );
00172 
00173     BlackBox::Pointer bbUnsafeGetBlackBox( const std::string& name );
00174 
00176     void bbAllocateConnectors();
00177     void bbDesallocateConnectors();
00178 
00179   private:
00180     //==================================================================
00181     // PRIVATE PART : MEMBERS AND USEFULL INTERNAL METHODS
00182 
00184     //ComplexBlackBox() : BlackBox("") {}
00185     
00186     // true if the box is a prototype of a ComplexBlackBoxDescriptor
00187     //    bool mIsAPrototype;
00188 
00190     ComplexBlackBoxDescriptor::Pointer mLockedDescriptor;
00192     ComplexBlackBoxDescriptor::WeakPointer mDescriptor;
00193     
00195     BlackBoxMapType mBlackBoxMap;
00196     
00197     
00199     typedef std::list<Connection::Pointer> ConnectionListType;
00201     ConnectionListType mConnectionList;
00202 
00204     std::vector<std::string> mExecutionList;
00205     
00206   };
00207   // Class ComplexBlackBox
00208   //===========================================================================
00209 
00210 
00211 
00212 }
00213 // namespace bbtk
00214 
00215 
00216 //#include "bbtkComplexBlackBoxMacros.h"
00217 
00218 #endif
00219 

Generated on Wed Nov 12 11:37:08 2008 for BBTK by  doxygen 1.5.6