#ifndef __creaImageIOListener_h_INCLUDED__ #define __creaImageIOListener_h_INCLUDED__ #include #include #include #include // Signal/slot mechanism #include #include #include namespace creaImageIO { class Listener : public wxThread { public: /// Ctors Listener(); /// Dtor virtual ~Listener(); ///Thread method that is executed once create is called void* Entry(); ///Thread method called upon exiting void OnExit(); ///Sets the new state of adding files void SetAddFilesState(bool addFiles){boost::mutex::scoped_lock lock(mMutex);mAddFiles=addFiles;} ///Sets the new state of removing files void SetRemoveFilesState(bool removeFiles){boost::mutex::scoped_lock lock(mMutex);mRemoveFiles=removeFiles;} ///Sets the new monitored drive void SetMonitoredDrive(const std::string& dr){boost::mutex::scoped_lock lock(mMutex);mDrive=dr;} ///Puts the name of the monitored drive in the given string void GetMonitoredDrive(std::string& drive){drive=mDrive;} ///Related with signals //============================================= typedef boost::signal MountingSignalType; typedef MountingSignalType::slot_function_type MountingCallbackType; //============================================= //================================================================== void ConnectObserver(MountingCallbackType callback); //================================================================== ///Sends a boost::signal to alert that the drive has changed its state (mounted/unmounted) void SendSignal(bool ivalid); private: /// The mutex boost::mutex mMutex; /// Boolean that declares if the files that are read on CD mount should be added bool mAddFiles; /// Boolean that declares if, on CD unmount, the files that were in the drive should be removed bool mRemoveFiles; ///Boolean that declares if a unit has been mounted bool mMounted; ///The monitored drive std::string mDrive; ///The validation signal MountingSignalType mMountingSignal; }; } #endif