IlvModule: The Dynamic Module Class
Every dynamic module is an instance of a subclass of the IlvModule base class, defined in the header file <ilviews/base/modules.h>.
Every dynamic module must define one and only one subclass. The constructor of this class is called when Views loads the module, making it possible to perform all the static initializations that the module requests (graphic classes registration, for example).
Once you have declared (in a public header file) and defined your module class, you have to enable Views to load it. To do so, add a call, outside the body of any function, to the macro ILVINITIALIZEMODULE, providing the class name of the module that you have defined as its only parameter.
Dynamic Module Code Skeleton
The skeleton of a Views dynamic module is the following:
#include <ilviews/base/modules.h>
// Pre-initialization code goes here
// This is, typically, the declaration of global variables or
// static data members.
class MyModule
: public IlvModule {
public:
MyModule(void*)
{
// Initialization code goes here
}
};
ILVINITIALIZEMODULE(MyModule);
The parameter that is provided to the constructor of the module class makes it possible for you to send application-dependent data to your module initialization. This is required if your module needs external data to initialize properly. We will clarify this point later in this chapter (see the section
Explicit Modepage 163).
Note: Most of the time, the complete initialization of a module has to be split into two parts: the declaration of variables, outside the code of any function, and their initialization, which may require function calls, that must appear in the module constructor. |
Published date: 05/24/2022
Last modified date: 02/24/2022