enables sharing mote-specific properties

This commit is contained in:
Fredrik Osterlind 2011-05-31 12:45:28 +02:00
parent 7043c25cd9
commit 5636b019b3
2 changed files with 19 additions and 0 deletions

View file

@ -148,4 +148,7 @@ public interface Mote {
* Called when mote is removed from simulation * Called when mote is removed from simulation
*/ */
public void removed(); public void removed();
public void setProperty(String key, Object obj);
public Object getProperty(String key);
} }

View file

@ -29,6 +29,8 @@
package se.sics.cooja.motes; package se.sics.cooja.motes;
import java.util.HashMap;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import se.sics.cooja.Mote; import se.sics.cooja.Mote;
@ -130,4 +132,18 @@ public abstract class AbstractWakeupMote implements Mote {
public void removed() { public void removed() {
} }
private HashMap<String, Object> properties = null;
public void setProperty(String key, Object obj) {
if (properties == null) {
properties = new HashMap<String, Object>();
}
properties.put(key, obj);
}
public Object getProperty(String key) {
if (properties == null) {
return null;
}
return properties.get(key);
}
} }