|
| virtual Sint32 | commit ()=0 |
| | Commits the transaction. More...
|
| |
| virtual void | abort ()=0 |
| | Aborts the transaction. More...
|
| |
| virtual bool | is_open ()=0 |
| | Indicates whether the transaction is open. More...
|
| |
| virtual Tag_struct | store (IElement *element, Tag_struct tag=NULL_TAG, const char *name=nullptr, Privacy_level privacy_level=LOCAL_SCOPE)=0 |
| | Stores a new database element in the database. More...
|
| |
| virtual Tag_struct | store (IJob *job, Tag_struct tag=NULL_TAG, const char *name=nullptr, Privacy_level privacy_level=LOCAL_SCOPE)=0 |
| | Stores a new database job in the database. More...
|
| |
| virtual Tag_struct | store_for_reference_counting (IElement *element, Tag_struct tag=NULL_TAG, const char *name=nullptr, Privacy_level privacy_level=LOCAL_SCOPE)=0 |
| | Stores a new database element in the database (for reference counting). More...
|
| |
| virtual Tag_struct | store_for_reference_counting (IJob *job, Tag_struct tag=NULL_TAG, const char *name=nullptr, Privacy_level privacy_level=LOCAL_SCOPE)=0 |
| | Stores a new database job in the database (for reference counting). More...
|
| |
| virtual const base::IInterface * | access (Tag_struct tag)=0 |
| | Retrieves an element from the database. More...
|
| |
| template<class T> |
| const T * | access (Tag_struct tag) |
| | Retrieves an element from the database. More...
|
| |
| virtual base::IInterface * | edit (Tag_struct tag)=0 |
| | Retrieves an element from the database and returns it ready for editing. More...
|
| |
| template<class T> |
| T * | edit (Tag_struct tag) |
| | Retrieves an element from the database and returns it ready for editing. More...
|
| |
| virtual Sint32 | localize (Tag_struct tag, Privacy_level privacy_level)=0 |
| | Localizes a tag to the given privacy level. More...
|
| |
| virtual Sint32 | remove (Tag_struct tag, bool only_localized=false)=0 |
| | Marks a tag for removal from the database. More...
|
| |
| virtual const char * | get_time_stamp () const =0 |
| | Returns the time stamp describing the current "time". More...
|
| |
| virtual const char * | get_time_stamp (Tag_struct tag) const =0 |
| | Returns the time stamp of the last change of a database element. More...
|
| |
| virtual bool | has_changed_since_time_stamp (Tag_struct tag, const char *time_stamp) const =0 |
| | Checks whether an element has been stored or changed in the database since a given time stamp. More...
|
| |
| virtual const ITag_set * | get_changed_elements_since_time_stamp (const char *time_stamp) const =0 |
| | Returns all elements (of type mi::neuraylib::IElement) that have been stored or changed in the database since a given time stamp. More...
|
| |
| virtual const char * | get_id () const =0 |
| | Returns the ID of this transaction. More...
|
| |
| virtual IScope * | get_scope () const =0 |
| | Returns the scope of this transaction. More...
|
| |
| virtual Sint32 | get_privacy_level (Tag_struct tag) const =0 |
| | Returns the privacy level of the element with a given tag. More...
|
| |
| virtual void | advise (Tag_struct tag)=0 |
| | Advises the database that a given tag is required soon. More...
|
| |
| virtual Tag_struct | reserve_tag ()=0 |
| | Reserves a tag. More...
|
| |
| virtual const char * | tag_to_name (Tag_struct tag)=0 |
| | Returns the name associated with a tag in the database. More...
|
| |
| virtual Tag_struct | name_to_tag (const char *name)=0 |
| | Returns the tag associated with a name in the database. More...
|
| |
| virtual Sint32 | execute_fragmented (IFragmented_job *job, Size count)=0 |
| | Executes a fragmented job synchronously. More...
|
| |
| virtual Sint32 | execute_fragmented_async (IFragmented_job *job, Size count, IExecution_listener *listener)=0 |
| | Executes a fragmented job asynchronously. More...
|
| |
| virtual void | invalidate_job_results (Tag_struct tag)=0 |
| | Invalidates the results of a database job. More...
|
| |
| virtual Uint32 | retain () const =0 |
| | Increments the reference count. More...
|
| |
| virtual Uint32 | release () const =0 |
| | Decrements the reference count. More...
|
| |
| virtual const IInterface * | get_interface (const Uuid &interface_id) const =0 |
| | Acquires a const interface from another. More...
|
| |
| template<class T> |
| const T * | get_interface () const |
| | Acquires a const interface from another. More...
|
| |
| virtual IInterface * | get_interface (const Uuid &interface_id)=0 |
| | Acquires a mutable interface from another. More...
|
| |
| template<class T> |
| T * | get_interface () |
| | Acquires a mutable interface from another. More...
|
| |
| virtual Uuid | get_iid () const =0 |
| | Returns the interface ID of the most derived interface. More...
|
| |
|
| using | Self = Interface_declare< id1, ... > |
| | Own type. More...
|
| |
| using | IID = Uuid_t< id1, ... > |
| | Declares the interface ID (IID) of this interface. More...
|
| |
| using | IID = Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> |
| | Declares the interface ID (IID) of this interface. More...
|
| |
| static bool | compare_iid (const Uuid &iid) |
| | Compares the interface ID iid against the interface ID of this interface and of its ancestors. More...
|
| |
| static bool | compare_iid (const Uuid &iid) |
| | Compares the interface ID iid against the interface ID of this interface. More...
|
| |
A transaction provides a consistent view on the database.
This view on the database is isolated from changes by other (parallel) transactions. Eventually, each transaction must be either committed or aborted, i.e., all changes become either atomically visible to transactions started afterwards, or not at all.
Transactions are associated with a scope of the database and can be created with mi::neuraylib::IScope::create_transaction<mi::neuraylib::IDice_transaction>().
- Concurrent accesses to database elements within a transaction
Access to database elements is provided by access() (read-only) and edit() (for modification). The interface pointers returned by these methods must be released when you are done, in particular before the transaction is committed or aborted. Releasing the last interface pointer obtained from edit() makes the changes also visible to later edit() calls for the same database element.
- Note that it is possible to access the same database element concurrently in the same transaction. Concurrently means that the interface pointer obtained from an earlier access() or edit() call has not yet been released and the same database element is accessed once more using access() or edit(). It is advisable to avoid such concurrent accesses since it can easily lead to difficult to understand effects. The semantics are as follows:
-
multiple access() calls: Since all obtained interface pointers are const there is no way to modify the database elements.
-
access() call after edit() calls: This use case is not supported.
-
edit() call after access() calls: The changes done to the interface pointer returned from edit() are not observable through any interface pointer returned from the access() calls.
-
multiple edit() calls: The changes done to the individual interface pointers are not observable through the other interface pointers. The changes from the interface pointer from the last edit() call survive, independent of the order in which the pointers are released.
- Concurrent transactions
If the same database element is edited in multiple overlapping transactions, the changes from the transaction created last survive, independent of the order in which the transactions are committed. If needed, the lifetime of transactions can be serialized across hosts (see mi::neuraylib::IDatabase::lock() for details).
template<class T>
| const T * mi::neuraylib::IDice_transaction::access |
( |
Tag_struct |
tag | ) |
|
|
inline |
Retrieves an element from the database.
The database searches for the most recent version of the named database element visible for the current transaction. That version will be returned.
If the tag identifies a database job the database ensures that the job has been executed and returns the result of the job.
This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const base::Uuid&) on the returned pointer, since the return type already is a const handle of the type T specified as template parameter.
- Parameters
-
| tag | The tag that identifies the requested database element. |
- Template Parameters
-
| T | The interface type of the element to retrieve. |
- Returns
- The requested element in the database, or
nullptr if the transaction is already closed, or the element is not of type T.
| virtual void mi::neuraylib::IDice_transaction::advise |
( |
Tag_struct |
tag | ) |
|
|
pure virtual |
Advises the database that a given tag is required soon.
If tag identifies a database job its execution will be triggered. If tag identifies a plain database element then fetching the data from other hosts or reading from disk will be triggered (if necessary).
In both cases the method does not block, but returns immediately, only later accesses via access() or edit() might block. Thus, this method can be used, for instance, to trigger parallel execution of jobs.
template<class T>
| T * mi::neuraylib::IDice_transaction::edit |
( |
Tag_struct |
tag | ) |
|
|
inline |
Retrieves an element from the database and returns it ready for editing.
The database searches for the most recent version of the named database element visible for the current transaction. The database creates a local copy which is used in this transaction (and replaces the old version when the transaction is committed).
Note that database jobs including their resulting database elements cannot be edited.
This templated member function is a wrapper of the non-template variant for the user's convenience. It eliminates the need to call mi::base::IInterface::get_interface(const base::Uuid&) on the returned pointer, since the return type already is a const handle of the type T specified as template parameter.
- Parameters
-
| tag | The tag that identifies the requested database element. |
- Template Parameters
-
| T | The interface type of the element to retrieve. |
- Returns
- The requested element in the database, or
nullptr if the transaction is already closed, or the element is not of type T.
| virtual Sint32 mi::neuraylib::IDice_transaction::remove |
( |
Tag_struct |
tag, |
|
|
bool |
only_localized = false |
|
) |
| |
|
pure virtual |
Marks a tag for removal from the database.
- Global removals
The purpose of global removals is to mark all versions of a tag for garbage collection. Such a marker has no effect while the tag is still referenced (in any scope) by other database elements or while the transaction where the removal request was made is still open. When these conditions do no longer apply, the tag becomes eligible for garbage collection and must no longer be used in any way. There is no guarantee when the garbage collection will actually remove the tag.
This implies that a remove() call might actually remove an element that was stored later under the same tag. This can potentially lead to invalid tag accesses. Those cases can be avoided by using mi::neuraylib::IDatabase::garbage_collection() after a transaction was committed and before starting the next one to force garbage collection of all possible elements.
- Local removals
The purpose of local removals is to undo the effects of an earlier localization via mi::neuraylib::IDice_transaction::localize(). A local removal request requires that a tag version exists in the scope of the transaction, and at least one more tag version exists in one of the parent scopes. The effect of a local removal request is to immediately hide the tag version in the scope of the transaction (the local copy), and to make the next tag version in one of the parent scopes accessible from the very same transaction. The hidden local copy will be lazily removed by the garbage collection of the database. There is no guarantee when this will happen.
- Parameters
-
| tag | The tag to be marked for removal. |
| only_localized | false for global removals (the default) or true for local removals. The flag is ignored in favor of global removals if the transaction belongs to the global scope. |
- Returns
- 0: Success (including subsequent global removals on elements already marked for global removal).
- -1: For global removals: there is no database element with tag
tag visible in this transaction. For local removals: there is no database element with tag tag in the scope of this transaction or there is no version of that database element in one of the parent scopes.
- -2: Invalid parameters (
tag is invalid).
- -3: The transaction is not open.