PLCnext API Documentation 25.0.2.69
SharedLibrary.hpp
1
2//
3// Copyright Phoenix Contact GmbH & Co. KG
4//
6#pragma once
8#include "Arp/System/Commons/Runtime/SharedLibraryMemoryLockOption.hpp"
9
10// forwards
11namespace Arp { namespace System { namespace Ve
12{
13class ISharedLibraryService;
14}}}
15
16namespace Arp { namespace System { namespace Commons { namespace Runtime
17{
18
21{
22public: // usings
23 using SymbolNames = std::vector<String>;
24
25public: // construction/destruction
26 SharedLibrary(void);
27
29 SharedLibrary(const SharedLibrary& arg) = delete;
30
32 SharedLibrary& operator=(const SharedLibrary& arg) = delete;
33
34 ~SharedLibrary(void);
35
36public: // operations
37 SymbolNames GetExportedFunctionNames(const String& path) const;
38
39 void Load(const String& path, SharedLibraryMemoryLockOption sharedLibraryMemoryLockOption = SharedLibraryMemoryLockOption::Nothing);
40 bool TryLoad(const String& path, SharedLibraryMemoryLockOption sharedLibraryMemoryLockOption = SharedLibraryMemoryLockOption::Nothing);
41 void Unload(void);
42
43 void* GetFunctionAddress(const String& symbolName);
44
45public: // static operations
46 static String GetArpLibrariesDirectory(void);
47 static String GetFormattedPath(const String& path);
48 static bool ProbeLibrary(const String& path, String& probedPath);
49
50private: // fields
51 Arp::System::Ve::ISharedLibraryService* pSharedLibraryService = nullptr;
52};
53
54}}}} // end of namesapce Arp::System::Commons::Runtime
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
High level API to enable work with dynamically loadable shared libraries.
Definition: SharedLibrary.hpp:21
void Load(const String &path, SharedLibraryMemoryLockOption sharedLibraryMemoryLockOption=SharedLibraryMemoryLockOption::Nothing)
Loads the specified shared library.
Definition: SharedLibrary.cpp:66
SharedLibrary(const SharedLibrary &arg)=delete
Copy contructor.
bool TryLoad(const String &path, SharedLibraryMemoryLockOption sharedLibraryMemoryLockOption=SharedLibraryMemoryLockOption::Nothing)
Loads the specified shared library.
Definition: SharedLibrary.cpp:86
static bool ProbeLibrary(const String &path, String &probedPath)
Probes the library
Definition: SharedLibrary.cpp:139
~SharedLibrary(void)
Destructs this instance and frees all resouces.
Definition: SharedLibrary.cpp:36
SharedLibrary & operator=(const SharedLibrary &arg)=delete
Assignment operator.
SharedLibrary(void)
Constructs an SharedLibrary instance.
Definition: SharedLibrary.cpp:23
static String GetFormattedPath(const String &path)
Formats the path depending on OS.
Definition: SharedLibrary.cpp:117
void * GetFunctionAddress(const String &symbolName)
Returns the address where specified symbol is located in the memory.
Definition: SharedLibrary.cpp:104
void Unload(void)
Unloads the shared library.
Definition: SharedLibrary.cpp:94
SymbolNames GetExportedFunctionNames(const String &path) const
Loads the specified shared library.
Definition: SharedLibrary.cpp:48
SharedLibraryMemoryLockOption
Options to lock the memory of shared library by !:SharedLibrary when loading the binary.
Definition: SharedLibraryMemoryLockOption.hpp:17
Root namespace for the PLCnext API