LibraryLink Utilities  3.0.1
Modern C++ wrapper over LibraryLink and WSTP
LibraryData.h
Go to the documentation of this file.
1 
7 #ifndef LLU_LIBRARYDATA_H
8 #define LLU_LIBRARYDATA_H
9 
10 #include <memory>
11 
12 /* If wstp.h has not been included before WolframLibrary.h, we need to detect if we are dealing with WL 12.0- or 12.1+.
13  * To achieve this we include a small header file dllexport.h which defines DLLIMPORT macro only since 12.1. */
14 
15 #pragma push_macro("DLLIMPORT") /* Although unlikely, DLLIMPORT might have been defined elsewhere, so save it and temporarily undefine. */
16 #undef DLLIMPORT
17 
18 #include "dllexport.h"
19 
20 #ifndef DLLIMPORT /* We are dealing with WL 12.0-, restore DLLIMPORT macro and include wstp.h even though we don't really need it at this point. */
21 #pragma pop_macro("DLLIMPORT")
22 
23 #include "wstp.h"
24 
25 #define MLINK WSLINK
26 #define MLENV WSENV
27 
28 #include "WolframLibrary.h"
29 
30 #else // 12.1+
31 
32 #include "WolframLibrary.h"
33 
34 #endif /* DLLIMPORT */
35 
36 
37 #include "WolframIOLibraryFunctions.h"
38 #include "WolframImageLibrary.h"
39 #include "WolframNumericArrayLibrary.h"
40 #include "WolframSparseLibrary.h"
41 
42 namespace LLU {
43 
48  struct LibraryData {
55  static void setLibraryData(WolframLibraryData ld);
56 
61  static bool hasLibraryData();
62 
68  static WolframLibraryData API();
69 
74  static const st_WolframNumericArrayLibrary_Functions* NumericArrayAPI();
75 
80  static const st_WolframSparseLibrary_Functions* SparseArrayAPI();
81 
86  static const st_WolframImageLibrary_Functions* ImageAPI();
87 
92  static const st_WolframIOLibrary_Functions* DataStoreAPI();
93 
98  static WolframLibraryData uncheckedAPI() noexcept;
99 
100  private:
102  static WolframLibraryData libData;
103  };
104 
105 } // namespace LLU
106 
107 #endif // LLU_LIBRARYDATA_H
LLU
Main namespace of LibraryLink Utilities.
Definition: Queue.h:13
LLU::LibraryData::SparseArrayAPI
static const st_WolframSparseLibrary_Functions * SparseArrayAPI()
Get a pointer to structure with function pointers to MSparseArray API.
Definition: LibraryData.cpp:37
LLU::LibraryData::API
static WolframLibraryData API()
Get currently owned WolframLibraryData, if any.
Definition: LibraryData.cpp:22
LLU::LibraryData::uncheckedAPI
static WolframLibraryData uncheckedAPI() noexcept
Get currently owned WolframLibraryData, even if it is a nullptr.
Definition: LibraryData.cpp:29
LLU::LibraryData::ImageAPI
static const st_WolframImageLibrary_Functions * ImageAPI()
Get a pointer to structure with function pointers to MImage API.
Definition: LibraryData.cpp:41
LLU::LibraryData::NumericArrayAPI
static const st_WolframNumericArrayLibrary_Functions * NumericArrayAPI()
Get a pointer to structure with function pointers to MNumericArray API.
Definition: LibraryData.cpp:33
LLU::LibraryData::hasLibraryData
static bool hasLibraryData()
Check if libData is populated.
Definition: LibraryData.cpp:18
LLU::LibraryData::DataStoreAPI
static const st_WolframIOLibrary_Functions * DataStoreAPI()
Get a pointer to structure with function pointers to DataStore API.
Definition: LibraryData.cpp:45
LLU::LibraryData::setLibraryData
static void setLibraryData(WolframLibraryData ld)
Set WolframLibraryData structure as static member of LibDataHolder.
Definition: LibraryData.cpp:14
LLU::LibraryData
This structure offers a static copy of WolframLibData accessible throughout the whole life of the DLL...
Definition: LibraryData.h:48