]> Creatis software - bbtk.git/blob - kernel/src/bbtkConnection.h
47c8e92a0da593a0e1d9eab6ccb190f7ae642456
[bbtk.git] / kernel / src / bbtkConnection.h
1 /*=========================================================================
2                                                                                 
3   Program:   bbtk
4   Module:    $RCSfile: bbtkConnection.h,v $
5   Language:  C++
6   Date:      $Date: 2008/04/08 06:59:30 $
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  *\file
20  *\brief Class bbtk::Connection
21  */
22 /**
23  *\class bbtk::Connection
24  *\brief DDD
25  *
26  */
27
28 #ifndef __bbtkConnection_h__
29 #define __bbtkConnection_h__
30
31 #include "bbtkSystem.h"
32
33 #include <string>
34
35 namespace bbtk
36 {
37
38   class Factory;
39
40   /// 
41   typedef int IOStatus;
42   /// 
43   const int MODIFIED = 0;
44   /// 
45   const int UPTODATE = 1;
46   /// 
47   const int UPDATING = 2;
48
49   class BlackBox;
50   class BlackBoxInputConnector;
51   class BlackBoxOutputConnector;
52
53   class BBTK_EXPORT Connection
54   {
55   public:
56     /// Ctor 
57     Connection(BlackBox* from, const std::string& output,
58                BlackBox* to, const std::string& input,
59                const Factory* f);
60     /// Dtor
61     ~Connection();
62
63     void Clear();
64     
65     /// Amont direction pipeline processing
66     /// 1) call bbBackwardUpdate(this) on the upstream box
67     /// 2) copies the upstream box output to the downstream box input adapting it if needed
68     virtual IOStatus BackwardUpdate();
69
70     /// Aval direction pipeline processing :
71     /// 1) copies the upstream box output to the downstream box input adapting it if needed
72     /// 2) call bbForwardUpdate(this) on the downstream box
73     //    virtual void ForwardUpdate();
74
75     virtual void SetModifiedStatus();
76     std::string GetFullName() const; 
77
78     /// Returns the initial black box of the connection
79     BlackBox* GetBlackBoxFrom() const { return mFrom; }
80     /// Returns the final black box of the connection
81     BlackBox* GetBlackBoxTo() const { return mTo; }
82     /// Returns the output of the initial black box of the connection
83     const std::string& GetBlackBoxFromOutput() const { return mOutput; }
84     /// Returns the input of the final black box of the connection
85     const std::string& GetBlackBoxToInput() const { return mInput; }
86
87     /// Sets the output of the initial black box of the connection
88     void SetBlackBoxFromOutput(const std::string& o) { mOutput = o; }
89   protected:
90     /// Black box origin of the connection
91     BlackBox* mFrom;
92     /// Output of mFrom which is connected
93     std::string mOutput;
94     /// Output connector of mFrom which is connected
95     //  BlackBoxOutputConnector* mOutputConnector;
96     /// Black box destination of the connection
97     BlackBox* mTo;
98     /// Input of mTo which is connected
99     std::string mInput;
100     /// Input connector of mTo which is connected
101     //  BlackBoxInputConnector* mInputConnector;
102     /// Adaptor black box if needed
103     BlackBox* mAdaptor;
104
105     /// The factory used to create adaptors
106     const Factory* mFactory;
107
108     /// Is the connection input type is any<thing> ?
109     bool mFromAny;
110
111     /// Is the connection output type is any<thing> ?
112     bool mToAny;
113
114
115     /// Have to do dynamic_cast ?
116     bool mDoDynamicCast;
117
118     /// Ctor with the black box from and to and their input and output
119     /// and a dummy int to differentiate from the public constructor.
120     /// Sets the members but does not test compatibility (used by bbtk::AdaptiveConnection)
121     //  Connection(BlackBox* from, const std::string& output,
122     //         BlackBox* to, const std::string& input, int   );
123     
124     void TransferData(); 
125   };
126
127 }// namespace bbtk
128
129 #endif
130