.. _data-providers-page:

#####################
Data Provider Plugins
#####################

|ProductName| and |WebProductName| supports dynamic loading of Data Provider Plugins. A Data Provider acts as a 
provider of data to the server (e.g. a file reader), allowing users to create their own in-house file readers with the 
same ease of use and performance as the built-in readers. The provider can be plugged into applications based on 
|ProductName|.

To create your own data providers plugins, please go to :ref:`data-provider-framework-page` 

The |ProductName| distribution includes two data provider plugins. These can be found in the **DataProviderPlugins** 
folder. Go to each data provider pages to read more about their support and features:

-   :ref:`dataprovider-openfoam-page`
-   :ref:`dataprovider-vtk-page`
-   :ref:`dataprovider-exchange-page`



------------------------------------------------

**Using Data Providers in HOOPS Envision for Desktop**

You can of course use data provider plugins in your own |ProductName| based application. 

Load a single data provider plugin using 
:func:`loadDataProviderPlugin() <cee::imp::cae::DataSourceCae::loadDataProviderPlugin()>` or load multiple 
plugins at once using 
:func:`loadDataProviderPluginsFromWildcard() <cee::imp::cae::DataSourceCae::loadDataProviderPluginsFromWildcard()>`.

Once the data provider plugins are loaded, you can open the supported files just like any other file by calling
:func:`cee::imp::cae::DataSourceCae::open()`. If the selected file cannot be opened by any of the built-in file 
interfaces, it will automatically check if any of the loaded data providers plugin can support it.

A data provider plugin can have a set of reader settings. These are found in 
:class:`ReaderSettingsDataProvider <cee::imp::cae::ReaderSettingsDataProvider>`. Use the 
:func:`ReaderSettings::addDataProviderSettings() <cee::imp::cae::ReaderSettings::addDataProviderSettings()>` to 
specify these options before opening a file. 

An example is the HOOPS Exchange plugin that requires the path to you HOOPS Exchange libraries:

.. code-block:: cpp

    for (size_t i = 0; i < cee::imp::cae::DataSourceCae::readerSettings().dataProviderSettingsCount(); ++i)
    {
        cee::imp::cae::ReaderSettingsDataProvider& settings = cee::imp::cae::DataSourceCae::readerSettings().dataProviderSettings(i);

        if (settings.providerIdString() == "ExchangeProvider")
        {
            settings.setStringValue("HOOPS_LIBRARY_PATH", "C:\\HOOPS_Exchange_Publish_2023_U1\\bin\\win64_v142");
        }
    }


------------------------------------------------

**Data Providers Plugins in HOOPS Demo Analyzer Desktop**

To use data provider plugins with HOOPS Demo Analyzer Desktop, copy the data provider plugins into the 
**DataProviders** folder in the installation. Or of you want to load them from a custom folder, you can define the 
environment variable **CEE_DATA_PROVIDERS_FOLDER** to point to the folder where your data provider plugins are located. 
HOOPS Demo Analyzer will load the data providers from the specified folder.  

Once they are loaded they will be added to the file interfaces and you can use "Open File..." just like for the built-in 
interfaces.

The reader options for a data provider is shown in the **Data Provider** panel of the **Settings** dialog.
Once any of this settings are edited, please reopen your case to account for this modification.

Polling of the data provider can be controlled by two settings in the **Advanced** panel of the **Settings** dialog:

-   Enable Data Provider polling
-   Show last state when a state is added


------------------------------------------------

**Data Provider Plugins in Envision for Web**

Data providers can be used with the RemoteModel server (UgServer).

1.  Unzip the Envision distribution archive info a folder
2.  Go to the **DataProviderPlugins** folder
3.  Place the cdp_*.[dll|so|dylib] and the (lib)tbb.[dll|so|dylib] in the folder of your HOOPS Envision 
    distribution or where you find this convenient
4.  Set the environment variable **CEW_UG_DATA_PROVIDER_FOLDER** to point to the folder containing the shared 
    library, for instance:

    ::

        export CEW_UG_DATA_PROVIDER_FOLDER=/path/to/dataprovider_plugins

The UgServer will load all data providers in the specified folder. The server will list the registered data provider 
plugins when a file is opened.

A data provider plugin can have a set of reader settings. For Envision Web, use the 
:js:meth:`RemoteModel.setReaderOptions()` to specify these options before opening a file.


An example is the HOOPS Exchange plugin that requires the path to you HOOPS Exchange libraries:

.. code-block:: ts

    this.m_model.setReaderOptions("ExchangeProvider", { 
        "HOOPS_LIBRARY_PATH": "/user/HOOPS_Exchange_Publish_2023_U1/bin/linux" 
    });


.. toctree::
    :caption: Data Provider Plugins
    :hidden:

    Introduction <self>
    plugins/index


