bbtkAtomicBlackBox.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkAtomicBlackBox.cxx,v $
00004   Language:  C++
00005   Date:      $Date: 2008/10/17 08:18:12 $
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 
00036 #include "bbtkAtomicBlackBox.h"
00037 
00038 namespace bbtk
00039 {
00040   
00041   //=========================================================================
00042   AtomicBlackBox::AtomicBlackBox(const std::string &name, bool alloc)
00043     : BlackBox(name)
00044   {
00045     bbtkDebugMessage("object",3,
00046                      "==> AtomicBlackBox::AtomicBlackBox(\""
00047                      <<name<<"\")"<<std::endl);
00048     bbtkDebugMessage("object",3,
00049                      "<== AtomicBlackBox::AtomicBlackBox(\""
00050                      <<name<<"\")"<<std::endl);
00051   }
00052   //========================================================================= 
00053   
00054   //=========================================================================
00056   AtomicBlackBox::AtomicBlackBox(AtomicBlackBox& from, 
00057                 const std::string &name, 
00058                 bool alloc)
00059     : BlackBox(from,name)
00060   {
00061     bbtkDebugMessage("object",3,
00062                      "==>AtomicBlackBox::AtomicBlackBox("
00063                      <<from.bbGetFullName()<<",\""
00064                      <<name<<"\")"<<std::endl);
00065     bbtkDebugMessage("object",3,
00066                      "<==AtomicBlackBox::AtomicBlackBox("
00067                      <<from.bbGetFullName()<<",\""
00068                      <<name<<"\")"<<std::endl);
00069     
00070   }
00071   //=========================================================================
00072   
00073   
00074   //=========================================================================
00076   AtomicBlackBox::~AtomicBlackBox()
00077   {
00078     bbtkDebugMessage("object",3,"==> AtomicBlackBox::~AtomicBlackBox()"
00079                      <<std::endl);
00080     bbtkDebugMessage("object",3,"<== AtomicBlackBox::~AtomicBlackBox()"
00081                      <<std::endl);
00082   } 
00083   //=========================================================================
00084   
00085 
00086 
00087   //=========================================================================
00089   IOStatus AtomicBlackBox::bbBackwardUpdate( Connection::Pointer caller )
00090   {
00091     bbtkDebugMessageInc("process",3,
00092                         "=> AtomicBlackBox::bbBackwardUpdate("
00093                         <<(caller?caller->GetFullName():"0")<<") ["
00094                         <<bbGetFullName()<<"]"<<std::endl);
00095     
00096     bbtkDebugMessage("process",5,"Initial Status  = "<<bbGetStatus()
00097                     <<std::endl);
00098     bbtkDebugMessage("process",5,"BoxProcessMode  = "
00099                     <<bbGetInputBoxProcessMode()<<std::endl);
00100    
00101 
00102     if ( ( bbGetStatus() == MODIFIED ) ||
00103         ( bbBoxProcessModeIsAlways() ) )
00104       {
00105 
00106         bbSetStatus(UPDATING);
00107         
00108         bool wasExecuting = bbGlobalGetSomeBoxExecuting();
00109         bbGlobalSetSomeBoxExecuting(true);
00110 
00111         // Updates its inputs
00112         IOStatus s = bbUpdateInputs();
00113     
00114         bbtkDebugMessage("process",6,"Inputs post-update status = "<<s<<std::endl);
00115         // If all inputs are in UPTODATE post-update status 
00116         // and mProcessMode is not "Always"
00117         // then the box is now UPTODATE
00118         IOStatus new_status;
00119         if ( ( s == UPTODATE ) && 
00120             ( ! bbBoxProcessModeIsAlways() ) ) 
00121             {
00122                 new_status = UPTODATE;
00123             }
00124         else 
00125             {
00126                 // else it remains MODIFIED
00127                  new_status = MODIFIED;
00128             }
00129         bbSetStatus(new_status);
00130 
00131         // User process
00132         bbProcess();
00133 
00134         // Displays the window (WxBlackbox)
00135         bbShowWindow(caller);
00136 
00137         bbGlobalSetSomeBoxExecuting(wasExecuting);
00138 
00139       }
00140     else 
00141       {
00142         bbtkDebugMessage("process",5,"Up-to-date : nothing to do"<<std::endl);
00143       }
00144 
00145     bbtkDebugMessage("process",5,"Final Status    = "
00146             <<bbGetStatus()<<std::endl);
00147     bbtkDebugMessage("process",3,
00148             "<= AtomicBlackBox::bbBackwardUpdate() ["
00149             <<bbGetFullName()<<"]"<<std::endl);
00150 
00151 
00152     return bbGetStatus();
00153 
00154   }
00155   //=========================================================================
00156   
00157     
00158   //=========================================================================
00159   Data AtomicBlackBox::bbGetOutput( const std::string &name )
00160   {
00161     bbtkDebugMessageInc("Data",7,
00162             "AtomicBlackBox::bbGetOutput(\""<<name<<"\") ["
00163             <<bbGetFullName()<<"]"
00164             <<std::endl);
00165     
00166     Data p = ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
00167                 ->GetOutputDescriptor(name))->GetGetFunctor()->Get(this);
00168     
00169     bbtkDebugDecTab("Data",7);
00170     return p;
00171   }
00172   //=========================================================================
00173   
00174   
00175   //=========================================================================
00177   Data AtomicBlackBox::bbGetInput( const std::string &name ) 
00178   {
00179     bbtkDebugMessageInc("Data",7,
00180             "AtomicBlackBox::bbGetInput(\""<<name<<"\") ["
00181             <<bbGetFullName()<<"]"
00182             <<std::endl);  
00183     
00184     Data p = ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
00185                 ->GetInputDescriptor(name))->GetGetFunctor()->Get(this);
00186     
00187     bbtkDebugDecTab("Data",7);
00188     return p;
00189   }
00190   //=========================================================================
00191   
00192   
00193   //=========================================================================
00195   void AtomicBlackBox::bbSetOutput( const std::string &name, Data data)
00196   {
00197     bbtkDebugMessageInc("Data",7,
00198             "AtomicBlackBox::bbSetOutput(\""<<name<<"\",data) ["
00199             <<bbGetFullName()<<"]"
00200             <<std::endl); 
00201     
00202     ((AtomicBlackBoxOutputDescriptor*)bbGetDescriptor()
00203         ->GetOutputDescriptor(name))->GetSetFunctor()->Set(this,data);
00204     
00205     bbtkDebugDecTab("Data",7);
00206   }  
00207   //=========================================================================
00208   
00209   
00210   //=========================================================================
00212   void AtomicBlackBox::bbSetInput(
00213                 const std::string &name,
00214                 Data data, 
00215                 bool setModified )
00216   {
00217     bbtkDebugMessageInc("Data",7,
00218             "AtomicBlackBox::bbSetInput(\""<<name<<"\",data) ["
00219             <<bbGetFullName()<<"]"
00220             <<std::endl);  
00221     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()->GetInputDescriptor(name))->GetSetFunctor()->Set(this,data);
00222     
00223     if (setModified) 
00224         {
00225             bbSetModifiedStatus();
00226         }
00227     
00228     bbtkDebugDecTab("Data",7);
00229   }
00230   //=========================================================================
00231   
00232     //=========================================================================
00234   void AtomicBlackBox::bbBruteForceSetInputPointer
00235     (
00236                     const std::string &name, 
00237                     void* data, 
00238                     bool setModified
00239     )
00240   {
00241     bbtkDebugMessageInc("Data",7,
00242             "AtomicBlackBox::bbBruteForceSetInputPointer(\""
00243             <<name<<"\",data) ["
00244             <<bbGetFullName()<<"]"
00245             <<std::endl);  
00246     ((AtomicBlackBoxInputDescriptor*)bbGetDescriptor()
00247         ->GetInputDescriptor(name))->GetSetFunctor()
00248             ->BruteForceSetPointer(this,data);
00249     
00250     if (setModified) 
00251       {
00252         bbSetModifiedStatus();
00253       }
00254     
00255     bbtkDebugDecTab("Data",7);
00256   }
00257   //=========================================================================
00258  
00259 
00260 
00261   //==========================================================================
00262   std::string AtomicBlackBox::GetObjectInfo() const 
00263   {
00264     std::stringstream i;
00265     return i.str();
00266   }
00267   //==========================================================================
00268 
00269   //==========================================================================
00270   size_t AtomicBlackBox::GetObjectSize() const 
00271   {
00272     return sizeof(*this);
00273   }
00274   //==========================================================================
00275   
00276   //==========================================================================
00277   size_t AtomicBlackBox::GetObjectRecursiveSize() const 
00278   {
00279     size_t s = GetObjectSize();
00280     return s;
00281   }
00282   //==========================================================================
00283 
00284  
00285 }
00286 // EO namespace bbtk

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