> ## Documentation Index
> Fetch the complete documentation index at: https://developer.synopsys.com/llms.txt
> Use this file to discover all available pages before exploring further.

# ansys::dpf::Context Class Reference

The class representing the DPF execution context. This is used to configure several aspects of DPF like:

`#include <dpf_api_base.h>`

## Public Types

| Type | Name |
| - | - |
| enum class | [EDpfLicenseContext](#a1149672f0fad6470e3533a15d358baef) \{ **eNone** = 0 , **eEntryLevel** = 1 , **ePremium** = 2 } Enum to select the license context. |
| enum class | [PluginLoadErrorMode](#a89c9954b0806e1ffbefd5d413d44a8e3) \{ **eSilent** = 0 , **eReportFirst** = 1 , **eReportAll** = 2 } Enum that determines the error reporting strategy during plugin loading. |

## Public Member Functions

| Type | Name |
| - | - |
| | [Context](#ae26354fe1dea7b2691e115275704278b) ([EDpfContext](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/namespaceansys_1_1dpf#a02d1b14b4a34eeae292e89f8ee7cfe60) context=EDpfContext::eDefault, std::string const \&setup\_file\_path="") |
| [EDpfContext](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/namespaceansys_1_1dpf#a02d1b14b4a34eeae292e89f8ee7cfe60) | [getContext](#af4b49f2ed79e09c7d20d59895d52c139) () const Get the DPF context enum value. |
| std::string const & | [getSetupFilePath](#a8e69df73d5d7695a12619e98bb4ef82b) () const Get the path to the XML file used to configure DPF. |
| [EDpfLicenseContext](#a1149672f0fad6470e3533a15d358baef) | [getLicenseContext](#a75bf6a9e641e9c9f24d61ef6364672c8) () const Get the DPF license context enum value. |
| [PluginLoadErrorMode](#a89c9954b0806e1ffbefd5d413d44a8e3) | [errorOnPluginLoad](#ab36cb19d02596f0c9e84670632a7567c) () const Get the error reporting mode for plugin loading. |
| [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) & | [withErrorOnPluginLoad](#a5fe6bfb18b6d33dd88f16bb006bb0d8c) ([PluginLoadErrorMode](#a89c9954b0806e1ffbefd5d413d44a8e3) error\_mode) Sets the mode in which DPF report errors when plugins are loaded. |
| [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) & | [withPremiumLicense](#a33a89b830c012a1563bf6534d5de7d48) () Sets the license context to Premium. |
| [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) & | [withEntryLevelLicense](#a6848f3f755ec83e57544e688182d534d) () Sets the license context to Entry. |

## Static Public Member Functions

| Type | Name |
| - | - |
| static [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) | [entryContext](#a30b9265329478de651ae53b753831bc4) () |
| static [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) | [premiumContext](#a8416bcd2b6a76249a97bf259851aa121) () |
| static [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) | [defaultContext](#a05d1af3aea226b6cb8547d1d56c9c146) () Creates a default context. |
| static [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) | [standaloneContext](#a327ad3dde1ba5c314c34d5b2552156f9) () Creates a standalone context. |
| static [Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md) | [userDefinedContext](#af2efd2673fef4ce34b56f85dad9d5520) (std::string const \&setup\_file="DpfCustomDefined.xml") Creates a user-defined context. |

## Detailed Description

The class representing the DPF execution context. This is used to configure several aspects of DPF like:

* The XML configuration file to be loaded.
* The license context to be used.

**See also**

[dpf::LibraryHandle](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1LibraryHandle.md), [dpf::core::applyContext](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1core.md#a5fbdf727da47ba6dd749ade51f1f2dcc)

## Constructor & Destructor Documentation

### Context()

```cpp theme={null}
ansys::dpf::Context::Context(
    EDpfContext context = EDpfContext::eDefault,
    std::string const & setup_file_path = ""
)
```

Defines the settings that will be used to load DPF. A DPF xml file is used to define those settings.

**Parameters**

| Direction | Name | Description |
| - | - | - |
| \[in] | context | Defines setup to use. |
| \[in] | setup\_file\_path | Optional path to a DPF xml file if using a custom defined location. If a file name is passed, instead of a path, it will search for it int the predefined location dpf/utilities. |

## Member Function Documentation

### defaultContext()

```cpp theme={null}
static Context ansys::dpf::Context::defaultContext()
```

`static`

Creates a default context.

Use with DPF runtime R2025R1 or later.

**Returns**

[Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md)

### entryContext()

```cpp theme={null}
static Context ansys::dpf::Context::entryContext()
```

`static`

**Returns**

Entry context instance that does not allow DPF to perform any license checkout, meaning that licensed DPF operators run will fail.

**See also**

[Using DPF Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/group__group__11.md)

### errorOnPluginLoad()

```cpp theme={null}
PluginLoadErrorMode ansys::dpf::Context::errorOnPluginLoad() const
```

Get the error reporting mode for plugin loading.

Use with DPF runtime R2025R1 or later.

**Returns**

PluginLoadErrorMode

### getContext()

```cpp theme={null}
EDpfContext ansys::dpf::Context::getContext() const
```

Get the DPF context enum value.

**Returns**

EDpfContext

### getLicenseContext()

```cpp theme={null}
EDpfLicenseContext ansys::dpf::Context::getLicenseContext() const
```

Get the DPF license context enum value.

Use with DPF runtime R2025R1 or later.

**Returns**

EDpfLicenseContext

### getSetupFilePath()

```cpp theme={null}
std::string const & ansys::dpf::Context::getSetupFilePath() const
```

Get the path to the XML file used to configure DPF.

**Returns**

std::string const&

### premiumContext()

```cpp theme={null}
static Context ansys::dpf::Context::premiumContext()
```

`static`

**Returns**

Premium context instance that allows DPF to perform license checkouts, allowing licensed DPF operators to run.

**See also**

[Using DPF Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/group__group__11.md)

### standaloneContext()

```cpp theme={null}
static Context ansys::dpf::Context::standaloneContext()
```

`static`

Creates a standalone context.

**Returns**

[Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md)

### userDefinedContext()

```cpp theme={null}
static Context ansys::dpf::Context::userDefinedContext(
    std::string const & setup_file = "DpfCustomDefined.xml"
)
```

`static`

Creates a user-defined context.

Use with DPF runtime R2025R1 or later.

**Parameters**

| Name | Description |
| - | - |
| setup\_file | The path to the DPF XML file with the user configuration. If a file name is provided as parameter, it will search in /utilities for it. The default XML file used is /utilities/DpfCustomDefined.xml, that the user can edit. |

**Returns**

[Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md)

### withEntryLevelLicense()

```cpp theme={null}
Context & ansys::dpf::Context::withEntryLevelLicense()
```

Sets the license context to Entry.

Use with DPF runtime R2025R1 or later.

**Returns**

[Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md)&

### withErrorOnPluginLoad()

```cpp theme={null}
Context & ansys::dpf::Context::withErrorOnPluginLoad(PluginLoadErrorMode error_mode)
```

Sets the mode in which DPF report errors when plugins are loaded.

Use with DPF runtime R2025R1 or later.

**Parameters**

| Name | Description |
| - | - |
| error\_mode | The strategy for error reporting. |

**Returns**

[Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md)&

### withPremiumLicense()

```cpp theme={null}
Context & ansys::dpf::Context::withPremiumLicense()
```

Sets the license context to Premium.

Use with DPF runtime R2025R1 or later.

**Returns**

[Context](https://developer.synopsys.com/docs/dpf/dpf-cpp-client-library/2025-r2/classansys_1_1dpf_1_1Context.md)&
