Main MRPT website > C++ reference for MRPT 1.5.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-2017, 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 { NULL }
22 #endif
23 
24 XSTYPES_DLL_API int XsLibraryLoader_load(XsLibraryLoader* thisp, const XsString* libraryName);
25 XSTYPES_DLL_API void* XsLibraryLoader_resolve(const XsLibraryLoader* thisp, const char *functionName);
29 
30 #ifdef __cplusplus
31 }
32 #endif
33 
34 /*! \brief The Xsens dynamic library loader base class
35 */
37 #ifdef __cplusplus
38 public:
39  /*! \brief Create a library loader */
40  inline XsLibraryLoader() :
41  m_handle(NULL)
42  {
43  // avoid compiler warnings about
44  // an unused handle. It is used in the c implementations
45  (void)m_handle;
46  }
47 
48  /*! \brief Destroy a library loader */
49  inline ~XsLibraryLoader()
50  {
51  unload();
52  }
53 
54  /*! \brief Load the library
55  \param[in] libraryName the name of the library to load
56  \return true if the library could be loaded, false otherwise
57  */
58  inline bool load(const XsString& libraryName)
59  {
60  return XsLibraryLoader_load(this, &libraryName) != 0;
61  }
62 
63  /*! \brief Return true if a library has been loaded
64 
65  \return true if a library has been loaded, false otherwise
66  */
67  inline bool isLoaded() const
68  {
69  return XsLibraryLoader_isLoaded(this) != 0;
70  }
71 
72  /*! \brief Resolve a function from the library
73 
74  \param[in] functionName the name of the function to resolve
75  \return a pointer to the resolved function, NULL if nothing could be resolved
76  */
77  inline void* resolve(const char *functionName) const
78  {
79  return XsLibraryLoader_resolve(this, functionName);
80  }
81 
82  /*! \brief Unload the loaded library
83  */
84  inline void unload() throw()
85  {
87  }
88 
89  /*! \brief Return a string describing the error that occurred
90 
91  Use this function after a function returned with an error to
92  receive some extra information about what went wrong.
93 
94  \returns a string describing the error that occurred
95  */
96  inline static XsString errorString()
97  {
98  XsString rv;
100  return rv;
101  }
102 private:
103 #endif
104  void* m_handle;
105 };
106 
107 #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:34
XSTYPES_DLL_API int XsLibraryLoader_load(XsLibraryLoader *thisp, const XsString *libraryName)



Page generated by Doxygen 1.8.14 for MRPT 1.5.9 Git: 690a4699f Wed Apr 15 19:29:53 2020 +0200 at miƩ abr 15 19:30:12 CEST 2020