Infinity.AdoptedOperation

g GObject.GInterface GObject.GInterface Infinity.AdoptedOperation Infinity.AdoptedOperation GObject.GInterface->Infinity.AdoptedOperation

Implementations:

Infinity.AdoptedNoOperation, Infinity.AdoptedSplitOperation

Methods

apply (by, buffer)

apply_transformed (transformed, by, buffer)

copy ()

get_flags ()

is_reversible ()

need_concurrency_id (against)

revert ()

transform (against, operation_lcs, against_lcs, concurrency_id)

Virtual Methods

do_apply (by, buffer)

do_apply_transformed (transformed, by, buffer)

do_copy ()

do_get_flags ()

do_need_concurrency_id (against)

do_revert ()

do_transform (against, operation_lcs, against_lcs, concurrency_id)

Properties

None

Signals

None

Fields

None

Class Details

class Infinity.AdoptedOperation
Bases:

GObject.GInterface

Structure:

Infinity.AdoptedOperationInterface

Infinity.AdoptedOperation is an opaque data type. You should only access it via the public API functions.

apply(by, buffer)
Parameters:
Raises:

GLib.Error

Returns:

True on success or False on error.

Return type:

bool

Applies self to buffer. The operation is considered to be applied by user by. If the operation cannot be applied then error is set and the function returns False.

apply_transformed(transformed, by, buffer)
Parameters:
Raises:

GLib.Error

Returns:

A Infinity.AdoptedOperation, or None on error. Free with GObject.Object.unref() when no longer needed.

Return type:

Infinity.AdoptedOperation

Applies transformed to buffer. The operation is considered to be applied by user by. The operation transformed must have originated from self by transformation with Infinity.AdoptedOperation.transform().

If self is reversible or does not affect the buffer (see Infinity.AdoptedOperationFlags), this function is equivalent to

Infinity.AdoptedOperation.apply(transformed, by, buffer), with the exception of the return value. In that case the return value will be self itself, with a reference added.

However, if self is not reversible and affects the buffer, the function attempts to construct an operation which is identical to self, but reversible, and returns it. The function can use information from the transformed operation and the buffer to construct the reversible operation. If a reversible operation cannot be constructed, the function returns an additional reference on self, and still applies the transformed operation to the buffer.

For example, an operation that deletes text in a text editor would be transmitting only the position and the length of the text to delete over the network. From that information alone, the operation cannot be made reversible. However, when the operation is applied to the buffer, the actual text that is being removed can be restored by looking it up in the buffer, making the operation reversible.

copy()
Returns:

A copy of self.

Return type:

Infinity.AdoptedOperation

Returns a copy of self.

get_flags()
Returns:

Infinity.AdoptedOperationFlags for self.

Return type:

Infinity.AdoptedOperationFlags

Returns the flags for self.

is_reversible()
Returns:

Whether self is reversible.

Return type:

bool

Returns whether self is reversible.

need_concurrency_id(against)
Parameters:

against (Infinity.AdoptedOperation) – The operation to transform against.

Returns:

Whether transformation of self against against requires a concurrency ID to be defined.

Return type:

bool

This function returns whether transforming self against against is not defined unambiguously. In that case, transformation requires a so-called concurrency ID which determines which of the two operations is transformed.

revert()
Returns:

The reverse operation of self.

Return type:

Infinity.AdoptedOperation

Returns a new Infinity.AdoptedOperation that undoes the effect of self. If self and then its reverse operation are applied to a buffer (in that order), the buffer remains unchanged.

self must be reversible for this function to be called (i.e. Infinity.AdoptedOperation.is_reversible() must return True).

transform(against, operation_lcs, against_lcs, concurrency_id)
Parameters:
Returns:

The transformed Infinity.AdoptedOperation, or None if the transformation failed.

Return type:

Infinity.AdoptedOperation or None

Performs an inclusion transformation of self against against, meaning that the effect of against is included in self.

