]> Creatis software - bbtk.git/blob - kernel/src/bbtkBlackBoxOutputConnector.cxx
=== MAJOR RELEASE ====
[bbtk.git] / kernel / src / bbtkBlackBoxOutputConnector.cxx
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
5   Language:  C++
6   Date:      $Date: 2008/04/18 12:59:15 $
7   Version:   $Revision: 1.4 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/bbtk/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18
19 /**
20  *  \file 
21  *  \brief Class bbtk::BlackBoxOutputConnector : 
22  */
23
24 #include "bbtkBlackBoxOutputConnector.h"
25 #include "bbtkMessageManager.h"
26 #include "bbtkBlackBox.h"
27 //#include <algorithm>
28
29 namespace bbtk
30 {
31
32   BlackBoxOutputConnector::BlackBoxOutputConnector() 
33   // : mStatus(MODIFIED)
34   {
35     bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::BlackBoxOutputConnector()"<<std::endl);
36   }
37
38   BlackBoxOutputConnector::~BlackBoxOutputConnector() 
39   {
40     bbtkDebugMessage("Kernel",9,
41                      "==> BlackBoxOutputConnector::~BlackBoxOutputConnector()"
42                      <<std::endl);
43     ConnectionVector::iterator i;
44     for (i=mConnection.begin();
45          i!=mConnection.end();
46          ++i)
47       (*i) = Connection::WeakPointer();
48     bbtkDebugMessage("Kernel",9,
49                      "<== BlackBoxOutputConnector::~BlackBoxOutputConnector()"
50                      <<std::endl);
51   }
52
53   ///
54   void BlackBoxOutputConnector::SetConnection(Connection::Pointer c)
55   {
56     bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::SetConnection("
57                      <<c<<")"<<std::endl);
58     mConnection.push_back(c);
59   }
60
61
62
63   ///
64   void BlackBoxOutputConnector::UnsetConnection(Connection::Pointer c)
65   {
66     bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection("
67                      <<c<<")"<<std::endl);
68
69     if (!c) 
70       {
71         bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : invalid connection");
72
73       }
74     //    c->Check();
75     //Connection::WeakPointer w(c);
76     ConnectionVector::iterator i;
77     //      = find(mConnection.begin(),mConnection.end(),c);
78     for (i=mConnection.begin();
79          i!=mConnection.end();
80          ++i)
81       {
82         if (i->lock()==c) break;
83       }
84     if (i==mConnection.end())
85       {
86         bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : connection is absent from connections list");
87       }
88     mConnection.erase(i);
89
90     bbtkDebugDecTab("Kernel",9);
91   }
92
93
94   
95   void BlackBoxOutputConnector::SetModifiedStatus()
96   {
97     bbtkDebugMessageInc("Process",5,
98                         "BlackBoxOutputConnector::SetModifiedStatus()"
99                         <<std::endl);
100     ConnectionVector::iterator i;
101     for (i=mConnection.begin();i!=mConnection.end();++i) 
102       {
103         (*i).lock()->SetModifiedStatus();
104       }
105     
106     bbtkDebugDecTab("Process",5);
107     
108    }
109  
110
111
112 }
113 // namespace bbtk
114