MOGAL
|
00001 /* 00002 00003 This file is a part of MOGAL, a Multi-Objective Genetic Algorithm 00004 Library. 00005 00006 Copyright (C) 2008-2012 Jori Liesenborgs 00007 00008 Contact: jori.liesenborgs@gmail.com 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00023 USA 00024 00025 */ 00026 00031 #ifndef MOGAL_MODULEBASE_H 00032 00033 #define MOGAL_MODULEBASE_H 00034 00035 #include "mogalconfig.h" 00036 00037 #ifdef MOGALCONFIG_LOADLIBRARY 00038 #include <windows.h> 00039 #endif // MOGALCONFIG_LOADLIBRARY 00040 00041 #include <errut/errorbase.h> 00042 #include <string> 00043 #include <list> 00044 00045 namespace mogal 00046 { 00047 00049 class MOGAL_IMPORTEXPORT ModuleBase : public errut::ErrorBase 00050 { 00051 protected: 00052 ModuleBase(); 00053 ~ModuleBase(); 00054 public: 00062 bool open(const std::string &modulePath); 00063 00070 bool open(const std::string &baseDirectory, const std::string &moduleName); 00071 00073 bool close(); 00074 00076 bool isOpen() const { return (m_pModule == 0)?false:true; } 00077 protected: 00087 virtual void onFoundFunctionName(const std::string &name, void *pFunction) = 0; 00088 00090 void registerFunctionName(const std::string &name) { m_functionNames.push_back(name); } 00091 private: 00092 #ifdef MOGALCONFIG_LOADLIBRARY 00093 HMODULE m_pModule; 00094 #else 00095 void *m_pModule; 00096 #endif // MOGALCONFIG_LOADLIBRARY 00097 00098 std::list<std::string> m_functionNames; 00099 }; 00100 00101 } // end namespace 00102 00103 #endif // MOGAL_MODULEBASE_H 00104