Class FunctionComparisonModel

java.lang.Object
ghidra.app.services.FunctionComparisonModel

public class FunctionComparisonModel extends Object
A collection of function comparison objects that describe how functions may be compared. Each comparison object is a mapping of a function (source) to a list of functions (targets).

This model is intended to be used by the FunctionComparisonProvider as the basis for its display. It should never be created manually, and should only be accessed via the FunctionComparisonService.

Note: Subscribers may register to be informed of changes to this model via the comparison model listener interface.

  • Constructor Details

    • FunctionComparisonModel

      public FunctionComparisonModel()
  • Method Details

    • addFunctionComparisonModelListener

      public void addFunctionComparisonModelListener(ghidra.app.plugin.core.functioncompare.FunctionComparisonModelListener listener)
      Adds the given subscriber to the list of those to be notified of model changes
      Parameters:
      listener - the model change subscriber
    • getComparisons

      public List<ghidra.app.plugin.core.functioncompare.FunctionComparison> getComparisons()
      Returns a list of all comparisons in the model, in sorted order by source function name
      Returns:
      a list of all comparisons in the model
    • setComparisons

      public void setComparisons(List<ghidra.app.plugin.core.functioncompare.FunctionComparison> comparisons)
      Replaces the current model with the comparisons provided
      Parameters:
      comparisons - the new comparison model
    • addComparison

      public void addComparison(ghidra.app.plugin.core.functioncompare.FunctionComparison comparison)
      Adds a single comparison to the model
      Parameters:
      comparison - the comparison to add
    • getTargets

      public Set<Function> getTargets(Function source)
      Returns a list of all targets in the model (across all comparisons) for a given source function
      Parameters:
      source - the source function
      Returns:
      list of associated target functions
    • compareFunctions

      public void compareFunctions(Set<Function> functions)
      Updates the model with a set of functions to compare. This will add the functions to any existing comparisons in the model and create new comparisons for functions not represented.

      Note: It is assumed that when using this method, all functions can be compared with all other functions; meaning each function will be added as both a source AND a target. To specify a specific source/target relationship, use compareFunctions(Function, Function).

      Parameters:
      functions - the set of functions to compare
    • compareFunctions

      public void compareFunctions(Set<Function> sourceFunctions, Set<Function> destinationFunctions)
      Updates the model with two sets of functions to compare. This will add the functions to any existing comparisons in the model and create new comparisons for functions not represented.

      Note: It is assumed that when using this method, all source functions can be compared to all destination functions; meaning all functions in the source function set will be added as sources, and all functions in the destination function set will be added as targets.

      Parameters:
      sourceFunctions -
      destinationFunctions -
    • compareFunctions

      public void compareFunctions(Function source, Function target)
      Compares two functions. If a comparison already exists in the model for the given source, the target will simply be added to it; otherwise a new comparison will be created.
      Parameters:
      source - the source function
      target - the target function
    • removeFunction

      public void removeFunction(Function function)
      Removes the given function from all comparisons in the model, whether stored as a source or target
      Parameters:
      function - the function to remove
    • removeFunctions

      public void removeFunctions(Collection<Function> functions)
      Removes all the given functions from all comparisons in the model
      Parameters:
      functions - the functions to remove
    • removeFunctions

      public void removeFunctions(Program program)
      Removes all functions in the model that come from the given program
      Parameters:
      program - the program to remove functions from
    • getSourceFunctions

      public Set<Function> getSourceFunctions()
      Returns all source functions in the model
      Returns:
      a set of all source functions
    • getTargetFunctions

      public Set<Function> getTargetFunctions()
      Returns all target functions in the model
      Returns:
      a set of all target functions
    • getTargetFunctions

      public Set<Function> getTargetFunctions(Function source)
      Returns a set of all target functions for a given source
      Parameters:
      source - the source function to search for
      Returns:
      the set of associated target functions