00001 /* 00002 * File Name: pdf_library.h 00003 */ 00004 00005 /* 00006 * This file is part of uds-plugin-pdf. 00007 * 00008 * uds-plugin-pdf is free software: you can redistribute it and/or modify 00009 * it under the terms of the GNU General Public License as published by 00010 * the Free Software Foundation, either version 2 of the License, or 00011 * (at your option) any later version. 00012 * 00013 * uds-plugin-pdf is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 * GNU General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU General Public License 00019 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00020 */ 00021 00022 /** 00023 * Copyright (C) 2008 iRex Technologies B.V. 00024 * All rights reserved. 00025 */ 00026 00027 #ifndef PDF_LIBRARY_H_ 00028 #define PDF_LIBRARY_H_ 00029 00030 #include "pdf_thread.h" 00031 #include "pdf_define.h" 00032 00033 namespace pdf 00034 { 00035 00036 /// PDFLibrary maintains all of the documents 00037 class PDFController; 00038 class PDFLibrary 00039 { 00040 public: 00041 ~PDFLibrary(); 00042 00043 /// get the instance of library 00044 static PDFLibrary & instance(); 00045 00046 /// get the instance of thread 00047 Thread & get_thread() { return thread; } 00048 00049 /// make enough memory for some one document 00050 bool make_enough_memory(PDFController *doc_ptr, 00051 const int page_num, 00052 const int length); 00053 00054 /// add new document 00055 void add_document(PDFController *doc_ptr); 00056 00057 /// remove the existing document 00058 void remove_document(PDFController *doc_ptr); 00059 00060 /// remove all of the tasks related to a document 00061 void remove_tasks_by_document(PDFController *doc); 00062 00063 /// handle adding render task 00064 void thread_add_render_task(Task *task, bool prerender, bool abort_current); 00065 00066 /// handle adding search task 00067 void thread_add_search_task(Task *task); 00068 00069 /// clear all of the render tasks 00070 void thread_cancel_render_tasks(void *user_data); 00071 00072 private: 00073 typedef std::vector<PDFController*> Documents; 00074 typedef Documents::iterator DocumentsIter; 00075 00076 private: 00077 // vector of documents 00078 Documents docs; 00079 00080 // the task executing thread 00081 Thread thread; 00082 00083 // memory limitation of PDF plugin 00084 unsigned int size_limit; 00085 00086 private: 00087 PDFLibrary(); 00088 PDFLibrary(const PDFLibrary &right); 00089 00090 /// try to start thread 00091 void try_start_thread(); 00092 00093 /// try to stop thread 00094 void try_stop_thread(); 00095 }; 00096 00097 }; 00098 00099 #endif //PDF_DOC_CONTROLLER_H_ 00100