DataProvider::DataProvider Class Reference

Data provider class. More...

## Static Public Member Functions

static bool | getAutoConfig ()
| Returns the auto config flag.
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. More...
static AbstractDataProvider | getFactoryObject (string path, *hash< auto > options)
| Returns a data provider object from the given factory, created with the given constructor options. More...
static AbstractDataProvider | getFactoryObjectFromString (string name)
| Returns a data provider object from the given factory with options given as string-formatted hash in curly brackets and child data providers separated by forward slashes. More...
static hash< auto > | getInfoAsData (hash< auto > info0)
| Converts an info hash with objects to a hash with string descriptions instead of the objects.
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. More...
static AbstractDataProviderType | getTypeEx (string path)
| Returns the given data provider type or throws an exception if not present. More...
static DataProviderTypeEntry | getTypeRoot ()
| Returns the root type entry.
static *list< string > | listFactories ()
| Returns a list of registered data provider factories.
static *list< string > | listTypes ()
| Returns a list of registered data provider type paths. More...
static | loadProvidersFromEnvironment ()
| Loads data providers from the environment.
static | loadTypesFromEnvironment ()
| Loads data types from the environment.
static | registerFactory (AbstractDataProviderFactory factory)
| Register a new data provider factory. More...
static | registerKnownFactories ()
| Registers all known data provider factories.
static | registerKnownTypes ()
| Registers all known data provider types.
static | registerType (string path, AbstractDataProviderType type)
| Register a new data provider type. More...
static | setAutoConfig ()
| Sets the flag that allows for automatic configuration from environment variables. More...

## Public Attributes

const | FactoryMap
| Map of known data provider factory names to modules.
const | FactoryModuleList = keys (map {$1: True}, FactoryMap.iterator())
| List of data provider factory modules.
const | TypeMap
| Map of known type path prefixes to modules.

## Static Protected Member Functions

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 | checkRequest ()
| Sets the env_config_locked variable if not already set.
static Mutex | factory_cache_lock ()
| data provider factory cache lock
static *AbstractDataProviderType | getTypeFromFields (string path, AbstractDataProviderType type, list< string > type_path, bool throw_exception)
| Returns the given data provider type and either throws an exception if not present or returns NOTHING. More...
static *AbstractDataProviderType | getTypeIntern (string path, bool throw_exception)
| Returns the given data provider type and either throws an exception if not present or returns NOTHING. More...
static | loadFromEnvironment (string func, string type)
| Loads modules from the QORE_DATA_PROVIDERS environment variable.
static *string | tryGetFactoryModuleName (string name)
| Tries to load a module corresponding to the given factory.
static *string | tryGetModuleName (string name, string func, string type)
| Tries to load a module corresponding to the given factory.
static *string | tryGetTypeModuleName (string name)
| Tries to load a module corresponding to the given factory.
static bool | tryLoad (string module_str, *bool verbose)
| Try to load the given module.
static *DataProviderTypeEntry | tryLoadTypeFromPath (list< string > type_path)
| Tries to load the given type.
static DataProviderTypeEntry | type_cache ()
| data provider data type cache
static Mutex | type_cache_lock ()
| data provider type cache lock

## Static Protected Attributes

static bool | allow_env_config = False
| flag to allow automatic configuration from environment variables More...
static bool | env_config_locked = False
| flag that locks the allow_env_config var
static hash< string, AbstractDataProviderFactory > | factory_cache
| data provider factory cache
static hash< string, string > | factory_module_map
| data provider factory module map
static hash< string, string > | type_module_map
| data provider type module map

## Detailed Description

Data provider class.

## Member Function Documentation

## getFactoryEx()

static AbstractDataProviderFactory DataProvider::DataProvider::getFactoryEx | ( | string | name | ) |

static

Returns the given data provider factory or throws an exception if not present.

Parameters

  name | the name of the data provider to retrieve

Returns
  the given data provider; an exception is thrown if the data provide is unknown

Exceptions

  PROVIDER-ERROR | the given provider is unknown

## getFactoryObject()

static AbstractDataProvider DataProvider::DataProvider::getFactoryObject | ( | string | path,
|  | *hash< auto > | options
| ) |  |

static

Returns a data provider object from the given factory, created with the given constructor options.

Parameters

  path | the `"/"-separated` path to the target data provider; the first element is the factory name
  options | factory creation options

Exceptions

  PROVIDER-ERROR | the given provider factory or child provider is unknown

## getFactoryObjectFromString()

