00001 // $Id: SLPluginFeature.hpp,v 1.7 2004/04/15 00:04:52 mr_lex Exp $ 00002 #ifndef SL_PLUGIN_FEATURE_HPP 00003 #define SL_PLUGIN_FEATURE_HPP 00004 00005 #include "segusoland.hpp" 00006 #include "SLConfig.hpp" 00007 #include "SLMime.hpp" 00008 #include "SLFileList.hpp" 00009 #include "SLDirectoryList.hpp" 00010 #include "SLDeviceList.hpp" 00011 #include "SLFileExt.hpp" 00012 00013 SL_NAMESPACE_BEGIN 00014 using namespace std; 00015 00030 class SLPluginFeature { 00031 public: 00032 class MimeTypes; 00033 class Devices; 00034 class Programs; 00035 class Files; 00036 class ConfigFile; 00037 class DBAccess; 00038 00043 class Exception : public SLException { 00044 public: 00049 Exception::Exception(const SLString &message) : 00050 SLException(message) 00051 { } 00052 }; 00053 00058 class Type { 00059 public: 00063 enum Types {MimeTypes, Devices, Programs, Files, ConfigFile, DBAccess}; 00064 00070 static const char *to_cstr(Types type) { 00071 switch(type) { 00072 case MimeTypes: 00073 return "MimeTypes"; 00074 break; 00075 case Devices: 00076 return "Devices"; 00077 break; 00078 case Programs: 00079 return "Programs"; 00080 break; 00081 case Files: 00082 return "Files"; 00083 break; 00084 case ConfigFile: 00085 return "ConfigFile"; 00086 break; 00087 case DBAccess: 00088 return "DBAccess"; 00089 break; 00090 default: 00091 return "UNKNOWN???"; 00092 break; 00093 } // switch 00094 } // to_cstr(); 00095 }; 00096 }; // class SLPluginFeature 00097 00098 00107 class SLPluginFeature::MimeTypes : public SLPluginFeature { 00108 public: 00119 virtual SLMime getMimeFromFile(const SLFile &file) = 0; 00120 00121 }; // class SLPluginFeature::Mime 00122 00123 00132 class SLPluginFeature::Devices : public SLPluginFeature { 00133 public: 00138 virtual SLDeviceList getDeviceList() = 0; 00139 }; // class SLPluginFeature::Devices 00140 00141 00151 class SLPluginFeature::Programs : public SLPluginFeature { 00152 public: 00153 // virtual SLProgramList getProgramList() = 0; 00154 }; // class SLPluginFeature::Programs 00155 00156 00211 class SLPluginFeature::DBAccess : public SLPluginFeature { 00212 public: 00213 class Connection; // REMOVE (for mkplugin.sh) 00214 class Results; // REMOVE (for mkplugin.sh) 00215 class Exception; // REMOVE (for mkplugin.sh) 00216 00224 virtual SLPluginFeature::DBAccess::Connection &getConnection(const char *dbName = "segusoland") = 0; 00225 }; // class SLPluginFeature::DBAccess 00226 00227 00233 class SLPluginFeature::DBAccess::Exception : public SLPluginFeature::Exception { 00234 public: 00235 Exception::Exception(const SLString &message) : 00236 SLPluginFeature::Exception(message) 00237 {} 00238 }; 00239 00240 00248 class SLPluginFeature::DBAccess::Results { 00249 public: 00255 virtual unsigned int getCount() = 0; 00256 00263 virtual bool next() = 0; 00264 00269 virtual unsigned int getRowCount() = 0; 00270 00277 virtual const char *getColumn(unsigned int i) = 0; 00278 }; 00279 00280 00292 class SLPluginFeature::DBAccess::Connection { 00293 public: 00300 virtual Results *execSQL(const char *SQL) = 0; 00301 00306 virtual void freeResults(Results *results) = 0; 00307 }; 00308 00309 00318 class SLPluginFeature::ConfigFile : public SLPluginFeature { 00319 public: 00320 //virtual SLConfig& loadConfig() = 0; 00321 //virtual void saveConfig(const SLConfig &config) = 0; 00322 00323 }; // class SLPluginFeature::ConfigFile 00324 00325 00372 class SLPluginFeature::Files : public SLPluginFeature { 00373 public: 00374 class Exception; 00375 00380 virtual const SLFileList getFileList() = 0; 00381 00387 virtual const SLDirectoryList getDirectoryList() = 0; 00388 00394 virtual SLFileList getFilesMatchingMime(const SLMime &mime) = 0; 00395 00401 virtual SLFileList getFilesMatchingExt(const SLFileExt &ext) = 0; 00402 00406 virtual void updateDirectory(SLDirectory &dir) = 0; 00407 00416 virtual void addDirectoryToDB(SLDirectory &dir, bool recursive = false) = 0; 00417 00426 virtual void delDirectoryFromDB(SLDirectory &dir, bool recursive = false) = 0; 00427 00428 }; // class SLPluginFeature::Files 00429 00430 00435 class SLPluginFeature::Files::Exception : public SLPluginFeature::Exception { 00436 public: 00438 Exception::Exception(const SLString &message) : 00439 SLPluginFeature::Exception(message) 00440 {} 00441 }; 00442 00443 00444 SL_NAMESPACE_END 00445 #endif // #ifndef SL_PLUGIN_FEATURE_HPP 00446 00447 // $Log: SLPluginFeature.hpp,v $ 00448 // Revision 1.7 2004/04/15 00:04:52 mr_lex 00449 // NEW: files plugin + autotools up to date 00450 // 00451 // Revision 1.6 2004/04/13 13:56:15 mr_lex 00452 // NEW: added mysql plugin 00453 // 00454 // Revision 1.5 2004/04/05 23:42:41 mr_lex 00455 // FIX: various Exceptions issues + unloading of plugins 00456 // 00457 // Revision 1.4 2004/04/05 18:11:54 mr_lex 00458 // NEW: 1st working version of plugins 00459 // 00460 // Revision 1.3 2004/04/05 01:42:30 mr_lex 00461 // FIX: bug with abstract class & plugins 00462 // 00463 // Revision 1.2 2004/04/03 15:07:34 mr_lex 00464 // NEW: plugin system and toolkit nearly mature 00465 // 00466 // Revision 1.1 2004/04/01 19:04:44 mr_lex 00467 // NEW: moved from plugins directory 00468 // 00469