2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbtkConnection.h,v $
32 Date: $Date: 2012/11/16 08:49:01 $
33 Version: $Revision: 1.14 $
34 =========================================================================*/
40 *\brief Class bbtk::Connection
43 *\class bbtk::Connection
48 #ifndef __bbtkConnection_h__
49 #define __bbtkConnection_h__
51 #include "bbtkSystem.h"
52 #include "bbtkObject.h"
60 BBTK_FORWARD_DECLARE_POINTER(Factory);
62 BBTK_FORWARD_DECLARE_POINTER(BlackBox);
63 class BlackBoxInputConnector;
64 class BlackBoxOutputConnector;
66 /// The type of input / output status
67 typedef unsigned char IOStatus;
68 /// Up-to-date status value
69 const IOStatus UPTODATE = 0;
70 /// Modified status value
71 const IOStatus MODIFIED = 1;
72 /// Out-of-date status value
73 const IOStatus OUTOFDATE = 2;
75 BBTK_EXPORT const std::string& GetIOStatusString( IOStatus );
78 class BBTK_EXPORT Connection : public Object
80 BBTK_OBJECT_INTERFACE(Connection);
81 typedef Object Superclass;
84 static Pointer New(BlackBoxPointer from, const std::string& output,
85 BlackBoxPointer to, const std::string& input,
86 const FactoryPointer f);
87 static Pointer New(BlackBoxPointer from, const std::string& output,
88 BlackBoxPointer to, const std::string& input);
94 /// Pipeline processing method
95 /// 1) call bbRecursiveExecute(this) on the from box
96 /// 2) copies the from box output to the to box input
97 /// adapting it if needed
98 /// 3) sets the new IOStatus of the to box input to the
99 /// status of the from box output
100 void RecursiveExecute();
103 void OnOutputChange(BlackBoxPointer, const std::string&,
106 std::string GetFullName() const;
108 /// Returns the original initial black box of the connection
109 BlackBoxPointer GetOriginalBlackBoxFrom() const { return mOriginalFrom.lock(); }
110 /// Returns the origianl final black box of the connection
111 BlackBoxPointer GetOriginalBlackBoxTo() const { return mOriginalTo.lock(); }
112 /// Returns the original output of the initial black box of the connection
113 const std::string& GetOriginalBlackBoxFromOutput() const { return mOriginalOutput; }
114 /// Returns the original input of the final black box of the connection
115 const std::string& GetOriginalBlackBoxToInput() const { return mOriginalInput; }
117 /// Returns the initial black box of the connection
118 BlackBoxPointer GetBlackBoxFrom() const { return mFrom; }
119 /// Returns the final black box of the connection
120 BlackBoxPointer GetBlackBoxTo() const { return mTo; }
121 /// Returns the output of the initial black box of the connection
122 const std::string& GetBlackBoxFromOutput() const { return mOutput; }
123 /// Returns the input of the final black box of the connection
124 const std::string& GetBlackBoxToInput() const { return mInput; }
126 /// Sets the initial black box of the connection
127 void SetBlackBoxFrom(BlackBoxPointer b) { mFrom = b; }
128 /// Sets the final black box of the connection
129 void SetBlackBoxTo(BlackBoxPointer b) { mTo = b; }
130 /// Sets the output of the initial black box of the connection
131 void SetBlackBoxFromOutput(const std::string& o) { mOutput = o; }
132 /// Sets the input of the final black box of the connection
133 void SetBlackBoxToInput(const std::string& o) { mInput = o; }
135 /// Checks that the connection is ok (throws error if not)
139 /// Black box origin of the connection
140 BlackBoxPointer mFrom;
141 BlackBoxWeakPointer mOriginalFrom;
142 /// Output of mFrom which is connected
144 std::string mOriginalOutput;
145 /// Output connector of mFrom which is connected
146 // BlackBoxOutputConnector* mOutputConnector;
147 /// Black box destination of the connection
149 BlackBoxWeakPointer mOriginalTo;
150 /// Input of mTo which is connected
152 std::string mOriginalInput;
153 /// Input connector of mTo which is connected
154 // BlackBoxInputConnector* mInputConnector;
155 /// Adaptor black box if needed
156 BlackBoxPointer mAdaptor;
158 /// The factory used to create adaptors
159 const FactoryWeakPointer mFactory;
161 /// Is the connection input type is any<thing> ?
164 /// Is the connection output type is any<thing> ?
168 /// Have to do dynamic_cast ?
171 /// Ctor with the black box from and to and their input and output
172 /// and a dummy int to differentiate from the public constructor.
173 /// Sets the members but does not test compatibility (used by bbtk::AdaptiveConnection)
174 // Connection(BlackBox* from, const std::string& output,
175 // BlackBox* to, const std::string& input, int );
181 Connection(BlackBoxPointer from, const std::string& output,
182 BlackBoxPointer to, const std::string& input,
183 const FactoryPointer f);
185 Connection(BlackBoxPointer from, const std::string& output,
186 BlackBoxPointer to, const std::string& input);