Commit 10bbd93d authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Removed optional version preamble. Since we don't flatten

signatures in 20141009, this is not needed any more.
parent 9e33b043
......@@ -13,17 +13,13 @@ namespace se.lth.control.labcomm {
byte[] buf = new byte[8];
private int current_tag;
public EncoderChannel(Stream writer, bool emitVersion) {
public EncoderChannel(Stream writer) {
this.writer = writer;
if (emitVersion) {
encodeString(Constant.VERSION);
bytes.WriteTo(writer);
bytes.SetLength(0);
writer.Flush();
}
}
public EncoderChannel(Stream writer) : this(writer, true) {
encodeString(Constant.VERSION);
bytes.WriteTo(writer);
bytes.SetLength(0);
writer.Flush();
}
public void register(SampleDispatcher dispatcher) {
......
......@@ -13,31 +13,20 @@ public class EncoderChannel implements Encoder {
private EncoderRegistry registry;
private int current_tag;
public EncoderChannel(Writer writer,
boolean emitVersion) throws IOException {
public EncoderChannel(Writer writer) throws IOException {
this.writer = writer;
bytes = new ByteArrayOutputStream();
data = new DataOutputStream(bytes);
registry = new EncoderRegistry();
if (emitVersion) {
encodeString(Constant.VERSION);
data.flush();
writer.write(bytes.toByteArray());
bytes.reset();
}
}
public EncoderChannel(Writer writer) throws IOException {
this(writer, true);
}
public EncoderChannel(OutputStream writer,
boolean emitVersion) throws IOException {
this(new WriterWrapper(writer), emitVersion);
encodeString(Constant.VERSION);
data.flush();
writer.write(bytes.toByteArray());
bytes.reset();
}
public EncoderChannel(OutputStream writer) throws IOException {
this(new WriterWrapper(writer), true);
this(new WriterWrapper(writer));
}
public void register(SampleDispatcher dispatcher) throws IOException {
......
......@@ -24,7 +24,7 @@ public class DecoderChannel implements Decoder {
int index = decodePacked32();
String name = decodeString();
ByteArrayOutputStream signature = new ByteArrayOutputStream();
collectFlatSignature(new EncoderChannel(signature, false));
collectFlatSignature(new EncoderChannel(signature));
registry.add(index, name, signature.toByteArray());
} break;
default: {
......
......@@ -12,28 +12,15 @@ public class EncoderChannel implements Encoder {
private DataOutputStream data;
private EncoderRegistry registry;
public EncoderChannel(Writer writer,
boolean emitVersion) throws IOException {
public EncoderChannel(Writer writer) throws IOException {
this.writer = writer;
bytes = new ByteArrayOutputStream();
data = new DataOutputStream(bytes);
registry = new EncoderRegistry();
if (emitVersion) {
throw new IllegalArgumentException("Labcomm 2006 does not support emitVersion");
}
}
public EncoderChannel(Writer writer) throws IOException {
this(writer, false);
}
public EncoderChannel(OutputStream writer,
boolean emitVersion) throws IOException {
this(new WriterWrapper(writer), emitVersion);
}
public EncoderChannel(OutputStream writer) throws IOException {
this(new WriterWrapper(writer), false);
this(new WriterWrapper(writer));
}
public void register(SampleDispatcher dispatcher) throws IOException {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment