]> Creatis software - creaImageIO.git/blob - src2/creaImageIOListener.h
Added Settings dialog, customize configuration options and the listener on an externa...
[creaImageIO.git] / src2 / creaImageIOListener.h
1 #ifndef __creaImageIOListener_h_INCLUDED__
2 #define __creaImageIOListener_h_INCLUDED__
3
4 #include <creaImageIOSystem.h>
5 #include <stdio.h>
6 #include <time.h>
7 #include <wx/thread.h>
8 // Signal/slot mechanism
9 #include <boost/signal.hpp>
10 #include <boost/bind.hpp>
11
12 namespace creaImageIO
13 {
14
15   class Listener : public wxThread
16   {
17   public:
18     /// Ctors 
19     Listener();
20     /// Dtor
21     virtual ~Listener();
22         ///Thread method that is executed once create is called
23         void* Entry();
24         ///Thread method called upon exiting
25     void  OnExit();
26         ///Sets the new state of adding files
27         void SetAddFilesState(bool addFiles){wxMutexLocker lock(mMutex);mAddFiles=addFiles;}
28         ///Sets the new state of removing files
29         void SetRemoveFilesState(bool removeFiles){wxMutexLocker lock(mMutex);mRemoveFiles=removeFiles;}
30         ///Sets the new monitored drive
31         void SetMonitoredDrive(const std::string& dr){wxMutexLocker lock(mMutex);mDrive=dr;}
32         ///Puts the name of the monitored drive in the given string
33         void GetMonitoredDrive(std::string& drive){drive=mDrive;}
34
35         ///Related with signals
36         //=============================================
37     typedef boost::signal<void (bool)>  MountingSignalType;
38     typedef MountingSignalType::slot_function_type MountingCallbackType;
39     //=============================================
40
41     //==================================================================
42     void ConnectObserver(MountingCallbackType callback);
43     //==================================================================
44
45         ///Sends a boost::signal to alert that the drive has changed its state (mounted/unmounted)
46         void SendSignal(bool ivalid);
47   
48
49   private:
50     /// The mutex
51     wxMutex mMutex;
52     /// Boolean that declares if the files that are read on CD mount should be added
53     bool mAddFiles;
54         /// Boolean that declares if, on CD unmount, the files that were in the drive should be removed
55     bool mRemoveFiles;
56         ///Boolean that declares if a unit has been mounted
57         bool mMounted;
58         ///The monitored drive
59         std::string mDrive;
60         ///The validation signal
61         MountingSignalType mMountingSignal;
62   };
63
64 }
65
66 #endif