interface.h

Go to the documentation of this file.
00001 /* -*- Mode: c++ -*- */
00002 /*
00003  *  this is part of Spm
00004  *
00005  *  Copyright (c) 2005-2008 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 __INTERFACE_H__
00022 #define __INTERFACE_H__
00023 
00024 #include <map>
00025 #include <util/propertyList.h>
00026 #include <boost/tuple/tuple.hpp>
00027 
00028 namespace Spm
00029 {
00030   namespace Plugin
00031   {
00032     typedef enum 
00033       {
00034         GPL = 0,
00035         LGPL = 1,
00036         BSD = 2,
00037         NOT_FREE = 3
00038       } license_e;
00039     typedef enum 
00040       {
00041         INTERFACE_TYPE,
00042         DOWNLOAD_TYPE,
00043         STEP_TYPE,
00044         INSTALLER_TYPE,
00045         INFO_TYPE,
00046       } pluginType_e;
00047 
00048     const int OPTION_NO_VALUE = 0;
00049     const int OPTION_VALUE_NOT_MANDATORY = 1;
00050     const int OPTION_VALUE_MANDATORY = 2;
00051 
00056     typedef struct 
00057     {
00058       miniXml::ustring pluginName_; 
00059       miniXml::ustring pluginDescription_; 
00060       miniXml::ustring pluginAuthor_; 
00061       miniXml::ustring pluginVersion_; 
00062       license_e pluginLicense_; 
00063       pluginType_e pluginType_; 
00064       std::map<miniXml::ustring,
00065                boost::tuple<miniXml::ustring, 
00066                             int, 
00067                             Util::PropertyList::propertyType_e> > options_; 
00068     } pluginDescription_t;
00069 
00074     class Interface
00075     {
00076     public :
00077       friend class Plugin;
00078       typedef enum {INITIALIZATION,
00079                     RUNNING,
00080                     ENDED,
00081                     FAILED} state_e;
00082     protected :
00083       pluginDescription_t description_;
00084       //mutable boost::recursive_mutex mutex_;
00085       Util::PropertyList options_;
00086       state_e currentState_;
00087 
00088       Interface ()
00089       {
00090       }
00091 
00092       Interface (const Util::PropertyList & pList) : options_(pList),
00093                                                      currentState_(INITIALIZATION)
00094       {
00095       }
00096 
00097       virtual void initInfo () = 0;
00098 
00099     public :
00100       virtual ~Interface (){};
00101       
00105       inline const pluginDescription_t & getDescription ()
00106       {
00107         return description_;
00108       }
00109 
00113       state_e getState ()
00114       {
00115         return currentState_;
00116       }
00117 
00121       state_e getState () const
00122       {
00123         return currentState_;
00124       }
00125     };
00126   }
00127 }
00128 
00129 #endif

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