| Qore DataProvider Module Reference 3.2.2

Loading...
Searching...
No Matches
DataProvider.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
24
25
27 namespace DataProvider {
38
41 const DPO_EnableServers = (1 << 0);
42
44
47 const DPO_DisableOnDemandInitialization = (1 << 1);
48
50
52 const DPO_EnableOnDemandActions = (1 << 2);
53
55 const DPO_AllOptions = ...;
56
58
60 class DataProvider {
61
62 public:
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
78 protected:
80 static hash<string, AbstractDataProviderFactory> factory_cache;
81
83 static hash<string, string> factory_module_map;
84
86 static Gate factory_cache_lock();
87
89 static DataProviderTypeCache type_cache();
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
120 public:
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
182 static registerFactory(AbstractDataProviderFactory factory);
183
185 static *AbstractDataProviderFactory getFactory(string name);
186
188
194 static AbstractDataProviderFactory getFactoryEx(string name);
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
250 static AbstractDataProvider getFactoryObjectFromString(string name);
251
253
263
264
265 static AbstractDataProvider getFactoryObjectFromStringUseEnv(string name);
266
268 protected:
269 static hash<FactoryInfo> getFactoryInfoFromString(string name);
270 public:
271
272
274 static *list<string> listFactories();
275
277 static DataProviderTypeCache getTypeCache();
278
280
288 static registerType(string path, AbstractDataProviderType type);
289
291
298 static *AbstractDataProviderType getType(string path);
299
301
310 static AbstractDataProviderType getTypeEx(string path);
311
313 static DataProviderTypeEntry getTypeRoot();
314
316 static lockAllTypes();
317
319
323 static *list<string> listTypes();
324
326 static registerKnownFactories();
327
329 static loadProvidersFromEnvironment(*LoggerInterface logger);
330
332 static *AbstractDataProvider tryLoadProviderForConnectionFromEnv(string name, *string subtype, *LoggerInterface logger);
333
335 static registerKnownTypes();
336
338 static loadTypesFromEnvironment(*LoggerInterface logger);
339
341
344 static hash<auto> getInfoAsData(hash<auto> info0, *bool with_type_info);
345
347
351 static setAutoConfig();
352
354 static bool getAutoConfig();
355
357 static list<string> getPathList(string path);
358
360 static list<string> getPathList(reference<string> path);
361
363
365 static registerStaticInitializer(code init);
366
368
370 static checkStaticInit();
371
373
375 static deferStaticInitialization();
376
378
380 static restoreStaticInitialization();
381
383 protected:
384 synchronized static checkStaticInitIntern();
385 public:
386
387
389
391 static shutdown();
392
394
399 static registerShutdownHandler(string key, code handler);
400
402
408 static bool deregisterShutdownHandler(string key);
409
411 protected:
412 static checkRequest();
413 public:
414
415
417 protected:
418 static *string tryGetFactoryModuleName(string name);
419 public:
420
421
423 protected:
424 static *string tryGetTypeModuleName(string name);
425 public:
426
427
429 protected:
430 static *string tryGetModuleName(string name, string func, string type);
431 public:
432
433
435 protected:
436 static *DataProviderTypeEntry tryLoadTypeFromPath(list<string> type_path);
437 public:
438
439
441 protected:
442 static bool tryLoad(string module_str, *bool init);
443 public:
444
445
447 protected:
448 static *object loadFromEnvironment(string func, string type, *hash<SymbolInfo> info, *LoggerInterface logger);
449 public:
450
451
453 protected:
454 static *object checkSymbol(hash<SymbolInfo> info, *LoggerInterface logger);
455 public:
456
457
459 protected:
460 static bool checkInjection(object obj, hash<string, string> module_map);
461 public:
462
463
465 protected:
466 static deregisterFactory(string name);
467 public:
468
469};
470
471// private hashdecls
472hashdecl SymbolInfo {
473 // symbol type
474 string type;
475 // symbol name
476 string name;
477 // subtype, if any
478 *string subtype;
479}
480hashdecl FactoryInfo {
481 // factory name
482 string name;
483 // path to final data provider in factory
484 list<string> path_list;
485 // factory options
486 auto options;
487}
488}
DataProvider::AbstractDataProviderFactory
Data provider factory class.
Definition AbstractDataProviderFactory.qc.dox.h:68
DataProvider::AbstractDataProvider
The AbstractDataProvider class.
Definition AbstractDataProvider.qc.dox.h:919
DataProvider::AbstractDataProviderType
describes a data type
Definition AbstractDataProviderType.qc.dox.h:139
DataProvider::DataProvider::getPathList
static list< string > getPathList(reference< string > path)
Returns a list of strings in a path separated by "/" characters, normalizes the argument.
DataProvider::DataProvider::getType
static *AbstractDataProviderType getType(string path)
Returns the given data provider type or NOTHING if not present.
DataProvider::DataProvider::getTypeEx
static AbstractDataProviderType getTypeEx(string path)
Returns the given data provider type or throws an exception if not present.
DataProvider::DataProvider::getOptions
static int getOptions()
Returns global data provider options.
DataProvider::DataProvider::registerKnownFactories
static registerKnownFactories()
Registers all known data provider factories.
DataProvider::DataProvider::tryLoadTypeFromPath
static *DataProviderTypeEntry tryLoadTypeFromPath(list< string > type_path)
Tries to load the given type.
DataProvider::DataProvider::setAutoConfig
static setAutoConfig()
Sets the flag that allows for automatic configuration from environment variables.
DataProvider::DataProvider::NoApp
const NoApp
An invalid app name.
Definition DataProvider.qc.dox.h:76
DataProvider::DataProvider::getFactoryObjectFromString
static AbstractDataProvider getFactoryObjectFromString(string name)
Returns a data provider object from the given factory string.
DataProvider::DataProvider::checkRequest
static checkRequest()
Sets the env_config_locked variable if not already set.
DataProvider::DataProvider::logger
static *LoggerInterface logger
Global logger.
Definition DataProvider.qc.dox.h:118
DataProvider::DataProvider::deferStaticInitialization
static deferStaticInitialization()
Defers static initialization until restoreStaticInitialization() is called.
DataProvider::DataProvider::registerFactory
static registerFactory(AbstractDataProviderFactory factory)
Register a new data provider factory.
DataProvider::DataProvider::getFactory
static *AbstractDataProviderFactory getFactory(string name)
Returns the given data provider factory or NOTHING if not present.
DataProvider::DataProvider::deregisterFactory
static deregisterFactory(string name)
Deregisters a factory if an exception occurs during the other module's initialization.
DataProvider::DataProvider::checkStaticInit
static checkStaticInit()
Checks for static initialization.
DataProvider::DataProvider::loadFromEnvironment
static *object loadFromEnvironment(string func, string type, *hash< SymbolInfo > info, *LoggerInterface logger)
Loads modules from the QORE_DATA_PROVIDERS environment variable.
DataProvider::DataProvider::factory_cache_lock
static Gate factory_cache_lock()
data provider factory cache lock
DataProvider::DataProvider::getFactoryEx
static AbstractDataProviderFactory getFactoryEx(string name)
Returns the given data provider factory or throws an exception if not present.
DataProvider::DataProvider::ilist
static list< code > ilist
Static initializer list.
Definition DataProvider.qc.dox.h:106
DataProvider::DataProvider::getFactoryObjectWithTemplate
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.
DataProvider::DataProvider::allow_env_config
static bool allow_env_config
flag to allow automatic configuration from environment variables
Definition DataProvider.qc.dox.h:97
DataProvider::DataProvider::getTypeCache
static DataProviderTypeCache getTypeCache()
Returns the data provider cache.
DataProvider::DataProvider::registerShutdownHandler
static registerShutdownHandler(string key, code handler)
Registers a handler to run when shutting down data provider services.
DataProvider::DataProvider::registerType
static registerType(string path, AbstractDataProviderType type)
Register a new data provider type.
DataProvider::DataProvider::checkOptions
static checkOptions(int options)
Checks for valid global data provider options.
DataProvider::DataProvider::getFactoryObjectFromStringUseEnv
static AbstractDataProvider getFactoryObjectFromStringUseEnv(string name)
Returns a data provider object from the given factory string using environment variables to find the ...
DataProvider::DataProvider::getPathList
static list< string > getPathList(string path)
Returns a list of strings in a path separated by "/" characters.
DataProvider::DataProvider::getGlobalLogger
static *LoggerInterface getGlobalLogger()
Returns the global data provider logger.
DataProvider::DataProvider::FactoryMap
const FactoryMap
Map of known data provider factory names to modules.
Definition DataProvider.qc.dox.h:64
DataProvider::DataProvider::listTypes
static *list< string > listTypes()
Returns a list of registered data provider type paths.
DataProvider::DataProvider::restoreStaticInitialization
static restoreStaticInitialization()
Restores static initialization deferred by deferStaticInitialization()
DataProvider::DataProvider::shutdown
static shutdown()
Shuts down background services related to data providers.
DataProvider::DataProvider::tryGetModuleName
static *string tryGetModuleName(string name, string func, string type)
Tries to load a module corresponding to the given factory.
DataProvider::DataProvider::checkInjection
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.
DataProvider::DataProvider::ilist_save
static list< *list< code > > ilist_save
Deferred static initializers.
Definition DataProvider.qc.dox.h:109
DataProvider::DataProvider::removeOptions
static removeOptions(int options)
Removes the given global data provider options.
DataProvider::DataProvider::type_module_map
static hash< string, string > type_module_map
data provider type module map
Definition DataProvider.qc.dox.h:92
DataProvider::DataProvider::addOptions
static addOptions(int options)
Adds the given global data provider options.
DataProvider::DataProvider::options
static int options
Global options.
Definition DataProvider.qc.dox.h:115
DataProvider::DataProvider::getFactoryObjectFromExample
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...
DataProvider::DataProvider::smap
static hash< string, code > smap
Shutdown handlers; key -> handler.
Definition DataProvider.qc.dox.h:112
DataProvider::DataProvider::factory_cache
static hash< string, AbstractDataProviderFactory > factory_cache
data provider factory cache
Definition DataProvider.qc.dox.h:80
DataProvider::DataProvider::type_cache
static DataProviderTypeCache type_cache()
data provider data type cache
DataProvider::DataProvider::getFactoryObjectFromExample
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...
DataProvider::DataProvider::listFactories
static *list< string > listFactories()
Returns a list of registered data provider factories.
DataProvider::DataProvider::getTypeRoot
static DataProviderTypeEntry getTypeRoot()
Returns the root type entry.
DataProvider::DataProvider::tryLoadProviderForConnectionFromEnv
static *AbstractDataProvider tryLoadProviderForConnectionFromEnv(string name, *string subtype, *LoggerInterface logger)
Tries to load a data provider from the environment from the connection name.
DataProvider::DataProvider::checkSymbol
static *object checkSymbol(hash< SymbolInfo > info, *LoggerInterface logger)
Returns True if an object of the given type has been loaded.
DataProvider::DataProvider::deregisterShutdownHandler
static bool deregisterShutdownHandler(string key)
Deregisters a shutdown handler.
DataProvider::DataProvider::registerKnownTypes
static registerKnownTypes()
Registers all known data provider types.
DataProvider::DataProvider::getFactoryInfoFromString
static hash< FactoryInfo > getFactoryInfoFromString(string name)
Returns a hash of factory information from a string.
DataProvider::DataProvider::loadProvidersFromEnvironment
static loadProvidersFromEnvironment(*LoggerInterface logger)
Loads data providers from the environment.
DataProvider::DataProvider::lockAllTypes
static lockAllTypes()
Locks all types.
DataProvider::DataProvider::tryLoad
static bool tryLoad(string module_str, *bool init)
Try to load the given module.
DataProvider::DataProvider::setOptions
static setOptions(int options)
Replaces data provider global options with the value provided.
DataProvider::DataProvider::loadTypesFromEnvironment
static loadTypesFromEnvironment(*LoggerInterface logger)
Loads data types from the environment.
DataProvider::DataProvider::mod_map
static hash< string, bool > mod_map
set of module already loaded
Definition DataProvider.qc.dox.h:103
DataProvider::DataProvider::registerStaticInitializer
static registerStaticInitializer(code init)
Registers a static initializer.
DataProvider::DataProvider::getFactoryObject
static AbstractDataProvider getFactoryObject(string path, *hash< auto > options)
Returns a data provider object from the given factory, created with the given constructor options.
DataProvider::DataProvider::tryGetTypeModuleName
static *string tryGetTypeModuleName(string name)
Tries to load a module corresponding to the given factory.
DataProvider::DataProvider::getInfoAsData
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.
DataProvider::DataProvider::factory_module_map
static hash< string, string > factory_module_map
data provider factory module map
Definition DataProvider.qc.dox.h:83
DataProvider::DataProvider::setGlobalLogger
static setGlobalLogger(*LoggerInterface logger)
Sets or clears the global logger.
DataProvider::DataProvider::getAutoConfig
static bool getAutoConfig()
Returns the auto config flag.
DataProvider::DataProvider::FactoryModuleList
const FactoryModuleList
List of data provider factory modules.
Definition DataProvider.qc.dox.h:72
DataProvider::DataProvider::env_config_locked
static bool env_config_locked
flag that locks the allow_env_config var
Definition DataProvider.qc.dox.h:100
DataProvider::DataProvider::checkStaticInitIntern
static synchronized checkStaticInitIntern()
Checks for static initialization.
DataProvider::DataProvider::TypeMap
const TypeMap
Map of known type path prefixes to modules.
Definition DataProvider.qc.dox.h:68
DataProvider::DataProvider::tryGetFactoryModuleName
static *string tryGetFactoryModuleName(string name)
Tries to load a module corresponding to the given factory.
DataProvider::DataProviderTypeCache
Data provider type cache class.
Definition DataProviderTypeCache.qc.dox.h:29
DataProvider::DataProviderTypeEntry
the DataProviderTypeEntry class
Definition DataProviderTypeEntry.qc.dox.h:70
DataProvider::DPO_EnableServers
const DPO_EnableServers
Definition DataProvider.qc.dox.h:41
DataProvider::DPO_DisableOnDemandInitialization
const DPO_DisableOnDemandInitialization
Disable on-demand initialization.
Definition DataProvider.qc.dox.h:47
DataProvider::DPO_EnableOnDemandActions
const DPO_EnableOnDemandActions
Enable on-demand initialization of actions.
Definition DataProvider.qc.dox.h:52
DataProvider::DPO_AllOptions
const DPO_AllOptions
The mask of all data provider options.
Definition DataProvider.qc.dox.h:55
DataProvider
Qore AbstractDataField class definition.
Definition AbstractDataField.qc.dox.h:27