Mercurial > hg > RemoteEditor > REPSessionManager
diff rep/Editor.java @ 224:6b0dd92b8e45
add optimizer to Editor
author | kent |
---|---|
date | Sun, 31 Aug 2008 13:28:34 +0900 |
parents | 4d9b32666ed2 |
children | 6c2f54265471 |
line wrap: on
line diff
--- a/rep/Editor.java Sun Aug 31 13:06:36 2008 +0900 +++ b/rep/Editor.java Sun Aug 31 13:28:34 2008 +0900 @@ -5,6 +5,7 @@ import java.util.List; import rep.channel.REPSocketChannel; +import rep.optimizers.*; import rep.translater.TranslaterImp1; public class Editor { @@ -15,11 +16,19 @@ private TranslaterImp1 translater; private List<REPCommand> sentList; private List<REPCommand> sentMergedList; + private REPCommandOptimizer optimizer; public Editor(){ + this(true); + } + public Editor(boolean doOptimize){ setHostAndPort(myChannel); translater = new TranslaterImp1(eid); sentList = new LinkedList<REPCommand>(); + + if (doOptimize) optimizer = new DeleteInsertOptimizer(); //タカノがつくったおぷてぃまいざ + else optimizer = new NullOptimizer(); //なにもしないけどOptimizer. + } public Editor(int editorNo, REPSocketChannel<REPCommand> channel){ @@ -37,8 +46,8 @@ sentList = new LinkedList<REPCommand>(); } - public LinkedList<REPCommand> translate(REPCommand command){ - LinkedList<REPCommand> list = new LinkedList<REPCommand>(); + public List<REPCommand> translate(REPCommand command){ + List<REPCommand> list = new LinkedList<REPCommand>(); if(command.eid == eid){ if(checkReturnedCommand(command)){ //エディタからのコマンドが元のエディタに戻ってきた @@ -59,8 +68,9 @@ //マージコマンドが返ってきた if(translater.checkMergeConflict(command)){ //マージ中にエディタからの割り込みがあった場合 - LinkedList<REPCommand> mergeAgainList = translater.getMergeAgain(); - //optimizer + List<REPCommand> mergeAgainList = translater.getMergeAgain(); + + mergeAgainList = optimizer.optimize(mergeAgainList); for(REPCommand againCommand: mergeAgainList){ myChannel.write(againCommand); }