DeeTransaction

## DeeTransaction DeeTransaction — A self contained change set for a DeeModel |

## Synopsis

    #include <dee.h>

    #define             DEE_TRANSACTION_ERROR
    struct              DeeTransaction;
    struct              DeeTransactionClass;
    enum                DeeTransactionError;
    gboolean            dee_transaction_commit              (DeeTransaction *self,
                                                             GError **error);
    GQuark              dee_transaction_error_quark         (void);
    DeeModel *          dee_transaction_get_target          (DeeTransaction *self);
    gboolean            dee_transaction_is_committed        (DeeTransaction *self);
    DeeModel *          dee_transaction_new                 (DeeModel *target);

## Object Hierarchy

      GObject
       +----DeeSerializableModel
             +----DeeTransaction

## Implemented Interfaces

DeeTransaction implements DeeModel and DeeSerializable.

## Properties

      "target"                   DeeModel*             : Read / Write / Construct Only

## Description

DeeTransaction is a self contained change set related to some particular DeeModel called the target model.

The transaction instance itself implements the DeeModel interface in a way that overlays the target model. In database terms the target model has isolation level READ_COMMITTED. Meaning that the target model is not modified until you call `dee_transaction_commit()`.

To flush the changes to the target model call `dee_transaction_commit()`. After committing the transaction will become invalid and must be freed with `g_object_unref()`. It is a programming error to try and access a transaction that has been committed with the sole exception of calling `dee_transaction_is_committed()`.

## Details

### DEE_TRANSACTION_ERROR

    #define DEE_TRANSACTION_ERROR dee_transaction_error_quark()

Error domain for the DeeTransaction. Error codes will be from the DeeTransactionError enumeration

### struct DeeTransaction

    struct DeeTransaction;

All fields in the DeeTransaction structure are private and should never be accessed directly

### struct DeeTransactionClass

    struct DeeTransactionClass {
    };

### enum DeeTransactionError

    typedef enum {
      DEE_TRANSACTION_ERROR_CONCURRENT_MODIFICATION = 1,
      DEE_TRANSACTION_ERROR_COMMITTED = 2
    } DeeTransactionError;

Error codes for the DeeTransaction class. These codes will be set when the error domain is DEE_TRANSACTION_ERROR.

`DEE_TRANSACTION_ERROR_CONCURRENT_MODIFICATION`: The target model has been modified while the transaction was open.

`DEE_TRANSACTION_ERROR_COMMITTED`: Raised when someone tries to commit a transaction that has already been committed

`DEE_TRANSACTION_ERROR_CONCURRENT_MODIFICATION` |
`DEE_TRANSACTION_ERROR_COMMITTED` |

### dee_transaction_commit ()

    gboolean            dee_transaction_commit              (DeeTransaction *self,
                                                             GError **error);

Apply a transaction to its target model. After this call the transaction is invalidated and must be freed with `g_object_unref()`.

`self` : | The transaction to commit
`error` : | Location to return a GError in or `NULL` to disregard errors. [allow-none]
Returns : | `TRUE` if and only if the transaction successfully applies to :target.

### dee_transaction_error_quark ()

    GQuark              dee_transaction_error_quark         (void);

### dee_transaction_get_target ()

    DeeModel *          dee_transaction_get_target          (DeeTransaction *self);

Get the target model of a transaction. This is just a convenience method for accessing the :target property.

`self` : | The transaction to retrieve the target model for
Returns : | The target model. [transfer none]

### dee_transaction_is_committed ()

    gboolean            dee_transaction_is_committed        (DeeTransaction *self);

Check if a DeeTransaction has been committed. This method is mainly for debugging and testing purposes.

`self` : | The transaction to inspect
Returns : | `TRUE` if and only if `dee_transaction_commit()` has completed successfully on the transaction.

### dee_transaction_new ()

    DeeModel *          dee_transaction_new                 (DeeModel *target);

`target` : | The DeeModel the transaction applies against
Returns : | A newly allocated DeeTransaction. Free with `g_object_unref()` when done using it - no matter if you call `dee_transaction_commit()` or not. [transfer full][type Dee.Transaction]

## Property Details

### The `"target"` property

      "target"                   DeeModel*             : Read / Write / Construct Only

Target model.