Qore ProviderIndexUtil Module Reference 1.0
Loading...
Searching...
No Matches
ProviderIndexUtil.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
4/* ProviderIndexUtil.qc Copyright 2025 Qore Technologies, s.r.o.
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23*/
24
28const ProviderIndexEnvVar = "QORE_PROVIDER_INDEX_DIR";
29
31public hashdecl DataProviderIndexInfo {
33 *hash<string, string> factorymap;
34
36 *hash<string, hash<string, bool>> appmap;
37
39 *hash<string, hash<string, bool>> schememap;
40
42 *hash<string, hash<auto>> appinfomap;
43
45
50 *hash<string, hash<string, hash<auto>>> actioninfomap;
51
53
58 *hash<string, hash<auto>> top_actioninfomap;
59};
60
62public hashdecl ProviderIndexInfo {
64 string path;
65
67 int size;
68
70 date delta;
71
73 hash<auto> summary;
74};
75
78
79public:
80
81
82protected:
84 static *LoggerInterface logger;
85
87 static Mutex m();
88
90 static *hash<DataProviderIndexInfo> index;
91
93 static bool initialized;
94
96 static bool apps_loaded;
97
98public:
99
101 static *list<hash<auto>> getCachedApps();
102
104
109 static *list<hash<auto>> searchCachedAppRegex(string regex_pattern, int regex_options = RE_Caseless);
110
112
118 static *list<hash<auto>> searchCachedAppSubstr(string substr, bool ignore_case = True);
119
121 static *hash<auto> tryGetAppInfo(string app);
122
124 static *list<hash<auto>> tryGetApproximateActionsForApp(string app);
125
127 static *hash<auto> tryGetApproximateAppAction(string app, string action);
128
130
138 static *list<hash<auto>> searchCachedAppActionRegex(string app, string regex_pattern, int regex_options = RE_Caseless);
139
141
149 static *list<hash<auto>> searchCachedAppActionSubstr(string app, string substr, bool ignore_case = True);
150
152
157 static *list<hash<auto>> searchCachedActionRegex(string regex_pattern, int regex_options = RE_Caseless);
158
160
165 static *list<hash<auto>> searchCachedActionSubstr(string substr, bool ignore_case = True);
166
168
170 static *list<hash<auto>> getAllCachedActions();
171
173 static addAppToCache(hash<auto> app);
174
176 static addActionToCache(hash<auto> action);
177
179 static bool removeCachedApp(string app);
180
182
186 static bool checkFactoryModule(string factory);
187
189
193 static bool checkAppModule(string app);
194
196
200 static bool checkSchemeModule(string scheme);
201
203
207 static bool tryLoadModule(string mod);
208
210 static *list<string> getAllAppModulesToLoad();
211
213protected:
215public:
216
217
219
221 static setGlobalLogger(*LoggerInterface logger);
222
224
226 static *LoggerInterface getGlobalLogger();
227
229 static hash<ProviderIndexInfo> writeDataProviderIndex(*hash<DataProviderIndexInfo> h, date delta, hash<auto> summary);
230
232 static *hash<DataProviderIndexInfo> readDataProviderIndex();
233
235protected:
236 static hash<auto> deserializeActions(hash<string, hash<string, hash<auto>>> actioninfomap, TypedHash action_info_th, TypedHash option_info_th, TypedHash path_vars_th, hash<auto> type_map);
237public:
238
239
241protected:
242 static hash<ProviderIndexInfo> writeIndex(*hash<auto> h, string type, date delta, hash<auto> summary);
243public:
244
245
247protected:
248 static *hash<auto> readIndex(string type);
249public:
250
251
253 static string getIndexPath(string type);
254
256 static setEnvironmentVariable(string dir);
257
259 static *string tryGetIndexDir(*bool throw_exception);
260
262 static log(Qore::Logger::LoggerLevel level, string fmt, ...);
263
265 static logArgs(Qore::Logger::LoggerLevel level, string fmt, *softlist<auto> args);
266};
267};
static *LoggerInterface logger
Global logger.
Definition ProviderIndexUtil.qc.dox.h:84
static *list< string > getAllAppModulesToLoad()
Returns a list of all app modules that have not been returned by a call to this method yet and are no...
static *string tryGetIndexDir(*bool throw_exception)
Try to get the index directory from the environment variable.
static setGlobalLogger(*LoggerInterface logger)
Sets or clears the global logger.
static bool apps_loaded
All apps loaded flag.
Definition ProviderIndexUtil.qc.dox.h:96
static *list< hash< auto > > getCachedApps()
Returns a list of cached app info.
static hash< auto > deserializeActions(hash< string, hash< string, hash< auto > > > actioninfomap, TypedHash action_info_th, TypedHash option_info_th, TypedHash path_vars_th, hash< auto > type_map)
Deserialize action options.
static setEnvironmentVariable(string dir)
Sets the environment variable.
static *list< hash< auto > > getAllCachedActions()
Returns all cached actions.
static *hash< auto > tryGetApproximateAppAction(string app, string action)
Try to return any cached approximate app action for the given app and action.
static bool checkFactoryModule(string factory)
Try to ensure that any required module is loaded for the given factory.
static addAppToCache(hash< auto > app)
Adds the given app and actions to the cache.
static hash< ProviderIndexInfo > writeIndex(*hash< auto > h, string type, date delta, hash< auto > summary)
Writes the index to the configured directory.
static *list< hash< auto > > searchCachedActionSubstr(string substr, bool ignore_case=True)
Searches for cached actions whose descriptions match a substring.
static log(Qore::Logger::LoggerLevel level, string fmt,...)
Log a message to the global logger if possible.
static bool checkAppModule(string app)
Try to ensure that any required modules are loaded for the given data provider application.
static bool initialized
Initialized flag.
Definition ProviderIndexUtil.qc.dox.h:93
static Mutex m()
Global mutex.
static string getIndexPath(string type)
Returns the index path for the given type.
static *list< hash< auto > > searchCachedActionRegex(string regex_pattern, int regex_options=RE_Caseless)
Searches for cached actions whose descriptions match a regular expression pattern.
static *hash< DataProviderIndexInfo > index
Global data provider index.
Definition ProviderIndexUtil.qc.dox.h:90
static addActionToCache(hash< auto > action)
Adds the given app and actions to the cache.
static *hash< auto > tryGetAppInfo(string app)
Try to return any cached app info for the given app.
static *list< hash< auto > > searchCachedAppActionSubstr(string app, string substr, bool ignore_case=True)
Searches for cached application actions whose descriptions match a substring.
static *list< hash< auto > > searchCachedAppActionRegex(string app, string regex_pattern, int regex_options=RE_Caseless)
Searches for cached application actions whose descriptions match a regular expression pattern.
static *hash< DataProviderIndexInfo > readDataProviderIndex()
Reads the data provider index from the configured directory.
static hash< ProviderIndexInfo > writeDataProviderIndex(*hash< DataProviderIndexInfo > h, date delta, hash< auto > summary)
Writes the data provider index to the configured directory.
static bool checkSchemeModule(string scheme)
Try to ensure that any required modules are loaded for the given connection scheme.
static *list< hash< auto > > searchCachedAppRegex(string regex_pattern, int regex_options=RE_Caseless)
Searches the app info cache for applications whose names or descriptions match a regular expression p...
static *hash< auto > readIndex(string type)
Reads the index from the configured directory.
static *LoggerInterface getGlobalLogger()
Returns the global data provider logger.
static bool removeCachedApp(string app)
Removes the given app and all its actions from the cache.
static bool tryLoadModule(string mod)
Tries to load the given module or path to the module.
static *list< hash< auto > > searchCachedAppSubstr(string substr, bool ignore_case=True)
Searches for cachde applications whose names or descriptions match a substring.
static checkDataIndex()
Checks if the data provider index has been populated.
static logArgs(Qore::Logger::LoggerLevel level, string fmt, *softlist< auto > args)
Log a message to the global logger if possible.
static *list< hash< auto > > tryGetApproximateActionsForApp(string app)
Try to return any cached approximate app action list for the given app.
contains all public definitions in the ProviderIndexUtil module
Definition ProviderIndexUtil.qc.dox.h:26
const ProviderIndexEnvVar
The environment variable for the provider index.
Definition ProviderIndexUtil.qc.dox.h:28
Data provider index.
Definition ProviderIndexUtil.qc.dox.h:31
*hash< string, hash< auto > > top_actioninfomap
Maps app actions to action info hashes.
Definition ProviderIndexUtil.qc.dox.h:58
*hash< string, hash< auto > > appinfomap
App to app info map.
Definition ProviderIndexUtil.qc.dox.h:42
*hash< string, hash< string, bool > > appmap
App to module map.
Definition ProviderIndexUtil.qc.dox.h:36
*hash< string, string > factorymap
Factory to module map.
Definition ProviderIndexUtil.qc.dox.h:33
*hash< string, hash< string, bool > > schememap
Scheme to module map.
Definition ProviderIndexUtil.qc.dox.h:39
*hash< string, hash< string, hash< auto > > > actioninfomap
Maps apps to actions to action info hashes.
Definition ProviderIndexUtil.qc.dox.h:50
Index info.
Definition ProviderIndexUtil.qc.dox.h:62
string path
Path to the index file.
Definition ProviderIndexUtil.qc.dox.h:64
int size
Size of the index file.
Definition ProviderIndexUtil.qc.dox.h:67
hash< auto > summary
Summary info for the indexing operation.
Definition ProviderIndexUtil.qc.dox.h:73
date delta
Elapsed time to create the Index.
Definition ProviderIndexUtil.qc.dox.h:70