downloadInterface.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2005 Guillaume Chevallereau
00006  *
00007  *  This program is free software. You can redistribute it and/or modify it 
00008  *  under the terms of the GNU General Public License as published by the 
00009  *  Free Software Foundation. Either version 2 of the license or (at your 
00010  *  option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be usefull but WITHOUT
00013  *  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
00014  *  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
00015  *  more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License along 
00018  *  with this program; if not, write to the Free Software Foundation, Inc., 
00019  *  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA
00020  */
00021 #ifndef __DOWNLOAD_INTERFACE_H__
00022 #define __DOWNLOAD_INTERFACE_H__
00023 
00024 #include <map>
00025 #include "interface.h"
00026 #include <boost/filesystem/path.hpp>
00027 #include <util/net.h>
00028 
00029 #define SPM_DOWNLOADER_PLUGIN(plugin)                                   \
00030   extern "C"                                                            \
00031   {                                                                     \
00032     Spm::Plugin::pluginDescription_t getSpmPluginDescription ()         \
00033     {                                                                   \
00034       return plugin ().getDescription ();                               \
00035     }                                                                   \
00036                                                                         \
00037     plugin * getSpmPluginInfo ()                                        \
00038     {                                                                   \
00039       return new plugin ();                                             \
00040     }                                                                   \
00041                                                                         \
00042     plugin * getSpmPlugin (const Spm::Util::urlDetails & url)           \
00043     {                                                                   \
00044       return new plugin (url);                                          \
00045     }                                                                   \
00046   }
00047 
00048 namespace Spm
00049 {
00050   namespace Plugin
00051   {
00056     class DownloadInterface : public Interface
00057     {
00058     protected :
00059       double fractionDone;
00060       Util::urlDetails url;
00061 
00062       DownloadInterface ()
00063       {
00064         description_.pluginType_ = DOWNLOAD_TYPE;
00065       }
00066       
00067       DownloadInterface (const Util::urlDetails & u)
00068       {
00069         url = u;
00070         fractionDone = -1;
00071         description_.pluginType_ = DOWNLOAD_TYPE;
00072       }
00073 
00074     public :
00075       virtual ~DownloadInterface (){};
00082       virtual void download (const miniXml::ustring & uri, 
00083                              const boost::filesystem::path & to) = 0;
00089       virtual bool handle (const miniXml::ustring & uri) = 0;
00090 
00091       double getFractionDone ()
00092       {
00093         return fractionDone;
00094       }
00095     };
00096   }
00097 }
00098 
00099 #endif

Generated on Sat Mar 21 17:00:14 2009 for libSpm by  doxygen 1.5.2