Qore Programming Language  0.8.7
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
ModuleManager.h
Go to the documentation of this file.
1 /* -*- mode: c++; indent-tabs-mode: nil -*- */
2 /*
3  ModuleManager.h
4 
5  Qore Programming Language
6 
7  Copyright 2003 - 2013 David Nichols
8 
9  This library is free software; you can redistribute it and/or
10  modify it under the terms of the GNU Lesser General Public
11  License as published by the Free Software Foundation; either
12  version 2.1 of the License, or (at your option) any later version.
13 
14  This library is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public
20  License along with this library; if not, write to the Free Software
21  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 */
23 
24 #ifndef _QORE_MODULEMANAGER_H
25 
26 #define _QORE_MODULEMANAGER_H
27 
28 #include <qore/QoreThreadLock.h>
29 #include <qore/QoreString.h>
30 
31 #include <vector>
32 
37 #define QORE_MODULE_API_MAJOR 0
38 #define QORE_MODULE_API_MINOR 16
39 
40 #define QORE_MODULE_COMPAT_API_MAJOR 0
41 #define QORE_MODULE_COMPAT_API_MINOR 14
42 
43 
45  unsigned char major;
46  unsigned char minor;
47 };
48 
50 DLLEXPORT extern const qore_mod_api_compat_s *qore_mod_api_list;
51 
53 DLLEXPORT extern const unsigned qore_mod_api_list_len;
54 
55 class QoreNamespace;
56 class QoreStringNode;
57 class QoreListNode;
58 class ExceptionSink;
59 
61 typedef QoreStringNode *(*qore_module_init_t)();
62 
64 typedef void (*qore_module_ns_init_t)(QoreNamespace *root_ns, QoreNamespace *qore_ns);
65 
67 typedef void (*qore_module_delete_t)();
68 
70 typedef void (*qore_module_parse_cmd_t)(const QoreString &cmd, ExceptionSink *xsink);
71 
72 enum mod_op_e { MOD_OP_NONE, MOD_OP_EQ, MOD_OP_GT,
73  MOD_OP_GE, MOD_OP_LT, MOD_OP_LE };
74 
76 
84 private:
86  DLLLOCAL ModuleManager(const ModuleManager&);
87 
89  DLLLOCAL ModuleManager& operator=(const ModuleManager&);
90 
91 public:
93 
96  DLLEXPORT static void addModuleDir(const char *dir);
97 
99 
102  DLLEXPORT static void addAutoModuleDir(const char *dir);
103 
105 
108  DLLEXPORT static void addModuleDirList(const char *strlist);
109 
111 
114  DLLEXPORT static void addAutoModuleDirList(const char *strlist);
115 
117  DLLEXPORT static QoreListNode *getModuleList();
118 
120  DLLEXPORT static QoreHashNode *getModuleHash();
121 
123 
129  DLLEXPORT static int runTimeLoadModule(const char *name, ExceptionSink *xsink);
130 
132 
137  DLLEXPORT static QoreStringNode *parseLoadModule(const char *name, QoreProgram *pgm = 0);
138 
140  DLLEXPORT static void addStandardModulePaths();
141 
142  // not exported in the public API
143  DLLLOCAL ModuleManager();
144 };
145 
147 DLLEXPORT extern ModuleManager MM;
148 
149 static inline bool is_module_api_supported(int major, int minor) {
150  for (unsigned i = 0; i < qore_mod_api_list_len; ++i)
151  if (qore_mod_api_list[i].major == major && qore_mod_api_list[i].minor == minor)
152  return true;
153  return false;
154 }
155 
156 #endif // _QORE_MODULEMANAGER_H