Infinity.AdoptedOperation¶
- Implementations:
Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
|
|
|
|
|
|
|
|
|
|
|
|
|
Properties¶
None
Signals¶
None
Fields¶
None
Class Details¶
- class Infinity.AdoptedOperation¶
- Bases:
- Structure:
Infinity.AdoptedOperation
is an opaque data type. You should only access it via the public API functions.- apply(by, buffer)¶
- Parameters:
by (
Infinity.AdoptedUser
) – AInfinity.AdoptedUser
.buffer (
Infinity.Buffer
) – TheInfinity.Buffer
to apply the operation to.
- Raises:
- Returns:
- Return type:
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:
transformed (
Infinity.AdoptedOperation
) – A transformed version of self.by (
Infinity.AdoptedUser
) – TheInfinity.AdoptedUser
applying the operation.buffer (
Infinity.Buffer
) – TheInfinity.Buffer
to apply the operation to.
- Raises:
- Returns:
A
Infinity.AdoptedOperation
, orNone
on error. Free withGObject.Object.unref
() when no longer needed.- Return type:
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 toInfinity.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:
Returns a copy of self.
- get_flags()¶
- Returns:
Infinity.AdoptedOperationFlags
for self.- Return type:
Returns the flags for self.
- is_reversible()¶
- Returns:
Whether self is reversible.
- Return type:
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:
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:
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 returnTrue
).
- transform(against, operation_lcs, against_lcs, concurrency_id)¶
- Parameters:
against (
Infinity.AdoptedOperation
) – The operation to transform against.operation_lcs (
Infinity.AdoptedOperation
) – The operation at a previous state, orNone
.against_lcs (
Infinity.AdoptedOperation
) – The against operation at a previous state, orNone
.concurrency_id (
int
) – The concurrency ID for the transformation.
- Returns:
The transformed
Infinity.AdoptedOperation
, orNone
if the transformation failed.- Return type:
Performs an inclusion transformation of self against against, meaning that the effect of against is included in self.
If
Infinity.AdoptedOperation.need_concurrency_id
() returnsTrue
for self and against, then operation_lcs and against_lcs must not beNone
. 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
() returnsTrue
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:
by (
Infinity.AdoptedUser
) – AInfinity.AdoptedUser
.buffer (
Infinity.Buffer
) – TheInfinity.Buffer
to apply the operation to.
- Returns:
- Return type:
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:
transformed (
Infinity.AdoptedOperation
) – A transformed version of operation.by (
Infinity.AdoptedUser
) – TheInfinity.AdoptedUser
applying the operation.buffer (
Infinity.Buffer
) – TheInfinity.Buffer
to apply the operation to.
- Returns:
A
Infinity.AdoptedOperation
, orNone
on error. Free withGObject.Object.unref
() when no longer needed.- Return type:
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 toInfinity.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:
Returns a copy of operation.
- do_get_flags() virtual¶
- Returns:
Infinity.AdoptedOperationFlags
for operation.- Return type:
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:
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:
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 returnTrue
).
- do_transform(against, operation_lcs, against_lcs, concurrency_id) virtual¶
- Parameters:
against (
Infinity.AdoptedOperation
) – The operation to transform against.operation_lcs (
Infinity.AdoptedOperation
) – The operation at a previous state, orNone
.against_lcs (
Infinity.AdoptedOperation
) – The against operation at a previous state, orNone
.concurrency_id (
Infinity.AdoptedConcurrencyId
) – The concurrency ID for the transformation.
- Returns:
The transformed
Infinity.AdoptedOperation
, orNone
if the transformation failed.- Return type:
Performs an inclusion transformation of operation against against, meaning that the effect of against is included in operation.
If
Infinity.AdoptedOperation.need_concurrency_id
() returnsTrue
for operation and against, then operation_lcs and against_lcs must not beNone
. 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
() returnsTrue
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.