Safir SDK Core
Loading...
Searching...
No Matches
DynamicLibraryLoader.h
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright Saab AB, 2012-2013 (http://safirsdkcore.com)
4*
5* Created by: Lars Hagström / lars@foldspace.nu
6*
7*******************************************************************************
8*
9* This file is part of Safir SDK Core.
10*
11* Safir SDK Core is free software: you can redistribute it and/or modify
12* it under the terms of version 3 of the GNU General Public License as
13* published by the Free Software Foundation.
14*
15* Safir SDK Core is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more details.
19*
20* You should have received a copy of the GNU General Public License
21* along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22*
23******************************************************************************/
24#ifndef __DYNAMIC_LIBRARY_LOADER_H__
25#define __DYNAMIC_LIBRARY_LOADER_H__
26
27#include <string>
28#include <Safir/Utilities/Internal/VisibilityHelpers.h>
29
30#ifdef lluf_utils_EXPORTS
31# define LLUF_UTILS_API SAFIR_HELPER_DLL_EXPORT
32#else
33# define LLUF_UTILS_API SAFIR_HELPER_DLL_IMPORT
34# define SAFIR_LIBRARY_NAME "lluf_utils"
35# include <Safir/Utilities/Internal/AutoLink.h>
36#endif
37#define LLUF_UTILS_LOCAL SAFIR_HELPER_DLL_LOCAL
38
39#ifndef SAFIR_NO_DEPRECATED
40
41namespace Safir
42{
43namespace Utilities
44{
53 {
54 public:
57
60
73 void Load(const std::string& libraryName,
74 const bool unloadOnDestruction,
75 const bool global = false);
76
77
91 void Load(const std::string& libraryName,
92 const std::string& path,
93 const bool unloadOnDestruction,
94 const bool global = false);
95
99 void Unload();
100
123 template<class T>
124 T* GetFunction(const std::string& functionName)
125 {
126 return reinterpret_cast<T*>(GetFunctionInternal(functionName));
127 }
128 private:
130 DynamicLibraryLoader& operator=(const DynamicLibraryLoader&) = delete;
131
132 void * GetFunctionInternal(const std::string& functionName);
133
134 class Impl;
135 Impl* m_impl;
136
137 bool m_unloadOnDestruction;
138 };
139}
140}
141
142
143#endif
144
145#endif
#define LLUF_UTILS_API
Definition DynamicLibraryLoader.h:33
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
This class provides a simple wrapper around dynamic loading functionality of the operating system.
Definition DynamicLibraryLoader.h:53
T * GetFunction(const std::string &functionName)
Find a function in the library.
Definition DynamicLibraryLoader.h:124
void Load(const std::string &libraryName, const bool unloadOnDestruction, const bool global=false)
Load a library.
void Load(const std::string &libraryName, const std::string &path, const bool unloadOnDestruction, const bool global=false)
Load a library from a given location.
void Unload()
Unload the library.