Ipopt Documentation  
IpLibraryLoader.hpp
Go to the documentation of this file.
1 // Copyright (C) 2021 COIN-OR Foundation
2 // All Rights Reserved.
3 // This code is published under the Eclipse Public License.
4 
5 #ifndef __IPLIBRARYLOADER_HPP__
6 #define __IPLIBRARYLOADER_HPP__
7 
8 #include "IpReferenced.hpp"
9 #include "IpException.hpp"
10 
11 #ifdef _WIN32
12 # define IPOPT_SHAREDLIBEXT "dll"
13 #elif defined(__APPLE__)
14 # define IPOPT_SHAREDLIBEXT "dylib"
15 #else
16 # define IPOPT_SHAREDLIBEXT "so"
17 #endif
18 
19 namespace Ipopt
20 {
21 
28 {
29 private:
30  std::string libname;
31  void* libhandle;
32 
36  LibraryLoader& operator=(const LibraryLoader&);
37 
38 public:
41  const std::string& libname_
42  )
43  : libname(libname_),
44  libhandle(NULL)
45  { }
46 
49  {
50  unloadLibrary();
51  }
52 
54  void loadLibrary();
55 
57  void unloadLibrary();
58 
63  void* loadSymbol(
64  const std::string& symbolname
65  );
66 };
67 
72 DECLARE_STD_EXCEPTION(DYNAMIC_LIBRARY_FAILURE);
73 
74 } // namespace Ipopt
75 
76 #endif /* __IPLIBRARYLOADER_HPP__ */
#define IPOPTLIB_EXPORT
Definition: config.h:94
DECLARE_STD_EXCEPTION(FATAL_ERROR_IN_LINEAR_SOLVER)
This file contains a base class for all exceptions and a set of macros to help with exceptions...
~LibraryLoader()
destructor
loading of a library at runtime
Storing the reference count of all the smart pointers that currently reference it.
LibraryLoader(const std::string &libname_)
constructor