8#include "Arp/System/Core/CommonTypeName.hxx"
9#include "Arp/System/Commons/Runtime/SharedLibrary.hpp"
10#include "Arp/System/Commons/Extensibility/SharedModuleLibraryLoader.hpp"
11#include "Arp/System/Commons/Extensibility/ModuleLibraryBase.hxx"
12#include "Arp/System/Commons/Exceptions/InvalidOperationException.hpp"
14namespace Arp {
namespace System {
namespace Commons {
namespace Extensibility
21template<
typename TModuleInterface>
52 template<
typename TModule>
87 ModuleLibraryFactoryFunction GetModuleLibraryFactoryFunction(
SharedLibrary& sharedLibrary)
const;
95template<
typename TModuleInterface>
101template<
typename TModuleInterface>
102template<
typename TModule>
108template<
typename TModuleInterface>
112 if (this->libraryBase ==
nullptr)
118 return this->libraryBase->GetFactory().Create(moduleName);
122template<
typename TModuleInterface>
125 return loader.GetFullPath();
128template<
typename TModuleInterface>
131 return loader.GetFileName();
134template<
typename TModuleInterface>
137 return loader.Exists();
140template<
typename TModuleInterface>
143 return loader.IsLoaded();
146template<
typename TModuleInterface>
150 if (this->loader.IsLoaded())
152 auto f = GetModuleLibraryFactoryFunction(this->loader.GetSharedLibrary());
157template<
typename TModuleInterface>
160 if (this->loader.IsLoaded())
162 this->libraryBase =
nullptr;
164 this->loader.Unload();
167template<
typename TModuleInterface>
168typename SharedModuleLibrary<TModuleInterface>::ModuleLibraryFactoryFunction
171 auto result =
reinterpret_cast<ModuleLibraryFactoryFunction
>(
173 if (result ==
nullptr)
176 "Could not get module library factory function from '{0}'", this->GetFileName());
This class represents a single application domain for each process and is implemented as singleton.
Definition: AppDomain.hpp:119
static AppDomain & GetCurrent(void)
Gets the current AppDomain instance.
Definition: AppDomain.hpp:242
This (meta programming) class provides the typename according the CLS (common language specification)...
Definition: CommonTypeName.hxx:30
Base class for a library providing extension modules
Definition: ModuleLibraryBase.hxx:34
Definition: SharedModuleLibraryLoader.hpp:16
Base class for loading a library with modules
Definition: SharedModuleLibrary.hxx:23
SharedModuleLibrary(const String &path)
Constructs an SharedModuleLibrary instance.
Definition: SharedModuleLibrary.hxx:96
SharedModuleLibrary(SharedModuleLibrary &&arg)=delete
Move constructor.
void Unload()
Unload the library
Definition: SharedModuleLibrary.hxx:158
const String & GetFullPath() const
Returns the full path to the library file
Definition: SharedModuleLibrary.hxx:123
bool IsLoaded() const
Returns true if the library is loaded
Definition: SharedModuleLibrary.hxx:141
String GetFileName() const
Returns the file name of the library (without directory)
Definition: SharedModuleLibrary.hxx:129
SharedModuleLibrary & operator=(SharedModuleLibrary &&arg)=delete
Move-assignment operator.
SharedModuleLibrary(const SharedModuleLibrary &arg)=delete
Copy constructor.
virtual ~SharedModuleLibrary(void)=default
Destructs this instance and frees all resources.
virtual String GetModuleLibraryFactoryFunctionName() const =0
Returns the name of the factory function for the module library
void Load()
Loads the library
Definition: SharedModuleLibrary.hxx:147
SharedModuleLibrary & operator=(const SharedModuleLibrary &arg)=delete
Copy-assignment operator.
ModuleInterfacePtr CreateModule() const
Creates a module by type
Definition: SharedModuleLibrary.hxx:103
std::unique_ptr< TModuleInterface > ModuleInterfacePtr
owning pointer to a module
Definition: SharedModuleLibrary.hxx:26
bool Exists() const
Returns true if the library file exists.
Definition: SharedModuleLibrary.hxx:135
This exception is used when a method call is invalid for object's current state.
Definition: InvalidOperationException.hpp:15
High level API to enable work with dynamically loadable shared libraries.
Definition: SharedLibrary.hpp:20
void * GetFunctionAddress(const String &symbolName)
Returns the address where specified symbol is located in the memory.
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API