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