interface.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 __INTERFACE_H__
00022 #define __INTERFACE_H__
00023 
00024 #include <string>
00025 #include <map>
00026 #include "pluginDef.h"
00027 
00028 namespace Spm
00029 {
00030   namespace Plugin
00031   {
00032     typedef enum {GPL = 0,
00033                   LGPL = 1,
00034                   BSD = 2,
00035                   NOT_FREE = 3} license_e;
00036     typedef enum {INITIALIZATION,
00037                   RUNNING,
00038                   ENDED,
00039                   FAILED} state_e;
00040     const int OPTION_NO_VALUE = 0;
00041     const int OPTION_VALUE_NOT_MANDATORY = 1;
00042     const int OPTION_VALUE_MANDATORY = 2;
00043 
00048     typedef struct 
00049     {
00050       std::string __pluginName;
00051       std::string __pluginDescription;
00052       std::string __pluginAuthor;
00053       std::string __pluginVersion;
00054       license_e __pluginLicense;
00055       pluginType_e __pluginType;
00056       std::map<std::string,
00057                std::pair<std::string,
00058                          int> > __interfaceOptions;
00059     } pluginDescription_t;
00060 
00061     class Interface
00062     {
00063       friend class Plugin;
00064     protected :
00065       pluginDescription_t __description;
00066       std::map<std::string,
00067                std::string> pluginOptions;
00068       state_e currentState;
00069 
00070       Interface ()
00071       {
00072       }
00073 
00074     public :
00075 
00076       Interface (const std::map<std::string, std::string> & pOptions)
00077       {
00078         for (std::map<std::string,std::string>::const_iterator itMap = pOptions.begin ();
00079              itMap != pOptions.end ();
00080              itMap++)
00081           pluginOptions[itMap->first] = itMap->second;
00082       }
00083 
00084       virtual ~Interface (){};
00085       
00086       virtual bool handle (const std::string & uri) = 0;
00087 
00088       inline const pluginDescription_t & getDescription ()
00089       {
00090         return __description;
00091       }
00092 
00096       state_e getState ()
00097       {
00098         return currentState;
00099       }
00100 
00104       state_e getState () const
00105       {
00106         return currentState;
00107       }
00108     };
00109   }
00110 }
00111 
00112 #endif

Generated on Wed Jul 4 15:27:21 2007 for libSpm by  doxygen 1.4.6