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: 2009/10/05 22:44:48 $
00006   Version:   $Revision: 1.8 $
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 "creaSystem.h"
00051 #include <list>
00052 
00053 namespace bbtk
00054 {
00055 
00056 
00057  
00058   //==================================================================
00059   class BBTK_EXPORT ComplexBlackBox : public bbtk::BlackBox
00060   {
00061     BBTK_OBJECT_INTERFACE(ComplexBlackBox);
00062     friend class ComplexBlackBoxDescriptor;
00063     typedef BlackBox Superclass;
00064   public: 
00065     //==================================================================
00066     // PUBLIC PART : ACCESSIBLE TO THE END-USER
00068     BlackBoxDescriptor::Pointer bbGetDescriptor() const { return mDescriptor.lock(); }
00070     //BlackBox* bbNew(const std::string& name);
00072     BlackBox::Pointer bbClone(const std::string& name);
00073 
00075     void Clear();
00077     void SetAsPrototype() { mLockedDescriptor.reset(); }
00079     bool IsAPrototype() const { return (!mLockedDescriptor); }
00080 
00081     std::string bbGetNameWithParent() const;
00082 
00083     void bbExecute(bool force = false);
00084   
00085     Data bbGetOutput( const std::string &label );
00086     Data bbGetInput ( const std::string &label );
00087     void bbSetOutput( const std::string &name, Data data);
00088     void bbSetInput ( const std::string &name, Data data,
00089                       bool setModified = true);
00090     void bbBruteForceSetInputPointer( const std::string &name, 
00091                                       void* data, 
00092                                       bool setModified = true);
00093 
00095     virtual void bbConnectInput( const std::string& name, Connection* c);
00097     virtual void bbConnectOutput( const std::string& name, Connection* c);
00098 
00099     BlackBox::Pointer bbGetBlackBox( const std::string& name );
00100 
00102     typedef std::map<std::string, BlackBox::Pointer> BlackBoxMapType;
00103 
00104     const BlackBoxMapType& bbGetBlackBoxMap() { return mBlackBoxMap; }
00105 
00106     void bbPrintBlackBoxes();
00107 
00115     void bbInsertHTMLGraph(  std::ofstream& s, 
00116                              int detail, 
00117                              int level,
00118                              bool instanceOrtype,
00119                              const std::string& output_dir,
00120                              bool relative_link );
00121 
00125     virtual void bbWriteDotFileBlackBox(FILE *ff,
00126                                         BlackBox::Pointer parentblackbox, 
00127                                         int detail, int level,
00128                                         bool instanceOrtype,
00129                                         bool relative_link );
00130     
00131     virtual void bbWriteDotInputOutputName(FILE *ff,
00132                                            bool inputoutput, 
00133                                            int detail, int level);
00134     
00135     virtual BlackBox::Pointer bbFindBlackBox(const std::string &blackboxname);
00136     
00137 
00138     void Check(bool recursive=true);
00139 
00140        
00141 
00142   protected:
00143     //==================================================================
00144     // PROTECTED PART : ACCESSIBLE TO ComplexBlackBoxDescriptor
00145     static ComplexBlackBox::Pointer 
00146     New(const std::string &name,
00147         ComplexBlackBoxDescriptor::Pointer desc);
00148                                  
00149   private:                       
00151     ComplexBlackBox(const std::string &name,
00152                     ComplexBlackBoxDescriptor::Pointer desc);
00154     ComplexBlackBox(ComplexBlackBox& from, const std::string &name);
00155     
00156   protected:
00157   
00158 
00159 
00160     void bbAddBlackBox( BlackBox::Pointer );
00161     void bbAddToExecutionList( const std::string& name );
00162     void bbUnsafeAddBlackBox( BlackBox::Pointer );
00163     void bbRemoveBlackBox( const std::string& name, 
00164                            bool remove_connections = true);
00165     void bbAddConnection( Connection::Pointer );
00166     
00167     //    void RemoveConnection( );
00168 
00169     BlackBox::Pointer bbUnsafeGetBlackBox( const std::string& name );
00170 
00172     void bbAllocateConnectors();
00173     void bbDesallocateConnectors();
00174 
00175   private:
00176     //==================================================================
00177     // PRIVATE PART : MEMBERS AND USEFULL INTERNAL METHODS
00178 
00180     //ComplexBlackBox() : BlackBox("") {}
00181     
00182     // true if the box is a prototype of a ComplexBlackBoxDescriptor
00183     //    bool mIsAPrototype;
00184 
00186     ComplexBlackBoxDescriptor::Pointer mLockedDescriptor;
00188     ComplexBlackBoxDescriptor::WeakPointer mDescriptor;
00189     
00191     BlackBoxMapType mBlackBoxMap;
00192     
00193     
00195     typedef std::list<Connection::Pointer> ConnectionListType;
00197     ConnectionListType mConnectionList;
00198 
00200     std::vector<std::string> mExecutionList;
00201     
00202   };
00203   // Class ComplexBlackBox
00204   //===========================================================================
00205 
00206 
00207 
00208 }
00209 // namespace bbtk
00210 
00211 
00212 //#include "bbtkComplexBlackBoxMacros.h"
00213 
00214 #endif
00215 

Generated on Thu May 31 14:12:03 2012 for BBTK by  doxygen 1.5.7.1