de.unihalle.informatik.MiToBo.core.operator
Class MTBPortHashAccess

java.lang.Object
  extended by de.unihalle.informatik.Alida.operator.ALDPortHashAccess
      extended by de.unihalle.informatik.MiToBo.core.operator.MTBPortHashAccess

public class MTBPortHashAccess
extends de.unihalle.informatik.Alida.operator.ALDPortHashAccess

Interface to the port database of the Alida / MiToBo operator history.

This class implements an interface to access the history database. It yields the only possibility to access the database, direct access is blocked to guarantee database consistency.

Compared to the superclass a special treatment of MiToBo images takes place to ensure proper association of MiToBo images and underlying ImageJ ImagePlus data. Objects are usually registered by their references in the port database, however, in case of MiToBo images and underlying ImagePlus data different object references, i.e. the MTBImage and the ImagePlus, essentially represent the same data in the system. Hence, for history database validity explicit associations need to be established between ImagePlus and MTBImage data.

Database consistency is ensured by introducing a specialized data type which is the MTBHistoryImageBox. If a MTBImage is fed into an operator as parameter the first time, a corresponding image box is created and registered in the local hash. Lateron, when the ImagePlus object linked to the MTBImage is directly used as parameter, the MiToBo images within all boxes are searched to find the corresponding MTBImage. Then the history port associated with the box is updated, ensuring history consistency and at the same time proper association of the ImagePlus with the formerly known MTBImage.

In case of using an ImagePlus as parameter that has not been seen before, the same mechanism is applied. First an image box is initialized for the new ImagePlus. When at a later point in time the MTBImage is used as parameter which is associated to the formerly seen ImagePlus, the association is explicitly established by linking the MTBImage to the box and updating the history port of the box accordingly.

Author:
moeller, posch

Nested Class Summary
private static class MTBPortHashAccess.MTBHistoryImageBox
          Database object boxing ImagePlus and MTBImage.
 
Field Summary
private static java.util.WeakHashMap<ij.ImagePlus,MTBPortHashAccess.MTBHistoryImageBox> boxLinksImagePlus
          Associative list for links between ImagePlus and associated image boxes.
private static java.util.WeakHashMap<MTBImage,MTBPortHashAccess.MTBHistoryImageBox> boxLinksMTBImage
          Associative list for links between MTBImages and associated image boxes.
static java.lang.String MPH_EXTENSION
          Default extension of MiToBo processing history file.
private static boolean verbose
          If true, verbose outputs are written to standard output.
 
Fields inherited from class de.unihalle.informatik.Alida.operator.ALDPortHashAccess
ALD_EXTENSION
 
Constructor Summary
protected MTBPortHashAccess()
          Constructor without function.
 
Method Summary
protected  de.unihalle.informatik.Alida.operator.ALDPort getHistoryLink(java.lang.Object obj)
          Gets the port to which the object is currently linked in history.
private static MTBPortHashAccess.MTBHistoryImageBox getImageBox(java.lang.Object obj)
          Gets the image container associated with the given image object.
protected  boolean isRegistered(java.lang.Object obj)
          Checks if an object is registered in the database.
private static boolean isRegisteredImageBox(java.lang.Object obj)
          Checks if the given image object is already registered.
protected  void register(java.lang.Object obj)
          Registers the object to the database.
private  void registerImageBox(java.lang.Object obj)
          Registers the given (image) object.
protected  void setHistoryLink(java.lang.Object obj, de.unihalle.informatik.Alida.operator.ALDPort port)
          Sets the port to which the object is to be linked in history.
 
Methods inherited from class de.unihalle.informatik.Alida.operator.ALDPortHashAccess
getNumEntries, readHistory, writeHistory, writeHistory, writeHistory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

boxLinksImagePlus

private static java.util.WeakHashMap<ij.ImagePlus,MTBPortHashAccess.MTBHistoryImageBox> boxLinksImagePlus
Associative list for links between ImagePlus and associated image boxes.

The hash provides fast access to stored image boxes by keeoing track of all included ImagePlus images as keys in the map.


boxLinksMTBImage

private static java.util.WeakHashMap<MTBImage,MTBPortHashAccess.MTBHistoryImageBox> boxLinksMTBImage
Associative list for links between MTBImages and associated image boxes.

The hash provides fast access to stored image boxes by keeping track of all included MiToBo images as keys in the map.


MPH_EXTENSION

public static final java.lang.String MPH_EXTENSION
Default extension of MiToBo processing history file.


verbose

private static boolean verbose
If true, verbose outputs are written to standard output.

Constructor Detail

MTBPortHashAccess

protected MTBPortHashAccess()
Constructor without function.

Note that there will be only one processing history per session and not many different objects of this type.

Method Detail

getHistoryLink

protected de.unihalle.informatik.Alida.operator.ALDPort getHistoryLink(java.lang.Object obj)
Gets the port to which the object is currently linked in history.

Overrides:
getHistoryLink in class de.unihalle.informatik.Alida.operator.ALDPortHashAccess
Returns:
Current port to which data is linked.

getImageBox

private static MTBPortHashAccess.MTBHistoryImageBox getImageBox(java.lang.Object obj)
Gets the image container associated with the given image object.

Returns:
Image box associated with the given object.

isRegistered

protected boolean isRegistered(java.lang.Object obj)
Checks if an object is registered in the database.

Overrides:
isRegistered in class de.unihalle.informatik.Alida.operator.ALDPortHashAccess
Parameters:
obj - Object to check.
Returns:
True, if object is known to the database.

isRegisteredImageBox

private static boolean isRegisteredImageBox(java.lang.Object obj)
Checks if the given image object is already registered.

An image is registered if a corresponding image container exists.

Parameters:
obj - Image object in question.
Returns:
True, if an associated image box already exists.

register

protected void register(java.lang.Object obj)
Registers the object to the database.

Overrides:
register in class de.unihalle.informatik.Alida.operator.ALDPortHashAccess
Parameters:
obj - Object to register.

registerImageBox

private void registerImageBox(java.lang.Object obj)
Registers the given (image) object.

Image objects are treated in a special way as different physical objects may relate to the same logical object. In particular, images are boxed in containers where each container keeps track of a pair of MTBImage/ImagePlus objects.

Parameters:
obj - Object to register.

setHistoryLink

protected void setHistoryLink(java.lang.Object obj,
                              de.unihalle.informatik.Alida.operator.ALDPort port)
Sets the port to which the object is to be linked in history.

Overrides:
setHistoryLink in class de.unihalle.informatik.Alida.operator.ALDPortHashAccess
Parameters:
port - New port the data object is to be linked to.