Skip to main content

DPF C++ Client Library 2025 R2

ansys::dpf::Context Class Reference

Last update: 16.07.2025

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

#include <dpf_api_base.h>

Public Types

enum class  EDpfLicenseContext { eNone = 0 , eEntryLevel = 1 , ePremium = 2 }
 Enum to select the license context.
 
enum class  PluginLoadErrorMode { eSilent = 0 , eReportFirst = 1 , eReportAll = 2 }
 Enum that determines the error reporting strategy during plugin loading.
 

Public Member Functions

 Context (EDpfContext context=EDpfContext::eDefault, std::string const &setup_file_path="")
 
EDpfContext getContext () const
 Get the DPF context enum value. More...
 
std::string const & getSetupFilePath () const
 Get the path to the XML file used to configure DPF. More...
 
EDpfLicenseContext getLicenseContext () const
 Get the DPF license context enum value. More...
 
PluginLoadErrorMode errorOnPluginLoad () const
 Get the error reporting mode for plugin loading. More...
 
ContextwithErrorOnPluginLoad (PluginLoadErrorMode error_mode)
 Sets the mode in which DPF report errors when plugins are loaded. More...
 
ContextwithPremiumLicense ()
 Sets the license context to Premium. More...
 
ContextwithEntryLevelLicense ()
 Sets the license context to Entry. More...
 

Static Public Member Functions

static Context entryContext ()
 
static Context premiumContext ()
 
static Context defaultContext ()
 Creates a default context. More...
 
static Context standaloneContext ()
 Creates a standalone context. More...
 
static Context userDefinedContext (std::string const &setup_file="DpfCustomDefined.xml")
 Creates a user-defined context. More...
 

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, dpf::core::applyContext

Constructor & Destructor Documentation

◆ Context()

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
[in]contextDefines setup to use.
[in]setup_file_pathOptional 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()

static Context ansys::dpf::Context::defaultContext ( )
static

Creates a default context.

Use with DPF runtime R2025R1 or later.

Returns
Context

◆ entryContext()

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

◆ errorOnPluginLoad()

PluginLoadErrorMode ansys::dpf::Context::errorOnPluginLoad ( ) const

Get the error reporting mode for plugin loading.

Use with DPF runtime R2025R1 or later.

Returns
PluginLoadErrorMode

◆ getContext()

EDpfContext ansys::dpf::Context::getContext ( ) const

Get the DPF context enum value.

Returns
EDpfContext

◆ getLicenseContext()

EDpfLicenseContext ansys::dpf::Context::getLicenseContext ( ) const

Get the DPF license context enum value.

Use with DPF runtime R2025R1 or later.

Returns
EDpfLicenseContext

◆ getSetupFilePath()

std::string const & ansys::dpf::Context::getSetupFilePath ( ) const

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

Returns
std::string const&

◆ premiumContext()

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

◆ standaloneContext()

static Context ansys::dpf::Context::standaloneContext ( )
static

Creates a standalone context.

Returns
Context

◆ userDefinedContext()

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
setup_fileThe 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

◆ withEntryLevelLicense()

Context & ansys::dpf::Context::withEntryLevelLicense ( )

Sets the license context to Entry.

Use with DPF runtime R2025R1 or later.

Returns
Context&

◆ withErrorOnPluginLoad()

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
error_modeThe strategy for error reporting.
Returns
Context&

◆ withPremiumLicense()

Context & ansys::dpf::Context::withPremiumLicense ( )

Sets the license context to Premium.

Use with DPF runtime R2025R1 or later.

Returns
Context&

Connect with Ansys