1 /*=========================================================================
3 Module: $RCSfile: bbtkConnection.h,v $
5 Date: $Date: 2008/11/13 14:46:43 $
6 Version: $Revision: 1.9 $
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 * ------------------------------------------------------------------------ */
33 *\brief Class bbtk::Connection
36 *\class bbtk::Connection
41 #ifndef __bbtkConnection_h__
42 #define __bbtkConnection_h__
44 #include "bbtkSystem.h"
45 #include "bbtkObject.h"
53 BBTK_FORWARD_DECLARE_POINTER(Factory);
55 BBTK_FORWARD_DECLARE_POINTER(BlackBox);
56 class BlackBoxInputConnector;
57 class BlackBoxOutputConnector;
62 const int MODIFIED = 0;
64 const int UPTODATE = 1;
66 /// const int UPDATING = 2;
69 class BBTK_EXPORT Connection : public Object
71 BBTK_OBJECT_INTERFACE(Connection);
72 typedef Object Superclass;
75 static Pointer New(BlackBoxPointer from, const std::string& output,
76 BlackBoxPointer to, const std::string& input,
77 const FactoryPointer f);
78 static Pointer New(BlackBoxPointer from, const std::string& output,
79 BlackBoxPointer to, const std::string& input);
85 /// Amont direction pipeline processing
86 /// 1) call bbBackwardUpdate(this) on the upstream box
87 /// 2) copies the upstream box output to the downstream box input adapting it if needed
88 virtual IOStatus BackwardUpdate();
90 /// Aval direction pipeline processing :
91 /// 1) copies the upstream box output to the downstream box input adapting it if needed
92 /// 2) call bbForwardUpdate(this) on the downstream box
93 // virtual void ForwardUpdate();
95 virtual void SetModifiedStatus();
96 std::string GetFullName() const;
98 /// Returns the original initial black box of the connection
99 BlackBoxPointer GetOriginalBlackBoxFrom() const { return mOriginalFrom.lock(); }
100 /// Returns the origianl final black box of the connection
101 BlackBoxPointer GetOriginalBlackBoxTo() const { return mOriginalTo.lock(); }
102 /// Returns the original output of the initial black box of the connection
103 const std::string& GetOriginalBlackBoxFromOutput() const { return mOriginalOutput; }
104 /// Returns the original input of the final black box of the connection
105 const std::string& GetOriginalBlackBoxToInput() const { return mOriginalInput; }
107 /// Returns the initial black box of the connection
108 BlackBoxPointer GetBlackBoxFrom() const { return mFrom; }
109 /// Returns the final black box of the connection
110 BlackBoxPointer GetBlackBoxTo() const { return mTo; }
111 /// Returns the output of the initial black box of the connection
112 const std::string& GetBlackBoxFromOutput() const { return mOutput; }
113 /// Returns the input of the final black box of the connection
114 const std::string& GetBlackBoxToInput() const { return mInput; }
116 /// Sets the initial black box of the connection
117 void SetBlackBoxFrom(BlackBoxPointer b) { mFrom = b; }
118 /// Sets the final black box of the connection
119 void SetBlackBoxTo(BlackBoxPointer b) { mTo = b; }
120 /// Sets the output of the initial black box of the connection
121 void SetBlackBoxFromOutput(const std::string& o) { mOutput = o; }
122 /// Sets the input of the final black box of the connection
123 void SetBlackBoxToInput(const std::string& o) { mInput = o; }
125 /// Checks that the connection is ok (throws error if not)
129 /// Black box origin of the connection
130 BlackBoxPointer mFrom;
131 BlackBoxWeakPointer mOriginalFrom;
132 /// Output of mFrom which is connected
134 std::string mOriginalOutput;
135 /// Output connector of mFrom which is connected
136 // BlackBoxOutputConnector* mOutputConnector;
137 /// Black box destination of the connection
139 BlackBoxWeakPointer mOriginalTo;
140 /// Input of mTo which is connected
142 std::string mOriginalInput;
143 /// Input connector of mTo which is connected
144 // BlackBoxInputConnector* mInputConnector;
145 /// Adaptor black box if needed
146 BlackBoxPointer mAdaptor;
148 /// The factory used to create adaptors
149 const FactoryWeakPointer mFactory;
151 /// Is the connection input type is any<thing> ?
154 /// Is the connection output type is any<thing> ?
158 /// Have to do dynamic_cast ?
161 /// Ctor with the black box from and to and their input and output
162 /// and a dummy int to differentiate from the public constructor.
163 /// Sets the members but does not test compatibility (used by bbtk::AdaptiveConnection)
164 // Connection(BlackBox* from, const std::string& output,
165 // BlackBox* to, const std::string& input, int );
171 Connection(BlackBoxPointer from, const std::string& output,
172 BlackBoxPointer to, const std::string& input,
173 const FactoryPointer f);
175 Connection(BlackBoxPointer from, const std::string& output,
176 BlackBoxPointer to, const std::string& input);