1 /*=========================================================================
3 Module: $RCSfile: bbtkBlackBoxOutputConnector.h,v $
5 Date: $Date: 2008/12/08 13:05:59 $
6 Version: $Revision: 1.6 $
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 * ------------------------------------------------------------------------ */
34 * \brief Class bbtk::BlackBoxOutputConnector :
37 * \class bbtk::BlackBoxOutputConnector
41 #ifndef __bbtkBlackBoxOutputConnector_h__
42 #define __bbtkBlackBoxOutputConnector_h__
44 #include "bbtkConnection.h"
45 #include "bbtkBlackBox.h"
46 #include "bbtkMessageManager.h"
49 // Change time management
50 //#include <bbtkChangeTime.h>
52 // Signal/slot mechanism for output change events
53 //#include <boost/signal.hpp>
54 //#include <boost/bind.hpp>
60 // BBTK_FORWARD_DECLARE_POINTER(BlackBox);
62 // void operator (void*)(ChangeCallbackType t) { return (void*)t; };
65 typedef void (*ChangeSignalFunctionType)(BlackBoxOutputConnector*);
66 bool operator==(void (*sg1)(BlackBoxOutputConnector*),
67 void (*sg2)(BlackBoxOutputConnector*))
71 bool operator==(boost::function1<void, bbtk::BlackBoxOutputConnector*, std::allocator<void> >,boost::function1<void, bbtk::BlackBoxOutputConnector*, std::allocator<void> >)
75 //boost::function<void ()(bbtk::BlackBoxOutputConnector*), std::allocator<void> >]
76 class BBTK_EXPORT BlackBoxOutputConnector
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;
84 typedef BlackBox::OutputChangeCallbackType OutputChangeCallbackType;
86 BlackBoxOutputConnector();
87 ~BlackBoxOutputConnector();
89 void SetConnection(Connection* c);
90 void UnsetConnection(Connection* c);
91 typedef std::vector<Connection*> ConnectionVector;
92 const ConnectionVector& GetConnectionVector() const { return mConnection; }
94 IOStatus GetStatus() const { return mStatus; }
95 void SetStatus( IOStatus s ) { mStatus = s; }
96 void SignalChange( BlackBox::Pointer box, const std::string& output );
99 // void SetModifiedStatus();
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; }
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&);
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();
116 /// Adds the function f to the list of functions to call when
117 /// the output changes.
118 /// f is of type ChangeCallbackType which is basically:
119 /// void (*ChangeCallbackType)(BlackBoxOutputConnector*)
120 /// To pass a member function 'f' of an instance 'c' of a class 'C'
121 /// as callback you have to 'bind' it, i.e. call:
122 /// AddChangeObserver ( boost::bind( &C::f , c, _1 ) );
123 void AddChangeObserver(OutputChangeCallbackType f);
125 /// Removes the function f from the list of functions to call when
126 /// the output changes (TO WRITE)
127 void RemoveChangeObserver(OutputChangeCallbackType f);
131 /// The vector of output connections
132 ConnectionVector mConnection;
133 /// The status of the output
136 BlackBox::OutputChangeSignalType mChangeSignal;
139 // ChangeTime mChangeTime;