]> Creatis software - bbtk.git/blob - kernel/src/bbtkBlackBoxOutputConnector.h
*** empty log message ***
[bbtk.git] / kernel / src / bbtkBlackBoxOutputConnector.h
1 /*=========================================================================                                                                               
2   Program:   bbtk
3   Module:    $RCSfile: bbtkBlackBoxOutputConnector.h,v $
4   Language:  C++
5   Date:      $Date: 2008/12/15 09:04:46 $
6   Version:   $Revision: 1.8 $
7 =========================================================================*/
8
9 /* ---------------------------------------------------------------------
10
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
13 *
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.
20 *
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
25 *  liability. 
26 *
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 * ------------------------------------------------------------------------ */                                                                         
30
31
32 /**
33  *  \file 
34  *  \brief Class bbtk::BlackBoxOutputConnector : 
35  */
36 /**
37  * \class bbtk::BlackBoxOutputConnector
38  * \brief 
39  */
40  
41 #ifndef __bbtkBlackBoxOutputConnector_h__
42 #define __bbtkBlackBoxOutputConnector_h__
43
44 #include "bbtkConnection.h"
45 #include "bbtkBlackBox.h"
46 #include "bbtkMessageManager.h"
47 #include <vector>
48
49 // Change time management
50 //#include <bbtkChangeTime.h>
51
52 // Signal/slot mechanism for output change events
53 //#include <boost/signal.hpp>
54 //#include <boost/bind.hpp>
55
56 namespace bbtk
57 {
58
59   //  class BlackBox;
60   //  BBTK_FORWARD_DECLARE_POINTER(BlackBox);
61
62   //  void  operator (void*)(ChangeCallbackType t) { return (void*)t; };
63  
64 /*
65   typedef void (*ChangeSignalFunctionType)(BlackBoxOutputConnector*);
66   bool operator==(void (*sg1)(BlackBoxOutputConnector*),
67                   void (*sg2)(BlackBoxOutputConnector*)) 
68   { return sg1==sg2;}
69 */
70 /*
71   bool operator==(boost::function1<void, bbtk::BlackBoxOutputConnector*, std::allocator<void> >,boost::function1<void, bbtk::BlackBoxOutputConnector*, std::allocator<void> >)
72   {
73   }
74 */
75   //boost::function<void ()(bbtk::BlackBoxOutputConnector*), std::allocator<void> >]
76   class BBTK_EXPORT BlackBoxOutputConnector 
77   {
78   public:
79  
80     //    typedef boost::signals::trackable ChangeObserverType;
81     //    typedef boost::signal<void (bbtk::BlackBox::Pointer*,const std::string&,IOStatus)>  ChangeSignalType;
82     //    typedef ChangeSignalType::slot_function_type ChangeCallbackType;
83
84     typedef BlackBox::OutputChangeCallbackType OutputChangeCallbackType;
85
86     BlackBoxOutputConnector();
87     ~BlackBoxOutputConnector();
88
89     void SetConnection(Connection* c);
90     void UnsetConnection(Connection* c);
91     typedef std::vector<Connection*> ConnectionVector;
92     const ConnectionVector& GetConnectionVector() const { return mConnection; }
93     
94     IOStatus GetStatus() const { return mStatus; }
95     void SetStatus( IOStatus s ) { mStatus = s; }
96     void SignalChange( BlackBox::Pointer box, const std::string& output );
97
98
99     //    void SetModifiedStatus();
100
101     /// Returns the ChangeTime of the output (const)
102     //  const ChangeTime& GetChangeTime() const { return mChangeTime; }
103     /// Returns the ChangeTime of the output 
104     //    ChangeTime& GetChangeTime() { return mChangeTime; }
105
106     /// To be called when the output has changed
107     /// (sets the ChangeTime to current time and 
108     ///  signals the change to observers)
109     //    void SetChangeTime(const ChangeTime&); 
110    
111     /// To be called when the output has changed
112     /// (sets the ChangeTime to current time and 
113     ///  signals the change to observers)
114     //    void SetChangeTimeToCurrentTime(); 
115
116     /// Adds the function f to the list of functions to call when 
117     /// the output changes.
118     void AddChangeObserver(OutputChangeCallbackType f); 
119
120     /// Removes the function f from the list of functions to call when 
121     /// the output changes (TO WRITE)
122     void RemoveChangeObserver(OutputChangeCallbackType f); 
123
124
125   private:
126     /// The vector of output connections
127     ConnectionVector mConnection;
128     /// The status of the output 
129     IOStatus mStatus;
130     /// The output changed signal 
131     BlackBox::OutputChangeSignalType mChangeSignal;
132
133   };
134   
135 }
136 // namespace bbtk
137 #endif