Free Electron
DL_Loader.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __platform_dl_loader_h__
8 #define __platform_dl_loader_h__
9 
10 namespace fe
11 {
12 
13 /**************************************************************************//**
14  @brief Raw access to a dynamic library
15 
16  @ingroup platform
17 *//***************************************************************************/
18 class FE_DL_PUBLIC DL_Loader
19 {
20  public:
21  DL_Loader(void)
22  {
23 #if FE_OS==FE_WIN32 || FE_OS==FE_WIN64
24 #else
25  m_handle=NULL;
26 #endif
27  }
28 
29  /** @brief Add a path search for managed
30  dynamic libraries. */
31 static Result addPath(String a_absPath);
32 
33  /** @brief Open a dynamic library
34 
35  If adaptname is TRUE, the filename is adapted
36  used using local convention
37  (MyLib is interpreted as libMyLib.so or MyLib.lib). */
38  BWORD openDL(String a_filename,BWORD a_adaptname=TRUE);
39 
40  /// @brief Close a dynamic library
41  BWORD closeDL(void);
42 
43  /** @brief Find the named symbol in the open library
44 
45  Returns a pointer to the named function, if it exists.
46  This may only work for functions wrapped in extern "C"
47  and explicitly exported. */
48  void *findDLFunction(String a_symbol);
49 
50  /// @brief Returns the name of the library as it was opened
51 const String& name(void) const { return m_name; }
52 
53  private:
54 
55  String adaptName(String a_filename,
56  String a_prefix,String a_format);
57 
58 #if FE_OS==FE_WIN32 || FE_OS==FE_WIN64
59  HINSTANCE m_handle;
60 #else
61  void *m_handle;
62 
63 static FE_DL_PUBLIC std::vector<String> ms_pathArray;
64 #endif
65 
66  String m_name;
67 };
68 
69 } // namespace
70 
71 #endif // __platform_dl_loader_h__
Raw access to a dynamic library.
Definition: DL_Loader.h:18
kernel
Definition: namespace.dox:3
Automatically reference-counted string container.
Definition: String.h:128
Result
Generalized return value indicating success or failure, and why.
Definition: Result.h:24
const String & name(void) const
Returns the name of the library as it was opened.
Definition: DL_Loader.h:51