]> Creatis software - bbtk.git/blob - kernel/src/bbtkBlackBoxOutputConnector.cxx
*** empty log message ***
[bbtk.git] / kernel / src / bbtkBlackBoxOutputConnector.cxx
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
4   Language:  C++
5   Date:      $Date: 2008/10/17 08:18:12 $
6   Version:   $Revision: 1.8 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
14 *  This software is governed by the CeCILL-B license under French law and 
15 *  abiding by the rules of distribution of free software. You can  use, 
16 *  modify and/ or redistribute the software under the terms of the CeCILL-B 
17 *  license as circulated by CEA, CNRS and INRIA at the following URL 
18 *  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html 
19 *  or in the file LICENSE.txt.
20 *
21 *  As a counterpart to the access to the source code and  rights to copy,
22 *  modify and redistribute granted by the license, users are provided only
23 *  with a limited warranty  and the software's author,  the holder of the
24 *  economic rights,  and the successive licensors  have only  limited
25 *  liability. 
26 *
27 *  The fact that you are presently reading this means that you have had
28 *  knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /**
33  *  \file 
34  *  \brief Class bbtk::BlackBoxOutputConnector : 
35  */
36
37 #include "bbtkBlackBoxOutputConnector.h"
38 #include "bbtkMessageManager.h"
39 #include "bbtkBlackBox.h"
40 //#include <algorithm>
41
42 namespace bbtk
43 {
44
45   BlackBoxOutputConnector::BlackBoxOutputConnector() 
46   // : mStatus(MODIFIED)
47   {
48     bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::BlackBoxOutputConnector()"<<std::endl);
49   }
50
51   BlackBoxOutputConnector::~BlackBoxOutputConnector() 
52   {
53     bbtkDebugMessage("Kernel",9,
54                      "==> BlackBoxOutputConnector::~BlackBoxOutputConnector()"
55                      <<std::endl);
56     /*
57     ConnectionVector::iterator i;
58     for (i=mConnection.begin();
59          i!=mConnection.end();
60          ++i)
61       (*i) = Connection::WeakPointer();
62     */
63     mConnection.clear();
64     bbtkDebugMessage("Kernel",9,
65                      "<== BlackBoxOutputConnector::~BlackBoxOutputConnector()"
66                      <<std::endl);
67   }
68
69   ///
70   void BlackBoxOutputConnector::SetConnection(Connection* c)
71   {
72     bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::SetConnection("
73                      <<c<<")"<<std::endl);
74     mConnection.push_back(c);
75   }
76
77
78
79   ///
80   void BlackBoxOutputConnector::UnsetConnection(Connection* c)
81   {
82     bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection("
83                      <<c<<")"<<std::endl);
84
85     if (!c) 
86       {
87         bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : invalid connection");
88
89       }
90     //    c->Check();
91     //Connection::WeakPointer w(c);
92     ConnectionVector::iterator i;
93     //  = find(mConnection.begin(),mConnection.end(),c);
94     for (i=mConnection.begin();
95          i!=mConnection.end();
96          ++i)
97       {
98         if (*i==c) break;
99       }
100     if (i==mConnection.end())
101       {
102         bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : connection is absent from connections list");
103       }
104     mConnection.erase(i);
105
106     bbtkDebugDecTab("Kernel",9);
107   }
108
109
110   
111   void BlackBoxOutputConnector::SetModifiedStatus()
112   {
113     bbtkDebugMessage("modified",2,
114                      "==> BlackBoxOutputConnector::SetModifiedStatus() ["
115                      <<this<<"]"
116                      <<std::endl);
117     ConnectionVector::iterator i;
118     for (i=mConnection.begin();i!=mConnection.end();++i) 
119       {
120         (*i)->SetModifiedStatus();
121       }
122     
123     
124    }
125  
126
127
128 }
129 // namespace bbtk
130