NDEVR
API Documentation
ModuleManager.h
1#pragma once
2#include "DLLInfo.h"
3#if defined(_WIN32)
4// On Windows, NDEVR commands use the stdcall convention
5#define NDEVRAPI_ATTR
6#define NDEVRAPI_CALL __stdcall
7#define NDEVRAPI_PTR NDEVRAPI_CALL
8#elif !QT_BUILD && defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH < 7
9#error "NDEVR isn't supported for the 'armeabi' NDK ABI"
10#elif !QT_BUILD && defined(__ANDROID__) && defined(__ARM_ARCH) && __ARM_ARCH >= 7 && defined(__ARM_32BIT_STATE)
11// On Android 32-bit ARM targets, NDEVR functions use the "hardfloat"
12// calling convention, i.e. float parameters are passed in registers. This
13// is true even if the rest of the application passes floats on the stack,
14// as it does by default when compiling for the armeabi-v7a NDK ABI.
15#define NDEVRAPI_ATTR __attribute__((pcs("aapcs-vfp")))
16#define NDEVRAPI_CALL
17#define NDEVRAPI_PTR VKAPI_ATTR
18#else
19// On other platforms, use the default calling convention
20#define NDEVRAPI_ATTR
21#define NDEVRAPI_CALL
22#define NDEVRAPI_PTR
23#endif
24#include <NDEVR/SoftwareService.h>
25#include <NDEVR/String.h>
26#include <NDEVR/Dictionary.h>
27#include <NDEVR/File.h>
28#include <NDEVR/TranslatedString.h>
30typedef void (NDEVRAPI_PTR* PFN_NDEVRVoidFunction)(void);
31namespace NDEVR
32{
33 struct Module;
34 class QTModelManager;
35 class QTWindowManager;
36 class Exception;
38}
40typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_InitializeForNDEVR)(Module& module);//InitializeForNDEVR
42typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_SetupRegistrationForNDEVR)();//SetupRegistrationForNDEVR
44typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_SetupMetatypesForNDEVR)();//SetupMetatypesForNDEVR
46typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_RegisterUserSettingsForNDEVR)();//RegisterUserSettingsForNDEVR
48typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_SetupFileStructureForNDEVR)();//SetupFileStructureForNDEVR
50typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_SetupFactoriesForNDEVR)();//SetupFileStructureForNDEVR
52typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_SetUpdateCheckerForNDEVR)();//SetupFileStructureForNDEVR
54typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_SetupManualsForNDEVR)();//SetupManualsForNDEVR
56typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_SetupUIThemesForNDEVR)();//SetupUIThemesForNDEVR
58typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_FactoryResetNDEVR)();//FactoryReset
60typedef void(*PFN_SetupUIForNDEVR)(QTModelManager* model_manager, QTWindowManager* window_manager);
62typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_DefineModuleResourcesForNDEVR)(ModuleResourceManager* resources);
64typedef PFN_NDEVRVoidFunction(NDEVRAPI_PTR* PFN_OnNDEVRExit)();//
65
66namespace NDEVR
67{
150
155 class NDEVR_BASE_API ModuleManager : public SoftwareServiceManager
156 {
157 public:
163
168 static void SetMainProgramModuleName(const StringView& name);
169
174 static void FindModules(const File& module_folder);
175
181 static void FindModules(const Buffer<String>& module_list, const File& module_folder);
182
188 static void FindModules(const File& module_list, const File& module_folder);
189
194 static void AddModule(const File& module_file);
195
200 static void CallModuleFunction(const StringView& function);
201
208 static void CallModuleFunction(const StringView& function, QTModelManager* model_manager, QTWindowManager* window_manager);
209
215 static void DefineModuleResources(const StringView& module_name, ModuleResourceManager* resources);
216
221 static void AddModule(const Module& module);
222
226 static void SaveModuleSettings();
227
232
236 static void OnExit();
237
243 static bool HasActiveModule(const StringView& module_name);
244
250 static bool IsModuleActive(const StringView& module_name);
251
255 static void ReadModuleSettings();
256
261 static void SetErrorCallback(const std::function<void(const Exception& e)>& callback);
262
268 static void* LoadDynamicLibrary(const StringView& library);
269
276 static void* LoadFromDynamicLibrary(void* library, const StringView& function);
277
284 static void* LoadFromDynamicLibrary(const StringView& library, const StringView& function);
285
292 static void SetInitialized(QTModelManager* model_manager, QTWindowManager* window_manager);
293
298 static bool IsInitialized();
299
305 private:
306 static bool s_initialized;
307 static QTModelManager* s_model_manager;
308 static QTWindowManager* s_window_manager;
309 };
310 template class NDEVR_BASE_API StringStream<Module::ModuleType>;
311}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
Provides consistent interface to handle errors through the throw expression.
Definition Exception.hpp:47
Logic for reading or writing to a file as well as navigating filesystems or other common file operati...
Definition File.h:53
Logic for the program-wide storage and execution of Modules.
static void FindModules(const Buffer< String > &module_list, const File &module_folder)
Discovers and loads modules from an explicit list of names within the given folder.
static bool IsModuleActive(const StringView &module_name)
Checks whether a specific module is currently marked as active.
static void AddModule(const Module &module)
Registers a pre-constructed Module into the module system.
static Buffer< String > ordered_modules
Module names in their load/execution order.
static void SetErrorCallback(const std::function< void(const Exception &e)> &callback)
Sets a callback to be invoked when a module hook function throws an exception.
static void SetInitialized(QTModelManager *model_manager, QTWindowManager *window_manager)
Marks the module system as fully initialized and stores the manager pointers for use when late-loaded...
static void SetupModuleRegistration()
Runs the registration setup hook on all modules to configure licensing.
static void ReadModuleSettings()
Reads module active/inactive states from persistent settings storage.
static void * LoadDynamicLibrary(const StringView &library)
Loads a dynamic library by name or path and returns an opaque handle.
static File MainModuleFolder()
Returns the primary folder where module libraries are located.
static bool HasActiveModule(const StringView &module_name)
Checks whether a module with the given name exists and is active.
static void DefineModuleResources(const StringView &module_name, ModuleResourceManager *resources)
Asks a specific module to declare its required resources.
static void FindModules(const File &module_list, const File &module_folder)
Discovers and loads modules listed in a ModuleList file within the given folder.
static String main_program_module_name
The name of the module designated as the main application entry-point.
static Dictionary< String, bool > module_active_list
Map of module names to their active/inactive state.
static void AddModule(const File &module_file)
Adds a single module by loading it from the specified library file.
static void * LoadFromDynamicLibrary(void *library, const StringView &function)
Resolves a function symbol from a previously loaded dynamic library.
static void SaveModuleSettings()
Persists the current module active/inactive states to settings storage.
static Dictionary< String, Dictionary< String, void * > > functions
Cached map of library names to their resolved function tables.
static Dictionary< String, Module > modules
Map of module names to their Module instances.
static bool IsInitialized()
Checks whether the module system has completed its initial setup sequence.
static void CallModuleFunction(const StringView &function)
Invokes a named hook function on all registered modules.
static void * LoadFromDynamicLibrary(const StringView &library, const StringView &function)
Loads a dynamic library and resolves a function symbol from it in one step.
static void CallModuleFunction(const StringView &function, QTModelManager *model_manager, QTWindowManager *window_manager)
Invokes a named UI hook function on all registered modules.
static void SetMainProgramModuleName(const StringView &name)
Sets the name of the main program module used as the application entry-point.
static void FindModules(const File &module_folder)
Discovers and loads all modules found in the given folder.
static void OnExit()
Invokes the exit cleanup hook on all modules and releases resources.
Stores all dependencies for a combination of modules that make up a complete software package.
A wrapper around DesignObjectLookup that provides signal and slot functionality and adds rendering ca...
Manages all windows and logic surrounding dialogs and views for displaying and managing a 3D environm...
Software Service Managers take a Software service to modify the behavior of the software.
Base interface for services that extend or modify software behavior through modules.
Logic for reading or writing to a string or a user friendly, TranslatedString.
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
Any text displayed to the user should be defined as a TranslatedString which allows the program to lo...
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Base class for extensions, typically added as external DLL's that can modify or enhance the behavior ...
File library
Path to the dynamic library file for this module.
Module(const StringView &name, const File &library)
Constructs a Module with the given name and library file.
bool allow_deferred_loading
Whether this module can be loaded asynchronously as a WASM side module.
void defineModuleResources(ModuleResourceManager *resources) const
Asks the module to declare its required resources via the given resource manager.
ModuleType
Categorizes the role a module plays within the application.
@ e_library_dependency
Module wraps a third-party library dependency.
@ e_utility
Module provides utility or tool functionality.
@ e_application
Module serves as an application entry-point.
@ e_undefined
Module type has not been specified.
String name
Internal identifier for the module.
Module()
Constructs a default Module with no name or library.
String activation_id
Identifier used for license activation checks.
TranslatedString description
User-facing description of the module.
void callModuleFunction(const StringView &function) const
Invokes a named hook function within this module.
bool isValid() const
Checks whether this module has a valid loaded library.
Dictionary< String, void * > loaded_functions
Cached map of hook function names to their resolved addresses.
void callModuleFunction(const StringView &function, QTModelManager *model_manager, QTWindowManager *window_manager) const
Invokes a named UI hook function within this module, passing the model and window managers.
void initialize()
Loads the dynamic library and resolves the module hook functions.
ModuleType type
The role category of this module.
String website
URL to the module's website or documentation.
String icon
Name or path of the icon associated with this module.
TranslatedString display_name
User-facing display name of the module.
void * module_ptr
Opaque pointer to the loaded dynamic library handle.
String version
Version string of the module.
String license_agreement
License agreement text for the module.
Module(const StringView &name)
Constructs a Module with the given name.
bool is_active
Whether the module is currently active.
bool allow_user_toggle_active
Whether the user is allowed to enable or disable this module.