DataDescriptionDefinitionDatabaseInterface Class Reference

#include <datadescriptiondefinitiondatabase.h>

Detailed Description

DataDescriptionDefinitionDatabaseInterface provides functions for loading, storing DescriptionDefinitions.

Public Member Functions

 MAXON_OBSERVABLE_STATIC (Result< void >, ObservableSaveDatabase,(const Id &databaseId, const Url &dataBaseUrl, Bool beforeSave), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE_STATIC (Result< void >, ObservableDatabaseRegistrationChange,(const Id &databaseId, Bool added), ObservableCombinerRunAllComponent)
 

Static Public Member Functions

static MAXON_METHOD Result< DataDescriptionDefinition > LoadDescription (LOADDESCRIPTIONMODE mode, const Id &category, const LanguageRef &language, const IdAndVersion &dataType, Id *foundInDatabase=nullptr)
 
static MAXON_METHOD Result< void > StoreDescription (const Id &databaseId, const Id &category, const LanguageRef &language, const IdAndVersion &dataType, const DataDescriptionDefinition &description, const DataDescriptionDefinition &overwrittenDescription, Bool usePendingSystem)
 
static MAXON_METHOD Result< BoolDeleteDescription (const Id &category, const LanguageRef &language, const IdAndVersion &dataType)
 
static MAXON_METHOD Result< BaseArray< IdAndVersion > > GetRegisteredDescriptions (const Id &databaseId, const Id &category, const LanguageRef &language)
 
static MAXON_METHOD Result< void > WriteDataBases ()
 
static MAXON_METHOD Result< void > WriteUserChangedDataBases ()
 
static MAXON_METHOD Bool QueryNeedsWriteDataBases ()
 
static MAXON_METHOD Bool QueryNeedsWriteDataBasesForUserChanges ()
 
static MAXON_METHOD Result< IntRenameId (const Id &oldId, const Id &newId)
 
static MAXON_METHOD Result< IntRenameAttribute (const InternedId &oldId, const InternedId &newId)
 
static MAXON_METHOD Result< BoolCheckUniqueAttributeName (const InternedId &searchId)
 
static MAXON_METHOD Result< DataDescription > UpdateDescription (const Id &databaseId, const Id &category, const LanguageRef &language, const IdAndVersion &dataType, DataDescriptionDefinition &descRef, Bool notifyParents)
 
static MAXON_METHOD Result< void > RegisterDatabaseWithUrl (const Id &databaseId, const Url &url, const CString &version=CString::DefaultValue())
 
static MAXON_METHOD Result< void > RegisterDatabase (const Id &databaseId, const DataDescriptionDefinitionDatabaseImplRef &ddb)
 
static MAXON_METHOD Result< void > UnregisterDatabase (const Id &databaseId)
 
static MAXON_METHOD Bool IsWritableDatabase (const Id &databaseId, const Id &languageId)
 
static MAXON_METHOD Result< BaseArray< Id > > GetRegisteredDatabases ()
 
static MAXON_METHOD Result< DataDescription > BuildDescription (const Id &category, const IdAndVersion &dataTypeId, const LanguageRef &language)
 
static MAXON_METHOD Result< DataDescription > BuildDescription (const Id &category, const LanguageRef &language, const IdAndVersion &descriptionId, const DataDescriptionDefinition &srcDefinition)
 
static MAXON_METHOD Result< void > RegisterMessage (const Id &dataTypeId, const Id &attributeId, const Id &cmdId, const DescriptionMessageFunction &func)
 
static MAXON_FUNCTION Result< void > RegisterMessage (const Id &dataTypeId, const InternedId &attributeId, const Id &cmdId, const DescriptionMessageFunction &func)
 
static MAXON_METHOD Result< void > RegisterValueChangedMessage (const Id &dataTypeId, const Id &attributeId, const DescriptionMessageFunction &func)
 
static MAXON_FUNCTION Result< void > RegisterValueChangedMessage (const Id &dataTypeId, const InternedId &attributeId, const DescriptionMessageFunction &func)
 
static MAXON_METHOD DescriptionMessageFunctionFindNodeMessage (const Id &dataTypeId, const Id &attributeId, const Id &cmdId)
 
static MAXON_METHOD Result< BoolFindNodeValueChangedMessage (const Id &dataTypeId, const Id &attributeId, const ValueReceiver< DescriptionMessageFunction & > &receiver)
 
static MAXON_METHOD Result< void > FixDatabaseProps (DBVERSION version, DataDictionary &entry)
 

Private Member Functions

 MAXON_INTERFACE_NONVIRTUAL (DataDescriptionDefinitionDatabaseInterface, MAXON_REFERENCE_STATIC, "net.maxon.interface.datadescriptiondefinitiondatabase", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel"))
 

Member Function Documentation

◆ MAXON_INTERFACE_NONVIRTUAL()

MAXON_INTERFACE_NONVIRTUAL ( DataDescriptionDefinitionDatabaseInterface  ,
MAXON_REFERENCE_STATIC  ,
"net.maxon.interface.datadescriptiondefinitiondatabase"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel")   
)
private

◆ LoadDescription()

static MAXON_METHOD Result<DataDescriptionDefinition> LoadDescription ( LOADDESCRIPTIONMODE  mode,
const Id category,
const LanguageRef &  language,
const IdAndVersion dataType,
Id foundInDatabase = nullptr 
)
static

Loads a description from the registered databases.

Parameters
[in]categoryDatabase category (e.g. DATADESCRIPTION_CATEGORY_DATA / DATADESCRIPTION_CATEGORY_UI).
[in]languageLanguage (only valid for category DATADESCRIPTION_CATEGORY_STRING).
[in]dataTypeData type id to load.
[out]foundInDatabaseOptional: Pointer to an Id of the database where the entry was found.
Returns
DataDescriptionDefinition on success.

◆ StoreDescription()

static MAXON_METHOD Result<void> StoreDescription ( const Id databaseId,
const Id category,
const LanguageRef &  language,
const IdAndVersion dataType,
const DataDescriptionDefinition &  description,
const DataDescriptionDefinition &  overwrittenDescription,
Bool  usePendingSystem 
)
static

Stores the given description under the given values.

Parameters
[in]databaseIdDatabase id (see RegisterDatabase()/GetRegisteredDatabases()).
[in]categoryDatabase category (e.g. DATADESCRIPTION_CATEGORY_DATA / DATADESCRIPTION_CATEGORY_UI).
[in]languageLanguage (only valid for category DATADESCRIPTION_CATEGORY_STRING).
[in]dataTypeData type id to store.
[in]descriptionDescription data to store.
Returns
OK on success.

◆ DeleteDescription()

static MAXON_METHOD Result<Bool> DeleteDescription ( const Id category,
const LanguageRef &  language,
const IdAndVersion dataType 
)
static

DeleteDescription deletes a description from the database.

Parameters
[in]categoryDatabase category (e.g. DATADESCRIPTION_CATEGORY_DATA / DATADESCRIPTION_CATEGORY_UI).
[in]languageLanguage (only valid for category DATADESCRIPTION_CATEGORY_STRING).
[in]dataTypeData type id to delete.
Returns
True/False on success. True means the description was found and deleted. False if the description was not found.

◆ GetRegisteredDescriptions()

static MAXON_METHOD Result<BaseArray<IdAndVersion> > GetRegisteredDescriptions ( const Id databaseId,
const Id category,
const LanguageRef &  language 
)
static

Return all registered descriptions.

Parameters
[in]databaseIdUnique id for the database. If Id() is given the result of all databases will be returned.
[in]categoryDatabase category (e.g. DATADESCRIPTION_CATEGORY_DATA / DATADESCRIPTION_CATEGORY_UI).
[in]languageLanguage (only valid for category DATADESCRIPTION_CATEGORY_STRING).
Returns
Array on success.

◆ WriteDataBases()

static MAXON_METHOD Result<void> WriteDataBases ( )
static

Save all databases (including user changes and version update changes).

Returns
OK on success.

◆ WriteUserChangedDataBases()

static MAXON_METHOD Result<void> WriteUserChangedDataBases ( )
static

Save all databases edited by a user.

Returns
OK on success.

◆ QueryNeedsWriteDataBases()

static MAXON_METHOD Bool QueryNeedsWriteDataBases ( )
static

QueryNeedsWriteDataBases returns true if changes to the databases are pending and not saved. Those changes can include user changes and automatic database version update changes.

Returns
True if databases were modified and are still unsaved.

◆ QueryNeedsWriteDataBasesForUserChanges()

static MAXON_METHOD Bool QueryNeedsWriteDataBasesForUserChanges ( )
static

QueryNeedsWriteDataBases returns true if changes from user to the databases are pending and not saved.

Returns
True if databases were modified and are still unsaved.

◆ RenameId()

static MAXON_METHOD Result<Int> RenameId ( const Id oldId,
const Id newId 
)
static

Renames a id in all databases to the new id.

Parameters
[in]oldIdOld id to rename
[in]newIdId to replace.
Returns
Number of values that were renamed.

◆ RenameAttribute()

static MAXON_METHOD Result<Int> RenameAttribute ( const InternedId oldId,
const InternedId newId 
)
static

Renames an attribute in all databases.

Parameters
[in]oldIdOld attribute key.
[in]newIdNew attribute key.
Returns
Number of values that were renamed.

◆ CheckUniqueAttributeName()

static MAXON_METHOD Result<Bool> CheckUniqueAttributeName ( const InternedId searchId)
static

Checks if the given id is unique in all databases.

Parameters
[in]searchIdId to search for.
Returns
True if the id is unique. False if the id already exists.

◆ UpdateDescription()

static MAXON_METHOD Result<DataDescription> UpdateDescription ( const Id databaseId,
const Id category,
const LanguageRef &  language,
const IdAndVersion dataType,
DataDescriptionDefinition &  descRef,
Bool  notifyParents 
)
static

UpdateDescription description.

Parameters
[in]databaseIdUnique id for the database.
[in]categoryDatabase category (e.g. DATADESCRIPTION_CATEGORY_DATA / DATADESCRIPTION_CATEGORY_UI / DATADESCRIPTION_CATEGORY_STRING).
[in]languageLanguage (only valid for category DATADESCRIPTION_CATEGORY_STRING).
[in]dataTypeData type id to store.
[in]descRefDescription ref to connect the update observable with.
[in]notifyParentsTrue if parents should be notified.
Returns
OK on success.

◆ RegisterDatabaseWithUrl()

static MAXON_METHOD Result<void> RegisterDatabaseWithUrl ( const Id databaseId,
const Url url,
const CString version = CString::DefaultValue() 
)
static

Registers a database for a specific module under the given url.

Parameters
[in]databaseIdUnique id for the database.
[in]urlAbsolute url to look for the database.
[in]versionAn optional version string to use for the database. This is used by some description processors to invalidate cached meta data which is derived from descriptions.
Returns
OK on success.

◆ RegisterDatabase()

static MAXON_METHOD Result<void> RegisterDatabase ( const Id databaseId,
const DataDescriptionDefinitionDatabaseImplRef &  ddb 
)
static

Registers a special database DataDescriptionDefinitionDatabaseImplRef under the given id.

Parameters
[in]databaseIdUnique id for the database.
[in]ddbDatabase implementation to register.
Returns
OK on success.

◆ UnregisterDatabase()

static MAXON_METHOD Result<void> UnregisterDatabase ( const Id databaseId)
static

Unregisters the database from the system.

Parameters
[in]databaseIdUnique id of the database.
Returns
OK on success.

◆ IsWritableDatabase()

static MAXON_METHOD Bool IsWritableDatabase ( const Id databaseId,
const Id languageId 
)
static

Returns true if the database is writable.

Parameters
[in]databaseIdUnique id of the database.
[in]languageIdLanguage id to check.
Returns
True if writable.

◆ GetRegisteredDatabases()

static MAXON_METHOD Result<BaseArray<Id> > GetRegisteredDatabases ( )
static

Returns the ids of all registered databases.

Returns
Array on success.

◆ BuildDescription() [1/2]

static MAXON_METHOD Result<DataDescription> BuildDescription ( const Id category,
const IdAndVersion dataTypeId,
const LanguageRef &  language 
)
static

Updates the description from the unique definition identified by #dataTypeId.

Parameters
[in]categoryDatabase category (e.g. DATADESCRIPTION_CATEGORY_DATA / DATADESCRIPTION_CATEGORY_UI / DATADESCRIPTION_CATEGORY_STRING).
[in]dataTypeIdIdentifier of the definition to process.
[in]languageLanguage for which to build the description (only valid for category DATADESCRIPTION_CATEGORY_STRING).
Returns
The result of the processed definition.

◆ BuildDescription() [2/2]

static MAXON_METHOD Result<DataDescription> BuildDescription ( const Id category,
const LanguageRef &  language,
const IdAndVersion descriptionId,
const DataDescriptionDefinition &  srcDefinition 
)
static

Processes a definition to create a usable DataDescription. For instance, include commands will be expanded, remove commands will be "erased", overrides will be aggregated, etc. The resulting description should not contain any entry with duplicated DESCRIPTION::BASE::IDENTIFIER. Can be used to process dynamically created definitions, not only definitions read from a database. The resulting descriptions are not cached.

Parameters
[in]categoryDescription category to build (e.g. DATADESCRIPTION_CATEGORY_DATA / DATADESCRIPTION_CATEGORY_UI / DATADESCRIPTION_CATEGORY_STRING).
[in]languageLanguage for which to build the description (only valid for category DATADESCRIPTION_CATEGORY_STRING).
[in]descriptionIdThe identifier of the original definition of #srcDefinition if available.
[in]srcDefinitionThe source definition to process.
Returns
The result of the processed definition.

◆ RegisterMessage() [1/2]

static MAXON_METHOD Result<void> RegisterMessage ( const Id dataTypeId,
const Id attributeId,
const Id cmdId,
const DescriptionMessageFunction func 
)
static

Registers a message callback for a datatype, attribute and variadic command.

Parameters
[in]dataTypeIdData type id to register.
[in]attributeIdAttribute id to register.
[in]cmdIdCommand Id to register.
[in]funcCallback function to register.
Returns
OK on success.

◆ RegisterMessage() [2/2]

static MAXON_FUNCTION Result<void> RegisterMessage ( const Id dataTypeId,
const InternedId attributeId,
const Id cmdId,
const DescriptionMessageFunction func 
)
static

◆ RegisterValueChangedMessage() [1/2]

static MAXON_METHOD Result<void> RegisterValueChangedMessage ( const Id dataTypeId,
const Id attributeId,
const DescriptionMessageFunction func 
)
static

Registers a value changed callback for a datatype and attribute id. Callback will be fired after the new value was changed.

Parameters
[in]dataTypeIdData type id to register.
[in]attributeIdAttribute id to register. Optional.
[in]funcCallback function to register.
Returns
OK on success.

◆ RegisterValueChangedMessage() [2/2]

static MAXON_FUNCTION Result<void> RegisterValueChangedMessage ( const Id dataTypeId,
const InternedId attributeId,
const DescriptionMessageFunction func 
)
static

◆ FindNodeMessage()

static MAXON_METHOD DescriptionMessageFunction* FindNodeMessage ( const Id dataTypeId,
const Id attributeId,
const Id cmdId 
)
static

Finds a registered command callback with a given datatype, attribute and variadic command.

Parameters
[in]dataTypeIdData type id to search for.
[in]attributeIdAttribute id to search for.
[in]cmdIdCommand id to search for.
Returns
Pointer to the callback. Nullptr if nothing was found.

◆ FindNodeValueChangedMessage()

static MAXON_METHOD Result<Bool> FindNodeValueChangedMessage ( const Id dataTypeId,
const Id attributeId,
const ValueReceiver< DescriptionMessageFunction & > &  receiver 
)
static

Finds a registered value changed callback with a given datatype and attribute id. It is possible to supply only both id inputs or just a #dataTypeId. But then the same callback will be found for multiple multiples attributes of this #datatypeId (i.e. global to #dataTypeId).

Parameters
[in]dataTypeIdData type id to search for.
[in]attributeIdAttribute id to search for. Optional.
[in]receiverReceiver for the various functions found (could be multiple hits).
Returns
Result of the receiver.

◆ FixDatabaseProps()

static MAXON_METHOD Result<void> FixDatabaseProps ( DBVERSION  version,
DataDictionary &  entry 
)
static

Fixes an entry of the resource database.

Parameters
[in]versionlast converted version.
[in]entryDataDictionary to convert.
Returns
OK on success.

◆ MAXON_OBSERVABLE_STATIC() [1/2]

MAXON_OBSERVABLE_STATIC ( Result< void >  ,
ObservableSaveDatabase  ,
(const Id &databaseId, const Url &dataBaseUrl, Bool beforeSave)  ,
ObservableCombinerRunAllComponent   
)

ObservableSaveDatabase will be triggered before and after a database is/was written. This can be used to add source control callbacks etc.

◆ MAXON_OBSERVABLE_STATIC() [2/2]

MAXON_OBSERVABLE_STATIC ( Result< void >  ,
ObservableDatabaseRegistrationChange  ,
(const Id &databaseId, Bool added)  ,
ObservableCombinerRunAllComponent   
)

ObservableDatabaseRegistrationChange after a database was added or removed to the system. This can be used to update editors.