include/GUI/DocumentFetcher.hpp

Go to the documentation of this file.
00001 #ifndef hpp_CPP_DocumentFetcher_CPP_hpp
00002 #define hpp_CPP_DocumentFetcher_CPP_hpp
00003 
00004 // We need download job declaration
00005 #include "DownloadJob.hpp"
00006 
00007 namespace UZI
00008 {
00010     class DocumentFetcher : public Cache::RequiredFetcherImplementation
00011     {
00012         // Members 
00013     private:
00015         juce::ThreadPool    threadPool;
00016 
00017         // RequiredFetcherImplementation interface
00018     public:    
00028         virtual bool queueDocumentToFetch(volatile Cache::Item & item, void * opaque = 0)
00029         {
00030             DownloadJob * job = new DownloadJob();
00031             if (!job) return false;
00032             if (!job->queueItemToFetch(&item, (juce::String *)opaque)) return false;
00033             threadPool.addJob(job);
00034             return true;
00035         }
00036 
00051         virtual uint32 isItemFetched(volatile Cache::Item & item) const
00052         {
00053             switch (item.getStatus())
00054             {
00055             case Cache::Item::Ready:
00056                 return item.getDataSize();
00057             case Cache::Item::WaitingFetching:
00058                 return -1; // Boolean result, either the item is fully fetched or it's not.
00059             default:
00060                 return -1;
00061             }
00062         }
00063 
00064         // Construction / Destruction
00065     public:
00066         DocumentFetcher() : threadPool(5, false, 0) {}
00067         ~DocumentFetcher() { threadPool.removeAllJobs(true, 2000); }
00068     };
00069 
00070 }
00071 
00072 #endif

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is