A transaction provides a consistent view on the database. More...
#include <dice.h>
Public Member Functions | |
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=0, 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=0, 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=0, 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=0, 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... | |
Public Member Functions inherited from mi::base::IInterface | |
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... | |
Static Public Attributes | |
static const mi::Uint8 | LOCAL_SCOPE = 255 |
Symbolic privacy level for the privacy level of the scope of this transaction. More... | |
Additional Inherited Members | |
Public Types inherited from mi::base::Interface_declare< 0x1885cbec, ... > | |
typedef Interface_declare< id1, ... > | Self |
Own type. More... | |
typedef Uuid_t< id1, ... > | IID |
Declares the interface ID (IID) of this interface. More... | |
Public Types inherited from mi::base::IInterface | |
typedef Uuid_t<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0> | IID |
Declares the interface ID (IID) of this interface. More... | |
Static Public Member Functions inherited from mi::base::Interface_declare< 0x1885cbec, ... > | |
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 Public Member Functions inherited from mi::base::IInterface | |
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>().
|
pure virtual |
Aborts the transaction.
Note that an abort() implicitly closes the transaction. A closed transaction does not allow any future operations and needs to be released.
|
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.
tag | The tag that identifies the requested database element. |
T | The interface type of the element to retrieve. |
NULL
if the transaction is already closed, or the element is not of type T
.
|
pure virtual |
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.
tag | The tag that identifies the requested database element. |
NULL
if the transaction is already closed.
|
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.
|
pure virtual |
Commits the transaction.
Note that a commit() implicitly closes the transaction. A closed transaction does not allow any future operations and needs to be released.
|
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.
tag | The tag that identifies the requested database element. |
T | The interface type of the element to retrieve. |
NULL
if the transaction is already closed, or the element is not of type T
.
|
pure virtual |
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.
tag | The tag that identifies the requested database element. |
NULL
if the transaction is already closed.
|
pure virtual |
Executes a fragmented job synchronously.
The fragmented job is conceptually split into count
fragments. Each fragment is executed exactly once in the cluster environment, either locally or remotely. The method returns when all fragments have been executed.
The fragments are executed independently by any number of threads and possibly on any number of hosts in parallel (see mi::neuraylib::IFragmented_job::get_scheduling_mode()). The number of fragments does not imply any specific parallel execution scheme. In principle, the DiCE job scheduling system may execute all fragments in parallel at the same time or all in serial order one after the other or anything in between. It is only guaranteed that each fragment is executed exactly once.
job | The fragmented job to be executed. All fragments executed on the initiating host operate on the given instance of the fragmented job. The fragments executed on different hosts in the cluster operate on a replicas of the given instance. The replicas result from serializing the instance given here and later restoring an instance of the same class by deserializing it on the remote host. That is, changes to the fragmented job instance applied during job execution never become visible during remote execution and, thus, should be avoided, unless these changes are intentional (results) or not relevant (host local caches). |
count | The number of fragments into which the job is split. This value needs to be greater than zero unless the scheduling mode is mi::neuraylib::IFragmented_job::ONCE_PER_HOST. In that case a value of zero means "as many fragments as remote hosts in the cluster". |
job
is NULL
or count
is zero but the scheduling mode is not mi::neuraylib::IFragmented_job::ONCE_PER_HOST).
|
pure virtual |
Executes a fragmented job asynchronously.
This method is similar to execute_fragmented() except that the execution happens asynchronously. A callback is used to signal the completion of the job.
job | The fragmented job to be executed. |
count | The number of fragments into which the job is split. This value needs to be greater than zero unless the scheduling mode is mi::neuraylib::IFragmented_job::ONCE_PER_HOST. In that case a value of zero means "as many fragments as remote hosts in the cluster". |
listener | The job_finished() method of this callback is called when the job has been completed (might be NULL ). |
job
is NULL
or count
is zero).
|
pure virtual |
Returns all elements (of type mi::neuraylib::IElement) that have been stored or changed in the database since a given time stamp.
time_stamp
should not stem from another concurrent transaction. Such changes will never be visible in this transaction, but the method might still return true
depending on the start order of the two transactions.time_stamp | The time stamp obtained from get_time_stamp() or get_time_stamp(mi::neuraylib::Tag_struct)const. |
NULL
in case of failure, i.e., the time stamp is invalid or there have been too many changes since the given time stamp.
|
pure virtual |
Returns the ID of this transaction.
The transaction ID is of most use when debugging an application as the value returned allows one to correlate log messages and admin HTTP server output with the API actions.
|
pure virtual |
Returns the privacy level of the element with a given tag.
tag | The tag of the element. |
|
pure virtual |
Returns the scope of this transaction.
|
pure virtual |
Returns the time stamp describing the current "time".
|
pure virtual |
Returns the time stamp of the last change of a database element.
|
pure virtual |
Checks whether an element has been stored or changed in the database since a given time stamp.
time_stamp
should not stem from another concurrent transaction. Such changes will never be visible in this transaction, but the method might still return true
depending on the start order of the two transactions.tag | The tag that identifies the database element. |
time_stamp | The time stamp obtained from get_time_stamp() or get_time_stamp(mi::neuraylib::Tag_struct)const. |
true
if the element has been stored or changed since the time stamp (or if tag
or time_stamp
is invalid), false
otherwise.
|
pure virtual |
Invalidates the results of a database job.
If the result of a database is invalidated the next access to that tag will trigger re-execution of the job. Re-execution of a database job might become necessary when database elements used as input for the job have changed.
|
pure virtual |
Indicates whether the transaction is open.
The ability to check whether the transaction is still open is particularly important for advised jobs, which shall be able to abort their operation if their results become irrelevant to the database in the meantime.
true
if the transaction is still open, or false
if the transaction is closed, i.e., it has been committed or aborted.
|
pure virtual |
Localizes a tag to the given privacy level.
Creates a copy of the identified database element and stores that copy in the given privacy level.
tag | The tag that identifies the database element to be localized. |
privacy_level | The desired privacy level of the copy (in the range from 0 to the privacy level of the scope of this transaction). In addition, the constant LOCAL_SCOPE can be used as a shortcut to indicate the privacy level of the scope of this transaction without supplying the actual value itself. |
tag
is invalid).
|
pure virtual |
Returns the tag associated with a name in the database.
name
, or NULL_TAG if there is no tag associated with name
.
|
pure virtual |
Marks a tag
for removal from the database.
Note that the element continues to be stored in the database as long as it is referenced by other elements (or jobs). If it is no longer referenced, it will be lazily removed by the garbage collection of the database. There is no guarantee when this will happen. This implies that a remove() call might actually remove an element that was stored later under the same tag.
tag | The tag that identifies the database element to be marked for removal. |
only_localized | If true , the element is only removed if it exists in the scope of the transaction; parent scopes are not considered. |
tag
visible in this transaction (only_localize
is false
) or there is no database element with tag tag
in the scope of this transaction (only_localized
is true
).tag
is invalid).
|
pure virtual |
Reserves a tag.
When storing a database element or database job a new tag is automatically assigned and returned. Alternatively, one can reserve a tag upfront and pass it later explicitly to the various store() method.
|
pure virtual |
Stores a new database element in the database.
After a successful store operation the passed interface pointer must no longer be used, except for releasing it. This is due to the fact that after a store() the database retains ownership of the stored data. You can obtain the stored version from the database using the access() or edit() methods.
element | The database element to be stored in the database. |
tag | An optional tag used to identify the database element in the database. The tag must be NULL_TAG (the default) or must have been obtained from previous calls to store(), store_for_reference_counting(), name_to_tag(), or reserve_tag(). An existing database element/job associated with this tag will be replaced. See also the documentation of the return value and the note below. |
name | An optional name used to identify the database element in the database. An existing database element/job associated with this name will be replaced. |
privacy_level | The privacy level under which to store db_element (in the range from 0 to the privacy level of the scope of this transaction). In addition, the constant LOCAL_SCOPE can be used as a shortcut to indicate the privacy level of the scope of this transaction without supplying the actual value itself. |
tag
or name_to_tag() applied to name
if there is already a database element/job associated with that tag, that database element/job is to be removed, and no other database element/job is referencing it anymore.tag
is ignored if name
is given and there is a database element/job with that name. The tag of that database element/job is used instead of tag
.
|
pure virtual |
Stores a new database job in the database.
After a successful store operation the passed interface pointer must no longer be used, except for releasing it. This is due to the fact that after a store() the database retains ownership of the stored data.
job | The database job to be stored in the database. |
tag | An optional tag used to identify the database job in the database. The tag must be NULL_TAG (the default) or must have been obtained from previous calls to store(), store_for_reference_counting(), name_to_tag(), or reserve_tag(). An existing database element/job associated with this tag will be replaced. See also the documentation of the return value and the note below. |
name | An optional name used to identify the database job in the database. An existing database element/job associated with this name will be replaced. |
privacy_level | The privacy level under which to store job (in the range from 0 to the privacy level of the scope of this transaction). In addition, the constant LOCAL_SCOPE can be used as a shortcut to indicate the privacy level of the scope of this transaction without supplying the actual value itself. |
tag
or name_to_tag() applied to name
if there is already a database element/job associated with that tag, that database element/job is to be removed, and no other database element/job is referencing it anymore.tag
is ignored if name
is given and there is a database element/job with that name. The tag of that database element/job is used instead of tag
.
|
pure virtual |
Stores a new database element in the database (for reference counting).
This method is similar to store() except that the database element will only be kept in the database as long as other elements in the database exist that list it in their set of references returned by the mi::neuraylib::IElement::get_references() method. The same effect can be achieved by calling store() followed by a remove() call on the returned tag.
|
pure virtual |
Stores a new database job in the database (for reference counting).
This method is similar to store() except that the database job will only be kept in the database as long as other elements in the database exist that list it in their set of references returned by the mi::neuraylib::IElement::get_references() method. The same effect can be achieved by calling store() followed by a remove() call on the returned tag.
|
pure virtual |
Returns the name associated with a tag in the database.
tag
, or NULL
if there is no name associated with tag
.
|
static |
Symbolic privacy level for the privacy level of the scope of this transaction.
This symbolic constant can be passed to store(), store_for_reference_counting(), and localize() to indicate the privacy level of the scope of this transaction. It has the same effect as passing the result of mi::neuraylib::IScope::get_privacy_level(), but is more convenient.