Qore DataProvider Module Reference  1.0.2
DataProvider.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3 
25 // minimum required Qore version
26 // assume local scope for variables, do not use "$" signs
27 // require type definitions everywhere
29 // enable all warnings
30 
31 
33 namespace DataProvider {
35 class DataProvider {
36 
37 public:
39  const FactoryMap = {
40  "db": "DbDataProvider",
41  "swagger": "SwaggerDataProvider",
42  "csvread": "CsvUtil",
43  "csvwrite": "CsvUtil",
44  "fixedlengthread": "FixedLengthUtil",
45  "fixedlengthwrite": "FixedLengthUtil",
46  "salesforcerest": "SalesforceRestDataProvider",
47  // provided by the xml module
48  "soap": "SoapDataProvider",
49  };
50 
52  const TypeMap = {
53  "qore/ftp": "FtpPollerUtil",
54  "qore/sftp": "SftpPollerUtil",
55  "qore/fsevents": "FsEventPollerUtil",
56  };
57 
59  const FactoryModuleList = keys (map {$1: True}, FactoryMap.iterator());
60  // "map" is used above to ensure that the values only appear once in the final list
61 
62 protected:
64  static hash<string, AbstractDataProviderFactory> factory_cache;
65 
67  static hash<string, string> factory_module_map;
68 
70  static Mutex factory_cache_lock();
71 
74 
76  static hash<string, string> type_module_map;
77 
79 
81  static bool allow_env_config = False;
82 
84  static bool env_config_locked = False;
85 
86 public:
87 
89 
94 
97 
99 
106 
108 
113  static AbstractDataProvider getFactoryObject(string path, *hash<auto> options);
114 
116 
124 
126  static *list<string> listFactories();
127 
130 
132 
141 
143 
150  static *AbstractDataProviderType getType(string path);
151 
153 
162  static AbstractDataProviderType getTypeEx(string path);
163 
166 
168  static lockAllTypes();
169 
171 
175  static *list<string> listTypes();
176 
179 
182 
185 
188 
190  static hash<auto> getInfoAsData(hash<auto> info0);
191 
193 
197  static setAutoConfig();
198 
200  static bool getAutoConfig();
201 
203  static list<string> getPathList(string path);
204 
206 protected:
207  static checkRequest();
208 public:
209 
210 
212 protected:
213  static *string tryGetFactoryModuleName(string name);
214 public:
215 
216 
218 protected:
219  static *string tryGetTypeModuleName(string name);
220 public:
221 
222 
224 protected:
225  static *string tryGetModuleName(string name, string func, string type);
226 public:
227 
228 
230 protected:
231  static *DataProviderTypeEntry tryLoadTypeFromPath(list<string> type_path);
232 public:
233 
234 
236 protected:
237  static bool tryLoad(string module_str, *bool verbose);
238 public:
239 
240 
242 protected:
243  static loadFromEnvironment(string func, string type);
244 public:
245 
246 
248 protected:
249  static bool checkInjection(object obj, hash<string, string> module_map);
250 public:
251 
252 };
253 };
DataProvider::DataProvider::getTypeRoot
static DataProviderTypeEntry getTypeRoot()
Returns the root type entry.
DataProvider::AbstractDataProviderFactory
Data provider factory class.
Definition: AbstractDataProviderFactory.qc.dox.h:34
DataProvider::DataProvider::loadProvidersFromEnvironment
static loadProvidersFromEnvironment()
Loads data providers from the environment.
DataProvider::AbstractDataProviderType
describes a data type
Definition: AbstractDataProviderType.qc.dox.h:161
DataProvider::DataProvider::getTypeEx
static AbstractDataProviderType getTypeEx(string path)
Returns the given data provider type or throws an exception if not present.
type
string type(auto arg)
DataProvider::DataProvider::registerFactory
static registerFactory(AbstractDataProviderFactory factory)
Register a new data provider factory.
DataProvider::DataProvider::tryLoad
static bool tryLoad(string module_str, *bool verbose)
Try to load the given module.
DataProvider::DataProvider::type_module_map
static hash< string, string > type_module_map
data provider type module map
Definition: DataProvider.qc.dox.h:76
DataProvider::DataProvider::setAutoConfig
static setAutoConfig()
Sets the flag that allows for automatic configuration from environment variables.
DataProvider::DataProvider::checkRequest
static checkRequest()
Sets the env_config_locked variable if not already set.
DataProvider::DataProvider::getTypeCache
static DataProviderTypeCache getTypeCache()
Returns the data provider cache.
DataProvider::DataProvider::getPathList
static list< string > getPathList(string path)
Returns a list of strings in a path separated by "/" characters.
DataProvider::DataProvider::factory_cache
static hash< string, AbstractDataProviderFactory > factory_cache
data provider factory cache
Definition: DataProvider.qc.dox.h:64
True
const True
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:32
DataProvider::DataProvider::registerKnownTypes
static registerKnownTypes()
Registers all known data provider types.
DataProvider::DataProvider::getInfoAsData
static hash< auto > getInfoAsData(hash< auto > info0)
Converts an info hash with objects to a hash with string descriptions instead of the objects.
DataProvider::DataProvider::loadTypesFromEnvironment
static loadTypesFromEnvironment()
Loads data types from the environment.
DataProvider::DataProvider::getFactoryObjectFromString
static AbstractDataProvider getFactoryObjectFromString(string name)
Returns a data provider object from the given factory with options given as string-formatted hash in ...
DataProvider::DataProvider::registerKnownFactories
static registerKnownFactories()
Registers all known data provider factories.
DataProvider::DataProvider::loadFromEnvironment
static loadFromEnvironment(string func, string type)
Loads modules from the QORE_DATA_PROVIDERS environment variable.
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::tryLoadTypeFromPath
static *DataProviderTypeEntry tryLoadTypeFromPath(list< string > type_path)
Tries to load the given type.
DataProvider::DataProvider::getFactoryEx
static AbstractDataProviderFactory getFactoryEx(string name)
Returns the given data provider factory or throws an exception if not present.
DataProvider::DataProvider::tryGetModuleName
static *string tryGetModuleName(string name, string func, string type)
Tries to load a module corresponding to the given factory.
DataProvider::DataProvider::getFactory
static *AbstractDataProviderFactory getFactory(string name)
Returns the given data provider factory or NOTHING if not present.
DataProvider::DataProvider::getAutoConfig
static bool getAutoConfig()
Returns the auto config flag.
DataProvider::DataProvider::lockAllTypes
static lockAllTypes()
Locks all types.
DataProvider::AbstractDataProvider
The AbstractDataProvider class.
Definition: AbstractDataProvider.qc.dox.h:194
DataProvider::DataProviderTypeEntry
the DataProviderTypeEntry class
Definition: DataProviderTypeEntry.qc.dox.h:55
DataProvider::DataProvider::tryGetTypeModuleName
static *string tryGetTypeModuleName(string name)
Tries to load a module corresponding to the given factory.
DataProvider::DataProviderTypeCache
Data provider type cache class.
Definition: DataProviderTypeCache.qc.dox.h:35
False
const False
DataProvider::DataProvider::listTypes
static *list< string > listTypes()
Returns a list of registered data provider type paths.
DataProvider::DataProvider::getType
static *AbstractDataProviderType getType(string path)
Returns the given data provider type or NOTHING if not present.
DataProvider::DataProvider::registerType
static registerType(string path, AbstractDataProviderType type)
Register a new data provider type.
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::factory_cache_lock
static Mutex factory_cache_lock()
data provider factory cache lock
DataProvider::DataProvider::listFactories
static *list< string > listFactories()
Returns a list of registered data provider factories.
DataProvider::DataProvider::tryGetFactoryModuleName
static *string tryGetFactoryModuleName(string name)
Tries to load a module corresponding to the given factory.
DataProvider::DataProvider::type_cache
static DataProviderTypeCache type_cache()
data provider data type cache
DataProvider::DataProvider::factory_module_map
static hash< string, string > factory_module_map
data provider factory module map
Definition: DataProvider.qc.dox.h:67