Unable to understand class definition in C ++

I am new to R-trees on disks, although I have encoded R-trees based on main memory. In order to understand disk-based R-trees, I use the libspatialIndex library. Understanding the library, I come across strange class definitions, as shown below:

class SIDX_DLL IStorageManager { public: virtual void loadByteArray(const id_type id, uint32_t& len, byte** data) = 0; virtual void storeByteArray(id_type& id, const uint32_t len, const byte* const data) = 0; virtual void deleteByteArray(const id_type id) = 0; virtual ~IStorageManager() {} }; // IStorageManager 

I do not understand this new class definition in which it uses SIDX_DLL in the class definition. Can someone please give me guidance on what SIDX_DLL represents in the class definition.

+4
source share
5 answers

This is a macro that allows you to use the same objects from client libraries and library implementations. Add the attributes needed to implement dynamic linking.

+1
source

Tools.h

 47 #if defined _WIN32 || defined _WIN64 || defined WIN32 || defined WIN64 48 #ifdef SPATIALINDEX_CREATE_DLL 49 #define SIDX_DLL __declspec(dllexport) 50 #else 51 #define SIDX_DLL __declspec(dllimport) 52 #endif 53 #else 54 #define SIDX_DLL 55 #endif 

This is just a macro that adds compiler-specific attributes to the class definition

+1
source

SIDX_DLL - macro. This is for creating the IStorageManager symbol exported to dll.

This kind of macro is usually defined as follows:

  #if defined(_MSC_VER) && defined(SIDX_EXPORTS) # define SIDX_DLL __declspec(dllexport) #elif defined(_MSC_VER) # define SIDX_DLL __declspec(dllimport) #else # define SIDX_DLL #endif 

SIDX_EXPORTS is a character defined by MSVC that is defined only when compiling the SIDX dll. In this case, SIDX_DLL expands to __declspec(dllexport) . In all other cases, it expands to __declspec(dllimport) - which imports the character to where it is used.

The empty SIDX_DLL (the last #else in the list) is for non-Windows environments.

+1
source

Defines. You can read about it in the http://libspatialindex.github.com/doxygen/Tools_8h_source.html 54 line.

0
source

This is a macro. It probably defines the import / export properties of the dll.

Go to its definition (F12) and you will see that it is defined as __declspec(import) and __declspec(export)

0
source

All Articles