creaImageIO_lib
|
Class that allows parallel lectures of several images. More...
#include <creaImageIOMultiThreadImageReader.h>
Classes | |
class | ImageToLoad |
Class that represents an image to be loaded. More... | |
struct | ImageToLoadPtrFilenameComparator |
ImageToLoadPtr comparator on filename (for image map) More... | |
struct | ImageToLoadPtrIndexer |
ImageToLoadPtr indexer for image queue. More... | |
struct | ImageToLoadPtrInversePriorityComparator |
ImageToLoadPtr comparator on inverse priority (for image to unload queue) More... | |
struct | ImageToLoadPtrPriorityComparator |
ImageToLoadPtr comparator on priority (for image queue) More... | |
struct | ImageToUnloadPtrIndexer |
ImageToLoadPtr indexer for to unload image queue. More... | |
Public Member Functions | |
MultiThreadImageReader (int number_of_threads=1) | |
Ctor with the number of threads to use. More... | |
~MultiThreadImageReader () | |
Dtor. More... | |
bool | Start () |
void | Stop () |
Stops the reader = stops the threads and delete the images loaded. More... | |
void | Request (MultiThreadImageReaderUser *user, const std::string &filename, int priority) |
vtkImageData * | GetImage (const std::string &filename) |
(no user callback but image returned) More... | |
int | GetMaximalPriority () |
void | OnMultiThreadImageReaderEvent (const std::string &filename, EventType type, vtkImageData *image) |
void | getAttributes (const std::string filename, std::map< std::string, std::string > &infos, std::vector< std::string > i_attr) |
Function to read attributes for a file. More... | |
MultiThreadImageReader (int number_of_threads=1) | |
Ctor with the number of threads to use. More... | |
~MultiThreadImageReader () | |
Dtor. More... | |
bool | Start () |
void | Stop () |
Stops the reader = stops the threads and delete the images loaded. More... | |
void | Request (MultiThreadImageReaderUser *user, const std::string &filename, int priority) |
vtkImageData * | GetImage (const std::string &filename) |
(no user callback but image returned) More... | |
int | GetMaximalPriority () |
void | OnMultiThreadImageReaderEvent (const std::string &filename, EventType type, vtkImageData *image) |
void | getAttributes (const std::string filename, std::map< std::string, std::string > &infos, std::vector< std::string > i_attr) |
Function to read attributes for a file. More... | |
void | MultiThreadImageReaderEventLock () |
void | MultiThreadImageReaderEventLock () |
void | MultiThreadImageReaderEventUnlock () |
void | MultiThreadImageReaderEventUnlock () |
wxMutex & | GetMultiThreadImageReaderUserMutex () |
QMutex * | GetMultiThreadImageReaderUserMutex () |
Protected Types | |
typedef ImageToLoad * | ImageToLoadPtr |
Type of pointer on an ImageToLoad struct. More... | |
typedef std::map < ImageToLoadPtr, vtkImageData *, ImageToLoadPtrFilenameComparator > | ImageMapType |
The type of map of images. More... | |
typedef std::vector < boost::shared_ptr < ThreadedImageReader > > | ThreadedImageReaderListType |
The type of list of threaded readers. More... | |
typedef ImageToLoad * | ImageToLoadPtr |
Type of pointer on an ImageToLoad struct. More... | |
typedef std::map < ImageToLoadPtr, vtkImageData *, ImageToLoadPtrFilenameComparator > | ImageMapType |
The type of map of images. More... | |
typedef std::vector < boost::shared_ptr < ThreadedImageReader > > | ThreadedImageReaderListType |
The type of list of threaded readers. More... | |
Protected Member Functions | |
int | GetMaximalPriorityWithoutLocking () |
void | SignalImageRead (ImageToLoadPtr p, bool purge) |
The callback from threaded readers when an image is read. More... | |
void | UpdateUnloadPriority (ImageToLoadPtr p, int priority) |
int | GetMaximalPriorityWithoutLocking () |
void | SignalImageRead (ImageToLoadPtr p, bool purge) |
The callback from threaded readers when an image is read. More... | |
void | UpdateUnloadPriority (ImageToLoadPtr p, int priority) |
Protected Attributes | |
bool | mDone |
ImageMapType | mImages |
The map of images. More... | |
ImageToLoadPtrPriorityComparator | mComparator |
Comparator for the image to load queue. More... | |
ImageToLoadPtrIndexer | mIndexer |
Indexer for the image to load queue. More... | |
IndexedHeap< ImageToLoadPtr, ImageToLoadPtrPriorityComparator, ImageToLoadPtrIndexer > | mQueue |
The image to load priority queue. More... | |
ThreadedImageReaderListType | mThreadedImageReaderList |
int | mNumberOfThreadedReadersRunning |
The number of currently running threaded readers. More... | |
std::string | mRequestedFilename |
For GetImage : the filename requested. More... | |
vtkImageData * | mRequestedImage |
For GetImage : the image requested. More... | |
ImageReader * | mReader |
If number of threads == 0 then uses an internal non-threaded reader. More... | |
IndexedHeap< ImageToLoadPtr, ImageToLoadPtrInversePriorityComparator, ImageToUnloadPtrIndexer > | mUnloadQueue |
The image to unload priority queue. More... | |
long | mTotalMem |
long | mTotalMemMax |
Friends | |
class | ThreadedImageReader |
Class that allows parallel lectures of several images.
TAKE CARE : For the moment it only supports a SINGLE USER
Definition at line 100 of file creaImageIOMultiThreadImageReader.h.
|
protected |
The type of map of images.
Definition at line 234 of file creaImageIOMultiThreadImageReader.h.
|
protected |
The type of map of images.
Definition at line 235 of file creaImageIOQMultiThreadImageReader.h.
|
protected |
Type of pointer on an ImageToLoad struct.
Definition at line 186 of file creaImageIOMultiThreadImageReader.h.
|
protected |
Type of pointer on an ImageToLoad struct.
Definition at line 187 of file creaImageIOQMultiThreadImageReader.h.
|
protected |
The type of list of threaded readers.
Definition at line 247 of file creaImageIOMultiThreadImageReader.h.
|
protected |
The type of list of threaded readers.
Definition at line 248 of file creaImageIOQMultiThreadImageReader.h.
|
inherited |
Enumerator | |
---|---|
ThreadedReaderStarted | |
ThreadedReaderStopped | |
ImageLoaded | |
ImageUnloaded | |
Error | |
ThreadedReaderStarted | |
ThreadedReaderStopped | |
ImageLoaded | |
ImageUnloaded | |
Error |
Definition at line 61 of file creaImageIOMultiThreadImageReader.h.
|
inherited |
Enumerator | |
---|---|
ThreadedReaderStarted | |
ThreadedReaderStopped | |
ImageLoaded | |
ImageUnloaded | |
Error | |
ThreadedReaderStarted | |
ThreadedReaderStopped | |
ImageLoaded | |
ImageUnloaded | |
Error |
Definition at line 62 of file creaImageIOQMultiThreadImageReader.h.
creaImageIO::MultiThreadImageReader::MultiThreadImageReader | ( | int | number_of_threads = 1 | ) |
Ctor with the number of threads to use.
Definition at line 86 of file creaImageIOMultiThreadImageReader.cpp.
References mComparator, mDone, mIndexer, mNumberOfThreadedReadersRunning, mQueue, mReader, mThreadedImageReaderList, and ThreadedImageReader.
creaImageIO::MultiThreadImageReader::~MultiThreadImageReader | ( | ) |
Dtor.
Definition at line 213 of file creaImageIOMultiThreadImageReader.cpp.
References mReader, mThreadedImageReaderList, and Stop().
creaImageIO::MultiThreadImageReader::MultiThreadImageReader | ( | int | number_of_threads = 1 | ) |
Ctor with the number of threads to use.
creaImageIO::MultiThreadImageReader::~MultiThreadImageReader | ( | ) |
Dtor.
void creaImageIO::MultiThreadImageReader::getAttributes | ( | const std::string | filename, |
std::map< std::string, std::string > & | infos, | ||
std::vector< std::string > | i_attr | ||
) |
Function to read attributes for a file.
Definition at line 243 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::ImageReader::getAttributes(), and mReader.
Referenced by creaImageIO::GimmickView::getAttributes().
void creaImageIO::MultiThreadImageReader::getAttributes | ( | const std::string | filename, |
std::map< std::string, std::string > & | infos, | ||
std::vector< std::string > | i_attr | ||
) |
Function to read attributes for a file.
vtkImageData * creaImageIO::MultiThreadImageReader::GetImage | ( | const std::string & | filename | ) |
(no user callback but image returned)
Request the image "filename" immediately Blocks until image loaded
Definition at line 347 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::MultiThreadImageReader::ImageToLoad::GetImage(), GetMaximalPriorityWithoutLocking(), mImages, mReader, creaImageIO::ImageReader::ReadImage(), creaImageIO::MultiThreadImageReader::ImageToLoad::SetImage(), and UpdateUnloadPriority().
Referenced by creaImageIO::GimmickView::GetDefaultImage(), creaImageIO::GimmickView::isSingle(), creaImageIO::GimmickView::readImages1(), creaImageIO::GimmickView::readImages2(), creaImageIO::GimmickView::readImages3(), creaImageIO::GimmickView::readImages4(), creaImageIO::GimmickView::ReadImagesNotThreaded(), and creaImageIO::GimmickView::ReadImagesNotThreadedInVector().
vtkImageData* creaImageIO::MultiThreadImageReader::GetImage | ( | const std::string & | filename | ) |
(no user callback but image returned)
Request the image "filename" immediately Blocks until image loaded
int creaImageIO::MultiThreadImageReader::GetMaximalPriority | ( | ) |
Definition at line 557 of file creaImageIOMultiThreadImageReader.cpp.
References GetMaximalPriorityWithoutLocking(), and creaImageIO::MultiThreadImageReaderUser::GetMultiThreadImageReaderUserMutex().
Referenced by creaImageIO::GimmickView::GetMaximalPriority().
int creaImageIO::MultiThreadImageReader::GetMaximalPriority | ( | ) |
|
protected |
Definition at line 566 of file creaImageIOMultiThreadImageReader.cpp.
References mQueue, and mUnloadQueue.
Referenced by GetImage(), and GetMaximalPriority().
|
protected |
|
inlineinherited |
Definition at line 84 of file creaImageIOMultiThreadImageReader.h.
Referenced by GetMaximalPriority(), Request(), SignalImageRead(), Start(), and Stop().
|
inlineinherited |
Definition at line 85 of file creaImageIOQMultiThreadImageReader.h.
|
inlineinherited |
Definition at line 80 of file creaImageIOMultiThreadImageReader.h.
Referenced by creaImageIO::ThreadedImageReader::Entry().
|
inlineinherited |
Definition at line 81 of file creaImageIOQMultiThreadImageReader.h.
|
inlineinherited |
Definition at line 82 of file creaImageIOMultiThreadImageReader.h.
Referenced by creaImageIO::ThreadedImageReader::Entry().
|
inlineinherited |
Definition at line 83 of file creaImageIOQMultiThreadImageReader.h.
|
virtual |
The virtual method to overload by MultiThreadImageReader users It is called when an image has been loaded or unloaded Provides :
Reimplemented from creaImageIO::MultiThreadImageReaderUser.
Definition at line 323 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::MultiThreadImageReaderUser::ImageLoaded, creaImageIO::MultiThreadImageReaderUser::ThreadedReaderStarted, and creaImageIO::MultiThreadImageReaderUser::ThreadedReaderStopped.
|
virtual |
The virtual method to overload by MultiThreadImageReader users It is called when an image has been loaded or unloaded Provides :
Reimplemented from creaImageIO::MultiThreadImageReaderUser.
void creaImageIO::MultiThreadImageReader::Request | ( | MultiThreadImageReaderUser * | user, |
const std::string & | filename, | ||
int | priority | ||
) |
Request the image "filename" with a given priority When the image is ready (or an error occurred) The observer's callback is invoked
Already requested : change the priority
Already requested : change the priority
Definition at line 250 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::MultiThreadImageReader::ImageToLoad::GetImage(), creaImageIO::MultiThreadImageReaderUser::GetMultiThreadImageReaderUserMutex(), creaImageIO::MultiThreadImageReader::ImageToLoad::Index(), mImages, mNumberOfThreadedReadersRunning, mQueue, mReader, creaImageIO::ImageReader::ReadImage(), creaImageIO::MultiThreadImageReader::ImageToLoad::SetImage(), creaImageIO::MultiThreadImageReader::ImageToLoad::SetPriority(), creaImageIO::MultiThreadImageReader::ImageToLoad::SetUser(), SignalImageRead(), and UpdateUnloadPriority().
Referenced by creaImageIO::GimmickView::RequestReading().
void creaImageIO::MultiThreadImageReader::Request | ( | MultiThreadImageReaderUser * | user, |
const std::string & | filename, | ||
int | priority | ||
) |
Request the image "filename" with a given priority When the image is ready (or an error occurred) The observer's callback is invoked
|
protected |
The callback from threaded readers when an image is read.
Definition at line 457 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::MultiThreadImageReader::ImageToLoad::GetFilename(), creaImageIO::MultiThreadImageReader::ImageToLoad::GetImage(), creaImageIO::MultiThreadImageReaderUser::GetMultiThreadImageReaderUserMutex(), creaImageIO::MultiThreadImageReader::ImageToLoad::GetUser(), GimmickMessage, creaImageIO::MultiThreadImageReaderUser::ImageLoaded, creaImageIO::MultiThreadImageReaderUser::ImageUnloaded, creaImageIO::MultiThreadImageReader::ImageToLoad::Index(), mImages, mTotalMem, mTotalMemMax, creaImageIO::MultiThreadImageReaderUser::MultiThreadImageReaderSendEvent(), and mUnloadQueue.
Referenced by creaImageIO::ThreadedImageReader::Entry(), and Request().
|
protected |
The callback from threaded readers when an image is read.
bool creaImageIO::MultiThreadImageReader::Start | ( | ) |
Starts the reader = create the threads which start to check periodically the queue of requested images to read
Definition at line 120 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::MultiThreadImageReaderUser::GetMultiThreadImageReaderUserMutex(), mNumberOfThreadedReadersRunning, and mThreadedImageReaderList.
Referenced by creaImageIO::GimmickView::RequestReading().
bool creaImageIO::MultiThreadImageReader::Start | ( | ) |
Starts the reader = create the threads which start to check periodically the queue of requested images to read
void creaImageIO::MultiThreadImageReader::Stop | ( | ) |
Stops the reader = stops the threads and delete the images loaded.
Definition at line 154 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::MultiThreadImageReaderUser::GetMultiThreadImageReaderUserMutex(), mDone, mImages, mNumberOfThreadedReadersRunning, and mThreadedImageReaderList.
Referenced by creaImageIO::GimmickView::stopReader(), and ~MultiThreadImageReader().
void creaImageIO::MultiThreadImageReader::Stop | ( | ) |
Stops the reader = stops the threads and delete the images loaded.
|
protected |
Definition at line 224 of file creaImageIOMultiThreadImageReader.cpp.
References creaImageIO::MultiThreadImageReader::ImageToLoad::GetPriority(), mUnloadQueue, creaImageIO::MultiThreadImageReader::ImageToLoad::SetPriority(), and creaImageIO::MultiThreadImageReader::ImageToLoad::UnloadIndex().
Referenced by GetImage(), and Request().
|
protected |
|
friend |
Definition at line 103 of file creaImageIOMultiThreadImageReader.h.
Referenced by MultiThreadImageReader().
|
protected |
Comparator for the image to load queue.
Definition at line 238 of file creaImageIOMultiThreadImageReader.h.
Referenced by MultiThreadImageReader().
|
protected |
Definition at line 140 of file creaImageIOMultiThreadImageReader.h.
Referenced by MultiThreadImageReader(), and Stop().
|
protected |
The map of images.
Definition at line 236 of file creaImageIOMultiThreadImageReader.h.
Referenced by creaImageIO::ThreadedImageReader::Entry(), GetImage(), Request(), SignalImageRead(), and Stop().
|
protected |
Indexer for the image to load queue.
Definition at line 240 of file creaImageIOMultiThreadImageReader.h.
Referenced by MultiThreadImageReader().
|
protected |
The number of currently running threaded readers.
Definition at line 251 of file creaImageIOMultiThreadImageReader.h.
Referenced by MultiThreadImageReader(), Request(), Start(), and Stop().
|
protected |
The image to load priority queue.
Definition at line 244 of file creaImageIOMultiThreadImageReader.h.
Referenced by creaImageIO::ThreadedImageReader::Entry(), GetMaximalPriorityWithoutLocking(), MultiThreadImageReader(), and Request().
|
protected |
If number of threads == 0 then uses an internal non-threaded reader.
Definition at line 263 of file creaImageIOMultiThreadImageReader.h.
Referenced by getAttributes(), GetImage(), MultiThreadImageReader(), Request(), and ~MultiThreadImageReader().
|
protected |
For GetImage : the filename requested.
The mutex used to access safely internal data from any thread LG : Removed ! We now use the embedded mutex in User from which we inherit...
Definition at line 258 of file creaImageIOMultiThreadImageReader.h.
|
protected |
For GetImage : the image requested.
Definition at line 260 of file creaImageIOMultiThreadImageReader.h.
|
protected |
Definition at line 249 of file creaImageIOMultiThreadImageReader.h.
Referenced by MultiThreadImageReader(), Start(), Stop(), and ~MultiThreadImageReader().
|
protected |
Definition at line 273 of file creaImageIOMultiThreadImageReader.h.
Referenced by SignalImageRead().
|
protected |
Definition at line 274 of file creaImageIOMultiThreadImageReader.h.
Referenced by SignalImageRead().
|
protected |
The image to unload priority queue.
The type of list of images loaded used to unload oldest image when memory limit exceeded
Definition at line 270 of file creaImageIOMultiThreadImageReader.h.
Referenced by GetMaximalPriorityWithoutLocking(), SignalImageRead(), and UpdateUnloadPriority().