Top | ![]() |
![]() |
![]() |
![]() |
InfAdoptedOperationInfAdoptedOperation — Operation that can be processed by InfAdoptedAlgorithm. |
GEnum ╰── InfAdoptedConcurrencyId GFlags ╰── InfAdoptedOperationFlags GInterface ╰── InfAdoptedOperation
InfAdoptedOperation is implemented by InfAdoptedNoOperation and InfAdoptedSplitOperation.
The InfAdoptedOperation interface must be implemented by operations that are supposed to be used by InfAdoptedAlgorithm. They basically need to define transformation rules for transformation against other operations.
gboolean inf_adopted_operation_need_concurrency_id (InfAdoptedOperation *operation
,InfAdoptedOperation *against
);
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.
operation |
The InfAdoptedOperation to transform. |
|
against |
The operation to transform against. |
InfAdoptedConcurrencyId inf_adopted_operation_get_concurrency_id (InfAdoptedOperation *operation
,InfAdoptedOperation *against
);
This function returns a concurrency ID for transformation of operation
against against
. It always returns INF_ADOPTED_CONCURRENCY_NONE
when
inf_adopted_operation_need_concurrency_id()
returns TRUE
for
operation
and against
(but that's not necessarily true the other way
around), since it is not possible to decide which operation to transform
without any additional information.
However, the function can be called on the same operations in a previous
state. In some cases, a decision can be made based on those previous
operations. This can then be used as concurrency ID to call
inf_adopted_operation_transform()
.
Note that the function is antisymmetric. If it returns
INF_ADOPTED_CONCURRENCY_SELF
, then it returns
INF_ADOPTED_CONCURRENCY_OTHER
for swapped arguments.
operation |
The InfAdoptedOperation to transform. |
|
against |
The operation to transform against. |
A concurrency ID between operation
and against
. Can be
INF_ADOPTED_CONCURRENCY_NONE
in case no decision can be made.
InfAdoptedOperation * inf_adopted_operation_transform (InfAdoptedOperation *operation
,InfAdoptedOperation *against
,gint concurrency_id
);
Performs an inclusion transformation of operation
against against
,
meaning that the effect of against
is included in operation
.
If inf_adopted_operation_need_concurrency_id()
returns TRUE
for operation
and against
, then concurrency_id
must not be
INF_ADOPTED_CONCURRENCY_NONE
. Otherwise, the parameter is ignored.
operation |
The InfAdoptedOperation to transform. |
|
against |
The operation to transform against. |
|
concurrency_id |
The concurrency ID for the transformation. |
InfAdoptedOperation *
inf_adopted_operation_copy (InfAdoptedOperation *operation
);
Returns a copy of operation
.
InfAdoptedOperationFlags
inf_adopted_operation_get_flags (InfAdoptedOperation *operation
);
Returns the flags for operation
.
void inf_adopted_operation_apply (InfAdoptedOperation *operation
,InfAdoptedUser *by
,InfBuffer *buffer
);
Applies operation
to buffer
. The operation is considered to be applied by
user by
.
gboolean
inf_adopted_operation_is_reversible (InfAdoptedOperation *operation
);
Returns whether operation
is reversible.
InfAdoptedOperation *
inf_adopted_operation_revert (InfAdoptedOperation *operation
);
Returns a new InfAdoptedOperation 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.
inf_adopted_operation_is_reversible()
must return TRUE).
InfAdoptedOperation * inf_adopted_operation_make_reversible (InfAdoptedOperation *operation
,InfAdoptedOperation *with
,InfBuffer *buffer
);
Some operations may not be reversible, but can be made reversible with some extra information such as another operation that collected enough information while being transformed, and the current buffer.
This function can only be called when operation
is not yet reversible
and returns a new operation that has the same effect as operation
, but is
reversible.
For example, an operation that deletes some range of text in a text editor is not reversible if it only stores the position and length of the range, but can be made reversible when it looks up what there is at that position in the buffer.
operation |
||
with |
Another InfAdoptedOperation that emerged from |
|
buffer |
A InfBuffer. |
A reversible InfAdoptedOperation, or NULL
if operation
cannot be made reversible with the given transformed operation with
and
buffer
.
typedef struct _InfAdoptedOperation InfAdoptedOperation;
InfAdoptedOperation is an opaque data type. You should only access it via the public API functions.
struct InfAdoptedOperationIface { gboolean (*need_concurrency_id)(InfAdoptedOperation* operation, InfAdoptedOperation* against); InfAdoptedConcurrencyId (*get_concurrency_id)(InfAdoptedOperation* op, InfAdoptedOperation* against); InfAdoptedOperation* (*transform)(InfAdoptedOperation* operation, InfAdoptedOperation* against, InfAdoptedConcurrencyId concurrency_id); InfAdoptedOperation* (*copy)(InfAdoptedOperation* operation); InfAdoptedOperationFlags (*get_flags)(InfAdoptedOperation* operation); void (*apply)(InfAdoptedOperation* operation, InfAdoptedUser* by, InfBuffer* buffer); InfAdoptedOperation* (*revert)(InfAdoptedOperation* operation); InfAdoptedOperation* (*make_reversible)(InfAdoptedOperation* operation, InfAdoptedOperation* with, InfBuffer* buffer); };
Various flags for InfAdoptedOperation.
The operation changes the content of the buffer. |
||
The operation is reversible, which means
that |