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.

Loading Descriptions

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 "
static maxon::Id g_pluginDatabase = maxon::Id { "net.maxonexample.plugin.database" };

// 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 ;

return maxon::OK ; }

// 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);

延伸阅读

maxon::DataDescriptionDefinitionDatabaseInterface::RegisterDatabaseWithUrl
static MAXON_METHOD Result< void > RegisterDatabaseWithUrl(const Id &databaseId, const Url &url)
maxon::OK
return OK
定义: apibase.h:2532
maxon::Id
定义: apibaseid.h:250
maxon::APPLICATION_URLTYPE::CURRENT_MODULE_RESOURCE_DIR
@ CURRENT_MODULE_RESOURCE_DIR
Resource directory of the module that invoked this call.
iferr_return
#define iferr_return
定义: resultbase.h:1434
datadescriptiondefinitiondatabase.h
maxon::Url
定义: url.h:819
MAXON_INITIALIZATION
#define MAXON_INITIALIZATION(...)
定义: module.h:735
maxon::Result< void >
maxon::DataDescriptionDefinitionDatabaseInterface::UnregisterDatabase
static MAXON_METHOD Result< void > UnregisterDatabase(const Id &databaseId)
iferr_scope_handler
#define iferr_scope_handler
定义: resultbase.h:1361
maxon::Application::GetUrl
static MAXON_FUNCTION Result< Url > GetUrl(APPLICATION_URLTYPE urlType)
application.h

Copyright  © 2014-2025 乐数软件    

工业和信息化部: 粤ICP备14079481号-1