Loading Data Descriptions

About

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.
static maxon::Id g_pluginDatabase = maxon::Id { "net.maxonexample.plugin.database" };
// loads resources in the beginning
static maxon::Result<void> LoadResources()
{
{
err.DiagOutput();
err.CritStop();
return err;
};
// get plugin res folder
// register database
return maxon::OK;
}
// frees resources at the end
static void FreeResources()
{
{
err.DiagOutput();
err.CritStop();
return;
};
// Unregister all descriptions.
}
MAXON_INITIALIZATION(LoadResources, FreeResources);

Further Reading

maxon::DataDescriptionDefinitionDatabaseInterface::RegisterDatabaseWithUrl
static MAXON_METHOD Result< void > RegisterDatabaseWithUrl(const Id &databaseId, const Url &url)
maxon::OK
return OK
Definition: apibase.h:2485
maxon::Id
Definition: apibaseid.h:273
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
Definition: resultbase.h:1434
datadescriptiondefinitiondatabase.h
maxon::Url
Definition: url.h:819
MAXON_INITIALIZATION
#define MAXON_INITIALIZATION(...)
Definition: module.h:729
maxon::Result< void >
maxon::DataDescriptionDefinitionDatabaseInterface::UnregisterDatabase
static MAXON_METHOD Result< void > UnregisterDatabase(const Id &databaseId)
iferr_scope_handler
#define iferr_scope_handler
Definition: resultbase.h:1361
maxon::Application::GetUrl
static MAXON_FUNCTION Result< Url > GetUrl(APPLICATION_URLTYPE urlType)
application.h