Qore DataProvider Module Reference  2.4
DataProvider.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
27 namespace DataProvider {
29 class DataProvider {
30 
31 public:
33  const FactoryMap = {
34  "db": "DbDataProvider",
35  "swagger": "SwaggerDataProvider",
36  "cdsrest": "CdsRestDataProvider",
37  "csvread": "CsvUtil",
38  "csvwrite": "CsvUtil",
39  "fixedlengthread": "FixedLengthUtil",
40  "fixedlengthwrite": "FixedLengthUtil",
41  "salesforcerest": "SalesforceRestDataProvider",
42  "servicenowrest": "ServiceNowRestDataProvider",
43  // provided by the xml module
44  "soap": "SoapDataProvider",
45  };
46 
48  const TypeMap = {
49  "qore/ftp": "FtpPollerUtil",
50  "qore/sftp": "SftpPollerUtil",
51  "qore/fsevents": "FsEventPollerUtil",
52  };
53 
55  const FactoryModuleList = keys (map {$1: True}, FactoryMap.iterator());
56  // "map" is used above to ensure that the values only appear once in the final list
57 
58 protected:
60  static hash<string, AbstractDataProviderFactory> factory_cache;
61 
63  static hash<string, string> factory_module_map;
64 
66  static Mutex factory_cache_lock();
67 
70 
72  static hash<string, string> type_module_map;
73 
75 
77  static bool allow_env_config = False;
78 
80  static bool env_config_locked = False;
81 
83  static hash<string, bool> mod_map;
84 
85 public:
86 
88 
93 
96 
98 
105 
107 
112  static AbstractDataProvider getFactoryObject(string path, *hash<auto> options);
113 
115 
125 
127 
137 
139 protected:
140  static hash<FactoryInfo> getFactoryInfoFromString(string name);
141 public:
142 
143 
145  static *list<string> listFactories();
146 
149 
151 
160 
162 
169  static *AbstractDataProviderType getType(string path);
170 
172 
181  static AbstractDataProviderType getTypeEx(string path);
182 
185 
187  static lockAllTypes();
188 
190 
194  static *list<string> listTypes();
195 
198 
201 
204 
207 
210 
212 
215  static hash<auto> getInfoAsData(hash<auto> info0, *bool with_type_info);
216 
218 
222  static setAutoConfig();
223 
225  static bool getAutoConfig();
226 
228  static list<string> getPathList(string path);
229 
231 protected:
232  static checkRequest();
233 public:
234 
235 
237 protected:
238  static *string tryGetFactoryModuleName(string name);
239 public:
240 
241 
243 protected:
244  static *string tryGetTypeModuleName(string name);
245 public:
246 
247 
249 protected:
250  static *string tryGetModuleName(string name, string func, string type);
251 public:
252 
253 
255 protected:
256  static *DataProviderTypeEntry tryLoadTypeFromPath(list<string> type_path);
257 public:
258 
259 
261 protected:
262  static bool tryLoad(string module_str, *bool verbose);
263 public:
264 
265 
267 protected:
268  static *object loadFromEnvironment(string func, string type, *hash<SymbolInfo> info);
269 public:
270 
271 
273 protected:
274  static *object checkSymbol(hash<SymbolInfo> info);
275 public:
276 
277 
279 protected:
280  static bool checkInjection(object obj, hash<string, string> module_map);
281 public:
282 
283 };
284 
285 // private hashdecls
286 hashdecl SymbolInfo {
287  // symbol type
288  string type;
289  # symbol name
290  string name;
291 }
292 hashdecl FactoryInfo {
293  // factory name
294  string name;
295  # path to final data provider in factory
296  list<string> path_list;
297  # factory options
298  auto options;
299 }
300 };
Data provider factory class.
Definition: AbstractDataProviderFactory.qc.dox.h:58
The AbstractDataProvider class.
Definition: AbstractDataProvider.qc.dox.h:586
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:187
static list< string > getPathList(string path)
Returns a list of strings in a path separated by "/" characters.
static *AbstractDataProviderType getType(string path)
Returns the given data provider type or NOTHING if not present.
static AbstractDataProviderType getTypeEx(string path)
Returns the given data provider type or throws an exception if not present.
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 *list< string > listFactories()
Returns a list of registered data provider factories.
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 AbstractDataProviderFactory getFactoryEx(string name)
Returns the given data provider factory or throws an exception if not present.
static Mutex factory_cache_lock()
data provider factory cache lock
static loadProvidersFromEnvironment()
Loads data providers from the environment.
static DataProviderTypeCache getTypeCache()
Returns the data provider cache.
static registerType(string path, AbstractDataProviderType type)
Register a new data provider type.
static AbstractDataProvider getFactoryObjectFromStringUseEnv(string name)
Returns a data provider object from the given factory string using environment variables to find the ...
static hash< FactoryInfo > getFactoryInfoFromString(string name)
Returns a hash of factory information from a string.
static *string tryGetModuleName(string name, string func, string type)
Tries to load a module corresponding to the given factory.
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 hash< string, string > type_module_map
data provider type module map
Definition: DataProvider.qc.dox.h:72
static *list< string > listTypes()
Returns a list of registered data provider type paths.
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 loadTypesFromEnvironment()
Loads data types from the environment.
static hash< string, AbstractDataProviderFactory > factory_cache
data provider factory cache
Definition: DataProvider.qc.dox.h:60
static *object checkSymbol(hash< SymbolInfo > info)
Returns True if an object of the given type has been loaded.
static DataProviderTypeCache type_cache()
data provider data type cache
static bool tryLoad(string module_str, *bool verbose)
Try to load the given module.
static DataProviderTypeEntry getTypeRoot()
Returns the root type entry.
static registerKnownTypes()
Registers all known data provider types.
static lockAllTypes()
Locks all types.
static *AbstractDataProvider tryLoadProviderForConnectionFromEnv(string name)
Tries to load a data provider from the environment from the connection name.
static hash< string, bool > mod_map
set of module already loaded
Definition: DataProvider.qc.dox.h:83
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 tryGetTypeModuleName(string name)
Tries to load a module corresponding to the given factory.
static hash< string, string > factory_module_map
data provider factory module map
Definition: DataProvider.qc.dox.h:63
static bool getAutoConfig()
Returns the auto config flag.
static *object loadFromEnvironment(string func, string type, *hash< SymbolInfo > info)
Loads modules from the QORE_DATA_PROVIDERS environment variable.
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:58
const True
const False
string type(auto arg)
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27