Qore DataProvider Module Reference 3.3.0
Loading...
Searching...
No Matches
DataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
27namespace DataProvider {
38
41const DPO_EnableServers = (1 << 0);
42
44
48
50
53
55const DPO_AllOptions = ...;
56
58
61
62public:
64 const FactoryMap = ...;
65
66
68 const TypeMap = ...;
69
70
72 const FactoryModuleList = keys (map {$1: True}, FactoryMap.iterator());
73 // "map" is used above to ensure that the values only appear once in the final list
74
76 const NoApp = "$NO_APP";
77
78protected:
80 static hash<string, AbstractDataProviderFactory> factory_cache;
81
83 static hash<string, string> factory_module_map;
84
86 static Gate factory_cache_lock();
87
90
92 static hash<string, string> type_module_map;
93
95
97 static bool allow_env_config = False;
98
100 static bool env_config_locked = False;
101
103 static hash<string, bool> mod_map;
104
106 static list<code> ilist;
107
109 static list<*list<code>> ilist_save;
110
112 static hash<string, code> smap;
113
115 static int options = 0;
116
118 static *LoggerInterface logger;
119
120public:
121
123
127 static setGlobalLogger(*LoggerInterface logger);
128
130
134 static *LoggerInterface getGlobalLogger();
135
137
143 static addOptions(int options);
144
146
152 static removeOptions(int options);
153
155
159 static int getOptions();
160
162
168 static setOptions(int options);
169
171
175 static checkOptions(int options);
176
178
183
186
188
195
197
207 static AbstractDataProvider getFactoryObjectWithTemplate(string path, *hash<auto> template_options, *hash<auto> options);
208
210
218 static AbstractDataProvider getFactoryObjectFromExample(string path, data example, *hash<auto> options);
219
221
229 static AbstractDataProvider getFactoryObjectFromExample(string path, InputStream example, *hash<auto> options);
230
232
237 static AbstractDataProvider getFactoryObject(string path, *hash<auto> options);
238
240
251
253
266
268protected:
269 static hash<FactoryInfo> getFactoryInfoFromString(string name);
270public:
271
272
274 static *list<string> listFactories();
275
278
280
288 static registerType(string path, AbstractDataProviderType type);
289
291
298 static *AbstractDataProviderType getType(string path);
299
301
311
314
316 static lockAllTypes();
317
319
323 static *list<string> listTypes();
324
327
329
338 static string renderExpression(hash<DataProviderExpression> exp, *hash<string, hash<DataProviderExpressionInfo>> emap = DataProviderGenericExpressions);
339
341 static loadProvidersFromEnvironment(*LoggerInterface logger);
342
344 static *AbstractDataProvider tryLoadProviderForConnectionFromEnv(string name, *string subtype, *LoggerInterface logger);
345
348
350 static loadTypesFromEnvironment(*LoggerInterface logger);
351
353
356 static hash<auto> getInfoAsData(hash<auto> info0, *bool with_type_info);
357
359
364
366 static bool getAutoConfig();
367
369 static list<string> getPathList(string path);
370
372 static list<string> getPathList(reference<string> path);
373
375
377 static registerStaticInitializer(code init);
378
380
383
385
388
390
393
395protected:
396 synchronized static checkStaticInitIntern();
397public:
398
399
401
403 static shutdown();
404
406
411 static registerShutdownHandler(string key, code handler);
412
414
420 static bool deregisterShutdownHandler(string key);
421
423protected:
424 static checkRequest();
425public:
426
427
429protected:
430 static *string tryGetFactoryModuleName(string name);
431public:
432
433
435protected:
436 static *string tryGetTypeModuleName(string name);
437public:
438
439
441protected:
442 static *string tryGetModuleName(string name, string func, string type);
443public:
444
445
447protected:
448 static *DataProviderTypeEntry tryLoadTypeFromPath(list<string> type_path);
449public:
450
451
453protected:
454 static bool tryLoad(string module_str, *bool init);
455public:
456
457
459protected:
460 static *object loadFromEnvironment(string func, string type, *hash<SymbolInfo> info, *LoggerInterface logger);
461public:
462
463
465protected:
466 static *object checkSymbol(hash<SymbolInfo> info, *LoggerInterface logger);
467public:
468
469
471protected:
472 static bool checkInjection(object obj, hash<string, string> module_map);
473public:
474
475
477
480protected:
481 static string renderExpressionArg(hash<DataProviderFieldReference> ref, hash<string, hash<DataProviderExpressionInfo>> emap, *hash<DataProviderArgInfo> arg_info);
482public:
483
484
486
489protected:
490 static string renderExpressionArg(hash<DataProviderExpression> exp, hash<string, hash<DataProviderExpressionInfo>> emap, *hash<DataProviderArgInfo> arg_info);
491public:
492
493
495
498protected:
499 static string renderExpressionArg(auto v, hash<string, hash<DataProviderExpressionInfo>> emap, *hash<DataProviderArgInfo> arg_info);
500public:
501
502
504
507protected:
508 static string renderExpressionTemplate(hash<DataProviderExpressionInfo> info, hash<DataProviderExpression> exp, hash<string, hash<DataProviderExpressionInfo>> emap);
509public:
510
511
513protected:
514 static deregisterFactory(string name);
515public:
516
517};
518
519// private hashdecls
520hashdecl SymbolInfo {
521 // symbol type
522 string type;
523 // symbol name
524 string name;
525 // subtype, if any
526 *string subtype;
527}
528hashdecl FactoryInfo {
529 // factory name
530 string name;
531 // path to final data provider in factory
532 list<string> path_list;
533 // factory options
534 auto options;
535}
536}
Data provider factory class.
Definition AbstractDataProviderFactory.qc.dox.h:68
The AbstractDataProvider class.
Definition AbstractDataProvider.qc.dox.h:1004
describes a data type
Definition AbstractDataProviderType.qc.dox.h:139
static list< string > getPathList(reference< string > path)
Returns a list of strings in a path separated by "/" characters, normalizes the argument.
static string renderExpressionTemplate(hash< DataProviderExpressionInfo > info, hash< DataProviderExpression > exp, hash< string, hash< DataProviderExpressionInfo > > emap)
Renders the expression from the template.
static *AbstractDataProviderType getType(string path)
Returns the given data provider type or NOTHING if not present.
static string renderExpressionArg(auto v, hash< string, hash< DataProviderExpressionInfo > > emap, *hash< DataProviderArgInfo > arg_info)
Returns a descriptive string for the given argument.
static AbstractDataProviderType getTypeEx(string path)
Returns the given data provider type or throws an exception if not present.
static int getOptions()
Returns global data provider options.
static registerKnownFactories()
Registers all known data provider factories.
static *DataProviderTypeEntry tryLoadTypeFromPath(list< string > type_path)
Tries to load the given type.
static setAutoConfig()
Sets the flag that allows for automatic configuration from environment variables.
static AbstractDataProvider getFactoryObjectFromString(string name)
Returns a data provider object from the given factory string.
static checkRequest()
Sets the env_config_locked variable if not already set.
static *LoggerInterface logger
Global logger.
Definition DataProvider.qc.dox.h:118
static deferStaticInitialization()
Defers static initialization until restoreStaticInitialization() is called.
static registerFactory(AbstractDataProviderFactory factory)
Register a new data provider factory.
static *AbstractDataProviderFactory getFactory(string name)
Returns the given data provider factory or NOTHING if not present.
static deregisterFactory(string name)
Deregisters a factory if an exception occurs during the other module's initialization.
static checkStaticInit()
Checks for static initialization.
static *object loadFromEnvironment(string func, string type, *hash< SymbolInfo > info, *LoggerInterface logger)
Loads modules from the QORE_DATA_PROVIDERS environment variable.
static Gate factory_cache_lock()
data provider factory cache lock
static AbstractDataProviderFactory getFactoryEx(string name)
Returns the given data provider factory or throws an exception if not present.
static list< code > ilist
Static initializer list.
Definition DataProvider.qc.dox.h:106
static AbstractDataProvider getFactoryObjectWithTemplate(string path, *hash< auto > template_options, *hash< auto > options)
Returns a data provider object from the given factory, created with the given constructor options.
static DataProviderTypeCache getTypeCache()
Returns the data provider cache.
static registerShutdownHandler(string key, code handler)
Registers a handler to run when shutting down data provider services.
static registerType(string path, AbstractDataProviderType type)
Register a new data provider type.
static checkOptions(int options)
Checks for valid global data provider options.
static AbstractDataProvider getFactoryObjectFromStringUseEnv(string name)
Returns a data provider object from the given factory string using environment variables to find the ...
static list< string > getPathList(string path)
Returns a list of strings in a path separated by "/" characters.
static *LoggerInterface getGlobalLogger()
Returns the global data provider logger.
static *list< string > listTypes()
Returns a list of registered data provider type paths.
static restoreStaticInitialization()
Restores static initialization deferred by deferStaticInitialization()
static shutdown()
Shuts down background services related to data providers.
static *string tryGetModuleName(string name, string func, string type)
Tries to load a module corresponding to the given factory.
static string renderExpressionArg(hash< DataProviderExpression > exp, hash< string, hash< DataProviderExpressionInfo > > emap, *hash< DataProviderArgInfo > arg_info)
Returns a descriptive string for the given expression argument.
static bool checkInjection(object obj, hash< string, string > module_map)
Check if the object is from a module that has been subject to dependency injections.
static list< *list< code > > ilist_save
Deferred static initializers.
Definition DataProvider.qc.dox.h:109
static removeOptions(int options)
Removes the given global data provider options.
static hash< string, string > type_module_map
data provider type module map
Definition DataProvider.qc.dox.h:92
static addOptions(int options)
Adds the given global data provider options.
static AbstractDataProvider getFactoryObjectFromExample(string path, InputStream example, *hash< auto > options)
Returns a data provider object from the given factory, created with the given options and example dat...
static hash< string, code > smap
Shutdown handlers; key -> handler.
Definition DataProvider.qc.dox.h:112
static hash< string, AbstractDataProviderFactory > factory_cache
data provider factory cache
Definition DataProvider.qc.dox.h:80
static DataProviderTypeCache type_cache()
data provider data type cache
static AbstractDataProvider getFactoryObjectFromExample(string path, data example, *hash< auto > options)
Returns a data provider object from the given factory, created with the given options and example dat...
static *list< string > listFactories()
Returns a list of registered data provider factories.
static DataProviderTypeEntry getTypeRoot()
Returns the root type entry.
static *AbstractDataProvider tryLoadProviderForConnectionFromEnv(string name, *string subtype, *LoggerInterface logger)
Tries to load a data provider from the environment from the connection name.
static *object checkSymbol(hash< SymbolInfo > info, *LoggerInterface logger)
Returns True if an object of the given type has been loaded.
static bool deregisterShutdownHandler(string key)
Deregisters a shutdown handler.
static registerKnownTypes()
Registers all known data provider types.
static hash< FactoryInfo > getFactoryInfoFromString(string name)
Returns a hash of factory information from a string.
static loadProvidersFromEnvironment(*LoggerInterface logger)
Loads data providers from the environment.
static lockAllTypes()
Locks all types.
static bool tryLoad(string module_str, *bool init)
Try to load the given module.
static string renderExpressionArg(hash< DataProviderFieldReference > ref, hash< string, hash< DataProviderExpressionInfo > > emap, *hash< DataProviderArgInfo > arg_info)
Returns a descriptive string for the given field reference argument.
static setOptions(int options)
Replaces data provider global options with the value provided.
static loadTypesFromEnvironment(*LoggerInterface logger)
Loads data types from the environment.
static hash< string, bool > mod_map
set of module already loaded
Definition DataProvider.qc.dox.h:103
static registerStaticInitializer(code init)
Registers a static initializer.
static AbstractDataProvider getFactoryObject(string path, *hash< auto > options)
Returns a data provider object from the given factory, created with the given constructor options.
static string renderExpression(hash< DataProviderExpression > exp, *hash< string, hash< DataProviderExpressionInfo > > emap=DataProviderGenericExpressions)
Returns a descriptive string for the given expression.
static *string tryGetTypeModuleName(string name)
Tries to load a module corresponding to the given factory.
static hash< auto > getInfoAsData(hash< auto > info0, *bool with_type_info)
Converts an info hash with objects to a hash with string descriptions instead of the objects.
static hash< string, string > factory_module_map
data provider factory module map
Definition DataProvider.qc.dox.h:83
static setGlobalLogger(*LoggerInterface logger)
Sets or clears the global logger.
static bool getAutoConfig()
Returns the auto config flag.
static synchronized checkStaticInitIntern()
Checks for static initialization.
static *string tryGetFactoryModuleName(string name)
Tries to load a module corresponding to the given factory.
Data provider type cache class.
Definition DataProviderTypeCache.qc.dox.h:29
the DataProviderTypeEntry class
Definition DataProviderTypeEntry.qc.dox.h:70
const DPO_EnableServers
Definition DataProvider.qc.dox.h:41
const DPO_DisableOnDemandInitialization
Disable on-demand initialization.
Definition DataProvider.qc.dox.h:47
const DPO_EnableOnDemandActions
Enable on-demand initialization of actions.
Definition DataProvider.qc.dox.h:52
const DPO_AllOptions
The mask of all data provider options.
Definition DataProvider.qc.dox.h:55
Qore AbstractDataField class definition.
Definition AbstractDataField.qc.dox.h:27
const DataProviderGenericExpressions
Data provider generic expression map.
Definition AbstractDataProvider.qc.dox.h:992