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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST