Loading Data Descriptions
Data descriptions list the attributes of MAXON API component. Such a description is created using the Resource Editor and saved to a *.json file.
To use the description, a plugin must load tihs file on program start.
A description can be loaded and freed using MAXON_INITIALIZATION() . The description file can be stored in the plugins "res" folder which can be obtaind using maxon::Application::GetUrl() .
The description is then loaded using maxon::DataDescriptionDefinitionDatabaseInterface::RegisterDatabaseWithUrl() . At the end, the description is freed using maxon::DataDescriptionDefinitionDatabaseInterface::UnregisterDatabase() .
// This exampe shows how to load a description database. #include " maxon/datadescriptiondefinitiondatabase.h " #include " maxon/application.h "// loads resources in the beginning static maxon::Result<void> LoadResources() { iferr_scope_handler { err.DiagOutput(); err.CritStop(); return err; };
// get plugin res folder const maxon::Url resDir = maxon::Application::GetUrl ( maxon::APPLICATION_URLTYPE::CURRENT_MODULE_RESOURCE_DIR ) iferr_return ;
// register database maxon::DataDescriptionDefinitionDatabaseInterface::RegisterDatabaseWithUrl (g_pluginDatabase, resDir) iferr_return ;
// frees resources at the end static void FreeResources() { iferr_scope_handler { err.DiagOutput(); err.CritStop(); return ; };
// Unregister all descriptions. maxon::DataDescriptionDefinitionDatabaseInterface::UnregisterDatabase (g_pluginDatabase) iferr_return ; } MAXON_INITIALIZATION (LoadResources, FreeResources);