#include <pdf_library.h>
Public Member Functions | |
~PDFLibrary () | |
Thread & | get_thread () |
get the instance of thread | |
bool | make_enough_memory (PDFController *doc_ptr, const int page_num, const int length) |
make enough memory for some one document | |
void | add_document (PDFController *doc_ptr) |
add new document | |
void | remove_document (PDFController *doc_ptr) |
remove the existing document | |
void | remove_tasks_by_document (PDFController *doc) |
remove all of the tasks related to a document | |
void | thread_add_render_task (Task *task, bool prerender, bool abort_current) |
handle adding render task | |
void | thread_add_search_task (Task *task) |
handle adding search task | |
void | thread_cancel_render_tasks (void *user_data) |
clear all of the render tasks | |
Static Public Member Functions | |
static PDFLibrary & | instance () |
get the instance of library |
Definition at line 35 of file pdf_library.h.
pdf::PDFLibrary::~PDFLibrary | ( | ) |
Definition at line 61 of file pdf_library.cpp.
References pdf::Thread::stop().
void pdf::PDFLibrary::add_document | ( | PDFController * | doc_ptr | ) |
add new document
Definition at line 111 of file pdf_library.cpp.
Referenced by pdf::PDFController::PDFController().
Thread& pdf::PDFLibrary::get_thread | ( | ) | [inline] |
get the instance of thread
Definition at line 44 of file pdf_library.h.
Referenced by pdf::PDFController::abort_search(), thread_add_render_task(), thread_add_search_task(), and thread_cancel_render_tasks().
PDFLibrary & pdf::PDFLibrary::instance | ( | ) | [static] |
get the instance of library
Definition at line 67 of file pdf_library.cpp.
Referenced by pdf::PDFController::abort_search(), pdf::PDFController::close(), pdf::PDFRenderTask::execute(), pdf::PDFController::PDFController(), pdf::PDFRenderer::post_render_task(), pdf::PDFController::search_all(), pdf::PDFController::search_next(), pdf::PDFController::set_memory_limit(), and pdf::PDFController::~PDFController().
bool pdf::PDFLibrary::make_enough_memory | ( | PDFController * | doc_ptr, | |
const int | page_num, | |||
const int | length | |||
) |
make enough memory for some one document
Definition at line 86 of file pdf_library.cpp.
References pdf::get_system_free_memory(), and WARNPRINTF.
00089 { 00090 if (length <= 0) 00091 { 00092 WARNPRINTF("Should NOT make enough memory by length:%d", length); 00093 return false; 00094 } 00095 00096 // check the free memory in system 00097 unsigned long free_mem = get_system_free_memory(); 00098 if (free_mem < static_cast<unsigned long>(length << 1)) 00099 { 00100 // release all of the cached bitmaps 00101 DocumentsIter idx = docs.begin(); 00102 for (; idx != docs.end(); ++idx) 00103 { 00104 (*idx)->clear_cached_bitmaps(); 00105 } 00106 } 00107 00108 return doc_ptr->make_enough_memory(page_num, length); 00109 }
void pdf::PDFLibrary::remove_document | ( | PDFController * | doc_ptr | ) |
remove the existing document
Definition at line 122 of file pdf_library.cpp.
Referenced by pdf::PDFController::~PDFController().
00123 { 00124 DocumentsIter idx = std::find(docs.begin(), docs.end(), doc_ptr); 00125 if (idx != docs.end()) 00126 { 00127 docs.erase(idx); 00128 } 00129 try_stop_thread(); 00130 }
void pdf::PDFLibrary::remove_tasks_by_document | ( | PDFController * | doc | ) |
remove all of the tasks related to a document
Definition at line 117 of file pdf_library.cpp.
References pdf::Thread::cancel_tasks().
Referenced by pdf::PDFController::close().
void pdf::PDFLibrary::thread_add_render_task | ( | Task * | task, | |
bool | prerender, | |||
bool | abort_current | |||
) |
handle adding render task
Definition at line 132 of file pdf_library.cpp.
References pdf::Thread::append_task(), get_thread(), and pdf::Thread::prepend_task().
Referenced by pdf::PDFRenderer::post_render_task().
00133 { 00134 if (prerender) 00135 { 00136 get_thread().append_task(task); 00137 } 00138 else 00139 { 00140 // post the rendering task into the thread's task list 00141 get_thread().prepend_task(task, abort_current); 00142 } 00143 }
void pdf::PDFLibrary::thread_add_search_task | ( | Task * | task | ) |
handle adding search task
Definition at line 145 of file pdf_library.cpp.
References get_thread(), and pdf::Thread::prepend_task().
Referenced by pdf::PDFController::search_all(), and pdf::PDFController::search_next().
00146 { 00147 get_thread().prepend_task(task, true); 00148 }
void pdf::PDFLibrary::thread_cancel_render_tasks | ( | void * | user_data | ) |
clear all of the render tasks
Definition at line 150 of file pdf_library.cpp.
References pdf::Thread::clear_all(), get_thread(), and pdf::TASK_RENDER.
Referenced by pdf::PDFRenderer::post_render_task(), and pdf::PDFController::set_memory_limit().
00151 { 00152 get_thread().clear_all(user_data, TASK_RENDER); 00153 }