bbtkBlackBoxInputConnector.cxx

Go to the documentation of this file.
00001 /*=========================================================================                                                                               
00002   Program:   bbtk
00003   Module:    $RCSfile: bbtkBlackBoxInputConnector.cxx,v $
00004   Language:  C++
00005   Date:      $Date: 2009/06/08 14:50:02 $
00006   Version:   $Revision: 1.11 $
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 "bbtkBlackBoxInputConnector.h"
00037 #include "bbtkMessageManager.h"
00038 #include "bbtkBlackBox.h"
00039 
00040 namespace bbtk
00041 {
00042 
00043   //========================================================================
00045   class BlackBoxInputConnector::Pimpl
00046   {
00047   public:
00048     Pimpl() : mConnection(0), mStatus(MODIFIED) {}
00049       
00051     BlackBoxWeakPointer mBox;
00053     Connection* mConnection;
00055     IOStatus mStatus;
00056 
00057   };
00058   //========================================================================
00059 
00060   //========================================================================
00061   BBTK_IMPL_PIMPL(BlackBoxInputConnector)
00062   //========================================================================
00063 
00064 
00065   //========================================================================
00066   BlackBoxInputConnector::BlackBoxInputConnector(BlackBox::Pointer b)  
00067   //: mBox(b), mConnection(0), mStatus(MODIFIED)
00068   {
00069     bbtkDebugMessage("kernel",9,
00070                      "["<<b->bbGetName()
00071                      <<"] BlackBoxInputConnector()"<<std::endl);
00072     PimplConstruct();
00073     p->mBox = b;
00074   }
00075   //========================================================================
00076 
00077   //========================================================================
00078   BlackBoxInputConnector::~BlackBoxInputConnector() 
00079   {
00080     bbtkDebugMessage("kernel",9,
00081                      "[DEAD BOX] ~BlackBoxInputConnector()"
00082                      <<std::endl);
00083     PimplDestruct();
00084   }
00085   //========================================================================
00086 
00087   //========================================================================
00089   Connection* BlackBoxInputConnector::GetConnection() const 
00090   { 
00091     return p->mConnection; 
00092   }
00093   //========================================================================
00094   
00095 
00096   //========================================================================
00098     bool BlackBoxInputConnector::IsConnected() const 
00099   { 
00100     return (p->mConnection != 0); 
00101   }
00102    //========================================================================
00103    
00104 
00105    //========================================================================
00107     IOStatus BlackBoxInputConnector::GetStatus() const 
00108    { 
00109      return p->mStatus; 
00110    }
00111   //========================================================================
00112 
00113   //========================================================================
00115     void BlackBoxInputConnector::SetStatus(IOStatus s) 
00116     { 
00117       p->mStatus = s; 
00118     }
00119    //========================================================================
00120    
00121     
00122 
00123   //========================================================================
00125     BlackBoxPointer BlackBoxInputConnector::GetBlackBox() const 
00126     { 
00127       return p->mBox.lock(); 
00128     } 
00129 
00130   //========================================================================
00131 
00132   //========================================================================
00133   void BlackBoxInputConnector::SetConnection(Connection* c) 
00134   { 
00135     bbtkDebugMessage("kernel",9,
00136                      "["<<p->mBox.lock()->bbGetName()
00137                      <<"] BlackBoxInputConnector::SetConnection("<<c<<")"<<std::endl);
00138     p->mConnection = c; 
00139   }
00140   //========================================================================
00141 
00142   //========================================================================
00143   void BlackBoxInputConnector::UnsetConnection(Connection* c) 
00144   { 
00145     bbtkDebugMessage("kernel",9,
00146                      "["<<p->mBox.lock()->bbGetName()
00147                      <<"] BlackBoxInputConnector::UnsetConnection("
00148                      <<c<<")"<<std::endl);
00149     p->mConnection = 0; 
00150   }
00151   //========================================================================
00152   
00153   //========================================================================
00154   void BlackBoxInputConnector::RecursiveExecute()
00155   {
00156     // If connected and OUTOFDATE : recursive update
00157     // Post-update status is updated by the connection 
00158     // (either MODIFIED or OUTOFDATE)
00159     if ( p->mConnection && (p->mStatus == OUTOFDATE) )
00160       {
00161         p->mConnection->RecursiveExecute();
00162       }
00163     else
00164       {
00165         if (!p->mBox.expired())
00166           bbtkDebugMessage("process",5,"["<<p->mBox.lock()->bbGetName()
00167                            <<"] --> BlackBoxInputConnector::RecursiveExecute() : "
00168                            <<"No connection or input not Out-of-date : nothing to do"
00169                            <<std::endl);
00170         else
00171           bbtkDebugMessage("process",5,
00172                            "[DEAD BOX] --> BlackBoxInputConnector::RecursiveExecute() : "
00173                            <<"No connection or input not Out-of-date : nothing to do"
00174                            <<std::endl);
00175           
00176       }
00177   }
00178   //========================================================================
00179 
00180 }
00181 // namespace bbtk
00182 

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