// Copyright (c) 2012-2023 Wojciech Figat. All rights reserved. #pragma once #include "Engine/Core/Collections/Dictionary.h" #include "MTypes.h" /// /// Domain separates multiple processes within one executed CLR environment. /// /// /// At once you can execute methods, get instances etc, only from on Domain at the time. /// If you want to execute any code that given domain contains, you need to switch context, and dispatch current thread to CLR environment. /// class FLAXENGINE_API MDomain { friend MCore; friend MAssembly; public: typedef Dictionary AssembliesDictionary; private: #if USE_MONO MonoDomain* _monoDomain; #endif StringAnsi _domainName; AssembliesDictionary _assemblies; public: MDomain(const StringAnsi& domainName) : _domainName(domainName) { } public: #if USE_MONO /// /// Gets native domain class. /// FORCE_INLINE MonoDomain* GetNative() const { return _monoDomain; } #endif /// /// Gets current domain name /// FORCE_INLINE const StringAnsi& GetName() const { return _domainName; } /// /// Gets the current domain assemblies. /// FORCE_INLINE const AssembliesDictionary& GetAssemblies() const { return _assemblies; } public: /// /// Attaches current CLR domain calls to the current thread. /// void Dispatch() const; /// /// Sets currently using domain. /// /// True if succeed in settings, false if failed. bool SetCurrentDomain(bool force = false); };