[cooja] Memory: Added add/removeMemoryMonitor functions

Provides a cleaner interface to access memory as VarMemory already
contains variable name based add/removeVarMonitor functions.
This commit is contained in:
Enrico Joerns 2014-08-28 19:24:50 +02:00
parent 77ab9359dd
commit e5653ac150
2 changed files with 33 additions and 9 deletions

View file

@ -29,6 +29,8 @@
*/
package org.contikios.cooja.mote.memory;
import org.contikios.cooja.mote.memory.MemoryInterface.SegmentMonitor;
import org.contikios.cooja.mote.memory.MemoryInterface.SegmentMonitor.EventType;
import org.contikios.cooja.mote.memory.MemoryLayout.DataType;
/**
@ -276,4 +278,27 @@ public abstract class Memory {
memIntf.setMemorySegment(addr, data);
}
/**
* Adds monitor to specified memory region.
*
* @param flag Select memory operation(s) to listen for (read, write, read/write)
* @param addr Start address of monitored region
* @param size Size of monitored region
* @param mm Monitor to add
* @return if monitor could be added, false if not
*/
public boolean addMemoryMonitor(EventType flag, long addr, int size, SegmentMonitor mm) {
return memIntf.addSegmentMonitor(flag, addr, size, mm);
}
/**
* Removes monitor assigned to the specified region.
*
* @param addr Start address of monitored region
* @param size Size of monitored region
* @param mm Monitor to remove
*/
public void removeMemoryMonitor(long addr, int size, SegmentMonitor mm) {
memIntf.removeSegmentMonitor(addr, size, mm);
}
}

View file

@ -360,13 +360,12 @@ public class VarMemory extends Memory {
}
/**
* Adds a MemoryMonitor for the specified address region.
* Adds a monitor for the specified address region.
*
* @param flag Select memory operation(s) to listen for (read, write,
* read/write)
* @param varName
* @param mm
* @return
* @param flag Select memory operation(s) to listen for (read, write, read/write)
* @param varName Name of variable to monitor
* @param mm Monitor to add
* @return if monitor could be added, false if not
*/
public boolean addVarMonitor(EventType flag, final String varName, final SegmentMonitor mm) {
return memIntf.addSegmentMonitor(
@ -377,10 +376,10 @@ public class VarMemory extends Memory {
}
/**
* Removes MemoryMonitor assigned to the specified region.
* Removes monitor assigned to the specified region.
*
* @param varName
* @param mm MemoryMonitor to remove
* @param varName Name of monitored variable
* @param mm Monitor to remove
*/
public void removeVarMonitor(String varName, SegmentMonitor mm) {
memIntf.removeSegmentMonitor(getVariable(varName).addr, getVariable(varName).size, mm);