MRPT  1.9.9
xslibraryloader.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2019, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #ifndef XSLIBRARYLOADER_H
10 #define XSLIBRARYLOADER_H
11 
12 #include "xsstring.h"
13 #include "xstypesconfig.h"
14 
15 struct XsLibraryLoader;
16 
17 #ifdef __cplusplus
18 extern "C"
19 {
20 #else
21 #define XSLIBRARYLOADER_INITIALIZER \
22  { \
23  nullptr \
24  }
26 #endif
27 
29  XsLibraryLoader* thisp, const XsString* libraryName);
31  const XsLibraryLoader* thisp, const char* functionName);
35 
36 #ifdef __cplusplus
37 }
38 #endif
39 
40 /*! \brief The Xsens dynamic library loader base class
41  */
43 {
44 #ifdef __cplusplus
45  public:
46  /*! \brief Create a library loader */
47  inline XsLibraryLoader() : m_handle(nullptr)
48  {
49  // avoid compiler warnings about
50  // an unused handle. It is used in the c implementations
51  (void)m_handle;
52  }
53 
54  /*! \brief Destroy a library loader */
55  inline ~XsLibraryLoader() { unload(); }
56  /*! \brief Load the library
57  \param[in] libraryName the name of the library to load
58  \return true if the library could be loaded, false otherwise
59  */
60  inline bool load(const XsString& libraryName)
61  {
62  return XsLibraryLoader_load(this, &libraryName) != 0;
63  }
64 
65  /*! \brief Return true if a library has been loaded
66 
67  \return true if a library has been loaded, false otherwise
68  */
69  inline bool isLoaded() const { return XsLibraryLoader_isLoaded(this) != 0; }
70  /*! \brief Resolve a function from the library
71 
72  \param[in] functionName the name of the function to resolve
73  \return a pointer to the resolved function, nullptr if nothing could be
74  resolved
75  */
76  inline void* resolve(const char* functionName) const
77  {
78  return XsLibraryLoader_resolve(this, functionName);
79  }
80 
81  /*! \brief Unload the loaded library
82  */
83  inline void unload() throw() { XsLibraryLoader_unload(this); }
84  /*! \brief Return a string describing the error that occurred
85 
86  Use this function after a function returned with an error to
87  receive some extra information about what went wrong.
88 
89  \returns a string describing the error that occurred
90  */
91  inline static XsString errorString()
92  {
93  XsString rv;
95  return rv;
96  }
97 
98  private:
99 #endif
100  void* m_handle;
101 };
102 
103 #endif // XSLIBRARYLOADER_H
struct XsLibraryLoader XsLibraryLoader
XSTYPES_DLL_API void XsLibraryLoader_getErrorString(XsString *error)
The Xsens dynamic library loader base class.
XSTYPES_DLL_API void * XsLibraryLoader_resolve(const XsLibraryLoader *thisp, const char *functionName)
#define XSTYPES_DLL_API
Definition: xstypesconfig.h:9
XSTYPES_DLL_API int XsLibraryLoader_isLoaded(const XsLibraryLoader *thisp)
XSTYPES_DLL_API int XsLibraryLoader_unload(XsLibraryLoader *thisp)
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
struct XsString XsString
Definition: xsstring.h:35
XSTYPES_DLL_API int XsLibraryLoader_load(XsLibraryLoader *thisp, const XsString *libraryName)



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 8fe78517f Sun Jul 14 19:43:28 2019 +0200 at lun oct 28 02:10:00 CET 2019