PLCnext API Documentation  22.9.0.33
Public Member Functions | Static Public Member Functions | Friends | List of all members
Arp::AppDomain Class Reference

This class represents a single application domain for each process and is implemented as singleton. More...

#include <AppDomain.hpp>

Inheritance diagram for Arp::AppDomain:
Inheritance graph

Public Member Functions

IApplicationGetApplication (void)
 Gets the application instance of the current process. More...
 
template<class TSingleton >
void AddSingleton (TSingleton *pSingleton)
 Adds a singleton instance to this AppDomain. More...
 
template<class TSingleton >
TSingleton & GetSingleton (void)
 Gets the singleton instance of the specified type. More...
 
template<class TSingleton >
TSingleton * GetSingletonPtr (void)
 Gets the singleton pointer of the specified type. More...
 
template<class TSingleton >
bool RemoveSingleton (void)
 Removes the singleton pointer of the specified type from this AppDomain. More...
 

Static Public Member Functions

static bool IsCreated (void)
 Determines if the appdomain was created yet. More...
 
static AppDomainGetCurrent (void)
 Gets the current AppDomain instance. More...
 
template<class TApp >
static TApp & Create (void)
 Creates the current AppDomain and application instances. More...
 
template<class TApp >
static TApp & Create (const String &appName)
 Creates the current AppDomain and application instances. More...
 
template<class TApp >
static void Dispose (void)
 Disposes the current AppDomain and destructs the application. More...
 
static void Assign (AppDomain &other)
 Assgins the current AppdDomain singleton from the as argument passed other. More...
 

Friends

class Singleton< AppDomain >
 

Detailed Description

This class represents a single application domain for each process and is implemented as singleton.

The main purpose of this class is to extend the scope of simple singletons from just inside a library to the whole application. The singleton pattern just wraps a global variable in an OOP manner. Because dynamic shared libraries (DSL) always gets its own set of static variables, it is difficult to provide and use singletons from within generic static libraries which compile into each DSL and generate a copy of the singleton variables. As far as a DSL is a regular Acf library and loaded via Acf configuration, the AppDomainSingleton will work correclty and all AppDomainSingleton(s) are accessible through the whole process from any DSL.

The second purpose of this class is to provide the application instance.

Member Function Documentation

◆ AddSingleton()

template<class TSingleton >
void Arp::AppDomain::AddSingleton ( TSingleton *  pSingleton)
inline

Adds a singleton instance to this AppDomain.

Parameters
pSingletonThe pointer to the singleton to add.
Template Parameters
TSingletonThe type of the singleton to add.

◆ Assign()

void Arp::AppDomain::Assign ( AppDomain other)
inlinestatic

Assgins the current AppdDomain singleton from the as argument passed other.

Parameters
otherThe other (main) AppDomain singleton to assign this isntance from.

This operation is called from within a DSL which was yet loaded and the AppDomain singleton (copy) is not initialized yet.

◆ Create() [1/2]

template<class TApp >
TApp & Arp::AppDomain::Create ( const String appName)
inlinestatic

Creates the current AppDomain and application instances.

Template Parameters
TAppThe application type of the application to create
Parameters
appNameThe name of the application instance to create
Returns
The created AppDomain instance as reference.

◆ Create() [2/2]

template<class TApp >
TApp & Arp::AppDomain::Create ( void  )
inlinestatic

Creates the current AppDomain and application instances.

Template Parameters
TAppThe application type of the application to create
Returns
The created AppDomain instance as reference.

◆ Dispose()

template<class TApp >
void Arp::AppDomain::Dispose ( void  )
inlinestatic

Disposes the current AppDomain and destructs the application.

Template Parameters
TAppThe application type of the application to create

◆ GetApplication()

IApplication & Arp::AppDomain::GetApplication ( void  )
inline

Gets the application instance of the current process.

Returns
GThe application instance of the current process.

◆ GetCurrent()

AppDomain & Arp::AppDomain::GetCurrent ( void  )
inlinestatic

Gets the current AppDomain instance.

Returns
The current AppDomain instance.

◆ GetSingleton()

template<class TSingleton >
TSingleton & Arp::AppDomain::GetSingleton ( void  )
inline

Gets the singleton instance of the specified type.

Template Parameters
TSingletonThe type of the singleton to get.
Returns
The singleton reference of the specified type.

◆ GetSingletonPtr()

template<class TSingleton >
TSingleton * Arp::AppDomain::GetSingletonPtr ( void  )
inline

Gets the singleton pointer of the specified type.

Template Parameters
TSingletonThe type of the singleton to get.
Returns
The singleton pointer of the specified type.

◆ IsCreated()

bool Arp::AppDomain::IsCreated ( void  )
inlinestatic

Determines if the appdomain was created yet.

Returns
true if the appdomain was created yet, otherwise false.

◆ RemoveSingleton()

template<class TSingleton >
bool Arp::AppDomain::RemoveSingleton ( void  )
inline

Removes the singleton pointer of the specified type from this AppDomain.

Template Parameters
TSingletonThe type of the singleton to remove.
Returns
true if the singleton exists and could be removed, otherwise false.

The documentation for this class was generated from the following file: