fw4spl
ProgressAdviser.hpp
1 /* ***** BEGIN LICENSE BLOCK *****
2  * FW4SPL - Copyright (C) IRCAD, 2009-2017.
3  * Distributed under the terms of the GNU Lesser General Public License (LGPL) as
4  * published by the Free Software Foundation.
5  * ****** END LICENSE BLOCK ****** */
6 
7 #ifndef __FWTOOLS_PROGRESSADVISER_HPP__
8 #define __FWTOOLS_PROGRESSADVISER_HPP__
9 
10 #include <fwTools/config.hpp>
11 
12 #include <fwCore/base.hpp>
13 
14 #include <boost/signals2.hpp>
15 
16 #include <string>
17 
18 namespace fwTools
19 {
20 
31 class FWTOOLS_CLASS_API ProgressAdviser : public ::boost::signals2::trackable
32 {
33 public:
34 
36  typedef ::boost::signals2::signal< void (float, std::string) > ProgessSignal; // signal for fctor or function
37  // returning void
38 
40  typedef ProgessSignal::slot_type ProgessHandler; // signal for fctor or function returning void and
41  // accepting a float as argument percent
42  // string for information
43 
44  FWTOOLS_API ProgressAdviser();
45  FWTOOLS_API virtual ~ProgressAdviser();
46 
47  /*
48  * @brief append a new handler ( a functor accepting a float as argument an returning void)
49  * @param[in] handler can be either a function or functor or boost::signal with a signature( float, std::string )
50  * and returning nothing
51  */
52  FWTOOLS_API void addHandler(const ProgessHandler& handler);
53 
55  FWTOOLS_API void notifyProgress(float percent, const std::string& msg = "") const;
56 
57 protected:
58 
60  ProgessSignal m_progressSignal;
61 
62 };
63 
64 }
65 
66 #endif /* __FWTOOLS_PROGRESSADVISER_HPP__ */
The namespace fwTools contains several tools like UUID, factory, dispatche, stringizer, macros, helper.
Subclasses Inherited from ProgressAdviser can notify progression This class is used as base class to ...
ProgessSignal::slot_type ProgessHandler
define the ProgessHandler type
ProgessSignal m_progressSignal
to notify progress simply use m_progressSignal( percent,msg ) to notify to Handler ...
::boost::signals2::signal< void(float, std::string) > ProgessSignal
define a boost signal signature for the ProgessHandler