static AbstractDataProvider DataProvider::DataProvider::getFactoryObjectFromString | ( | string | name | ) |

static

Returns a data provider object from the given factory with options given as string-formatted hash in curly brackets and child data providers separated by forward slashes.

Example:
  DbDataProvider db = DataProvider::getFactoryObjectFromString("db{oracle:user/password@db}/my_table");

Exceptions

  PROVIDER-ERROR | the given provider factory or child provider is unknown

## getType()

static *AbstractDataProviderType DataProvider::DataProvider::getType | ( | string | path | ) |

static

Returns the given data provider type or NOTHING if not present.

Parameters

  path | a `"/"` separated path for the type; trailing path elements can be a path into fields

Returns
  the given data provider type; NOTHING is returned if the type cannot be resolved

Note
  types are stored based on the path provided which may differ from their type names (which may be generic and therefore not suitable for indexing)

## getTypeEx()

static AbstractDataProviderType DataProvider::DataProvider::getTypeEx | ( | string | path | ) |

static

Returns the given data provider type or throws an exception if not present.

Parameters

  path | a `"/"` separated path for the type; trailing path elements can be a path into fields

Returns
  the given data provider type; an exception is thrown if the data provide is unknown

Exceptions

  PROVIDER-ERROR | the given data provider type path is unknown

Note
  types are stored based on the path provided which may differ from their type names (which may be generic and therefore not suitable for indexing)

## getTypeFromFields()

static *AbstractDataProviderType DataProvider::DataProvider::getTypeFromFields | ( | string | path,
|  | AbstractDataProviderType | type,
|  | list< string > | type_path,
|  | bool | throw_exception
| ) |  |

staticprotected

Returns the given data provider type and either throws an exception if not present or returns NOTHING.

Parameters

  path | a `"/"` separated path for the type
  type | the base type for the search
  type_path | the path in the type for fields leading to the final return type
  throw_exception | if True then an exception is thrown if the path cannot be resolved, OTHERWISE NOTHING is returned

Returns
  the given data provider type or NOTHING is returned if the path cannot be resolved and the throw_exception argument is False

Exceptions

  PROVIDER-ERROR | the given data provider type path is unknown; only thrown if the throw_exception argument is True

Note
  types are stored based on the path provided which may differ from their type names (which may be generic and therefore not suitable for indexing)

## getTypeIntern()

static *AbstractDataProviderType DataProvider::DataProvider::getTypeIntern | ( | string | path,
|  | bool | throw_exception
| ) |  |

staticprotected

Returns the given data provider type and either throws an exception if not present or returns NOTHING.

Parameters

  path | a `"/"` separated path for the type
  throw_exception | if True then an exception is thrown if the path cannot be resolved, OTHERWISE NOTHING is returned

Returns
  the given data provider type or NOTHING is returned if the path cannot be resolved and the throw_exception argument is False

Exceptions

  PROVIDER-ERROR | the given data provider type path is unknown; only thrown if the throw_exception argument is True

Note
  types are stored based on the path provided which may differ from their type names (which may be generic and therefore not suitable for indexing)

## listTypes()

static *list<string> DataProvider::DataProvider::listTypes | ( |  | ) |

static

Returns a list of registered data provider type paths.

Note
  types are stored based on the path provided which may differ from their type names (which may be generic and therefore not suitable for indexing)

## registerFactory()

static DataProvider::DataProvider::registerFactory | ( | AbstractDataProviderFactory | factory | ) |

static

Register a new data provider factory.

Parameters

  factory | the new data provider factory

Exceptions

  PROVIDER-ERROR | the given provider has already been registered

## registerType()

static DataProvider::DataProvider::registerType | ( | string | path,
|  | AbstractDataProviderType | type
| ) |  |

static

Register a new data provider type.

Parameters

  path | a `"/"` separated path for the type; this is the lookup index
  type | the new data provider type

Exceptions

  PROVIDER-ERROR | the given provider has already been registered

Note
  types are stored based on the path provided which may differ from their type names (which may be generic and therefore not suitable for indexing)

## setAutoConfig()

static DataProvider::DataProvider::setAutoConfig | ( |  | ) |

static

Sets the flag that allows for automatic configuration from environment variables.

Must be called before any requests for types or factories are made, or an exception is raised

Exceptions

  DATA-PROVIDER-ERROR | cannot call this method after requests for types or factories are made

## Member Data Documentation

## allow_env_config

bool DataProvider::DataProvider::allow_env_config = False

staticprotected

flag to allow automatic configuration from environment variables

must be set before any requests for types or factories are made