00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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