creaImageIO_lib
creaImageIO::Listener Class Reference

#include <creaImageIOListener.h>

Inheritance diagram for creaImageIO::Listener:
Collaboration diagram for creaImageIO::Listener:

Public Types

typedef boost::signal< void(bool)> MountingSignalType
 Related with signals. More...
 
typedef
MountingSignalType::slot_function_type 
MountingCallbackType
 

Public Member Functions

 Listener ()
 Ctors. More...
 
virtual ~Listener ()
 Dtor. More...
 
void * Entry ()
 Thread method that is executed once create is called. More...
 
void OnExit ()
 Thread method called upon exiting. More...
 
void SetAddFilesState (bool addFiles)
 Sets the new state of adding files. More...
 
void SetRemoveFilesState (bool removeFiles)
 Sets the new state of removing files. More...
 
void SetMonitoredDrive (const std::string &dr)
 Sets the new monitored drive. More...
 
void GetMonitoredDrive (std::string &drive)
 Puts the name of the monitored drive in the given string. More...
 
void ConnectObserver (MountingCallbackType callback)
 
void SendSignal (bool ivalid)
 Sends a boost::signal to alert that the drive has changed its state (mounted/unmounted) More...
 

Private Attributes

boost::mutex mMutex
 The mutex. More...
 
bool mAddFiles
 Boolean that declares if the files that are read on CD mount should be added. More...
 
bool mRemoveFiles
 Boolean that declares if, on CD unmount, the files that were in the drive should be removed. More...
 
bool mMounted
 Boolean that declares if a unit has been mounted. More...
 
std::string mDrive
 The monitored drive. More...
 
MountingSignalType mMountingSignal
 The validation signal. More...
 

Detailed Description

Definition at line 44 of file creaImageIOListener.h.

Member Typedef Documentation

typedef MountingSignalType::slot_function_type creaImageIO::Listener::MountingCallbackType

Definition at line 67 of file creaImageIOListener.h.

typedef boost::signal<void (bool)> creaImageIO::Listener::MountingSignalType

Related with signals.

Definition at line 66 of file creaImageIOListener.h.

Constructor & Destructor Documentation

creaImageIO::Listener::Listener ( )

Ctors.

Definition at line 44 of file creaImageIOListener.cpp.

References GimmickDebugMessage.

45  {
46 
47  boost::mutex::scoped_lock lock(mMutex);
48  GimmickDebugMessage(6,"Listener::Listener"
49  <<std::endl);
50  mDrive="E:";
51  mMounted=false;
52  mAddFiles=false;
53  mRemoveFiles=true;
54 
55  }
creaImageIO::Listener::~Listener ( )
virtual

Dtor.

Destructor.

Definition at line 60 of file creaImageIOListener.cpp.

References GimmickDebugMessage.

61  {
62  boost::mutex::scoped_lock lock(mMutex);
63  GimmickDebugMessage(6,"Listener::~Listener"
64  <<std::endl);
65  }

Member Function Documentation

void creaImageIO::Listener::ConnectObserver ( MountingCallbackType  callback)

Definition at line 117 of file creaImageIOListener.cpp.

118  {
119  mMountingSignal.connect(callback);
120  }
void * creaImageIO::Listener::Entry ( )

Thread method that is executed once create is called.

Definition at line 68 of file creaImageIOListener.cpp.

References GimmickDebugMessage.

69  {
70  GimmickDebugMessage(6,"Listener::Entry()"<<std::endl);
71  while(!TestDestroy())
72  {
73  try
74  {
75  fs::exists( mDrive );
76  if(!mMounted && mAddFiles)
77  {
78  mMounted=true;
80  }
81  else if(!mMounted)
82  {
83  mMounted=true;
84  }
85 
86  }
87  catch (...)
88  {
89  if(mMounted && mRemoveFiles)
90  {
91  mMounted=false;
93  }
94  else if(mMounted)
95  {
96  mMounted=false;
97  }
98  }
99 
100  clock_t endwait;
101  endwait = clock () + 0.001 * CLOCKS_PER_SEC ;
102  while (clock() < endwait ) {}
103 
104  }
105  return 0;
106  }
void creaImageIO::Listener::GetMonitoredDrive ( std::string &  drive)
inline

Puts the name of the monitored drive in the given string.

Definition at line 62 of file creaImageIOListener.h.

References mDrive.

Referenced by creaImageIO::WxGimmickView::OnDriveMount().

62 {drive=mDrive;}

Here is the caller graph for this function:

void creaImageIO::Listener::OnExit ( )

Thread method called upon exiting.

Definition at line 111 of file creaImageIOListener.cpp.

References GimmickDebugMessage.

112  {
113  GimmickDebugMessage(6,"Listener::OnExit() "<<std::endl);
114  }
void creaImageIO::Listener::SendSignal ( bool  ivalid)

Sends a boost::signal to alert that the drive has changed its state (mounted/unmounted)

Definition at line 123 of file creaImageIOListener.cpp.

124  {
125  mMountingSignal(mount);
126  }
void creaImageIO::Listener::SetAddFilesState ( bool  addFiles)
inline

Sets the new state of adding files.

Definition at line 56 of file creaImageIOListener.h.

References mAddFiles, and mMutex.

Referenced by creaImageIO::WxGimmickView::OnListenerCallback().

56 {boost::mutex::scoped_lock lock(mMutex);mAddFiles=addFiles;}

Here is the caller graph for this function:

void creaImageIO::Listener::SetMonitoredDrive ( const std::string &  dr)
inline

Sets the new monitored drive.

Definition at line 60 of file creaImageIOListener.h.

References mDrive, and mMutex.

Referenced by creaImageIO::WxGimmickView::OnListenerCallback().

60 {boost::mutex::scoped_lock lock(mMutex);mDrive=dr;}

Here is the caller graph for this function:

void creaImageIO::Listener::SetRemoveFilesState ( bool  removeFiles)
inline

Sets the new state of removing files.

Definition at line 58 of file creaImageIOListener.h.

References mMutex, and mRemoveFiles.

Referenced by creaImageIO::WxGimmickView::OnListenerCallback().

58 {boost::mutex::scoped_lock lock(mMutex);mRemoveFiles=removeFiles;}

Here is the caller graph for this function:

Member Data Documentation

bool creaImageIO::Listener::mAddFiles
private

Boolean that declares if the files that are read on CD mount should be added.

Definition at line 82 of file creaImageIOListener.h.

Referenced by SetAddFilesState().

std::string creaImageIO::Listener::mDrive
private

The monitored drive.

Definition at line 88 of file creaImageIOListener.h.

Referenced by GetMonitoredDrive(), and SetMonitoredDrive().

bool creaImageIO::Listener::mMounted
private

Boolean that declares if a unit has been mounted.

Definition at line 86 of file creaImageIOListener.h.

MountingSignalType creaImageIO::Listener::mMountingSignal
private

The validation signal.

Definition at line 90 of file creaImageIOListener.h.

boost::mutex creaImageIO::Listener::mMutex
private

The mutex.

Definition at line 80 of file creaImageIOListener.h.

Referenced by SetAddFilesState(), SetMonitoredDrive(), and SetRemoveFilesState().

bool creaImageIO::Listener::mRemoveFiles
private

Boolean that declares if, on CD unmount, the files that were in the drive should be removed.

Definition at line 84 of file creaImageIOListener.h.

Referenced by SetRemoveFilesState().


The documentation for this class was generated from the following files: