8#ifndef ARP_USE_ARP_SYSTEM_CORE
10#include "Arp/Base/Core/AppDomainSingleton.hxx"
15#include "Arp/System/Core/Singleton.hxx"
16#include "Arp/System/Core/AppDomain.hpp"
30template <
class Derived>
31class AppDomainSingleton
35 typedef AppDomainSingleton<Derived> SingletonBase;
42 AppDomainSingleton(
void) =
default;
44 ~AppDomainSingleton(
void) =
default;
52 template <
class T =
Instance,
class ...Args>
53 static Derived & CreateInstance(Args && ... args);
57 static bool IsCreated(
void);
62 static Derived& GetInstance(
void);
68 static Derived* GetInstancePtr(
void);
72 static
void DisposeInstance(
void);
75 static Derived* GetInstancePtrInternal(
void);
78 AppDomainSingleton(const AppDomainSingleton& arg) = delete;
79 AppDomainSingleton& operator=(const AppDomainSingleton& arg) = delete;
84template <class Derived>
85template <class T, class ...Args>
86inline Derived& AppDomainSingleton<Derived>::CreateInstance(Args&& ... args)
88 Derived* pInstance = GetInstancePtrInternal();
90 if(pInstance !=
nullptr)
92 throw Exception(
"AppDomain Singleton instance of type '{0}' was created yet!", TypeName<Derived>());
95 pInstance =
new T(std::forward<Args>(args)...);
102template <
class Derived>
103inline bool AppDomainSingleton<Derived>::IsCreated(
void)
110 return AppDomainSingleton::GetInstancePtrInternal() !=
nullptr;
113template <
class Derived>
114inline Derived& AppDomainSingleton<Derived>::GetInstance()
116 Derived* pResult = GetInstancePtrInternal();
119 throw Exception(
"AppDomain Singleton instance of type '{0}' was not created yet!", TypeName<Derived>());
124template <
class Derived>
125inline Derived* AppDomainSingleton<Derived>::GetInstancePtr()
127 return GetInstancePtrInternal();
130template <
class Derived>
131inline Derived* AppDomainSingleton<Derived>::GetInstancePtrInternal()
136template <
class Derived>
137inline void AppDomainSingleton<Derived>::DisposeInstance()
140 delete GetInstancePtrInternal();
static bool IsCreated(void)
Determines if this singleton instance is created yet.
Definition: AppDomain.cpp:42
static Instance & GetCurrent(void)
Gets the singleton instance of this class.
Definition: AppDomain.cpp:83
static Instance & GetInstance(void)
Gets a reference of the singleton instance.
Definition: AppDomain.cpp:50
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
Deprecated! The class implements an adapter for enums to define the string literals of the enum entri...
Definition: EnumStrings.hxx:38