If Infinity.AdoptedOperation.need_concurrency_id() returns True for self and against, then operation_lcs and against_lcs must not be None. In this case they must be the same operations as self and against at the earlierst state to which both of them can be transformed. This information can then be used to resolve any conflicts in the transformation of self against against.

The concurrency_id parameter is used if Infinity.AdoptedOperation.need_concurrency_id() returns True and no conflict resolution can be deduced from operation_lcs and against_lcs. In this case concurrency_id defines a unique way to transform the two operations. Usually, this is derived from the user IDs of the users who issued the two conflicting operations.

do_apply(by, buffer) virtual
Parameters:
Returns:

True on success or False on error.

Return type:

bool

Applies operation to buffer. The operation is considered to be applied by user by. If the operation cannot be applied then error is set and the function returns False.

do_apply_transformed(transformed, by, buffer) virtual
Parameters:
Returns:

A Infinity.AdoptedOperation, or None on error. Free with GObject.Object.unref() when no longer needed.

Return type:

Infinity.AdoptedOperation

Applies transformed to buffer. The operation is considered to be applied by user by. The operation transformed must have originated from operation by transformation with Infinity.AdoptedOperation.transform().

If operation is reversible or does not affect the buffer (see Infinity.AdoptedOperationFlags), this function is equivalent to

Infinity.AdoptedOperation.apply(transformed, by, buffer), with the exception of the return value. In that case the return value will be operation itself, with a reference added.

However, if operation is not reversible and affects the buffer, the function attempts to construct an operation which is identical to operation, but reversible, and returns it. The function can use information from the transformed operation and the buffer to construct the reversible operation. If a reversible operation cannot be constructed, the function returns an additional reference on operation, and still applies the transformed operation to the buffer.

For example, an operation that deletes text in a text editor would be transmitting only the position and the length of the text to delete over the network. From that information alone, the operation cannot be made reversible. However, when the operation is applied to the buffer, the actual text that is being removed can be restored by looking it up in the buffer, making the operation reversible.

do_copy() virtual
Returns:

A copy of operation.

Return type:

Infinity.AdoptedOperation

Returns a copy of operation.

do_get_flags() virtual
Returns:

Infinity.AdoptedOperationFlags for operation.

Return type:

Infinity.AdoptedOperationFlags

Returns the flags for operation.

do_need_concurrency_id(against) virtual
Parameters:

against (Infinity.AdoptedOperation) – The operation to transform against.

Returns:

Whether transformation of operation against against requires a concurrency ID to be defined.

Return type:

bool

This function returns whether transforming operation against against is not defined unambiguously. In that case, transformation requires a so-called concurrency ID which determines which of the two operations is transformed.

do_revert() virtual
Returns:

The reverse operation of operation.

Return type:

Infinity.AdoptedOperation

Returns a new Infinity.AdoptedOperation that undoes the effect of operation. If operation and then its reverse operation are applied to a buffer (in that order), the buffer remains unchanged.

operation must be reversible for this function to be called (i.e. Infinity.AdoptedOperation.is_reversible() must return True).

do_transform(against, operation_lcs, against_lcs, concurrency_id) virtual
Parameters:
Returns:

The transformed Infinity.AdoptedOperation, or None if the transformation failed.

Return type:

Infinity.AdoptedOperation or None

Performs an inclusion transformation of operation against against, meaning that the effect of against is included in operation.

If Infinity.AdoptedOperation.need_concurrency_id() returns True for operation and against, then operation_lcs and against_lcs must not be None. In this case they must be the same operations as operation and against at the earlierst state to which both of them can be transformed. This information can then be used to resolve any conflicts in the transformation of operation against against.

The concurrency_id parameter is used if Infinity.AdoptedOperation.need_concurrency_id() returns True and no conflict resolution can be deduced from operation_lcs and against_lcs. In this case concurrency_id defines a unique way to transform the two operations. Usually, this is derived from the user IDs of the users who issued the two conflicting operations.