1 /*=========================================================================
3 Module: $RCSfile: bbtkBlackBoxOutputConnector.cxx,v $
5 Date: $Date: 2008/12/08 14:02:15 $
6 Version: $Revision: 1.10 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
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.
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
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 * ------------------------------------------------------------------------ */
34 * \brief Class bbtk::BlackBoxOutputConnector :
37 #include "bbtkBlackBoxOutputConnector.h"
38 #include "bbtkMessageManager.h"
39 #include "bbtkBlackBox.h"
40 //#include <algorithm>
45 //======================================================================
46 BlackBoxOutputConnector::BlackBoxOutputConnector()
49 bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::BlackBoxOutputConnector()"<<std::endl);
51 //======================================================================
54 //======================================================================
55 BlackBoxOutputConnector::~BlackBoxOutputConnector()
57 bbtkDebugMessage("Kernel",9,
58 "==> BlackBoxOutputConnector::~BlackBoxOutputConnector()"
61 ConnectionVector::iterator i;
62 for (i=mConnection.begin();
65 (*i) = Connection::WeakPointer();
68 bbtkDebugMessage("Kernel",9,
69 "<== BlackBoxOutputConnector::~BlackBoxOutputConnector()"
72 //======================================================================
74 //======================================================================
76 void BlackBoxOutputConnector::SetConnection(Connection* c)
78 bbtkDebugMessage("Kernel",9,"BlackBoxOutputConnector::SetConnection("
80 mConnection.push_back(c);
81 // AddChangeObserver(boost::bind(&Connection::SignalChange,c));
83 //======================================================================
86 //======================================================================
87 void BlackBoxOutputConnector::UnsetConnection(Connection* c)
89 bbtkDebugMessageInc("Kernel",9,"BlackBoxOutputConnector::UnsetConnection("
94 bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : invalid connection");
98 //Connection::WeakPointer w(c);
99 ConnectionVector::iterator i;
100 // = find(mConnection.begin(),mConnection.end(),c);
101 for (i=mConnection.begin();
102 i!=mConnection.end();
107 if (i==mConnection.end())
109 bbtkInternalError("BlackBoxOutputConnector::UnsetConnection("<<c<<") : connection is absent from connections list");
111 mConnection.erase(i);
112 // RemoveChangeObserver(boost::bind(&Connection::SignalChange,c));
114 bbtkDebugDecTab("Kernel",9);
116 //======================================================================
119 //======================================================================
120 void BlackBoxOutputConnector::SignalChange( BlackBox::Pointer box,
121 const std::string& output )
123 IOStatus s = OUTOFDATE; //mStatus;
124 //if (s==UPTODATE) s=MODIFIED;
126 bbtkDebugMessage("change",2,
127 "==> BlackBoxOutputConnector::SignalChange("
128 <<box->bbGetFullName()<<",'"
129 <<output<<"','"<<GetIOStatusString(s)<<"') ["
133 mChangeSignal(box,output,s);
135 bbtkDebugMessage("change",2,
136 "<== BlackBoxOutputConnector::SignalChange("
137 <<box->bbGetFullName()<<",'"
138 <<output<<"','"<<GetIOStatusString(s)<<"') ["
142 //======================================================================
144 void BlackBoxOutputConnector::SetModifiedStatus()
146 bbtkDebugMessage("modified",2,
147 "==> BlackBoxOutputConnector::SetModifiedStatus() ["
150 ConnectionVector::iterator i;
151 for (i=mConnection.begin();i!=mConnection.end();++i)
153 (*i)->SetModifiedStatus();
160 //======================================================================
161 void BlackBoxOutputConnector::SetChangeTime(const ChangeTime& t)
163 bbtkDebugMessage("change",2,
164 "==> BlackBoxOutputConnector::SetChangeTime("<<t<<") ["
167 if (mChangeTime.Set(t))
171 bbtkDebugMessage("change",2,
172 "<== BlackBoxOutputConnector::SetChangeTime("<<t<<") ["
176 //======================================================================
179 //======================================================================
180 void BlackBoxOutputConnector::SetChangeTimeToCurrentTime()
182 bbtkDebugMessage("change",2,
183 "==> BlackBoxOutputConnector::SetChangeTimetoCurrentTime() ["
186 mChangeTime.Set(ChangeTime::GetCurrentTime());
189 bbtkDebugMessage("change",2,
190 "<==> BlackBoxOutputConnector::SetChangeTimetoCurrentTime() ["
194 //======================================================================
198 //======================================================================
199 void BlackBoxOutputConnector::AddChangeObserver(OutputChangeCallbackType f)
201 mChangeSignal.connect(f);
203 //======================================================================
205 //======================================================================
206 /// Removes the function f from the list of functions to call when
207 /// the output changes (TO WRITE)
208 void BlackBoxOutputConnector::RemoveChangeObserver(OutputChangeCallbackType f)
210 bbtkError("BlackBoxOutputConnector::RemoveChangeObserver not implemented");
212 //mChangeSignal.disconnect(f);
214 //======================================================================