Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * module_manager.h - manager for modules (i.e. shared objects) 00004 * 00005 * Generated: Wed Aug 23 16:15:02 2006 00006 * Copyright 2006 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __UTILS_SYSTEM_DYNAMIC_MODULE_MODULE_MANAGER_H_ 00025 #define __UTILS_SYSTEM_DYNAMIC_MODULE_MODULE_MANAGER_H_ 00026 00027 #include <utils/system/dynamic_module/module.h> 00028 00029 namespace fawkes { 00030 00031 /** Manager interface to load and unload modules, keeps track of loaded modules 00032 * and does not reload modules if they are already loaded 00033 */ 00034 class ModuleManager { 00035 public: 00036 00037 /** Virtual destructor for pure virtual class 00038 */ 00039 virtual ~ModuleManager() {} 00040 00041 /** Open a module 00042 * @param filename The file name of the module that should be 00043 * opened. If the ModuleManager implementation takes a base dir 00044 * argument (recommended) this filename is relative to that 00045 * base dir 00046 * @return Returns the module if the file was opened successfully 00047 * or NULL otherwise. Do NOT delete the module after usage but use 00048 * closeModule to close it. 00049 * @exception ModuleOpenException thrown if the module could not be opened 00050 */ 00051 virtual Module * open_module(const char *filename) = 0; 00052 00053 /** Close a module by Module instance 00054 * @param module The module that is to be closed 00055 */ 00056 virtual void close_module(Module *module) = 0; 00057 00058 /** Close a module by filename 00059 * @param filename the name of the module file that should be closed, this 00060 * is compared to loaded modules and must match what 00061 * Module::GetBaseFilename() returns 00062 */ 00063 virtual void close_module(const char *filename) = 0; 00064 00065 /** Check if the module for the given filename is already 00066 * opened 00067 * @param filename the name of the module file to check if it is opened. 00068 * It is compared to loaded modules and must match what 00069 * Module::GetBaseFilename() returns 00070 * @return true if module has been opened, false otherwise 00071 */ 00072 virtual bool module_opened(const char *filename) = 0; 00073 00074 /** Get a module if opened. 00075 * This will return a pointer to a module if it had already been opened! The 00076 * reference count is increased and you have to manually unref the module once 00077 * you are done with it! This method works similar to open_module() with the 00078 * difference that it is not tried to load the module if it is not open. 00079 * @param filename file name of the module 00080 * @return a pointer to the module with the reference cound incremented by one 00081 * if the module had been opened already or NULL if it was not opened. 00082 */ 00083 virtual Module * get_module(const char *filename) = 0; 00084 00085 /** Get the file extension for the current module type 00086 * @return Returns a string with the file extension that has to 00087 * be used for modules on the current system (for example "so") 00088 */ 00089 virtual const char * get_module_file_extension() = 0; 00090 00091 }; 00092 00093 } // end namespace fawkes 00094 00095 #endif