prepared OT framework for use by RaceLog

This commit is contained in:
Axel Uhl committed 2013-07-09 16:52:42 +02:00
1 parent 550fc52d24
commit dc8dc67196
24 files changed
+47 -42

No files matched your search

@@ -0,0 +1,23 @@
package com.sap.sailing.operationaltransformation;
public interface OperationWithTransformationSupport<S, O extends OperationWithTransformationSupport<S, O>> extends Operation<S> {
/**
* Implements the specific transformation rule for the implementing subclass for the set of possible peer operations
* along which to transform this operation, assuming this is the client operation. See
* {@link Transformer#transform(Operation, Operation)} for the specification.
*
* @return the result of transforming <code>this</code> operation along <code>serverOp</code>
*/
O transformClientOp(O serverOp);
/**
* Implements the specific transformation rule for the implementing subclass for the set of possible peer operations
* along which to transform this operation, assuming this is the server operation. See
* {@link Transformer#transform(Operation, Operation)} for the specification.
*
* @return the result of transforming <code>this</code> operation along <code>clientOp</code>
*/
O transformServerOp(O clientOp);
}
@@ -0,0 +1,13 @@
package com.sap.sailing.operationaltransformation;
public class OperationalTransformer<S, O extends OperationWithTransformationSupport<S, O>> implements Transformer<O> {
@Override
public ClientServerOperationPair<O> transform(O clientOp, O serverOp) {
ClientServerOperationPair<O> result = new ClientServerOperationPair<O>(
clientOp.transformClientOp(serverOp), serverOp.transformServerOp(clientOp));
return result;
}
}
@@ -55,4 +55,9 @@ obtain the current state of a peer using the {@link com.sap.runlet.operationaltr
operation.
</p>
Consider using {@link com.sap.sailing.operationaltransformation.OperationalTransformer} as the basis for your transformation
logic. It generically works with {@link com.sap.sailing.operationaltransformation.OperationWithTransformationSupport} if you
can afford to have your operation classes implement the transformation logic. The benefit of doing so is that adding more
operations requires you to consider the transformation logic.
</body>