All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ModuleManager.h
Go to the documentation of this file.
/* -*- mode: c++; indent-tabs-mode: nil -*- */
/*
ModuleManager.h
Qore Programming Language
Copyright 2003 - 2013 David Nichols
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef _QORE_MODULEMANAGER_H
#define _QORE_MODULEMANAGER_H
#include <qore/QoreThreadLock.h>
#include <qore/QoreString.h>
#include <vector>
#define QORE_MODULE_API_MAJOR 0
#define QORE_MODULE_API_MINOR 16
#define QORE_MODULE_COMPAT_API_MAJOR 0
#define QORE_MODULE_COMPAT_API_MINOR 14
struct qore_mod_api_compat_s {
unsigned char major;
unsigned char minor;
};
DLLEXPORT extern const qore_mod_api_compat_s *qore_mod_api_list;
DLLEXPORT extern const unsigned qore_mod_api_list_len;
class QoreNamespace;
class QoreStringNode;
class QoreListNode;
class ExceptionSink;
typedef QoreStringNode *(*qore_module_init_t)();
typedef void (*qore_module_ns_init_t)(QoreNamespace *root_ns, QoreNamespace *qore_ns);
typedef void (*qore_module_delete_t)();
typedef void (*qore_module_parse_cmd_t)(const QoreString &cmd, ExceptionSink *xsink);
enum mod_op_e { MOD_OP_NONE, MOD_OP_EQ, MOD_OP_GT,
MOD_OP_GE, MOD_OP_LT, MOD_OP_LE };
class ModuleManager {
private:
DLLLOCAL ModuleManager(const ModuleManager&);
DLLLOCAL ModuleManager& operator=(const ModuleManager&);
public:
DLLEXPORT static void addModuleDir(const char *dir);
DLLEXPORT static void addAutoModuleDir(const char *dir);
DLLEXPORT static void addModuleDirList(const char *strlist);
DLLEXPORT static void addAutoModuleDirList(const char *strlist);
DLLEXPORT static QoreListNode *getModuleList();
DLLEXPORT static QoreHashNode *getModuleHash();
DLLEXPORT static int runTimeLoadModule(const char *name, ExceptionSink *xsink);
DLLEXPORT static QoreStringNode *parseLoadModule(const char *name, QoreProgram *pgm = 0);
DLLEXPORT static void addStandardModulePaths();
// not exported in the public API
DLLLOCAL ModuleManager();
};
DLLEXPORT extern ModuleManager MM;
static inline bool is_module_api_supported(int major, int minor) {
for (unsigned i = 0; i < qore_mod_api_list_len; ++i)
if (qore_mod_api_list[i].major == major && qore_mod_api_list[i].minor == minor)
return true;
return false;
}
#endif // _QORE_MODULEMANAGER_H