Qore Programming Language  0.8.3
include/qore/ModuleManager.h (4311)
Go to the documentation of this file.
00001 /* -*- mode: c++; indent-tabs-mode: nil -*- */
00002 /*
00003   ModuleManager.h
00004 
00005   Qore Programming Language
00006 
00007   Copyright 2003 - 2011 David Nichols
00008 
00009   This library is free software; you can redistribute it and/or
00010   modify it under the terms of the GNU Lesser General Public
00011   License as published by the Free Software Foundation; either
00012   version 2.1 of the License, or (at your option) any later version.
00013 
00014   This library is distributed in the hope that it will be useful,
00015   but WITHOUT ANY WARRANTY; without even the implied warranty of
00016   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017   Lesser General Public License for more details.
00018 
00019   You should have received a copy of the GNU Lesser General Public
00020   License along with this library; if not, write to the Free Software
00021   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00022 */
00023 
00024 #ifndef _QORE_MODULEMANAGER_H
00025 
00026 #define _QORE_MODULEMANAGER_H
00027 
00028 #include <qore/QoreThreadLock.h>
00029 #include <qore/QoreString.h>
00030 
00031 #include <vector>
00032 
00037 #define QORE_MODULE_API_MAJOR 0  //!< the major number of the Qore module API implemented
00038 #define QORE_MODULE_API_MINOR 11 //!< the minor number of the Qore module API implemented
00039 
00040 #define QORE_MODULE_COMPAT_API_MAJOR 0  //!< the major number of the earliest recommended Qore module API
00041 #define QORE_MODULE_COMPAT_API_MINOR 11 //!< the minor number of the earliest recommended Qore module API 
00042 
00044 struct qore_mod_api_compat_s {
00045    unsigned char major;
00046    unsigned char minor;
00047 };
00048 
00050 DLLEXPORT extern const qore_mod_api_compat_s *qore_mod_api_list;
00051 
00053 DLLEXPORT extern const unsigned qore_mod_api_list_len;
00054 
00055 class QoreNamespace;
00056 class QoreStringNode;
00057 class QoreListNode;
00058 class ExceptionSink;
00059 
00061 typedef QoreStringNode *(*qore_module_init_t)();
00062 
00064 typedef void (*qore_module_ns_init_t)(QoreNamespace *root_ns, QoreNamespace *qore_ns);
00065 
00067 typedef void (*qore_module_delete_t)();
00068 
00070 typedef void (*qore_module_parse_cmd_t)(const QoreString &cmd, ExceptionSink *xsink);
00071 
00073 class version_list_t : public std::vector<int> {
00074 private:
00075    QoreString ver;
00076 public:
00077    DLLLOCAL char set(const char *v);
00078    DLLLOCAL const char *getString() const { return ver.getBuffer(); }
00079 };
00080 
00081 class ModuleInfo;
00082 
00083 enum mod_op_e { MOD_OP_NONE, MOD_OP_EQ, MOD_OP_GT, 
00084                 MOD_OP_GE, MOD_OP_LT, MOD_OP_LE };
00085 
00087 
00094 class ModuleManager {
00095 private:
00097    DLLLOCAL ModuleManager(const ModuleManager&);
00098 
00100    DLLLOCAL ModuleManager& operator=(const ModuleManager&);
00101 
00102 public:
00104 
00107    DLLEXPORT static void addModuleDir(const char *dir);
00108 
00110 
00113    DLLEXPORT static void addAutoModuleDir(const char *dir);
00114 
00116 
00119    DLLEXPORT static void addModuleDirList(const char *strlist);
00120 
00122 
00125    DLLEXPORT static void addAutoModuleDirList(const char *strlist);
00126 
00128    DLLEXPORT static QoreListNode *getModuleList();
00129 
00131    DLLEXPORT static QoreHashNode *getModuleHash();
00132 
00134 
00140    DLLEXPORT static int runTimeLoadModule(const char *name, ExceptionSink *xsink);
00141 
00143 
00148    DLLEXPORT static QoreStringNode *parseLoadModule(const char *name, QoreProgram *pgm = 0);
00149 
00151 
00153    DLLLOCAL ModuleManager();
00154 
00156 
00158    DLLLOCAL static void init(bool se);      
00159 
00161 
00163    DLLLOCAL static void cleanup();
00164 
00166 
00168    DLLLOCAL static void issue_parse_cmd(const char *mname, QoreProgram *pgm, QoreString &cmd);
00169 };
00170 
00172 DLLEXPORT extern ModuleManager MM;
00173 
00174 static inline bool is_module_api_supported(int major, int minor) {
00175    for (unsigned i = 0; i < qore_mod_api_list_len; ++i)
00176       if (qore_mod_api_list[i].major == major && qore_mod_api_list[i].minor == minor)
00177          return true;
00178    return false;
00179 }
00180 
00181 #endif // _QORE_MODULEMANAGER_H
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines