Commit 99430c1c authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Removing unneccessary method

parent 39e9af9d
...@@ -416,12 +416,6 @@ aspect CS_Class { ...@@ -416,12 +416,6 @@ aspect CS_Class {
env.println("private class Dispatcher : SampleDispatcher {"); env.println("private class Dispatcher : SampleDispatcher {");
env.indent(); env.indent();
env.println(); env.println();
env.println("public SampleDispatcher getSampleIdentity() {");
env.indent();
env.println("return dispatcher;");
env.unindent();
env.println("}");
env.println();
env.println("public String getName() {"); env.println("public String getName() {");
env.indent(); env.indent();
env.println("return \"" + getName() + "\";"); env.println("return \"" + getName() + "\";");
......
...@@ -170,7 +170,7 @@ namespace se.lth.control.labcomm2014 { ...@@ -170,7 +170,7 @@ namespace se.lth.control.labcomm2014 {
int index = (int)ReadInt(4); int index = (int)ReadInt(4);
try { try {
DecoderRegistry.Entry e = ref_registry.get(index); DecoderRegistry.Entry e = ref_registry.get(index);
return e.getSampleDispatcher().getSampleIdentity(); return e.getSampleDispatcher();
} catch (NullReferenceException) { } catch (NullReferenceException) {
return null; return null;
} }
......
...@@ -90,11 +90,11 @@ namespace se.lth.control.labcomm2014 { ...@@ -90,11 +90,11 @@ namespace se.lth.control.labcomm2014 {
} }
} }
private Dictionary<SampleDispatcher, Entry> byIdentity; private Dictionary<SampleDispatcher, Entry> byDispatcher;
private Dictionary<int, Entry> byIndex; private Dictionary<int, Entry> byIndex;
public DecoderRegistry() { public DecoderRegistry() {
byIdentity = new Dictionary<SampleDispatcher, Entry>(); byDispatcher = new Dictionary<SampleDispatcher, Entry>();
byIndex = new Dictionary<int, Entry>(); byIndex = new Dictionary<int, Entry>();
} }
...@@ -102,7 +102,7 @@ namespace se.lth.control.labcomm2014 { ...@@ -102,7 +102,7 @@ namespace se.lth.control.labcomm2014 {
SampleHandler handler) { SampleHandler handler) {
lock(this) { lock(this) {
Entry e; Entry e;
byIdentity.TryGetValue(dispatcher.getSampleIdentity(), out e); byDispatcher.TryGetValue(dispatcher, out e);
if (e != null) { if (e != null) {
e.check(dispatcher.getName(), dispatcher.getSignature()); e.check(dispatcher.getName(), dispatcher.getSignature());
e.setHandler(handler); e.setHandler(handler);
...@@ -117,7 +117,7 @@ namespace se.lth.control.labcomm2014 { ...@@ -117,7 +117,7 @@ namespace se.lth.control.labcomm2014 {
} }
if (e == null) { if (e == null) {
e = new Entry(dispatcher, handler); e = new Entry(dispatcher, handler);
byIdentity.Add(dispatcher.getSampleIdentity(), e); byDispatcher.Add(dispatcher, e);
} }
} }
} }
...@@ -132,7 +132,7 @@ namespace se.lth.control.labcomm2014 { ...@@ -132,7 +132,7 @@ namespace se.lth.control.labcomm2014 {
if (e != null) { if (e != null) {
e.check(name, signature); e.check(name, signature);
} else { } else {
foreach (Entry e2 in byIdentity.Values) { foreach (Entry e2 in byDispatcher.Values) {
if (e2.match(name, signature)) { if (e2.match(name, signature)) {
e2.setIndex(index); e2.setIndex(index);
e = e2; e = e2;
......
...@@ -26,19 +26,19 @@ namespace se.lth.control.labcomm2014 { ...@@ -26,19 +26,19 @@ namespace se.lth.control.labcomm2014 {
} }
private int userIndex = Constant.FIRST_USER_INDEX; private int userIndex = Constant.FIRST_USER_INDEX;
private Dictionary<SampleDispatcher, Entry> byIdentity; private Dictionary<SampleDispatcher, Entry> byDispatcher;
public EncoderRegistry() { public EncoderRegistry() {
byIdentity = new Dictionary<SampleDispatcher, Entry>(); byDispatcher = new Dictionary<SampleDispatcher, Entry>();
} }
public int add(SampleDispatcher dispatcher) { public int add(SampleDispatcher dispatcher) {
lock(this) { lock(this) {
Entry e; Entry e;
byIdentity.TryGetValue(dispatcher.getSampleIdentity(), out e); byDispatcher.TryGetValue(dispatcher, out e);
if (e == null) { if (e == null) {
e = new Entry(dispatcher, userIndex); e = new Entry(dispatcher, userIndex);
byIdentity.Add(dispatcher.getSampleIdentity(), e); byDispatcher.Add(dispatcher, e);
userIndex++; userIndex++;
} }
return e.getIndex(); return e.getIndex();
...@@ -48,7 +48,7 @@ namespace se.lth.control.labcomm2014 { ...@@ -48,7 +48,7 @@ namespace se.lth.control.labcomm2014 {
public int getTag(SampleDispatcher sample) { public int getTag(SampleDispatcher sample) {
lock(this) { lock(this) {
Entry e; Entry e;
byIdentity.TryGetValue(sample, out e); byDispatcher.TryGetValue(sample, out e);
if (e == null) { if (e == null) {
throw new Exception("'" + throw new Exception("'" +
sample.ToString() + sample.ToString() +
......
...@@ -16,10 +16,6 @@ namespace se.lth.control.labcomm2014 { ...@@ -16,10 +16,6 @@ namespace se.lth.control.labcomm2014 {
this.name = name; this.name = name;
} }
public SampleDispatcher getSampleIdentity() {
return this;
}
public String getName() { public String getName() {
return name; return name;
} }
......
...@@ -4,8 +4,6 @@ namespace se.lth.control.labcomm2014 { ...@@ -4,8 +4,6 @@ namespace se.lth.control.labcomm2014 {
public interface SampleDispatcher { public interface SampleDispatcher {
SampleDispatcher getSampleIdentity();
String getName(); String getName();
byte[] getSignature(); byte[] getSignature();
......
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